term

package
v1.2.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CastOf

func CastOf[F field.Element[F], T Expr[F, T]](arg T, bitwidth uint) T

CastOf constructs a new expression which has been annotated by the user to be within a given range.

func ComplexityOfTerm

func ComplexityOfTerm[F field.Element[F], T Expr[F, T]](c T) uint

ComplexityOfTerm attempts to provide a cost estimate for the given expression.

func Conjunction

func Conjunction[F field.Element[F], T Logical[F, T]](terms ...T) T

Conjunction builds the logical conjunction (i.e. and) for a given set of constraints.

func Const

func Const[F field.Element[F], T Expr[F, T]](val F) T

Const construct an AIR expression representing a given constant.

func Const64

func Const64[F field.Element[F], T Expr[F, T]](val uint64) T

Const64 construct an AIR expression representing a given constant from a uint64.

func Disjunction

func Disjunction[F field.Element[F], T Logical[F, T]](terms ...T) T

Disjunction creates a constraint representing the disjunction of a given set of constraints.

func Equals

func Equals[F field.Element[F], S Logical[F, S], T Expr[F, T]](lhs T, rhs T) S

Equals constructs an Equal representing the equality of two expressions.

func Exponent

func Exponent[F field.Element[F], T Expr[F, T]](arg T, pow uint64) T

Exponent constructs a new expression representing the given argument raised to a given a given power.

func False

func False[F field.Element[F], T Logical[F, T]]() T

False constructs a logical falsehood

func IfElse

func IfElse[F field.Element[F], S Logical[F, S], T Expr[F, T]](condition S, trueBranch T, falseBranch T) T

IfElse constructs a new conditional with true and false branches. Note, the true branch is taken when the condition evaluates to zero.

func IfThenElse

func IfThenElse[F field.Element[F], T Logical[F, T]](condition T, trueBranch T, falseBranch T) T

IfThenElse constructs a new conditional branch, where either the true branch or the false branch can (optionally) be nil (but both cannot). Note, the true branch is taken when the condition evaluates to zero.

func IsConstant

func IsConstant[F field.Element[F], T Expr[F, T]](term T) (F, bool)

IsConstant checks whether an artibrary term corresponds to a constant or not.

func IsConstant64

func IsConstant64[F field.Element[F], T Expr[F, T]](term T) (constant uint64, ok bool)

IsConstant64 checks whether a given term is a 64bit constant (or not) and, if so, what constant it is.

func IsFalse

func IsFalse[F field.Element[F], T Logical[F, T]](term T) bool

IsFalse Check whether a given term corresponds to logical falsehood which, in this system, corresponds to an empty disjunct.

func IsPowerOf2

func IsPowerOf2(val big.Int) (n uint, ok bool)

IsPowerOf2 checks whether a given big integer matches 2^n for some n and, if so, n is returned.

func IsTrue

func IsTrue[F field.Element[F], T Logical[F, T]](term T) bool

IsTrue checks whether a given term corresponds to logical truth which, in this system, corresponds to an empty conjunct.

func IsUnsafeExpr

func IsUnsafeExpr[F field.Element[F], S Logical[F, S], T Expr[F, T]](c T) bool

IsUnsafeExpr determines whether or not a given expression contains an unsafe operation (i.e. a runtime cast). Specifically, something which could fail at runtime.

func IsUnsafeLogical

func IsUnsafeLogical[F field.Element[F], S Logical[F, S], T Expr[F, T]](c S) bool

IsUnsafeLogical determines whether or not a given logical expression contains an unsafe operation (i.e. a runtime case). Specifically, something which could fail at runtime.

func LabelledConstant

func LabelledConstant[F field.Element[F], T Expr[F, T]](label string, value F) T

LabelledConstant construct an expression representing a constant with a given label.

func Negation

func Negation[F field.Element[F], T Logical[F, T]](body T) T

Negation constructs a term representing the negation of a logical term.

func NewRegisterAccess

func NewRegisterAccess[F field.Element[F], T Expr[F, T]](register register.Id, bitwidth uint, shift int) T

NewRegisterAccess constructs an AIR expression representing the value of a given register on the current row.

func NewVectorAccess

func NewVectorAccess[F field.Element[F], T Expr[F, T]](vars []*RegisterAccess[F, T]) T

NewVectorAccess constructs a new vector access for a given set of registers.

func Normalise

func Normalise[F field.Element[F], T Expr[F, T]](arg T) T

Normalise normalises the result of evaluating a given expression to be either 0 (if its value was 0) or 1 (otherwise).

func NotEquals

func NotEquals[F field.Element[F], S Logical[F, S], T Expr[F, T]](lhs T, rhs T) S

NotEquals constructs an NotEqual representing the NotEquality of two expressions.

func Product

func Product[F field.Element[F], T Expr[F, T]](terms ...T) T

Product returns the product of zero or more multiplications.

func SubdivideExpr

func SubdivideExpr[F field.Element[F], S Logical[F, S], T Expr[F, T]](c T, mapping register.LimbsMap) T

SubdivideExpr subdivides a computation by splitting all register accesses into vector accesses over their limbs.

func SubdivideExprs

func SubdivideExprs[F field.Element[F], S Logical[F, S], T Expr[F, T]](cs []T, mapping register.LimbsMap) []T

SubdivideExprs subdivides an array of zero or more logical computations.

func SubdivideLogical

