assignment

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: 23 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

Index

Constants

This section is empty.

Variables

View Source
var INNER_WORKERS uint

INNER_WORKERS controls the number of goroutines for row-parallel computation within a single computed register assignment. A value of 0 (default) means auto-detect from runtime.GOMAXPROCS(0). This can be set from the CLI to coordinate with outer-level parallelism in ParallelTraceExpansion.

Functions

func LexicographicSortRegisters

func LexicographicSortRegisters(n uint, prefix string, bitwidth uint) []register.Register

LexicographicSortRegisters is a helper for allocated the registers needed for a lexicographic sort.

func ReadPadding

func ReadPadding[F field.Element[F]](trace tr.Trace[F], regs ...register.Ref) []F

ReadPadding reads the padding values determined for a given set of registers in a trace.

func ReadRegisterRefs

func ReadRegisterRefs[F field.Element[F]](trace tr.Trace[F], regs ...register.Refs) []array.Vector[F]

ReadRegisterRefs reads the values for a given set of registers from a trace.

func ReadRegisters

func ReadRegisters[F field.Element[F]](trace tr.Trace[F], mid module.Id, regs ...register.Id) array.Vector[F]

ReadRegisters reads the values for a given set of registers from a trace.

func ReadRegistersRef

func ReadRegistersRef[F field.Element[F]](trace tr.Trace[F], regs ...register.Ref) []array.Array[F]

ReadRegistersRef reads the values for a given set of registers from a trace.

Types

type ComputedRegister

type ComputedRegister[F field.Element[F]] struct {
	// Module in which expression is evaluated
	Module schema.ModuleId
	// Target indices for computed column
	Targets []register.Id
	// The computation which accepts a given trace and computes
	// the value of this column at a given row.
	Expr term.Computation[word.BigEndian]
	// Direction in which value is computed (true = forward, false = backward).
	// More specifically, a forwards direction means the computation starts on
	// the first row, whilst a backwards direction means it starts on the last.
	Direction bool
}

ComputedRegister describes a column whose values are computed on-demand, rather than being stored in a data array. Typically computed columns read values from other columns in a trace in order to calculate their value. There is an expectation that this computation is acyclic. Furthermore, computed columns give rise to "trace expansion". That is where the initial trace provided by the user is expanded by determining the value of all computed columns.

func NewComputedRegister

func NewComputedRegister[F field.Element[F]](expr term.Computation[word.BigEndian], dir bool, module schema.ModuleId,
	limbs ...register.Id) *ComputedRegister[F]

NewComputedRegister constructs a new set of computed column(s) with a given determining expression. More specifically, that expression is used to compute the values for the columns during trace expansion. For each, the resulting value is split across the target columns.

func (*ComputedRegister[F]) Bounds

func (p *ComputedRegister[F]) Bounds(mid sc.ModuleId) util.Bounds

Bounds determines the well-definedness bounds for this assignment for both the negative (left) or positive (right) directions. For example, consider an expression such as "(shift X -1)". This is technically undefined for the first row of any trace and, by association, any constraint evaluating this expression on that first row is also undefined (and hence must pass).

func (*ComputedRegister[F]) Compute

func (p *ComputedRegister[F]) Compute(tr trace.Trace[F], schema schema.AnySchema[F],
) ([]array.MutArray[F], error)

Compute the values of columns defined by this assignment. Specifically, this creates a new column which contains the result of evaluating a given expression on each row.

func (*ComputedRegister[F]) Consistent

func (p *ComputedRegister[F]) Consistent(schema sc.AnySchema[F]) []error

Consistent performs some simple checks that the given assignment is consistent with its enclosing schema This provides a double check of certain key properties, such as that registers used for assignments are valid, etc.

func (*ComputedRegister[F]) IsRecursive

func (p *ComputedRegister[F]) IsRecursive() bool

IsRecursive checks whether or not this computation is recursive (i.e. the target column is defined in terms of itself).

