pub enum Operations<T> {
    Atom(T),
    Pow(Box<Self>, u64),
    Add(Box<Self>, Box<Self>),
    Mul(Box<Self>, Box<Self>),
    Sub(Box<Self>, Box<Self>),
    Double(Box<Self>),
    Square(Box<Self>),
    Cache(CacheId, Box<Self>),
    IfFeature(FeatureFlag, Box<Self>, Box<Self>),
}

Variants§

§

Atom(T)

§

Pow(Box<Self>, u64)

§

Add(Box<Self>, Box<Self>)

§

Mul(Box<Self>, Box<Self>)

§

Sub(Box<Self>, Box<Self>)

§

Double(Box<Self>)

§

Square(Box<Self>)

§

Cache(CacheId, Box<Self>)

§

IfFeature(FeatureFlag, Box<Self>, Box<Self>)

Implementations§

source§

impl<T: Literal> Operations<T>where T::F: Field,

source

pub fn pow(self, p: u64) -> Self

Exponentiate a constant expression.

source§

impl<F: Field, ChallengeTerm: Copy> Operations<ConstantExprInner<F, ChallengeTerm>>

source

pub fn value( &self, c: &Constants<F>, chals: &dyn Index<ChallengeTerm, Output = F> ) -> F

Evaluate the given constant expression to a field element.

source§

impl<T: Literal + PartialEq> Operations<T>where T::F: Field,

source

pub fn apply_feature_flags(&self, features: &FeatureFlags) -> Self

source§

impl<C, Column> Operations<ExprInner<C, Column>>

source

pub fn cell(col: Column, row: CurrOrNext) -> Expr<C, Column>

Convenience function for constructing cell variables.

source

pub fn double(self) -> Self

source

pub fn square(self) -> Self

source

pub fn constant(c: C) -> Expr<C, Column>

Convenience function for constructing constant expressions.

source

pub fn degree(&self, d1_size: u64, zk_rows: u64) -> u64

Return the degree of the expression. The degree of a cell is defined by the first argument d1_size, a constant being of degree zero. The degree of the expression is defined recursively using the definition of the degree of a multivariate polynomial. The function can be (and is) used to compute the domain size, hence the name of the first argument d1_size. The second parameter zk_rows is used to define the degree of the constructor VanishesOnZeroKnowledgeAndPreviousRows.

source§

impl<'a, F: Field, Column: PartialEq + Copy, ChallengeTerm: AlphaChallengeTerm<'a>> Operations<ExprInner<Operations<ConstantExprInner<F, ChallengeTerm>>, Column>>

source

pub fn literal(x: F) -> Self

Convenience function for constructing expressions from literal field elements.

source

pub fn combine_constraints( alphas: impl Iterator<Item = u32>, cs: Vec<Self> ) -> Self

Combines multiple constraints [c0, ..., cn] into a single constraint alpha^alpha0 * c0 + alpha^{alpha0 + 1} * c1 + ... + alpha^{alpha0 + n} * cn.

source§

impl<F: FftField, Column: Copy, ChallengeTerm: Copy> Operations<ExprInner<Operations<ConstantExprInner<F, ChallengeTerm>>, Column>>

source

pub fn to_polish(&self) -> Vec<PolishToken<F, Column, ChallengeTerm>>

Compile an expression to an RPN expression.

source§

impl<F: FftField, Column: PartialEq + Copy, ChallengeTerm: Copy> Operations<ExprInner<Operations<ConstantExprInner<F, ChallengeTerm>>, Column>>

source

pub fn evaluate<'a, Evaluations: ColumnEvaluations<F, Column = Column>, Challenge: Index<ChallengeTerm, Output = F>, Environment: ColumnEnvironment<'a, F, ChallengeTerm, Challenge, Column = Column>>( &self, d: D<F>, pt: F, evals: &Evaluations, env: &Environment ) -> Result<F, ExprError<Column>>