func SubdivideLogical[F field.Element[F], S Logical[F, S], T Expr[F, T]](c S, mapping register.LimbsMap) S

SubdivideLogical subdivides a logical computation by splitting all register accesses into vector accesses over their limbs.

func SubdivideLogicals

func SubdivideLogicals[F field.Element[F], S Logical[F, S], T Expr[F, T]](cs []S, mapping register.LimbsMap,
) []S

SubdivideLogicals Subdivides an array of zero or more logical computations.

func Subtract

func Subtract[F field.Element[F], T Expr[F, T]](terms ...T) T

Subtract returns the subtraction of the subsequent expressions from the first.

func Sum

func Sum[F field.Element[F], T Expr[F, T]](terms ...T) T

Sum zero or more expressions together.

func True

func True[F field.Element[F], T Logical[F, T]]() T

True constructs a logical truth

Types

type Add

type Add[F field.Element[F], T Expr[F, T]] struct{ Args []T }

Add represents the addition of zero or more expressions.

func (*Add[F, T]) Air

func (p *Add[F, T]) Air()

Air indicates this term can be used at the AIR level.

func (*Add[F, T]) ApplyShift

func (p *Add[F, T]) ApplyShift(shift int) T

ApplyShift implementation for Term interface.

func (*Add[F, T]) Bounds