func (*ComputedRegister[F]) Lisp

func (p *ComputedRegister[F]) Lisp(schema sc.AnySchema[F]) sexp.SExp

Lisp converts this constraint into an S-Expression.

func (*ComputedRegister[F]) RegistersExpanded

func (p *ComputedRegister[F]) RegistersExpanded() []register.Ref

RegistersExpanded identifies registers expanded by this assignment.

func (*ComputedRegister[F]) RegistersRead

func (p *ComputedRegister[F]) RegistersRead() []register.Ref

RegistersRead returns the set of columns that this assignment depends upon. That can include both input columns, as well as other computed columns.

func (*ComputedRegister[F]) RegistersWritten

func (p *ComputedRegister[F]) RegistersWritten() []register.Ref

RegistersWritten identifies registers assigned by this assignment.

func (*ComputedRegister[F]) Substitute

func (p *ComputedRegister[F]) Substitute(mapping map[string]F)

Substitute any matchined labelled constants within this assignment

type LexicographicSort

type LexicographicSort[F field.Element[F]] struct {
	// contains filtered or unexported fields
}

LexicographicSort provides the necessary computation for filling out columns added to enforce lexicographic sorting constraints between one or more source columns. Specifically, a delta column is required along with one selector column (binary) for each source column.

func NewLexicographicSort

func NewLexicographicSort[F field.Element[F]](targets []register.Ref, signs []bool, sources []register.Ref,
	bitwidth uint) *LexicographicSort[F]

NewLexicographicSort constructs a new LexicographicSorting assignment.

func (*LexicographicSort[F]) Bounds

func (p *LexicographicSort[F]) Bounds(_ sc.ModuleId) util.Bounds

Bounds determines the well-definedness bounds for this assignment for both the negative (left) or positive (right) directions. For example, consider an expression such as "(shift X -1)". This is technically undefined for the first row of any trace and, by association, any constraint evaluating this expression on that first row is also undefined (and hence must pass).

func (*LexicographicSort[F]) Compute

func (p *LexicographicSort[F]) Compute(trace tr.Trace[F], schema sc.AnySchema[F],
) ([]array.MutArray[F], error)

Compute computes the values of columns defined as needed to support the LexicographicSortingGadget. That includes the delta column, and the bit selectors.

func (*LexicographicSort[F]) Consistent

func (p *LexicographicSort[F]) Consistent(schema sc.AnySchema[F]) []error

Consistent performs some simple checks that the given schema is consistent. This provides a double check of certain key properties, such as that registers used for assignments are large enough, etc.

func (*LexicographicSort[F]) Lisp

func (p *LexicographicSort[F]) Lisp(schema sc.AnySchema[F]) sexp.SExp

Lisp converts this schema element into a simple S-Expression, for example so it can be printed.

func (*LexicographicSort[F]) RegistersExpanded

func (p *LexicographicSort[F]) RegistersExpanded() []register.Ref

RegistersExpanded identifies registers expanded by this assignment.

func (*LexicographicSort[F]) RegistersRead

func (p *LexicographicSort[F]) RegistersRead() []register.Ref

RegistersRead returns the set of columns that this assignment depends upon. That can include both input columns, as well as other computed columns.

func (*LexicographicSort[F]) RegistersWritten

func (p *LexicographicSort[F]) RegistersWritten() []register.Ref

RegistersWritten identifies registers assigned by this assignment.

func (*LexicographicSort[F]) Substitute

func (p *LexicographicSort[F]) Substitute(mapping map[string]F)

Substitute any matchined labelled constants within this assignment

type NativeComputation

type NativeComputation[F field.Element[F]] struct {
	// Name of the function being invoked.
	Function string
	// Target columns declared by this sorted permutation (in the order
	// of declaration).
	Targets []register.Refs
	// Source columns which define the new (sorted) columns.
	Sources []register.Refs
}

