pub struct ConstraintCompiler { /* private fields */ }Expand description
The constraint compiler that records the constraints of a chip.
Implementations§
Source§impl ConstraintCompiler
impl ConstraintCompiler
Sourcepub fn new<A: MachineAir<SP1Field>>(air: &A, num_public_values: usize) -> Self
pub fn new<A: MachineAir<SP1Field>>(air: &A, num_public_values: usize) -> Self
Creates a new ConstraintCompiler
Sourcepub fn with_sizes(
num_public_values: usize,
preprocessed_width: usize,
main_width: usize,
) -> Self
pub fn with_sizes( num_public_values: usize, preprocessed_width: usize, main_width: usize, ) -> Self
Creates a new ConstraintCompiler with specific dimensions.
Sourcepub fn ast(
&self,
) -> Ast<ExprRef<SP1Field>, ExprExtRef<BinomialExtensionField<SP1Field, 4>>>
pub fn ast( &self, ) -> Ast<ExprRef<SP1Field>, ExprExtRef<BinomialExtensionField<SP1Field, 4>>>
Returns the currently recorded AST.
Sourcepub fn register_module(
&mut self,
name: String,
params: Vec<(String, Attribute, Shape<ExprRef<SP1Field>, ExprExtRef<BinomialExtensionField<SP1Field, 4>>>)>,
body: impl FnOnce(&mut Self) -> Shape<ExprRef<SP1Field>, ExprExtRef<BinomialExtensionField<SP1Field, 4>>>,
)
pub fn register_module( &mut self, name: String, params: Vec<(String, Attribute, Shape<ExprRef<SP1Field>, ExprExtRef<BinomialExtensionField<SP1Field, 4>>>)>, body: impl FnOnce(&mut Self) -> Shape<ExprRef<SP1Field>, ExprExtRef<BinomialExtensionField<SP1Field, 4>>>, )
Records a module (that is usually just a function call that represents an operation).
Sourcepub fn modules(
&self,
) -> &BTreeMap<String, Func<ExprRef<SP1Field>, ExprExtRef<BinomialExtensionField<SP1Field, 4>>>>
pub fn modules( &self, ) -> &BTreeMap<String, Func<ExprRef<SP1Field>, ExprExtRef<BinomialExtensionField<SP1Field, 4>>>>
The modules that has been recorded.
Trait Implementations§
Source§impl AirBuilder for ConstraintCompiler
impl AirBuilder for ConstraintCompiler
type F = KoalaBear
type Expr = ExprRef<KoalaBear>
type Var = ExprRef<KoalaBear>
type M = DenseMatrix<ExprRef<KoalaBear>>
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)
fn is_transition(&self) -> Self::Expr
Source§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.Source§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.Source§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.
Source§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.
Source§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.
Source§fn when_transition_window(
&mut self,
size: usize,
) -> FilteredAirBuilder<'_, Self>
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.fn assert_one<I>(&mut self, x: I)
fn assert_eq<I1, I2>(&mut self, x: I1, y: I2)
Source§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.Source§impl Clone for ConstraintCompiler
impl Clone for ConstraintCompiler
Source§fn clone(&self) -> ConstraintCompiler
fn clone(&self) -> ConstraintCompiler
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConstraintCompiler
impl Debug for ConstraintCompiler
Source§impl Drop for ConstraintCompiler
impl Drop for ConstraintCompiler
Source§impl ExtensionBuilder for ConstraintCompiler
impl ExtensionBuilder for ConstraintCompiler
type EF = BinomialExtensionField<KoalaBear, 4>
type ExprEF = ExprExtRef<BinomialExtensionField<KoalaBear, 4>>
type VarEF = ExprExtRef<BinomialExtensionField<KoalaBear, 4>>
fn assert_zero_ext<I>(&mut self, x: I)
fn assert_eq_ext<I1, I2>(&mut self, x: I1, y: I2)
fn assert_one_ext<I>(&mut self, x: I)
Source§impl MessageBuilder<AirInteraction<ExprRef<KoalaBear>>> for ConstraintCompiler
impl MessageBuilder<AirInteraction<ExprRef<KoalaBear>>> for ConstraintCompiler
Source§fn send(
&mut self,
message: AirInteraction<ExprRef<SP1Field>>,
scope: InteractionScope,
)
fn send( &mut self, message: AirInteraction<ExprRef<SP1Field>>, scope: InteractionScope, )
Sends a message.
Source§fn receive(
&mut self,
message: AirInteraction<ExprRef<SP1Field>>,
scope: InteractionScope,
)
fn receive( &mut self, message: AirInteraction<ExprRef<SP1Field>>, scope: InteractionScope, )
Receives a message.
Source§impl PairBuilder for ConstraintCompiler
impl PairBuilder for ConstraintCompiler
fn preprocessed(&self) -> Self::M
Auto Trait Implementations§
impl Freeze for ConstraintCompiler
impl RefUnwindSafe for ConstraintCompiler
impl Send for ConstraintCompiler
impl Sync for ConstraintCompiler
impl Unpin for ConstraintCompiler
impl UnsafeUnpin for ConstraintCompiler
impl UnwindSafe for ConstraintCompiler
Blanket Implementations§
Source§impl<AB> BaseAirBuilder for AB
impl<AB> BaseAirBuilder for AB
Source§fn when_not<I: Into<Self::Expr>>(
&mut self,
condition: I,
) -> FilteredAirBuilder<'_, Self>
fn when_not<I: Into<Self::Expr>>( &mut self, condition: I, ) -> FilteredAirBuilder<'_, Self>
Returns a sub-builder whose constraints are enforced only when
condition is not one.Source§fn assert_all_eq<I1: Into<Self::Expr>, I2: Into<Self::Expr>>(
&mut self,
left: impl IntoIterator<Item = I1>,
right: impl IntoIterator<Item = I2>,
)
fn assert_all_eq<I1: Into<Self::Expr>, I2: Into<Self::Expr>>( &mut self, left: impl IntoIterator<Item = I1>, right: impl IntoIterator<Item = I2>, )
Asserts that an iterator of expressions are all equal.
Source§fn assert_all_zero<I: Into<Self::Expr>>(
&mut self,
iter: impl IntoIterator<Item = I>,
)
fn assert_all_zero<I: Into<Self::Expr>>( &mut self, iter: impl IntoIterator<Item = I>, )
Asserts that an iterator of expressions are all zero.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<AB> ByteAirBuilder for ABwhere
AB: BaseAirBuilder,
impl<AB> ByteAirBuilder for ABwhere
AB: BaseAirBuilder,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<AB> ExtensionAirBuilder for ABwhere
AB: BaseAirBuilder,
impl<AB> ExtensionAirBuilder for ABwhere
AB: BaseAirBuilder,
Source§fn assert_ext_eq<I: Into<Self::Expr>>(
&mut self,
left: BinomialExtension<I>,
right: BinomialExtension<I>,
)
fn assert_ext_eq<I: Into<Self::Expr>>( &mut self, left: BinomialExtension<I>, right: BinomialExtension<I>, )
Asserts that the two field extensions are equal.
Source§fn assert_is_base_element<I: Into<Self::Expr> + Clone>(
&mut self,
element: BinomialExtension<I>,
)
fn assert_is_base_element<I: Into<Self::Expr> + Clone>( &mut self, element: BinomialExtension<I>, )
Checks if an extension element is a base element.
Source§fn if_else_ext(
&mut self,
condition: impl Into<Self::Expr> + Clone,
a: BinomialExtension<impl Into<Self::Expr> + Clone>,
b: BinomialExtension<impl Into<Self::Expr> + Clone>,
) -> BinomialExtension<Self::Expr>
fn if_else_ext( &mut self, condition: impl Into<Self::Expr> + Clone, a: BinomialExtension<impl Into<Self::Expr> + Clone>, b: BinomialExtension<impl Into<Self::Expr> + Clone>, ) -> BinomialExtension<Self::Expr>
Performs an if else on extension elements.
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self to use its UpperHex implementation when
Debug-formatted.Source§impl<Challenger, A> FromChallenger<Challenger, A> for Challengerwhere
Challenger: Clone,
impl<Challenger, A> FromChallenger<Challenger, A> for Challengerwhere
Challenger: Clone,
fn from_challenger(challenger: &Challenger, _backend: &A) -> Challenger
Source§impl<AB> InstructionAirBuilder for ABwhere
AB: BaseAirBuilder,
impl<AB> InstructionAirBuilder for ABwhere
AB: BaseAirBuilder,
Source§fn send_state(
&mut self,
clk_high: impl Into<Self::Expr>,
clk_low: impl Into<Self::Expr>,
pc: [impl Into<Self::Expr>; 3],
multiplicity: impl Into<Self::Expr>,
)
fn send_state( &mut self, clk_high: impl Into<Self::Expr>, clk_low: impl Into<Self::Expr>, pc: [impl Into<Self::Expr>; 3], multiplicity: impl Into<Self::Expr>, )
Sends the current CPU state.
Source§fn receive_state(
&mut self,
clk_high: impl Into<Self::Expr>,
clk_low: impl Into<Self::Expr>,
pc: [impl Into<Self::Expr>; 3],
multiplicity: impl Into<Self::Expr>,
)
fn receive_state( &mut self, clk_high: impl Into<Self::Expr>, clk_low: impl Into<Self::Expr>, pc: [impl Into<Self::Expr>; 3], multiplicity: impl Into<Self::Expr>, )
Receives the current CPU state.
Source§fn send_syscall(
&mut self,
clk_high: impl Into<Self::Expr> + Clone,
clk_low: impl Into<Self::Expr> + Clone,
syscall_id: impl Into<Self::Expr> + Clone,
arg1: [impl Into<Self::Expr>; 3],
arg2: [impl Into<Self::Expr>; 3],
multiplicity: impl Into<Self::Expr>,
scope: InteractionScope,
)
fn send_syscall( &mut self, clk_high: impl Into<Self::Expr> + Clone, clk_low: impl Into<Self::Expr> + Clone, syscall_id: impl Into<Self::Expr> + Clone, arg1: [impl Into<Self::Expr>; 3], arg2: [impl Into<Self::Expr>; 3], multiplicity: impl Into<Self::Expr>, scope: InteractionScope, )
Sends an syscall operation to be processed (with “ECALL” opcode).
Source§fn receive_syscall(
&mut self,
clk_high: impl Into<Self::Expr> + Clone,
clk_low: impl Into<Self::Expr> + Clone,
syscall_id: impl Into<Self::Expr> + Clone,
arg1: [Self::Expr; 3],
arg2: [Self::Expr; 3],
multiplicity: impl Into<Self::Expr>,
scope: InteractionScope,
)
fn receive_syscall( &mut self, clk_high: impl Into<Self::Expr> + Clone, clk_low: impl Into<Self::Expr> + Clone, syscall_id: impl Into<Self::Expr> + Clone, arg1: [Self::Expr; 3], arg2: [Self::Expr; 3], multiplicity: impl Into<Self::Expr>, scope: InteractionScope, )
Receives a syscall operation to be processed.
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<AB> MachineAirBuilder for ABwhere
AB: BaseAirBuilder + AirBuilderWithPublicValues,
impl<AB> MachineAirBuilder for ABwhere
AB: BaseAirBuilder + AirBuilderWithPublicValues,
Source§fn extract_public_values(
&self,
) -> PublicValues<[Self::PublicVar; 4], [Self::PublicVar; 3], [Self::PublicVar; 4], Self::PublicVar>
fn extract_public_values( &self, ) -> PublicValues<[Self::PublicVar; 4], [Self::PublicVar; 3], [Self::PublicVar; 4], Self::PublicVar>
Extract public values from the air builder and convert them to the proper type.
This is commonly used throughout the codebase to access public values in AIR
implementations.
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<AB> SepticExtensionAirBuilder for ABwhere
AB: BaseAirBuilder,
impl<AB> SepticExtensionAirBuilder for ABwhere
AB: BaseAirBuilder,
Source§fn assert_septic_ext_eq<I: Into<Self::Expr>>(
&mut self,
left: SepticExtension<I>,
right: SepticExtension<I>,
)
fn assert_septic_ext_eq<I: Into<Self::Expr>>( &mut self, left: SepticExtension<I>, right: SepticExtension<I>, )
Asserts that the two field extensions are equal.
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref() only in debug builds, and is erased in release
builds.