assignment

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: Apache-2.0 Imports: 12 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

Index

Constants

This section is empty.

Variables

View Source
var NATIVES map[string]NativeComputation = map[string]NativeComputation{
	"id":                   {idNativeFunction},
	"filter":               {filterNativeFunction},
	"map-if":               {mapIfNativeFunction},
	"fwd-changes-within":   {fwdChangesWithinNativeFunction},
	"fwd-unchanged-within": {fwdUnchangedWithinNativeFunction},
	"bwd-changes-within":   {bwdChangesWithinNativeFunction},
	"fwd-fill-within":      {fwdFillWithinNativeFunction},
	"bwd-fill-within":      {bwdFillWithinNativeFunction},
}

NATIVES map holds the supported set of native computations.

Functions

This section is empty.

Types

type ByteDecomposition

type ByteDecomposition struct {
	// contains filtered or unexported fields
}

ByteDecomposition is part of a range constraint for wide columns (e.g. u32) implemented using a byte decomposition.

func NewByteDecomposition

func NewByteDecomposition(prefix string, context trace.Context, source uint, bitwidth uint) *ByteDecomposition

NewByteDecomposition creates a new sorted permutation

func (*ByteDecomposition) Bounds

func (p *ByteDecomposition) Bounds() 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 (*ByteDecomposition) CheckConsistency added in v1.0.2

func (p *ByteDecomposition) CheckConsistency(schema sc.Schema) error

CheckConsistency 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 (*ByteDecomposition) Columns

func (p *ByteDecomposition) Columns() iter.Iterator[sc.Column]

Columns returns the columns declared by this byte decomposition (in the order of declaration).

func (*ByteDecomposition) ComputeColumns

func (p *ByteDecomposition) ComputeColumns(tr trace.Trace) ([]trace.ArrayColumn, error)

ComputeColumns computes the values of columns defined by this assignment. This requires computing the value of each byte column in the decomposition.

func (*ByteDecomposition) Context

func (p *ByteDecomposition) Context() trace.Context

Context returns the evaluation context for this declaration.

func (*ByteDecomposition) Dependencies

func (p *ByteDecomposition) Dependencies() []uint

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

func (*ByteDecomposition) IsComputed

func (p *ByteDecomposition) IsComputed() bool

IsComputed Determines whether or not this declaration is computed.

func (*ByteDecomposition) Lisp

func (p *ByteDecomposition) Lisp(schema sc.Schema) sexp.SExp

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

type Computation

type Computation struct {
	// Context where in which source and target columns exist.
	ColumnContext tr.Context
	// Name of the function being invoked.
	Name string
	// Target columns declared by this sorted permutation (in the order
	// of declaration).
	Targets []sc.Column
	// Source columns which define the new (sorted) columns.
	Sources []uint
}

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

func NewComputation

func NewComputation(context tr.Context, functionName string, targets []sc.Column, sources []uint) *Computation

NewComputation 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 (*Computation) Bounds

func (p *Computation) Bounds() 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 (*Computation) CheckConsistency added in v1.0.2

func (p *Computation) CheckConsistency(schema sc.Schema) error

CheckConsistency 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 (*Computation) Columns

func (p *Computation) Columns() iter.Iterator[sc.Column]

Columns returns the columns declared by this computed column.

func (*Computation) ComputeColumns

func (p *Computation) ComputeColumns(trace tr.Trace) ([]tr.ArrayColumn, error)

ComputeColumns 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 (*Computation) Context

func (p *Computation) Context() trace.Context

Context returns the evaluation context for this computed column.

func (*Computation) Dependencies

func (p *Computation) Dependencies() []uint

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

func (*Computation) IsComputed

func (p *Computation) IsComputed() bool

IsComputed Determines whether or not this declaration is computed (which it is).

func (*Computation) Lisp

func (p *Computation) Lisp(schema sc.Schema) sexp.SExp

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

type ComputedColumn

type ComputedColumn struct {
	// contains filtered or unexported fields
}

ComputedColumn 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 NewComputedColumn

