Skip to main content

Module expr

Module expr 

Source

Re-exportsΒ§

use crate::circuits::berkeley_columns; πŸ”’
use crate::circuits::berkeley_columns::BerkeleyChallengeTerm; πŸ”’
use crate::circuits::constraints::FeatureFlags; πŸ”’
use crate::circuits::domains::Domain; πŸ”’
use crate::circuits::gate::CurrOrNext; πŸ”’
use crate::circuits::lookup::lookups::LookupPattern; πŸ”’
use crate::circuits::lookup::lookups::LookupPatterns; πŸ”’
use crate::circuits::polynomials::foreign_field_common::KimchiForeignElement; πŸ”’
use crate::circuits::polynomials::permutation::eval_vanishes_on_last_n_rows; πŸ”’
use crate::collections::HashMap; πŸ”’
use crate::collections::HashSet; πŸ”’
use crate::proof::PointEvaluations; πŸ”’
use alloc::boxed::Box; πŸ”’
use alloc::format; πŸ”’
use alloc::string::String; πŸ”’
use alloc::string::ToString; πŸ”’
use alloc::vec; πŸ”’
use alloc::vec; πŸ”’
use alloc::vec::Vec; πŸ”’
use ark_ff::FftField; πŸ”’
use ark_ff::Field; πŸ”’
use ark_ff::One; πŸ”’
use ark_ff::PrimeField; πŸ”’
use ark_ff::Zero; πŸ”’
use ark_poly::univariate::DensePolynomial; πŸ”’
use ark_poly::EvaluationDomain; πŸ”’
use ark_poly::Evaluations; πŸ”’
use ark_poly::Radix2EvaluationDomain as D; πŸ”’
use core::cmp::Ordering; πŸ”’
use core::fmt; πŸ”’
use core::fmt::Debug; πŸ”’
use core::fmt::Debug; πŸ”’
use core::fmt::Display; πŸ”’
use core::iter::FromIterator; πŸ”’
use core::ops::Add; πŸ”’
use core::ops::AddAssign; πŸ”’
use core::ops::Index; πŸ”’
use core::ops::Mul; πŸ”’
use core::ops::MulAssign; πŸ”’
use core::ops::Neg; πŸ”’
use core::ops::Sub; πŸ”’
use itertools::Itertools; πŸ”’
use o1_utils::field_helpers::pows; πŸ”’
use o1_utils::foreign_field::ForeignFieldHelpers; πŸ”’
use o1_utils::FieldHelpers; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Serialize; πŸ”’
use serde::Serialize; πŸ”’
use thiserror::Error; πŸ”’
use CurrOrNext::Curr; πŸ”’
use CurrOrNext::Next; πŸ”’
use self::constraints::ExprOps; πŸ”’
pub use auto_clone;
pub use auto_clone_array;
use rayon::prelude::*; πŸ”’

ModulesΒ§

constraints
A number of useful constraints
prologue
You can import this module like use kimchi::circuits::expr::prologue::* to obtain a number of handy aliases and helpers

StructsΒ§

Cache
A cache
CacheId
A key for a cached value
Constants
The collection of constants required to evaluate an Expr.
FCol πŸ”’
A witness-column access resolved for the fused evaluator: at row i it reads evals[(scale * i + offset) % len] – the same indexing as SubEvals.
Linearization
A β€œlinearization”, which is linear combination with E coefficients of columns.
RowOffset
Variable
A type representing a variable which can appear in a constraint. It specifies a column and a relative position (Curr or Next)

EnumsΒ§

ConstantExprInner
ConstantTerm
Define the constant terms an expression can use. It can be any constant term (Literal), a matrix (Mds - used by the permutation used by Poseidon for instance), or endomorphism coefficients (EndoCoefficient - used as an optimisation). As for challengeTerm, it has been used initially to implement the PLONK IOP, with the custom gate Poseidon. However, the terms have no built-in semantic in the expression framework. TODO: we should generalize the expression type over challenges and constants. See https://github.com/MinaProtocol/mina/issues/15287
Either πŸ”’
Use as a result of the expression evaluations routine. For now, the left branch is the result of an evaluation and the right branch is the ID of an element in the cache
EvalResult πŸ”’
ExprError
ExprInner
FOp πŸ”’
Flat bytecode for the fused evaluator: a stack machine walked once per domain row, with intermediates living in a register frame rather than full-domain arrays.
FeatureFlag
The feature flags that can be used to enable or disable parts of constraints.
Operations
PolishToken
For efficiency of evaluation, we compile expressions to reverse Polish notation expressions, which are vectors of the below tokens.

ConstantsΒ§

_DERIVE_ocaml_FromValue_from_value_lifetime_FOR_FeatureFlag πŸ”’
_DERIVE_ocaml_IntoValue_FOR_FeatureFlag πŸ”’

TraitsΒ§

AlphaChallengeTerm
The Challenge term that contains an alpha. Is used to make a random linear combination of constraints
ColumnEnvironment
ColumnEvaluations
FormattedOutput
Literal

FunctionsΒ§

fused_eval_mode πŸ”’
Execution mode for the experimental fused row-wise evaluator. KIMCHI_FUSED_EVAL=1 uses it (falling back to the vectorised path for expressions it does not handle); =verify runs both and asserts they agree.
l0_1
Computes prod_{j != n} (1 - omega^j) Assure we don’t multiply by (1 - omega^n) = (1 - omega^0) = (1 - 1) = 0
mul_monomials πŸ”’
unnormalized_lagrange_basis
unnormalized_lagrange_evals πŸ”’
Compute the evaluations of the unnormalized lagrange polynomial on H_8 or H_4. Taking H_8 as an example, we show how to compute this polynomial on the expanded domain.

Type AliasesΒ§

ConstantExpr
Expr
An multi-variate polynomial over the base ring C with variables
Monomials πŸ”’