Trait AirBuilder

Source
pub trait AirBuilder: Sized {
    type F: PrimeCharacteristicRing + Sync;
    type Expr: Algebra<Self::F> + Algebra<Self::Var>;
    type Var: Into<Self::Expr> + Clone + Send + Sync + Add<Self::F, Output = Self::Expr> + Add<Self::Var, Output = Self::Expr> + Add<Self::Expr, Output = Self::Expr> + Sub<Self::F, Output = Self::Expr> + Sub<Self::Var, Output = Self::Expr> + Sub<Self::Expr, Output = Self::Expr> + Mul<Self::F, Output = Self::Expr> + Mul<Self::Var, Output = Self::Expr> + Mul<Self::Expr, Output = Self::Expr>;
    type M: Matrix<Self::Var>;

Show 17 methods // Required methods fn main(&self) -> Self::M; fn is_first_row(&self) -> Self::Expr; fn is_last_row(&self) -> Self::Expr; fn is_transition_window(&self, size: usize) -> Self::Expr; fn assert_zero<I: Into<Self::Expr>>(&mut self, x: I); // Provided methods fn is_transition(&self) -> Self::Expr { ... } fn when<I: Into<Self::Expr>>( &mut self, condition: I, ) -> FilteredAirBuilder<'_, Self> { ... } fn when_ne<I1: Into<Self::Expr>, I2: Into<Self::Expr>>( &mut self, x: I1, y: I2, ) -> FilteredAirBuilder<'_, Self> { ... } fn when_first_row(&mut self) -> FilteredAirBuilder<'_, Self> { ... } fn when_last_row(&mut self) -> FilteredAirBuilder<'_, Self> { ... } fn when_transition(&mut self) -> FilteredAirBuilder<'_, Self> { ... } fn when_transition_window( &mut self, size: usize, ) -> FilteredAirBuilder<'_, Self> { ... } fn assert_zeros<const N: usize, I: Into<Self::Expr>>( &mut self, array: [I; N], ) { ... } fn assert_bools<const N: usize, I: Into<Self::Expr>>( &mut self, array: [I; N], ) { ... } fn assert_one<I: Into<Self::Expr>>(&mut self, x: I) { ... } fn assert_eq<I1: Into<Self::Expr>, I2: Into<Self::Expr>>( &mut self, x: I1, y: I2, ) { ... } fn assert_bool<I: Into<Self::Expr>>(&mut self, x: I) { ... }
}
Expand description

A builder which contains both a trace on which AIR constraints can be evaluated as well as a method of accumulating the AIR constraint evaluations.

Supports both symbolic cases where the constraints are treated as polynomials and collected into a vector as well cases where the constraints are evaluated on an evaluation trace and combined using randomness.

Required Associated Types§

Source

type F: PrimeCharacteristicRing + Sync

Underlying field type.

This should usually implement Field but there are a few edge cases (mostly involving PackedFields) where it may only implement PrimeCharacteristicRing.

Source

type Expr: Algebra<Self::F> + Algebra<Self::Var>

Serves as the output type for an AIR constraint evaluation.

Source

type Var: Into<Self::Expr> + Clone + Send + Sync + Add<Self::F, Output = Self::Expr> + Add<Self::Var, Output = Self::Expr> + Add<Self::Expr, Output = Self::Expr> + Sub<Self::F, Output = Self::Expr> + Sub<Self::Var, Output = Self::Expr> + Sub<Self::Expr, Output = Self::Expr> + Mul<Self::F, Output = Self::Expr> + Mul<Self::Var, Output = Self::Expr> + Mul<Self::Expr, Output = Self::Expr>

The type of the variable appearing in the trace matrix.

Serves as the input type for an AIR constraint evaluation.

Source

type M: Matrix<Self::Var>

Matrix type holding variables.

Required Methods§

Source

fn main(&self) -> Self::M

Return the matrix representing the main (primary) trace registers.

Source

fn is_first_row(&self) -> Self::Expr

Expression evaluating to 1 on the first row, 0 elsewhere.

Source

fn is_last_row(&self) -> Self::Expr

Expression evaluating to 1 on the last row, 0 elsewhere.

Source

fn is_transition_window(&self, size: usize) -> Self::Expr

Expression evaluating to 1 on rows except the last size - 1 rows, 0 otherwise.

Source

fn assert_zero<I: Into<Self::Expr>>(&mut self, x: I)

Assert that the given element is zero.

Where possible, batching multiple assert_zero calls into a single assert_zeros call will improve performance.

Provided Methods§

Source

fn is_transition(&self) -> Self::Expr

Expression evaluating to 1 on all transition rows (not last row), 0 on last row.

Source

fn when<I: Into<Self::Expr>>( &mut self, condition: I, ) -> FilteredAirBuilder<'_, Self>

Returns a sub-builder whose constraints are enforced only when condition is nonzero.

Source

fn when_ne<I1: Into<Self::Expr>, I2: Into<Self::Expr>>( &mut self, x: I1, y: I2, ) -> FilteredAirBuilder<'_, Self>

Returns a sub-builder whose constraints are enforced only when x != y.

Source

fn when_first_row(&mut self) -> FilteredAirBuilder<'_, Self>

Returns a sub-builder whose constraints are enforced only on the first row.

Source

fn when_last_row(&mut self) -> FilteredAirBuilder<'_, Self>

Returns a sub-builder whose constraints are enforced only on the last row.

Source

fn when_transition(&mut self) -> FilteredAirBuilder<'_, Self>

Returns a sub-builder whose constraints are enforced on all rows except the last.

Source

fn when_transition_window( &mut self, size: usize, ) -> FilteredAirBuilder<'_, Self>

Returns a sub-builder whose constraints are enforced on all rows except the last size - 1.

Source

fn assert_zeros<const N: usize, I: Into<Self::Expr>>(&mut self, array: [I; N])

Assert that every element of a given array is 0.

This should be preferred over calling assert_zero multiple times.

Source

fn assert_bools<const N: usize, I: Into<Self::Expr>>(&mut self, array: [I; N])

Assert that a given array consists of only boolean values.

Source

fn assert_one<I: Into<Self::Expr>>(&mut self, x: I)

Assert that x element is equal to 1.

Source

fn assert_eq<I1: Into<Self::Expr>, I2: Into<Self::Expr>>( &mut self, x: I1, y: I2, )

Assert that the given elements are equal.

Source

fn assert_bool<I: Into<Self::Expr>>(&mut self, x: I)

Assert that x is a boolean, i.e. either 0 or 1.

Where possible, batching multiple assert_bool calls into a single assert_bools call will improve performance.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<AB: AirBuilder> AirBuilder for FilteredAirBuilder<'_, AB>

Source§

type F = <AB as AirBuilder>::F

Source§

type Expr = <AB as AirBuilder>::Expr

Source§

type Var = <AB as AirBuilder>::Var

Source§

type M = <AB as AirBuilder>::M