func NewComputedColumn(context trace.Context, name string, datatype sc.Type,
	expr sc.Evaluable) *ComputedColumn

NewComputedColumn constructs a new computed column with a given name and determining expression. More specifically, that expression is used to compute the values for this column during trace expansion.

func (*ComputedColumn) Bounds

func (p *ComputedColumn) Bounds() 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 (*ComputedColumn) CheckConsistency added in v1.0.2

func (p *ComputedColumn) CheckConsistency(schema sc.Schema) error

CheckConsistency 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 (*ComputedColumn) Columns

func (p *ComputedColumn) Columns() iter.Iterator[sc.Column]

Columns returns the columns declared by this computed column.

func (*ComputedColumn) ComputeColumns

func (p *ComputedColumn) ComputeColumns(tr trace.Trace) ([]trace.ArrayColumn, error)

ComputeColumns computes 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 (*ComputedColumn) Context

func (p *ComputedColumn) Context() trace.Context

Context returns the evaluation context for this computed column.

func (*ComputedColumn) Dependencies

func (p *ComputedColumn) Dependencies() []uint

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

func (*ComputedColumn) IsComputed

func (p *ComputedColumn) IsComputed() bool

IsComputed Determines whether or not this declaration is computed (which it is).

func (*ComputedColumn) Lisp

func (p *ComputedColumn) Lisp(schema sc.Schema) sexp.SExp

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

func (*ComputedColumn) Name

func (p *ComputedColumn) Name() string

Name returns the name of this computed column.

type DataColumn

type DataColumn struct {
	// Context where this data column is located.
	TraceContext trace.Context
	// Name of this datacolumn
	ColumnName string
	// Expected type of values held in this column.  Observe that this should be
	// true for the input columns for any valid trace and, furthermore, every
	// computed column should have values of this type.
	DataType sc.Type
}

DataColumn represents a column of user-provided values.

func NewDataColumn

func NewDataColumn(context trace.Context, name string, base sc.Type) *DataColumn

NewDataColumn constructs a new data column with a given name.

func (*DataColumn) Columns

func (p *DataColumn) Columns() iter.Iterator[sc.Column]

Columns returns the columns declared by this computed column.

func (*DataColumn) Context

func (p *DataColumn) Context() trace.Context

Context returns the evaluation context for this column.

func (*DataColumn) IsComputed

func (p *DataColumn) IsComputed() bool

IsComputed Determines whether or not this declaration is computed (which data columns never are).

func (*DataColumn) Lisp

func (p *DataColumn) Lisp(schema sc.Schema) sexp.SExp

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

func (*DataColumn) Module

func (p *DataColumn) Module() uint

Module identifies the module which encloses this column.

func (*DataColumn) Name

func (p *DataColumn) Name() string

Name provides access to information about the ith column in a schema.

func (*DataColumn) Type

func (p *DataColumn) Type() sc.Type

Type Returns the expected type of data in this column

type Interleaving

type Interleaving struct {
	// The new (interleaved) column
	Target sc.Column
	// Sources are the columns used by this interleaving to define the new
	// (interleaved) column.
	Sources []uint
}

Interleaving generates a new column by interleaving two or more existing colummns. For example, say Z interleaves X and Y (in that order) and we have a trace X=[1,2], Y=[3,4]. Then, the interleaved column Z has the values Z=[1,3,2,4].

func NewInterleaving

func NewInterleaving(context tr.Context, name string, sources []uint, datatype sc.Type) *Interleaving

NewInterleaving constructs a new interleaving assignment.

func (*Interleaving) Bounds

func (p *Interleaving) Bounds() 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 (*Interleaving) CheckConsistency added in v1.0.2

func (p *Interleaving) CheckConsistency(schema sc.Schema) error

CheckConsistency 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 (*Interleaving) Columns

func (p *Interleaving) Columns() iter.Iterator[sc.Column]

Columns returns the column declared by this interleaving.

func (*Interleaving) ComputeColumns

func (p *Interleaving) ComputeColumns(trace tr.Trace) ([]tr.ArrayColumn, error)

ComputeColumns computes the values of columns defined by this assignment. This requires copying the data in the source columns to create the interleaved column.