NativeComputation currently describes a native computation which accepts a set of input columns, and assigns a set of output columns.

func NewNativeComputation

func NewNativeComputation[F field.Element[F]](fn string, targets []register.Refs,
	sources []register.Refs) *NativeComputation[F]

NewNativeComputation defines a set of target columns which are assigned from a given set of source columns using a function to multiplex input to output.

func (*NativeComputation[F]) Bounds

func (p *NativeComputation[F]) Bounds(_ sc.ModuleId) util.Bounds

Bounds determines the well-definedness bounds for this assignment for both the negative (left) or positive (right) directions. For example, consider an expression such as "(shift X -1)". This is technically undefined for the first row of any trace and, by association, any constraint evaluating this expression on that first row is also undefined (and hence must pass).

func (*NativeComputation[F]) Compute

func (p *NativeComputation[F]) Compute(trace tr.Trace[F], schema sc.AnySchema[F],
) ([]array.MutArray[F], error)

Compute computes the values of columns defined by this assignment. This requires copying the data in the source columns, and sorting that data according to the permutation criteria.

func (*NativeComputation[F]) Consistent

func (p *NativeComputation[F]) Consistent(_ sc.AnySchema[F]) []error

Consistent performs some simple checks that the given schema is consistent. This provides a double check of certain key properties, such as that registers used for assignments are large enough, etc.

func (*NativeComputation[F]) Lisp

func (p *NativeComputation[F]) Lisp(schema sc.AnySchema[F]) sexp.SExp

Lisp converts this schema element into a simple S-Expression, for example so it can be printed.

func (*NativeComputation[F]) RegistersExpanded

func (p *NativeComputation[F]) RegistersExpanded() []register.Ref

RegistersExpanded identifies registers expanded by this assignment.

func (*NativeComputation[F]) RegistersRead

func (p *NativeComputation[F]) RegistersRead() []register.Ref

RegistersRead returns the set of columns that this assignment depends upon. That can include both input columns, as well as other computed columns.

func (*NativeComputation[F]) RegistersWritten

func (p *NativeComputation[F]) RegistersWritten() []register.Ref

RegistersWritten identifies registers assigned by this assignment.

func (*NativeComputation[F]) Substitute

func (p *NativeComputation[F]) Substitute(map[string]F)

Substitute any matchined labelled constants within this assignment

type NativeComputationFn

type NativeComputationFn[F any] func([]array.Vector[F], array.Builder[F]) []array.MutVector[F]

NativeComputationFn defines the type of a native function for computing a given set of output columns as a function of a given set of input columns.

type PseudoInverse

type PseudoInverse[F field.Element[F]] struct {
	// Target index for computed column
	Target register.Ref

	Expr air.Term[F]
}

PseudoInverse represents a computation which computes the multiplicative inverse of a given expression.

func NewPseudoInverse

func NewPseudoInverse[F field.Element[F]](target register.Ref, expr air.Term[F]) *PseudoInverse[F]

NewPseudoInverse constructs a new pseudo-inverse assignment for the given target register and expression.

func (*PseudoInverse[F]) Bounds

func (e *PseudoInverse[F]) Bounds(mid schema.ModuleId) util.Bounds

Bounds determines the well-definedness bounds for this assignment. It is the same as that of the expression it is inverting.

func (*PseudoInverse[F]) Compute

func (e *PseudoInverse[F]) Compute(tr trace.Trace[F], schema schema.AnySchema[F]) ([]array.MutArray[F], error)

Compute performs the inversion.

func (*PseudoInverse[F]) Consistent

func (e *PseudoInverse[F]) Consistent(schema.AnySchema[F]) []error

Consistent performs some simple checks that the given assignment is consistent with its enclosing schema This provides a double check of certain key properties, such as that registers used for assignments are valid, etc.

func (*PseudoInverse[F]) Lisp

func (e *PseudoInverse[F]) Lisp(schema schema.AnySchema[F]) sexp.SExp

