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
Index ¶
- type Constraint
- func (p Constraint[F, E]) Accepts(tr trace.Trace[F], sc schema.AnySchema[F]) (bit.Set, schema.Failure)
- func (p Constraint[F, E]) Bounds(module uint) util.Bounds
- func (p Constraint[F, E]) Consistent(schema schema.AnySchema[F]) []error
- func (p Constraint[F, E]) Contexts() []schema.ModuleId
- func (p Constraint[F, E]) Lisp(mapping schema.AnySchema[F]) sexp.SExp
- func (p Constraint[F, E]) Name() string
- func (p Constraint[F, E]) Substitute(mapping map[string]F)
- type Failure
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Constraint ¶
type Constraint[F field.Element[F], E term.Evaluable[F]] struct { Handle string // Context in which all target columns are evaluated. TargetContext schema.ModuleId // Context in which all source columns are evaluated. SourceContext schema.ModuleId // Target expression of interleaving. Target E // Source expressions of interleaving. Sources []E }
Constraint declares a constraint that one expression represents the interleaving of one or more expressions. For example, suppose X=[1,2] and Y=[3,4]. Then Z=[1,3,2,4] is the interleaving of X and Y.
func NewConstraint ¶
func NewConstraint[F field.Element[F], E term.Evaluable[F]](handle string, targetContext schema.ModuleId, sourceContext schema.ModuleId, target E, sources []E) Constraint[F, E]
NewConstraint creates a new Interleave
func (Constraint[F, E]) Accepts ¶
func (p Constraint[F, E]) Accepts(tr trace.Trace[F], sc schema.AnySchema[F]) (bit.Set, schema.Failure)
Accepts checks whether a Interleave holds between the source and target columns.
func (Constraint[F, E]) Bounds ¶
func (p Constraint[F, E]) Bounds(module uint) util.Bounds
Bounds determines the well-definedness bounds for this constraint 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 (Constraint[F, E]) Consistent ¶
func (p Constraint[F, E]) Consistent(schema schema.AnySchema[F]) []error
Consistent applies a number of internal consistency checks. Whilst not strictly necessary, these can highlight otherwise hidden problems as an aid to debugging.
func (Constraint[F, E]) Contexts ¶
func (p Constraint[F, E]) Contexts() []schema.ModuleId
Contexts returns the evaluation contexts (i.e. enclosing module + length multiplier) for this constraint. Most constraints have only a single evaluation context, though some (e.g. lookups) have more. Note that all constraints have at least one context (which we can call the "primary" context).
func (Constraint[F, E]) Lisp ¶
func (p Constraint[F, E]) Lisp(mapping schema.AnySchema[F]) sexp.SExp
Lisp converts this schema element into a simple S-Expression, for example so it can be printed.
func (Constraint[F, E]) Name ¶
func (p Constraint[F, E]) Name() string
Name returns a unique name for a given constraint. This is useful purely for identifying constraints in reports, etc.
func (Constraint[F, E]) Substitute ¶
func (p Constraint[F, E]) Substitute(mapping map[string]F)
Substitute any matchined labelled constants within this constraint
type Failure ¶
type Failure[F any] struct { // Handle of the failing constraint Handle string // Relevant context for target expressions. TargetContext schema.ModuleId // Target expression involved Target term.Evaluable[F] // Relevant context for source expressions. SourceContext schema.ModuleId // Source expression which were missing Source term.Evaluable[F] // Target row on which constraint Row uint }
Failure provides structural information about a failing lookup constraint.
func (*Failure[F]) RequiredCells ¶
RequiredCells identifies the cells required to evaluate the failing constraint at the failing row.