func (*Interleaving) Context

func (p *Interleaving) Context() tr.Context

Context returns the evaluation context for this interleaving.

func (*Interleaving) Dependencies

func (p *Interleaving) Dependencies() []uint

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

func (*Interleaving) IsComputed

func (p *Interleaving) IsComputed() bool

IsComputed Determines whether or not this declaration is computed (which an interleaving column is by definition).

func (*Interleaving) Lisp

func (p *Interleaving) Lisp(schema sc.Schema) sexp.SExp

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

func (*Interleaving) Module

func (p *Interleaving) Module() uint

Module returns the module which encloses this interleaving.

type LexicographicSort

type LexicographicSort 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(prefix string, context tr.Context,
	sources []uint, signs []bool, bitwidth uint) *LexicographicSort

NewLexicographicSort constructs a new LexicographicSorting assignment.

func (*LexicographicSort) Bounds

func (p *LexicographicSort) Bounds() 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) CheckConsistency added in v1.0.2

func (p *LexicographicSort) CheckConsistency(schema sc.Schema) error

CheckConsistency 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) Columns

func (p *LexicographicSort) Columns() iter.Iterator[sc.Column]

Columns returns the columns declared by this assignment.

func (*LexicographicSort) ComputeColumns

func (p *LexicographicSort) ComputeColumns(trace tr.Trace) ([]tr.ArrayColumn, error)

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

func (*LexicographicSort) Context

func (p *LexicographicSort) Context() tr.Context

Context returns the evaluation context for this declaration.

func (*LexicographicSort) Dependencies

func (p *LexicographicSort) Dependencies() []uint

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

func (*LexicographicSort) IsComputed

func (p *LexicographicSort) IsComputed() bool

IsComputed Determines whether or not this declaration is computed (which it is).

func (*LexicographicSort) Lisp

func (p *LexicographicSort) Lisp(schema sc.Schema) sexp.SExp

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

type NativeComputation

type NativeComputation struct {
	// Function which will be applied to a given set of input columns, whilst
	// writing to a given set of output columns.
	Function func(tr.Trace, []uint) []field.FrArray
}

NativeComputation embeds information about a support native computation. This can be used, for example, to check that a native function is being called correctly, etc.

type SortedPermutation

type SortedPermutation struct {
	// Context where in which source and target columns are evaluated.
	ColumnContext tr.Context
	// Target columns declared by this sorted permutation (in the order
	// of declaration).
	Targets []sc.Column
	// Signs determines the sorting direction for each target column.
	Signs []bool
	// Source columns which define the new (sorted) columns.
	Sources []uint
}

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

func NewSortedPermutation

func NewSortedPermutation(context tr.Context, targets []sc.Column,
	signs []bool, sources []uint) *SortedPermutation

NewSortedPermutation creates a new sorted permutation

func (*SortedPermutation) Bounds

func (p *SortedPermutation) Bounds() 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) CheckConsistency added in v1.0.2

func (p *SortedPermutation) CheckConsistency(schema sc.Schema) error

CheckConsistency 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) Columns

func (p *SortedPermutation) Columns() iter.Iterator[sc.Column]

Columns returns the columns declared by this sorted permutation (in the order of declaration).

func (*SortedPermutation) ComputeColumns

func (p *SortedPermutation) ComputeColumns(trace tr.Trace) ([]tr.ArrayColumn, error)

ComputeColumns 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) Context

func (p *SortedPermutation) Context() tr.Context

Context returns the evaluation context for this declaration.

func (*SortedPermutation) Dependencies

func (p *SortedPermutation) Dependencies() []uint

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

func (*SortedPermutation) IsComputed

func (p *SortedPermutation) IsComputed() bool

IsComputed Determines whether or not this declaration is computed.

func (*SortedPermutation) Lisp

func (p *SortedPermutation) Lisp(schema sc.Schema) sexp.SExp

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

func (*SortedPermutation) Module

func (p *SortedPermutation) Module() uint

Module returns the module which encloses this sorted permutation.

Jump to

Keyboard shortcuts

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