func (p *Add[F, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*Add[F, T]) EvalAt

func (p *Add[F, T]) EvalAt(k int, tr trace.Module[F], sc register.Map) (F, error)

EvalAt implementation for Evaluable interface.

func (*Add[F, T]) Lisp

func (p *Add[F, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp implementation for Lispifiable interface.

func (*Add[F, T]) RequiredCells

func (p *Add[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*Add[F, T]) RequiredRegisters

func (p *Add[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*Add[F, T]) ShiftRange

func (p *Add[F, T]) ShiftRange() (int, int)

ShiftRange implementation for Term interface.

func (*Add[F, T]) Simplify

func (p *Add[F, T]) Simplify(casts bool) T

Simplify implementation for Term interface.

func (*Add[F, T]) Substitute

func (p *Add[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*Add[F, T]) ValueRange

func (p *Add[F, T]) ValueRange() math.Interval

ValueRange implementation for Term interface.

type Cast

type Cast[F field.Element[F], T Expr[F, T]] struct {
	Arg      T
	BitWidth uint
	Bound    F
}

Cast attempts to narrow the width a given expression.

func (*Cast[F, T]) ApplyShift

func (p *Cast[F, T]) ApplyShift(shift int) T

ApplyShift implementation for Term interface.

func (*Cast[F, T]) Bounds

func (p *Cast[F, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*Cast[F, T]) EvalAt

func (p *Cast[F, T]) EvalAt(k int, tr trace.Module[F], sc register.Map) (F, error)

EvalAt implementation for Evaluable interface.

func (*Cast[F, T]) Lisp

func (p *Cast[F, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp implementation for Lispifiable interface.

func (*Cast[F, T]) Range

func (p *Cast[F, T]) Range() math.Interval

Range returns the range of values which this cast represents.

func (*Cast[F, T]) RequiredCells

func (p *Cast[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*Cast[F, T]) RequiredRegisters

func (p *Cast[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*Cast[F, T]) ShiftRange

func (p *Cast[F, T]) ShiftRange() (int, int)

ShiftRange implementation for Term interface.

func (*Cast[F, T]) Simplify

func (p *Cast[F, T]) Simplify(casts bool) T

Simplify implementation for Term interface.

func (*Cast[F, T]) Substitute

func (p *Cast[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*Cast[F, T]) ValueRange

func (p *Cast[F, T]) ValueRange() math.Interval

ValueRange implementation for Term interface.

type Computation

type Computation[F any] interface {
	Expr[F, Computation[F]]
}

Computation represents an "unbound" term. That is, it captures any possible term (i.e. rather than a fixed set as for MIR or AIR, etc).

func NewComputation

func NewComputation[F field.Element[F], S Logical[F, S], T Expr[F, T]](term Expr[F, T]) Computation[F]

NewComputation takes an arbitrary term and converts in into an instance of computation by wrapping it.

func NewComputations

func NewComputations[F field.Element[F], S Logical[F, S], T Expr[F, T]](terms []T) []Computation[F]

NewComputations constructs an array of zero or more computations.

type ComputationTerm

type ComputationTerm = Expr[word.BigEndian, Computation[word.BigEndian]]

ComputationTerm provides a convenient alias for a big endian term.

type Conjunct

type Conjunct[F field.Element[F], T Logical[F, T]] struct {
	// Terms here are disjuncted to formulate the final logical result.
	Args []T
}

Conjunct erpresents the logical AND of zero or more terms. Observe that if there are no terms, then this is equivalent to logical truth.

func (*Conjunct[F, T]) ApplyShift

func (p *Conjunct[F, T]) ApplyShift(shift int) T

ApplyShift implementation for LogicalTerm interface.

func (*Conjunct[F, T]) Bounds

func (p *Conjunct[F, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*Conjunct[F, T]) Lisp

func (p *Conjunct[F, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp returns a lisp representation of this equation, which is useful for debugging.

func (*Conjunct[F, S]) Negate

func (p *Conjunct[F, S]) Negate() S

Negate implementation for LogicalTerm interface

func (*Conjunct[F, T]) RequiredCells

func (p *Conjunct[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*Conjunct[F, T]) RequiredRegisters

func (p *Conjunct[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*Conjunct[F, T]) ShiftRange

func (p *Conjunct[F, T]) ShiftRange() (int, int)

ShiftRange implementation for LogicalTerm interface.

func (*Conjunct[F, T]) Simplify

func (p *Conjunct[F, T]) Simplify(casts bool) T

Simplify this term as much as reasonably possible.

func (*Conjunct[F, T]) Substitute

func (p *Conjunct[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*Conjunct[F, T]) TestAt

func (p *Conjunct[F, T]) TestAt(k int, tr trace.Module[F], sc register.Map) (bool, uint, error)

TestAt implementation for Testable interface.

type Constant

type Constant[F field.Element[F], T Expr[F, T]] struct{ Value F }

Constant represents a constant value within an expression.

func (*Constant[F, T]) Air

func (p *Constant[F, T]) Air()

Air indicates this term can be used at the AIR level.

func (*Constant[F, T]) ApplyShift

func (p *Constant[F, T]) ApplyShift(int) T

ApplyShift implementation for Term interface.

func (*Constant[F, T]) Bounds

func (p *Constant[F, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*Constant[F, T]) EvalAt

func (p *Constant[F, T]) EvalAt(k int, _ trace.Module[F], _ register.Map) (F, error)

EvalAt implementation for Evaluable interface.

func (*Constant[F, T]) Lisp

func (p *Constant[F, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp implementation for Lispifiable interface.

func (*Constant[F, T]) RequiredCells

func (p *Constant[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*Constant[F, T]) RequiredRegisters

func (p *Constant[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*Constant[F, T]) ShiftRange

func (p *Constant[F, T]) ShiftRange() (int, int)

ShiftRange implementation for Term interface.

func (*Constant[F, T]) Simplify

func (p *Constant[F, T]) Simplify(casts bool) T

Simplify implementation for Term interface.

func (*Constant[F, T]) Substitute

func (p *Constant[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*Constant[F, T]) ValueRange

func (p *Constant[F, T]) ValueRange() util_math.Interval

ValueRange implementation for Term interface.

type Contextual

type Contextual interface {
	// RequiredRegisters returns the set of registers on which this term depends.
	// That is, registers whose values may be accessed when evaluating this term
	// on a given trace.
	RequiredRegisters() *set.SortedSet[uint]
	// RequiredCells returns the set of trace cells on which evaluation of this
	// constraint element depends.
	RequiredCells(int, trace.ModuleId) *set.AnySortedSet[trace.CellRef]
}

Contextual captures something which requires an evaluation context (i.e. a single enclosing module) in order to make sense. For example, expressions require a single context. This interface is separated from Evaluable (and Testable) because HIR expressions do not implement Evaluable.

type Costable

type Costable interface {
	Complexity() uint
}

Costable represents a component which can self-determine an approximage cost measure.

type Disjunct

type Disjunct[F field.Element[F], T Logical[F, T]] struct {
	Args []T
}

Disjunct erpresents the logical OR of zero or more terms. Observe that if there are no terms, then this is equivalent to logical falsehood.

func (*Disjunct[F, T]) ApplyShift

func (p *Disjunct[F, T]) ApplyShift(shift int) T

ApplyShift implementation for LogicalTerm interface.

func (*Disjunct[F, T]) Bounds

func (p *Disjunct[F, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*Disjunct[F, T]) Lisp

func (p *Disjunct[F, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp returns a lisp representation of this equation, which is useful for debugging.

func (*Disjunct[F, S]) Negate

func (p *Disjunct[F, S]) Negate() S

Negate implementation for LogicalTerm interface

func (*Disjunct[F, T]) RequiredCells

func (p *Disjunct[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*Disjunct[F, T]) RequiredRegisters

func (p *Disjunct[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*Disjunct[F, T]) ShiftRange

func (p *Disjunct[F, T]) ShiftRange() (int, int)

ShiftRange implementation for LogicalTerm interface.

func (*Disjunct[F, T]) Simplify

func (p *Disjunct[F, T]) Simplify(casts bool) T

Simplify this term as much as reasonably possible.

func (*Disjunct[F, T]) Substitute

func (p *Disjunct[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*Disjunct[F, T]) TestAt

func (p *Disjunct[F, T]) TestAt(k int, tr trace.Module[F], sc register.Map) (bool, uint, error)

TestAt implementation for Testable interface.

type Equal

type Equal[F field.Element[F], S Logical[F, S], T Expr[F, T]] struct {
	Lhs Expr[F, T]
	Rhs Expr[F, T]
}

Equal represents an Equal between two terms (e.g. "X==Y", or "X!=Y+1", etc). Equals are either equalities (or negated equalities) or inequalities.

func (*Equal[F, S, T]) ApplyShift

func (p *Equal[F, S, T]) ApplyShift(shift int) S

ApplyShift implementation for LogicalTerm interface.

func (*Equal[F, S, T]) Bounds

func (p *Equal[F, S, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*Equal[F, S, T]) Lisp

func (p *Equal[F, S, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp returns a lisp representation of this Equal, which is useful for debugging.

func (*Equal[F, S, T]) Negate

func (p *Equal[F, S, T]) Negate() S

Negate implementation for LogicalTerm interface

func (*Equal[F, S, T]) RequiredCells

func (p *Equal[F, S, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*Equal[F, S, T]) RequiredRegisters

func (p *Equal[F, S, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*Equal[F, S, T]) ShiftRange

func (p *Equal[F, S, T]) ShiftRange() (int, int)

ShiftRange implementation for LogicalTerm interface.

func (*Equal[F, S, T]) Simplify

func (p *Equal[F, S, T]) Simplify(casts bool) S

Simplify this term as much as reasonably possible. nolint

func (*Equal[F, S, T]) Substitute

func (p *Equal[F, S, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*Equal[F, S, T]) TestAt

func (p *Equal[F, S, T]) TestAt(k int, tr trace.Module[F], sc register.Map) (bool, uint, error)

TestAt implementation for Testable interface.

type Evaluable

type Evaluable[F any] interface {
	util.Boundable
	Contextual
	Substitutable[F]
	// EvalAt evaluates this expression in a given tabular context.
	// Observe that if this expression is *undefined* within this
	// context then it returns "nil".  An expression can be
	// undefined for several reasons: firstly, if it accesses a
	// row which does not exist (e.g. at index -1); secondly, if
	// it accesses a register which does not exist.
	EvalAt(int, trace.Module[F], register.Map) (F, error)
	// Lisp converts this schema element into a simple S-Expression, for example
	// so it can be printed.
	Lisp(bool, register.Map) sexp.SExp
	// ValueRange returns the interval of values that this term can evaluate to.
	// For terms accessing registers, this is determined by the declared width of
	// the register.
	ValueRange() math.Interval
}

Evaluable captures something which can be evaluated on a given table row to produce an evaluation point. For example, expressions in the Mid-Level or Arithmetic-Level IR can all be evaluated at rows of a table.

type Exp

type Exp[F field.Element[F], T Expr[F, T]] struct {
	Arg T
	Pow uint64
}

Exp represents the a given value taken to a power.

func (*Exp[F, T]) ApplyShift

func (p *Exp[F, T]) ApplyShift(shift int) T

ApplyShift implementation for Term interface.

func (*Exp[F, T]) Bounds

func (p *Exp[F, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*Exp[F, T]) EvalAt

func (p *Exp[F, T]) EvalAt(k int, tr trace.Module[F], sc register.Map) (F, error)

EvalAt implementation for Evaluable interface.

func (*Exp[F, T]) Lisp

func (p *Exp[F, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp implementation for Lispifiable interface.

func (*Exp[F, T]) RequiredCells

func (p *Exp[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*Exp[F, T]) RequiredRegisters

func (p *Exp[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*Exp[F, T]) ShiftRange

func (p *Exp[F, T]) ShiftRange() (int, int)

ShiftRange implementation for Term interface.

func (*Exp[F, T]) Simplify

func (p *Exp[F, T]) Simplify(casts bool) T

Simplify implementation for Term interface.

func (*Exp[F, T]) Substitute

func (p *Exp[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*Exp[F, T]) ValueRange

func (p *Exp[F, T]) ValueRange() math.Interval

ValueRange implementation for Term interface.

type Expr

type Expr[F any, T any] interface {
	Contextual
	Shiftable[T]
	Evaluable[F]
	util.Boundable
	Substitutable[F]

	// Simplify constant expressions down to single values.  For example, "(+ 1
	// 2)" would be collapsed down to "3".  This is then progagated throughout
	// an expression, so that e.g. "(+ X (+ 1 2))" becomes "(+ X 3)"", etc.
	// There is also an option to retain casts, or not.
	Simplify(casts bool) T
}

Expr represents a component of an HIR/MIR/AIR expression.

type IfZero

type IfZero[F field.Element[F], S Logical[F, S], T Expr[F, T]] struct {
	// Elements contained within this list.
	Condition S
	// True branch
	TrueBranch T
	// False branch
	FalseBranch T
}

IfZero returns the true branch when the condition evaluates to zero, and the false branch otherwise.

func (*IfZero[F, S, T]) ApplyShift

func (p *IfZero[F, S, T]) ApplyShift(shift int) T

ApplyShift implementation for Term interface.

func (*IfZero[F, S, T]) Bounds

func (p *IfZero[F, S, T]) Bounds() util.Bounds

Bounds returns max shift in either the negative (left) or positive direction (right).

func (*IfZero[F, S, T]) EvalAt

func (p *IfZero[F, S, T]) EvalAt(k int, tr trace.Module[F], sc register.Map) (F, error)

EvalAt implementation for Evaluable interface.

func (*IfZero[F, S, T]) Lisp

func (p *IfZero[F, S, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp implementation for Lispifiable interface.

func (*IfZero[F, S, T]) RequiredCells

func (p *IfZero[F, S, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*IfZero[F, S, T]) RequiredRegisters

func (p *IfZero[F, S, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*IfZero[F, S, T]) ShiftRange

func (p *IfZero[F, S, T]) ShiftRange() (int, int)

ShiftRange implementation for Term interface.

func (*IfZero[F, S, T]) Simplify

func (p *IfZero[F, S, T]) Simplify(casts bool) T

Simplify implementation for Term interface.

nolint

func (*IfZero[F, S, T]) Substitute

func (p *IfZero[F, S, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*IfZero[F, S, T]) ValueRange

func (p *IfZero[F, S, T]) ValueRange() math.Interval

ValueRange implementation for Term interface.

type Ite

type Ite[F field.Element[F], T Logical[F, T]] struct {
	// Elements contained within this list.
	Condition T
	// True branch (optional).
	TrueBranch Logical[F, T]
	// False branch (optional).
	FalseBranch Logical[F, T]
}

Ite represents an "If Then Else" expression which returns the (optional) true branch when the condition evaluates to zero, and the (optional false branch otherwise.

func (*Ite[F, T]) ApplyShift

func (p *Ite[F, T]) ApplyShift(shift int) T

ApplyShift implementation for LogicalTerm interface.

func (*Ite[F, T]) Bounds

func (p *Ite[F, T]) Bounds() util.Bounds

Bounds returns max shift in either the negative (left) or positive direction (right).

func (*Ite[F, T]) Lisp

func (p *Ite[F, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp implementation for Lispifiable interface.

func (*Ite[F, S]) Negate

func (p *Ite[F, S]) Negate() S

Negate implementation for LogicalTerm interface

func (*Ite[F, T]) RequiredCells

func (p *Ite[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*Ite[F, T]) RequiredRegisters

func (p *Ite[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*Ite[F, T]) ShiftRange

func (p *Ite[F, T]) ShiftRange() (int, int)

ShiftRange implementation for LogicalTerm interface.

func (*Ite[F, T]) Simplify

func (p *Ite[F, T]) Simplify(casts bool) T

Simplify this Negate as much as reasonably possible. Overall, simplifying ite is surprisingly tricky. However, its useful to retain ite rathe the compile it out completely as, in some cases, we can optimise things more effectively.

func (*Ite[F, T]) Substitute

func (p *Ite[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*Ite[F, T]) TestAt

func (p *Ite[F, T]) TestAt(k int, tr trace.Module[F], sc register.Map) (bool, uint, error)

TestAt implementation for Testable interface.

type LabelledConst

type LabelledConst[F field.Element[F], T Expr[F, T]] struct {
	Label string
	Value F
}

LabelledConst represents a constant value which is labelled with a given name. The purpose of this is to allow labelled constants to be substituted for different values when desired.

func (*LabelledConst[F, T]) ApplyShift

func (p *LabelledConst[F, T]) ApplyShift(int) T

ApplyShift implementation for Term interface.

func (*LabelledConst[F, T]) Bounds

func (p *LabelledConst[F, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*LabelledConst[F, T]) EvalAt

func (p *LabelledConst[F, T]) EvalAt(k int, _ trace.Module[F], _ register.Map) (F, error)

EvalAt implementation for Evaluable interface.

func (*LabelledConst[F, T]) Lisp

func (p *LabelledConst[F, T]) Lisp(_ bool, _ register.Map) sexp.SExp

Lisp implementation for Lispifiable interface.

func (*LabelledConst[F, T]) RequiredCells

func (p *LabelledConst[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*LabelledConst[F, T]) RequiredRegisters

func (p *LabelledConst[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*LabelledConst[F, T]) ShiftRange

func (p *LabelledConst[F, T]) ShiftRange() (int, int)

ShiftRange implementation for Term interface.

func (*LabelledConst[F, T]) Simplify

func (p *LabelledConst[F, T]) Simplify(casts bool) T

Simplify implementation for Term interface.

func (*LabelledConst[F, T]) Substitute

func (p *LabelledConst[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*LabelledConst[F, T]) ValueRange

func (p *LabelledConst[F, T]) ValueRange() util_math.Interval

ValueRange implementation for Term interface.

type Logical

type Logical[F any, T any] interface {
	Contextual
	Shiftable[T]
	Testable[F]

	// Simplify constant expressions down to single values.  For example, "(+ 1
	// 2)" would be collapsed down to "3".  This is then progagated throughout
	// an expression, so that e.g. "(+ X (+ 1 2))" becomes "(+ X 3)"", etc.
	// There is also an option to retain casts, or not.
	Simplify(casts bool) T

	// Negate this logical term
	Negate() T
}

Logical represents a term which can be tested for truth or falsehood. For example, an equality comparing two arithmetic terms is a logical term.

type LogicalComputation

type LogicalComputation[F any] interface {
	Logical[F, LogicalComputation[F]]
}

LogicalComputation represents an "unbound" term. That is, it captures any possible term (i.e. rather than a fixed set as for MIR or AIR, etc).

func NewLogicalComputation

func NewLogicalComputation[F field.Element[F], S Logical[F, S], T Expr[F, T]](term Logical[F, S],
) LogicalComputation[F]

NewLogicalComputation takes an arbitrary logical term and converts in into an instance of computation by wrapping it.

func NewLogicalComputations

func NewLogicalComputations[F field.Element[F], S Logical[F, S], T Expr[F, T]](terms []S) []LogicalComputation[F]

NewLogicalComputations constructs an array of zero or more computations.

type LogicalComputationTerm

type LogicalComputationTerm = Logical[word.BigEndian, LogicalComputation[word.BigEndian]]

LogicalComputationTerm provides a convenient alias for a big endian logical term.

type Mul

type Mul[F field.Element[F], T Expr[F, T]] struct{ Args []T }

Mul represents the product over zero or more expressions.

func (*Mul[F, T]) Air

func (p *Mul[F, T]) Air()

Air indicates this term can be used at the AIR level.

func (*Mul[F, T]) ApplyShift

func (p *Mul[F, T]) ApplyShift(shift int) T

ApplyShift implementation for Term interface.

func (*Mul[F, T]) Bounds

func (p *Mul[F, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*Mul[F, T]) EvalAt

func (p *Mul[F, T]) EvalAt(k int, tr trace.Module[F], sc register.Map) (F, error)

EvalAt implementation for Evaluable interface.

func (*Mul[F, T]) IsDefined

func (p *Mul[F, T]) IsDefined() bool

IsDefined implementation for Evaluable interface.

func (*Mul[F, T]) Lisp

func (p *Mul[F, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp implementation for Lispifiable interface.

func (*Mul[F, T]) RequiredCells

func (p *Mul[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*Mul[F, T]) RequiredRegisters

func (p *Mul[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*Mul[F, T]) ShiftRange

func (p *Mul[F, T]) ShiftRange() (int, int)

ShiftRange implementation for Term interface.

func (*Mul[F, T]) Simplify

func (p *Mul[F, T]) Simplify(casts bool) T

Simplify implementation for Term interface.

func (*Mul[F, T]) Substitute

func (p *Mul[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*Mul[F, T]) ValueRange

func (p *Mul[F, T]) ValueRange() math.Interval

ValueRange implementation for Term interface.

type Negate

type Negate[F field.Element[F], T Logical[F, T]] struct {
	Arg T
}

Negate represents an Negate between two terms (e.g. "X==Y", or "X!=Y+1", etc). Negate are either Negateities (or negated Negateities) or inNegateities.

func (*Negate[F, T]) ApplyShift

func (p *Negate[F, T]) ApplyShift(shift int) T

ApplyShift implementation for LogicalTerm interface.

func (*Negate[F, T]) Bounds

func (p *Negate[F, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*Negate[F, T]) Lisp

func (p *Negate[F, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp returns a lisp representation of this Negate, which is useful for debugging.

func (*Negate[F, T]) Negate

func (p *Negate[F, T]) Negate() T

Negate implementation for LogicalTerm interface

func (*Negate[F, T]) RequiredCells

func (p *Negate[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*Negate[F, T]) RequiredRegisters

func (p *Negate[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*Negate[F, T]) ShiftRange

func (p *Negate[F, T]) ShiftRange() (int, int)

ShiftRange implementation for LogicalTerm interface.

func (*Negate[F, T]) Simplify

func (p *Negate[F, T]) Simplify(casts bool) T

Simplify this Negate as much as reasonably possible.

func (*Negate[F, T]) Substitute

func (p *Negate[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*Negate[F, T]) TestAt

func (p *Negate[F, T]) TestAt(k int, tr trace.Module[F], sc register.Map) (bool, uint, error)

TestAt implementation for Testable interface.

type Norm

type Norm[F field.Element[F], T Expr[F, T]] struct{ Arg T }

Norm reduces the value of an expression to either zero (if it was zero) or one (otherwise).

func (*Norm[F, T]) ApplyShift

func (p *Norm[F, T]) ApplyShift(shift int) T

ApplyShift implementation for Term interface.

func (*Norm[F, T]) Bounds

func (p *Norm[F, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*Norm[F, T]) EvalAt

func (p *Norm[F, T]) EvalAt(k int, tr trace.Module[F], sc register.Map) (F, error)

EvalAt implementation for Evaluable interface.

func (*Norm[F, T]) IsDefined

func (p *Norm[F, T]) IsDefined() bool

IsDefined implementation for Evaluable interface.

func (*Norm[F, T]) Lisp

func (p *Norm[F, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp implementation for Lispifiable interface.

func (*Norm[F, T]) RequiredCells

func (p *Norm[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*Norm[F, T]) RequiredRegisters

func (p *Norm[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*Norm[F, T]) ShiftRange

func (p *Norm[F, T]) ShiftRange() (int, int)

ShiftRange implementation for Term interface.

func (*Norm[F, T]) Simplify

func (p *Norm[F, T]) Simplify(casts bool) T

Simplify implementation for Term interface.

func (*Norm[F, T]) Substitute

func (p *Norm[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*Norm[F, T]) ValueRange

func (p *Norm[F, T]) ValueRange() math.Interval

ValueRange implementation for Term interface.

type NotEqual

type NotEqual[F field.Element[F], S Logical[F, S], T Expr[F, T]] struct {
	Lhs Expr[F, T]
	Rhs Expr[F, T]
}

NotEqual represents an NotEqual between two terms (e.g. "X==Y", or "X!=Y+1", etc). NotEquals are either NotEqualities (or negated NotEqualities) or inNotEqualities.

func (*NotEqual[F, S, T]) ApplyShift

func (p *NotEqual[F, S, T]) ApplyShift(shift int) S

ApplyShift implementation for LogicalTerm interface.

func (*NotEqual[F, S, T]) Bounds

func (p *NotEqual[F, S, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*NotEqual[F, S, T]) Lisp

func (p *NotEqual[F, S, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp returns a lisp representation of this NotEqual, which is useful for debugging.

func (*NotEqual[F, S, T]) Negate

func (p *NotEqual[F, S, T]) Negate() S

Negate implementation for LogicalTerm interface

func (*NotEqual[F, S, T]) RequiredCells

func (p *NotEqual[F, S, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*NotEqual[F, S, T]) RequiredRegisters

func (p *NotEqual[F, S, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*NotEqual[F, S, T]) ShiftRange

func (p *NotEqual[F, S, T]) ShiftRange() (int, int)

ShiftRange implementation for LogicalTerm interface.

func (*NotEqual[F, S, T]) Simplify

func (p *NotEqual[F, S, T]) Simplify(casts bool) S

Simplify this term as much as reasonably possible.

nolint

func (*NotEqual[F, S, T]) Substitute

func (p *NotEqual[F, S, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*NotEqual[F, S, T]) TestAt

func (p *NotEqual[F, S, T]) TestAt(k int, tr trace.Module[F], sc register.Map) (bool, uint, error)

TestAt implementation for Testable interface.

type RegisterAccess

type RegisterAccess[F field.Element[F], T Expr[F, T]] struct {
	// contains filtered or unexported fields
}

RegisterAccess represents reading the value held at a given register in the tabular context. Furthermore, the current row maybe shifted up (or down) by a given amount. Suppose we are evaluating a constraint on row k=5 which contains the register accesses "STAMP(0)" and "CT(-1)". Then, STAMP(0) accesses the STAMP register at row 5, whilst CT(-1) accesses the CT register at row 4.

func FieldAccess

func FieldAccess[F field.Element[F], T Expr[F, T]](register register.Id, shift int,
) *RegisterAccess[F, T]

FieldAccess constructs an AIR expression representing the value of a given register on the current row. There is an assumption here that the register being read has "field type". That is, it does not represent fixed width value in the usual sense. Such registers should only occur lower down in the pipeling for e.g. handling inverses, etc.

func RawRegisterAccess

func RawRegisterAccess[F field.Element[F], T Expr[F, T]](register register.Id, bitwidth uint, shift int,
) *RegisterAccess[F, T]

RawRegisterAccess constructs an AIR expression representing the value of a given register on the current row.

func (*RegisterAccess[F, T]) Air

func (p *RegisterAccess[F, T]) Air()

Air indicates this term can be used at the AIR level.

func (*RegisterAccess[F, T]) ApplyShift

func (p *RegisterAccess[F, T]) ApplyShift(shift int) T

ApplyShift implementation for Term interface.

func (*RegisterAccess[F, T]) BitWidth

func (p *RegisterAccess[F, T]) BitWidth() uint

BitWidth returns the declared bitwidth of the variable being accessed. Observe that the actual width of this access may be smaller than this if a mask is being applied.

func (*RegisterAccess[F, T]) Bounds

func (p *RegisterAccess[F, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*RegisterAccess[F, T]) EvalAt

func (p *RegisterAccess[F, T]) EvalAt(k int, module trace.Module[F], _ register.Map) (F, error)

EvalAt implementation for Evaluable interface.

func (*RegisterAccess[F, T]) HasFieldType

func (p *RegisterAccess[F, T]) HasFieldType() bool

HasFieldType checks whether or not this register access is for a register which has "field width". That is, it does not have a true bitwidth per se.

func (*RegisterAccess[F, T]) IsDefined

func (p *RegisterAccess[F, T]) IsDefined() bool

IsDefined implementation for Evaluable interface.

func (*RegisterAccess[F, T]) Lisp

func (p *RegisterAccess[F, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp implementation for Lispifiable interface.

func (*RegisterAccess[F, T]) MarshalBinary

func (p *RegisterAccess[F, T]) MarshalBinary() ([]byte, error)

MarshalBinary converts the RegisterAccess into a sequence of bytes.

func (*RegisterAccess[F, T]) Mask

func (p *RegisterAccess[F, T]) Mask(maskwidth uint) *RegisterAccess[F, T]

Mask constructs a variation on this register access which only uses the "masked" portion of the given register. For example, this can be used to implement a cast.

func (*RegisterAccess[F, T]) MaskWidth

func (p *RegisterAccess[F, T]) MaskWidth() uint

MaskWidth returns the portion of the underlying column / register actually read by this access. For example, given a register of type u16 we might only be accessing the first u8 portion. In such case, the access is acting like a cast.

func (*RegisterAccess[F, T]) Register

func (p *RegisterAccess[F, T]) Register() register.Id

Register returns the id of the register being accessed.

func (*RegisterAccess[F, T]) RelativeShift

func (p *RegisterAccess[F, T]) RelativeShift() int

RelativeShift returns the relative shift of this access.

func (*RegisterAccess[F, T]) RequiredCells

func (p *RegisterAccess[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*RegisterAccess[F, T]) RequiredRegisters

func (p *RegisterAccess[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*RegisterAccess[F, T]) ShiftRange

func (p *RegisterAccess[F, T]) ShiftRange() (int, int)

ShiftRange implementation for Term interface.

func (*RegisterAccess[F, T]) Simplify

func (p *RegisterAccess[F, T]) Simplify(casts bool) T

Simplify implementation for Term interface.

func (*RegisterAccess[F, T]) Substitute

func (p *RegisterAccess[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*RegisterAccess[F, T]) UnmarshalBinary

func (p *RegisterAccess[F, T]) UnmarshalBinary(data []byte) error

UnmarshalBinary initialises this RegisterAccess from a given set of data bytes. This should match exactly the encoding above.

func (*RegisterAccess[F, T]) UnmarshalBuffer

func (p *RegisterAccess[F, T]) UnmarshalBuffer(buf *bytes.Buffer) error

UnmarshalBuffer initialises this RegisterAccess from a given byte buffer. This should match exactly the encoding above.

func (*RegisterAccess[F, T]) ValueRange

func (p *RegisterAccess[F, T]) ValueRange() util_math.Interval

ValueRange implementation for Term interface.

type Shiftable

type Shiftable[T any] interface {
	// ApplyShift applies a given shift to all variable accesses in a given term
	// by a given amount. This can be used to normalise shifting in certain
	// circumstances.
	ApplyShift(int) T

	// ShiftRange returns the minimum and maximum shift value used anywhere in
	// the given term.
	ShiftRange() (int, int)
}

Shiftable captures something which can contain row shifted accesses, and where we want information or to manipulate those accesses.

type Sub

type Sub[F field.Element[F], T Expr[F, T]] struct{ Args []T }

Sub represents the subtraction over zero or more expressions.

func (*Sub[F, T]) Air

func (p *Sub[F, T]) Air()

Air indicates this term can be used at the AIR level.

func (*Sub[F, T]) ApplyShift

func (p *Sub[F, T]) ApplyShift(shift int) T

ApplyShift implementation for Term interface.

func (*Sub[F, T]) Bounds

func (p *Sub[F, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*Sub[F, T]) EvalAt

func (p *Sub[F, T]) EvalAt(k int, tr trace.Module[F], sc register.Map) (F, error)

EvalAt implementation for Evaluable interface.

func (*Sub[F, T]) IsDefined

func (p *Sub[F, T]) IsDefined() bool

IsDefined implementation for Evaluable interface.

func (*Sub[F, T]) Lisp

func (p *Sub[F, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp implementation for Lispifiable interface.

func (*Sub[F, T]) RequiredCells

func (p *Sub[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*Sub[F, T]) RequiredRegisters

func (p *Sub[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*Sub[F, T]) ShiftRange

func (p *Sub[F, T]) ShiftRange() (int, int)

ShiftRange implementation for Term interface.

func (*Sub[F, T]) Simplify

func (p *Sub[F, T]) Simplify(casts bool) T

Simplify implementation for Term interface.

func (*Sub[F, T]) Substitute

func (p *Sub[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*Sub[F, T]) ValueRange

func (p *Sub[F, T]) ValueRange() math.Interval

ValueRange implementation for Term interface.

type Substitutable

type Substitutable[F any] interface {
	// Substitute any matchined labelled constants within this constraint
	Substitute(map[string]F)
}

Substitutable captures the notion of a term which may contain labelled constants that can be substituted.

type Testable

type Testable[F any] interface {
	util.Boundable
	Contextual
	Substitutable[F]
	// TestAt evaluates this expression in a given tabular context and checks it
	// against zero. Observe that if this expression is *undefined* within this
	// context then it returns "nil".  An expression can be undefined for
	// several reasons: firstly, if it accesses a row which does not exist (e.g.
	// at index -1); secondly, if it accesses a register which does not exist.
	TestAt(int, trace.Module[F], register.Map) (bool, uint, error)
	// Lisp converts this schema element into a simple S-Expression, for example
	// so it can be printed.
	Lisp(bool, register.Map) sexp.SExp
}

Testable captures the notion of a constraint which can be tested on a given row of a given trace. It is very similar to Evaluable, except that it only indicates success or failure. The reason for using this interface over Evaluable is that, for historical reasons, constraints at the HIR cannot be Evaluable (i.e. because they return multiple values, rather than a single value). However, constraints at the HIR level remain testable.

type VectorAccess

type VectorAccess[F field.Element[F], T Expr[F, T]] struct{ Vars []*RegisterAccess[F, T] }

VectorAccess represents the bitwise concatenation of one or more registers. Registers are organised in little endian form. That is, the least significant register comes first (i.e. has index 0 in the array).

func RawVectorAccess

func RawVectorAccess[F field.Element[F], T Expr[F, T]](vars []*RegisterAccess[F, T]) *VectorAccess[F, T]

RawVectorAccess constructs a new vector access for a given set of registers.

func (*VectorAccess[F, T]) ApplyShift

func (p *VectorAccess[F, T]) ApplyShift(shift int) T

ApplyShift implementation for Term interface.

func (*VectorAccess[F, T]) Bounds

func (p *VectorAccess[F, T]) Bounds() util.Bounds

Bounds implementation for Boundable interface.

func (*VectorAccess[F, T]) EvalAt

func (p *VectorAccess[F, T]) EvalAt(k int, tr trace.Module[F], sc register.Map) (F, error)

EvalAt implementation for Evaluable interface.

func (*VectorAccess[F, T]) IsDefined

func (p *VectorAccess[F, T]) IsDefined() bool

IsDefined implementation for Evaluable interface.

func (*VectorAccess[F, T]) Lisp

func (p *VectorAccess[F, T]) Lisp(global bool, mapping register.Map) sexp.SExp

Lisp implementation for Lispifiable interface.

func (*VectorAccess[F, T]) RequiredCells

func (p *VectorAccess[F, T]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells implementation for Contextual interface

func (*VectorAccess[F, T]) RequiredRegisters

func (p *VectorAccess[F, T]) RequiredRegisters() *set.SortedSet[uint]

RequiredRegisters implementation for Contextual interface.

func (*VectorAccess[F, T]) ShiftRange

func (p *VectorAccess[F, T]) ShiftRange() (int, int)

ShiftRange implementation for Term interface.

func (*VectorAccess[F, T]) Simplify

func (p *VectorAccess[F, T]) Simplify(casts bool) T

Simplify implementation for Term interface.

func (*VectorAccess[F, T]) Substitute

func (p *VectorAccess[F, T]) Substitute(mapping map[string]F)

Substitute implementation for Substitutable interface.

func (*VectorAccess[F, T]) ValueRange

func (p *VectorAccess[F, T]) ValueRange() util_math.Interval

ValueRange implementation for Term interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL