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 // Evaluation Context for this constraint which must match that of the // source expressions. Context schema.ModuleId // BitWidth of delta (i.e. maximum difference between columns) BitWidth uint // Optional selector expression which determines on which rows this // constraint is active. Selector util.Option[E] // Sources returns the indices of the columns composing the "right" table of the // Sorted. Sources []E // Signs returns sorting direction of all columns. Signs []bool // Strict determines whether or not this constraint is strict (i.e. doesn't // permit equal values). Strict bool }
Constraint declares a constraint that one (or more) columns are lexicographically sorted.
func NewConstraint ¶
func NewConstraint[F field.Element[F], E term.Evaluable[F]](handle string, context schema.ModuleId, bitwidth uint, selector util.Option[E], sources []E, signs []bool, strict bool) Constraint[F, E]
NewConstraint creates a new Sorted
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 Sorted 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