pub struct ConstraintCircuitMonad<II: InputIndicator> {
pub circuit: Rc<RefCell<ConstraintCircuit<II>>>,
pub builder: ConstraintCircuitBuilder<II>,
}
Expand description
ConstraintCircuit
with extra context pertaining to the whole multicircuit.
This context is needed to ensure that two equal nodes (meaning: same expression) are not added to the multicircuit. It also enables a rudimentary check for node equivalence (commutation + constant folding), in which case the existing expression is used instead.
One can create new instances of ConstraintCircuitMonad
by applying arithmetic
operations to existing instances, e.g., let c = a * b;
.
Fields§
§circuit: Rc<RefCell<ConstraintCircuit<II>>>
§builder: ConstraintCircuitBuilder<II>
Implementations§
Source§impl<II: InputIndicator> ConstraintCircuitMonad<II>
impl<II: InputIndicator> ConstraintCircuitMonad<II>
Sourcepub fn consume(&self) -> ConstraintCircuit<II>
pub fn consume(&self) -> ConstraintCircuit<II>
Unwrap a ConstraintCircuitMonad to reveal its inner ConstraintCircuit
Sourcepub fn lower_to_degree(
multicircuit: &mut [Self],
info: DegreeLoweringInfo,
) -> (Vec<Self>, Vec<Self>)
pub fn lower_to_degree( multicircuit: &mut [Self], info: DegreeLoweringInfo, ) -> (Vec<Self>, Vec<Self>)
Lower the degree of a given multicircuit to the target degree. This is achieved by introducing additional variables and constraints. The appropriate substitutions are applied to the given multicircuit. The target degree must be greater than 1.
The new constraints are returned as two vector of ConstraintCircuitMonads: the first corresponds to main columns and constraints, the second to auxiliary columns and constraints. The modifications are applied to the function argument in-place.
Each returned constraint is guaranteed to correspond to some
CircuitExpression::BinaryOperation(BinOp::Sub, lhs, rhs)
where
lhs
is the new variable, andrhs
is the (sub)circuit replaced bylhs
. These can then be used to construct new columns, as well as derivation rules for filling those new columns.
For example, starting with the constraint set {x^4}, we insert {y - x^2} and modify in-place (x^4) –> (y^2).
The highest index of main and auxiliary columns used by the multicircuit have to be provided. The uniqueness of the new columns’ indices depends on these provided values. Note that these indices are generally not equal to the number of used columns, especially when a tables’ constraints are built using the master table’s column indices.
Sourcepub fn all_nodes_in_multicircuit(
multicircuit: &[ConstraintCircuit<II>],
) -> Vec<ConstraintCircuit<II>>
pub fn all_nodes_in_multicircuit( multicircuit: &[ConstraintCircuit<II>], ) -> Vec<ConstraintCircuit<II>>
Returns all nodes used in the multicircuit.
This is distinct from ConstraintCircuitBuilder::all_nodes
because it
- only considers nodes used in the given multicircuit, not all nodes in the builder,
- returns the nodes as
ConstraintCircuit
s, not asConstraintCircuitMonad
s, and - keeps duplicates, allowing to count how often a node occurs.
Sourcepub fn num_visible_nodes(constraints: &[Self]) -> usize
pub fn num_visible_nodes(constraints: &[Self]) -> usize
Counts the number of nodes in this multicircuit. Only counts nodes that are used; not nodes that have been forgotten.
Sourcepub fn multicircuit_degree(multicircuit: &[ConstraintCircuitMonad<II>]) -> isize
pub fn multicircuit_degree(multicircuit: &[ConstraintCircuitMonad<II>]) -> isize
Returns the maximum degree of all circuits in the multicircuit.
Trait Implementations§
Source§impl<II: InputIndicator> Add for ConstraintCircuitMonad<II>
impl<II: InputIndicator> Add for ConstraintCircuitMonad<II>
Source§impl<'a, II: InputIndicator + Arbitrary<'a>> Arbitrary<'a> for ConstraintCircuitMonad<II>
impl<'a, II: InputIndicator + Arbitrary<'a>> Arbitrary<'a> for ConstraintCircuitMonad<II>
Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self
from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self
from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured
this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured
this type
needs to construct itself. Read moreSource§impl<II: Clone + InputIndicator> Clone for ConstraintCircuitMonad<II>
impl<II: Clone + InputIndicator> Clone for ConstraintCircuitMonad<II>
Source§fn clone(&self) -> ConstraintCircuitMonad<II>
fn clone(&self) -> ConstraintCircuitMonad<II>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<II: InputIndicator> Debug for ConstraintCircuitMonad<II>
impl<II: InputIndicator> Debug for ConstraintCircuitMonad<II>
Source§impl<II: InputIndicator> Display for ConstraintCircuitMonad<II>
impl<II: InputIndicator> Display for ConstraintCircuitMonad<II>
Source§impl<II: InputIndicator> Hash for ConstraintCircuitMonad<II>
impl<II: InputIndicator> Hash for ConstraintCircuitMonad<II>
Source§impl<II: InputIndicator> Mul for ConstraintCircuitMonad<II>
impl<II: InputIndicator> Mul for ConstraintCircuitMonad<II>
Source§impl<II: InputIndicator> Neg for ConstraintCircuitMonad<II>
impl<II: InputIndicator> Neg for ConstraintCircuitMonad<II>
Source§impl<II: InputIndicator> PartialEq for ConstraintCircuitMonad<II>
impl<II: InputIndicator> PartialEq for ConstraintCircuitMonad<II>
Source§impl<II: InputIndicator> Sub for ConstraintCircuitMonad<II>
impl<II: InputIndicator> Sub for ConstraintCircuitMonad<II>
Source§impl<II: InputIndicator> Sum for ConstraintCircuitMonad<II>
impl<II: InputIndicator> Sum for ConstraintCircuitMonad<II>
This will panic if the iterator is empty because the neutral element needs a unique ID, and we have no way of getting that here.
impl<II: InputIndicator> Eq for ConstraintCircuitMonad<II>
Auto Trait Implementations§
impl<II> Freeze for ConstraintCircuitMonad<II>
impl<II> !RefUnwindSafe for ConstraintCircuitMonad<II>
impl<II> !Send for ConstraintCircuitMonad<II>
impl<II> !Sync for ConstraintCircuitMonad<II>
impl<II> Unpin for ConstraintCircuitMonad<II>
impl<II> !UnwindSafe for ConstraintCircuitMonad<II>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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