pub struct ConstraintSystem<F: TowerField> { /* private fields */ }Expand description
Builder context for algebraic constraints.
Implementations§
Source§impl<F: TowerField> ConstraintSystem<F>
impl<F: TowerField> ConstraintSystem<F>
Sourcepub fn from_ast(ast: ConstraintAst<F>) -> Self
pub fn from_ast(ast: ConstraintAst<F>) -> Self
Create a builder from an existing AST.
Sourcepub fn scale(&self, coeff: F, expr: Expr<'_, F>) -> Expr<'_, F>
pub fn scale(&self, coeff: F, expr: Expr<'_, F>) -> Expr<'_, F>
Scalar multiplication:
coeff * expr.
Use this for powers of 2, coefficients, etc.
Orphan rules prevent implementing F * Expr
via operator overloading.
Sourcepub fn sum(&self, children: &[Expr<'_, F>]) -> Expr<'_, F>
pub fn sum(&self, children: &[Expr<'_, F>]) -> Expr<'_, F>
N-ary sum. More efficient than chaining binary +
for linear combinations (avoids deep Add chains).
Sourcepub fn constrain(&self, expr: Expr<'_, F>)
pub fn constrain(&self, expr: Expr<'_, F>)
Register a constraint:
expr = 0.
The expression must evaluate to zero for every valid row in the execution trace.
pub fn constrain_named(&self, label: &'static str, expr: Expr<'_, F>)
Sourcepub fn assert_boolean(&self, s: Expr<'_, F>)
pub fn assert_boolean(&self, s: Expr<'_, F>)
Assert that s is boolean:
s * (s + 1) = 0.
In GF(2^k), s + 1 equals s - 1.
Enforces s ∈ {0, 1}.
Sourcepub fn assert_zero_when(&self, sel: Expr<'_, F>, body: Expr<'_, F>)
pub fn assert_zero_when(&self, sel: Expr<'_, F>, body: Expr<'_, F>)
Assert that body = 0 whenever sel = 1.
Registers sel * body = 0.
When sel = 0, the constraint
is trivially satisfied.
Sourcepub fn assert_one_hot(&self, selectors: &[Expr<'_, F>])
pub fn assert_one_hot(&self, selectors: &[Expr<'_, F>])
Assert that exactly one selector is active. Enforces: sum(selectors) = 1.
In GF(2^k): sum(s_i) + 1 = 0.
Sourcepub fn assert_paired_bus_mutex(&self, s_send: usize, s_recv: usize)
pub fn assert_paired_bus_mutex(&self, s_send: usize, s_recv: usize)
Emit the s_send · s_recv = 0 mutex root
plus boolean checks on both selectors.
Sourcepub fn build(self) -> ConstraintAst<F>
pub fn build(self) -> ConstraintAst<F>
Consume the builder and
produce a ConstraintAst.
All Expr handles must be
dropped before calling this
(enforced by the borrow checker,
build takes self).
Trait Implementations§
Source§impl<F: TowerField> Default for ConstraintSystem<F>
impl<F: TowerField> Default for ConstraintSystem<F>
Auto Trait Implementations§
impl<F> !Freeze for ConstraintSystem<F>
impl<F> !RefUnwindSafe for ConstraintSystem<F>
impl<F> Send for ConstraintSystem<F>
impl<F> !Sync for ConstraintSystem<F>
impl<F> Unpin for ConstraintSystem<F>where
F: Unpin,
impl<F> UnsafeUnpin for ConstraintSystem<F>
impl<F> UnwindSafe for ConstraintSystem<F>where
F: UnwindSafe,
Blanket Implementations§
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
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>
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>
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 more