permutation

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Constraint

type Constraint[F field.Element[F]] struct {
	Handle string
	// Evaluation Context for this constraint which must match that of the
	// source and target expressions.
	Context schema.ModuleId
	// Targets returns the indices of the columns composing the "left" table of the
	// permutation.
	Targets []register.Id
	// Sources returns the indices of the columns composing the "right" table of the
	// permutation.
	Sources []register.Id
}

Constraint declares a constraint that one (or more) columns are a permutation of another.

func NewConstraint

func NewConstraint[F field.Element[F]](handle string, context schema.ModuleId, targets []register.Id,
	sources []register.Id) Constraint[F]

NewConstraint creates a new permutation

func (Constraint[F]) Accepts

func (p Constraint[F]) Accepts(tr trace.Trace[F], _ schema.AnySchema[F]) (bit.Set, schema.Failure)

Accepts checks whether a permutation holds between the source and target columns.

func (Constraint[F]) Bounds

func (p Constraint[F]) 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]) Consistent

func (p Constraint[F]) 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]) Contexts

func (p Constraint[F]) 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]) Lisp

func (p Constraint[F]) 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]) Name

func (p Constraint[F]) Name() string

Name returns a unique name for a given constraint. This is useful purely for identifying constraints in reports, etc.

func (Constraint[F]) Substitute

func (p Constraint[F]) Substitute(map[string]F)

Substitute any matchined labelled constants within this constraint

type Failure

type Failure struct {
	Msg string
}

Failure provides structural information about a failing permutation constraint.

func (*Failure) Message

func (p *Failure) Message() string

Message provides a suitable error message

func (*Failure) String

func (p *Failure) String() string

Jump to

Keyboard shortcuts

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