Lisp converts this constraint into an S-Expression.

func (*PseudoInverse[F]) RegistersExpanded

func (e *PseudoInverse[F]) RegistersExpanded() []register.Ref

RegistersExpanded identifies registers expanded by this assignment.

func (*PseudoInverse[F]) RegistersRead

func (e *PseudoInverse[F]) RegistersRead() []register.Ref

RegistersRead returns the set of columns that this assignment depends upon. That can include input columns, as well as other computed columns.

func (*PseudoInverse[F]) RegistersWritten

func (e *PseudoInverse[F]) RegistersWritten() []register.Ref

RegistersWritten identifies registers assigned by this assignment.

func (*PseudoInverse[F]) RequiredCells

func (e *PseudoInverse[F]) RequiredCells(row int, mid trace.ModuleId) *set.AnySortedSet[trace.CellRef]

RequiredCells returns the set of trace cells on which this term depends. In this case, that is the empty set.

func (*PseudoInverse[F]) RequiredRegisters

func (e *PseudoInverse[F]) RequiredRegisters() *set.SortedSet[uint]

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.

func (*PseudoInverse[F]) Substitute

func (e *PseudoInverse[F]) Substitute(map[string]F)

Substitute implementation for Substitutable interface.

type SortedPermutation

type SortedPermutation[F field.Element[F]] struct {
	// Target columns declared by this sorted permutation (in the order
	// of declaration).
	Targets []register.Ref
	// Signs determines the sorting direction for each target column.
	Signs []bool
	// Source columns which define the new (sorted) columns.
	Sources []register.Ref
}

SortedPermutation declares one or more columns as sorted permutations of existing columns.

func NewSortedPermutation

func NewSortedPermutation[F field.Element[F]](targets []register.Ref, signs []bool,
	sources []register.Ref) *SortedPermutation[F]

NewSortedPermutation creates a new sorted permutation

func (*SortedPermutation[F]) Bounds

func (p *SortedPermutation[F]) Bounds(_ sc.ModuleId) util.Bounds

Bounds determines the well-definedness bounds for this assignment for both the negative (left) or positive (right) directions. For example, consider an expression such as "(shift X -1)". This is technically undefined for the first row of any trace and, by association, any constraint evaluating this expression on that first row is also undefined (and hence must pass).

func (*SortedPermutation[F]) Compute

func (p *SortedPermutation[F]) Compute(trace tr.Trace[F], schema sc.AnySchema[F]) ([]array.MutArray[F], error)

Compute computes the values of columns defined by this assignment. This requires copying the data in the source columns, and sorting that data according to the permutation criteria.

func (*SortedPermutation[F]) Consistent

func (p *SortedPermutation[F]) Consistent(schema sc.AnySchema[F]) []error

Consistent performs some simple checks that the given schema is consistent. This provides a double check of certain key properties, such as that registers used for assignments are large enough, etc.

func (*SortedPermutation[F]) Lisp

func (p *SortedPermutation[F]) Lisp(schema sc.AnySchema[F]) sexp.SExp

Lisp converts this schema element into a simple S-Expression, for example so it can be printed.

func (*SortedPermutation[F]) RegistersExpanded

func (p *SortedPermutation[F]) RegistersExpanded() []register.Ref

RegistersExpanded identifies registers expanded by this assignment.

func (*SortedPermutation[F]) RegistersRead

func (p *SortedPermutation[F]) RegistersRead() []register.Ref

RegistersRead returns the set of columns that this assignment depends upon. That can include both input columns, as well as other computed columns.

func (*SortedPermutation[F]) RegistersWritten

func (p *SortedPermutation[F]) RegistersWritten() []register.Ref

RegistersWritten identifies registers assigned by this assignment.

func (*SortedPermutation[F]) Substitute

func (p *SortedPermutation[F]) Substitute(mapping map[string]F)

Substitute any matchined labelled constants within this assignment

Jump to

Keyboard shortcuts

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