Evaluate an expression as a field element against an environment.

source

pub fn evaluate_<Evaluations: ColumnEvaluations<F, Column = Column>>( &self, d: D<F>, pt: F, evals: &Evaluations, c: &Constants<F>, chals: &dyn Index<ChallengeTerm, Output = F> ) -> Result<F, ExprError<Column>>

Evaluate an expression as a field element against the constants.

source

pub fn evaluate_constants<'a, Challenge: Index<ChallengeTerm, Output = F>, Environment: ColumnEnvironment<'a, F, ChallengeTerm, Challenge, Column = Column>>( &self, env: &Environment ) -> Expr<F, Column>

Evaluate the constant expressions in this expression down into field elements.

source

pub fn evaluations<'a, Challenge: Index<ChallengeTerm, Output = F>, Environment: ColumnEnvironment<'a, F, ChallengeTerm, Challenge, Column = Column>>( &self, env: &Environment ) -> Evaluations<F, D<F>>

Compute the polynomial corresponding to this expression, in evaluation form. The routine will first replace the constants (verifier challenges and constants like the matrix used by Poseidon) in the expression with their respective values using evaluate_constants and will after evaluate the monomials with the corresponding column values using the method evaluations.

source§

impl<F: FftField, Column: Copy> Operations<ExprInner<F, Column>>

source

pub fn evaluate<Evaluations: ColumnEvaluations<F, Column = Column>>( &self, d: D<F>, pt: F, zk_rows: u64, evals: &Evaluations ) -> Result<F, ExprError<Column>>

Evaluate an expression into a field element.

source

pub fn evaluations<'a, ChallengeTerm, Challenge: Index<ChallengeTerm, Output = F>, Environment: ColumnEnvironment<'a, F, ChallengeTerm, Challenge, Column = Column>>( &self, env: &Environment ) -> Evaluations<F, D<F>>

Compute the polynomial corresponding to this expression, in evaluation form.

source§

impl<F: Neg<Output = F> + Clone + One + Zero + PartialEq, Column: Ord + Copy + Hash> Operations<ExprInner<F, Column>>where ExprInner<F, Column>: Literal, <ExprInner<F, Column> as Literal>::F: Field,

source

pub fn linearize( &self, evaluated: HashSet<Column> ) -> Result<Linearization<Expr<F, Column>, Column>, ExprError<Column>>

There is an optimization in PLONK called “linearization” in which a certain polynomial is expressed as a linear combination of other polynomials in order to reduce the number of evaluations needed in the IOP (by relying on the homomorphic property of the polynomial commitments used.)

The function performs this “linearization”, which we now describe in some detail.

In mathematical language, an expression e: Expr<F> is an element of the polynomial ring F[V], where V is a set of variables.

Given a subset V_0 of V (and letting V_1 = V \setminus V_0), there is a map factor_{V_0}: F[V] -> (F[V_1])[V_0]. That is, polynomials with F coefficients in the variables V = V_0 \cup V_1 are the same thing as polynomials with F[V_1] coefficients in variables V_0.

There is also a function lin_or_err : (F[V_1])[V_0] -> Result<Vec<(V_0, F[V_1])>, &str>

which checks if the given input is in fact a degree 1 polynomial in the variables V_0 (i.e., a linear combination of V_0 elements with F[V_1] coefficients) returning this linear combination if so.

Given an expression e and set of columns C_0, letting V_0 = { Variable { col: c, row: r } | c in C_0, r in { Curr, Next } }, this function computes lin_or_err(factor_{V_0}(e)), although it does not compute it in that way. Instead, it computes it by reducing the expression into a sum of monomials with F coefficients, and then factors the monomials.

source§

impl<'a, F, Column: FormattedOutput + Debug + Clone, ChallengeTerm> Operations<ExprInner<Operations<ConstantExprInner<F, ChallengeTerm>>, Column>>where F: PrimeField, ChallengeTerm: AlphaChallengeTerm<'a>,

