@@ -16,6 +16,7 @@ import (
1616 "bytes"
1717 "encoding/gob"
1818 "math"
19+ "math/big"
1920
2021 "github.com/consensys/go-corset/pkg/schema"
2122 "github.com/consensys/go-corset/pkg/util/collection/iter"
@@ -33,14 +34,22 @@ const (
3334 UNUSED_REGISTER = math .MaxUint
3435)
3536
36- // Sanity check
37- var _ schema.Module = & Function [uint ]{}
37+ // FunctionInstance represents a specific instance of a function. That is, a
38+ // mapping from input values to expected output values.
39+ type FunctionInstance struct {
40+ // Identifies corresponding function.
41+ Function uint
42+ // Inputs identifies the input arguments
43+ Inputs map [string ]big.Int
44+ // Outputs identifies the outputs
45+ Outputs map [string ]big.Int
46+ }
3847
3948// Function defines a distinct functional entity within the system. Functions
4049// accepts zero or more inputs and produce zero or more outputs. Functions
4150// declare zero or more internal registers for use, and their interpretation is
4251// given by a sequence of zero or more instructions.
43- type Function [T any ] struct {
52+ type Function [T Instruction [ T ] ] struct {
4453 // Unique name of this function.
4554 name string
4655 // Registers describes zero or more registers of a given width. Each
@@ -51,7 +60,7 @@ type Function[T any] struct {
5160}
5261
5362// NewFunction constructs a new function with the given components.
54- func NewFunction [T any ](name string , registers []Register , code []T ) Function [T ] {
63+ func NewFunction [T Instruction [ T ] ](name string , registers []Register , code []T ) Function [T ] {
5564 return Function [T ]{name , registers , code }
5665}
5766
@@ -75,7 +84,9 @@ func (p *Function[T]) Code() []T {
7584// Constraints provides access to those constraints associated with this
7685// function.
7786func (p * Function [T ]) Constraints () iter.Iterator [schema.Constraint ] {
78- return iter.NewArrayIterator [schema.Constraint ](nil )
87+ var constraint Constraint [T ] = Constraint [T ]{p .name , p .registers , p .code }
88+ //
89+ return iter.NewUnitIterator [schema.Constraint ](constraint )
7990}
8091
8192// Consistent applies a number of internal consistency checks. Whilst not
0 commit comments