Trait AirBuilder
pub trait AirBuilder: Sized {
type F: PrimeCharacteristicRing + Sync;
type Expr: Algebra<Self::F> + Algebra<Self::Var>;
type Var: Into<Self::Expr> + Copy + Send + Sync + Add<Self::F, Output = Self::Expr, Output = Self::Expr, Output = Self::Expr> + Add + Add<Self::Expr> + Sub<Self::F, Output = Self::Expr, Output = Self::Expr, Output = Self::Expr> + Sub + Sub<Self::Expr> + Mul<Self::F, Output = Self::Expr, Output = Self::Expr, Output = Self::Expr> + Mul + Mul<Self::Expr>;
type PreprocessedWindow: WindowAccess<Self::Var> + Clone;
type MainWindow: WindowAccess<Self::Var> + Clone;
type PublicVar: Into<Self::Expr> + Copy;
Show 19 methods
// Required methods
fn main(&self) -> Self::MainWindow;
fn preprocessed(&self) -> &Self::PreprocessedWindow;
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>(&mut self, x: I)
where I: Into<Self::Expr>;
// Provided methods
fn is_transition(&self) -> Self::Expr { ... }
fn when<I>(&mut self, condition: I) -> FilteredAirBuilder<'_, Self>
where I: Into<Self::Expr> { ... }
fn when_ne<I1, I2>(&mut self, x: I1, y: I2) -> FilteredAirBuilder<'_, Self>
where I1: Into<Self::Expr>,
I2: Into<Self::Expr> { ... }
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>(&mut self, array: [I; N])
where I: Into<Self::Expr> { ... }
fn assert_bools<const N: usize, I>(&mut self, array: [I; N])
where I: Into<Self::Expr> { ... }
fn assert_one<I>(&mut self, x: I)
where I: Into<Self::Expr> { ... }
fn assert_eq<I1, I2>(&mut self, x: I1, y: I2)
where I1: Into<Self::Expr>,
I2: Into<Self::Expr> { ... }
fn public_values(&self) -> &[Self::PublicVar] { ... }
fn assert_bool<I>(&mut self, x: I)
where I: Into<Self::Expr> { ... }
}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§
type F: PrimeCharacteristicRing + Sync
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.
type Expr: Algebra<Self::F> + Algebra<Self::Var>
type Expr: Algebra<Self::F> + Algebra<Self::Var>
Serves as the output type for an AIR constraint evaluation.
type Var: Into<Self::Expr> + Copy + Send + Sync + Add<Self::F, Output = Self::Expr, Output = Self::Expr, Output = Self::Expr> + Add + Add<Self::Expr> + Sub<Self::F, Output = Self::Expr, Output = Self::Expr, Output = Self::Expr> + Sub + Sub<Self::Expr> + Mul<Self::F, Output = Self::Expr, Output = Self::Expr, Output = Self::Expr> + Mul + Mul<Self::Expr>
type Var: Into<Self::Expr> + Copy + Send + Sync + Add<Self::F, Output = Self::Expr, Output = Self::Expr, Output = Self::Expr> + Add + Add<Self::Expr> + Sub<Self::F, Output = Self::Expr, Output = Self::Expr, Output = Self::Expr> + Sub + Sub<Self::Expr> + Mul<Self::F, Output = Self::Expr, Output = Self::Expr, Output = Self::Expr> + Mul + Mul<Self::Expr>
The type of the variable appearing in the trace matrix.
Serves as the input type for an AIR constraint evaluation.
type PreprocessedWindow: WindowAccess<Self::Var> + Clone
type PreprocessedWindow: WindowAccess<Self::Var> + Clone
Two-row window over the preprocessed trace columns.
type MainWindow: WindowAccess<Self::Var> + Clone
type MainWindow: WindowAccess<Self::Var> + Clone
Two-row window over the main trace columns.
Required Methods§
fn main(&self) -> Self::MainWindow
fn main(&self) -> Self::MainWindow
Return the current and next row slices of the main (primary) trace.
fn preprocessed(&self) -> &Self::PreprocessedWindow
fn preprocessed(&self) -> &Self::PreprocessedWindow
Return the preprocessed registers as a two-row window.
When no preprocessed columns exist, this returns a zero-width window.
fn is_first_row(&self) -> Self::Expr
fn is_first_row(&self) -> Self::Expr
Expression evaluating to a non-zero value only on the first row.
fn is_last_row(&self) -> Self::Expr
fn is_last_row(&self) -> Self::Expr
Expression evaluating to a non-zero value only on the last row.
fn is_transition_window(&self, size: usize) -> Self::Expr
fn is_transition_window(&self, size: usize) -> Self::Expr
Expression evaluating to zero only on the last size - 1 rows.
§Panics
Implementations should panic if size > 2, since only two-row
windows are currently supported.
fn assert_zero<I>(&mut self, x: I)
fn assert_zero<I>(&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§
fn is_transition(&self) -> Self::Expr
fn is_transition(&self) -> Self::Expr
Expression evaluating to zero only on the last row.
fn when<I>(&mut self, condition: I) -> FilteredAirBuilder<'_, Self>
fn when<I>(&mut self, condition: I) -> FilteredAirBuilder<'_, Self>
Returns a sub-builder whose constraints are enforced only when condition is nonzero.
fn when_ne<I1, I2>(&mut self, x: I1, y: I2) -> FilteredAirBuilder<'_, Self>
fn when_ne<I1, I2>(&mut self, x: I1, y: I2) -> FilteredAirBuilder<'_, Self>
Returns a sub-builder whose constraints are enforced only when x != y.
fn when_first_row(&mut self) -> FilteredAirBuilder<'_, Self>
fn when_first_row(&mut self) -> FilteredAirBuilder<'_, Self>
Returns a sub-builder whose constraints are enforced only on the first row.
fn when_last_row(&mut self) -> FilteredAirBuilder<'_, Self>
fn when_last_row(&mut self) -> FilteredAirBuilder<'_, Self>
Returns a sub-builder whose constraints are enforced only on the last row.
fn when_transition(&mut self) -> FilteredAirBuilder<'_, Self>
fn when_transition(&mut self) -> FilteredAirBuilder<'_, Self>
Returns a sub-builder whose constraints are enforced on all rows except the last.
fn when_transition_window(
&mut self,
size: usize,
) -> FilteredAirBuilder<'_, Self>
fn when_transition_window( &mut self, size: usize, ) -> FilteredAirBuilder<'_, Self>
Like when_transition, but requires a window of size rows.
fn assert_zeros<const N: usize, I>(&mut self, array: [I; N])
fn assert_zeros<const N: usize, I>(&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.
fn assert_bools<const N: usize, I>(&mut self, array: [I; N])
fn assert_bools<const N: usize, I>(&mut self, array: [I; N])
Assert that a given array consists of only boolean values.
fn assert_one<I>(&mut self, x: I)
fn assert_one<I>(&mut self, x: I)
Assert that x element is equal to 1.
fn assert_eq<I1, I2>(&mut self, x: I1, y: I2)
fn assert_eq<I1, I2>(&mut self, x: I1, y: I2)
Assert that the given elements are equal.
fn public_values(&self) -> &[Self::PublicVar]
fn public_values(&self) -> &[Self::PublicVar]
Public input values available during constraint evaluation.
Returns an empty slice by default.
fn assert_bool<I>(&mut self, x: I)
fn assert_bool<I>(&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.