source

pub fn latex_str(&self) -> Vec<String>

Converts the expression in LaTeX

Trait Implementations§

source§

impl<T: Literal> Add<Operations<T>> for Operations<T>where T::F: Field,

§

type Output = Operations<T>

The resulting type after applying the + operator.
source§

fn add(self, other: Self) -> Self

Performs the + operation. Read more
source§

impl<F: Zero + Clone, Column: Clone> AddAssign<Operations<ExprInner<F, Column>>> for Expr<F, Column>where ExprInner<F, Column>: Literal, <ExprInner<F, Column> as Literal>::F: Field,

source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
source§

impl<T: Clone> Clone for Operations<T>

source§

fn clone(&self) -> Operations<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for Operations<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: FormattedOutput + Clone> FormattedOutput for Operations<T>

source§

fn is_alpha(&self) -> bool

source§

fn ocaml(&self, cache: &mut HashMap<CacheId, Self>) -> String

source§

fn latex(&self, cache: &mut HashMap<CacheId, Self>) -> String

source§

fn text(&self, cache: &mut HashMap<CacheId, Self>) -> String

source§

impl<F, Column, ChallengeTerm> From<Operations<ConstantExprInner<F, ChallengeTerm>>> for Expr<ConstantExpr<F, ChallengeTerm>, Column>

source§

fn from(x: ConstantExpr<F, ChallengeTerm>) -> Self

Converts to this type from the input type.
source§

impl<T> From<T> for Operations<T>

source§

fn from(x: T) -> Self

Converts to this type from the input type.
source§

impl<T: Hash> Hash for Operations<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: Literal + Clone> Literal for Operations<T>

§

type F = <T as Literal>::F

source§

fn literal(x: Self::F) -> Self

source§

fn to_literal(self) -> Result<Self::F, Self>

source§

fn to_literal_ref(&self) -> Option<&Self::F>

source§

fn as_literal(&self, constants: &Constants<Self::F>) -> Self

Obtains the representation of some constants as a literal. This is useful before converting Kimchi expressions with constants to folding compatible expressions.
source§

impl<T: Literal + PartialEq> Mul<Operations<T>> for Operations<T>where T::F: Field,

§

type Output = Operations<T>

The resulting type after applying the * operator.
source§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
source§

impl<F, Column> MulAssign<Operations<ExprInner<F, Column>>> for Expr<F, Column>where F: Zero + One + PartialEq + Clone, Column: PartialEq + Clone, ExprInner<F, Column>: Literal, <ExprInner<F, Column> as Literal>::F: Field,

source§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
source§

impl<T: Literal> Neg for Operations<T>where T::F: One + Neg<Output = T::F> + Copy,

§

type Output = Operations<T>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self

Performs the unary - operation. Read more
source§

impl<T: Literal + PartialEq> One for Operations<T>where T::F: Field,

source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
source§

fn is_one(&self) -> bool

Returns true if self is equal to the multiplicative identity. Read more
source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
source§

impl<T: PartialEq> PartialEq<Operations<T>> for Operations<T>

source§

fn eq(&self, other: &Operations<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Literal> Sub<Operations<T>> for Operations<T>where T::F: Field,

§

type Output = Operations<T>

The resulting type after applying the - operator.
source§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more
source§

impl<T: Literal> Zero for Operations<T>where T::F: Field,

source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl<T: Eq> Eq for Operations<T>

source§

impl<T> StructuralEq for Operations<T>

source§

impl<T> StructuralPartialEq for Operations<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Operations<T>where T: RefUnwindSafe,

§

impl<T> Send for Operations<T>where T: Send,

§

impl<T> Sync for Operations<T>where T: Sync,

§

impl<T> Unpin for Operations<T>where T: Unpin,

§

impl<T> UnwindSafe for Operations<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V