Multilinear Polynomials #
This file defines computable representations of multilinear polynomials.
The first representation is by their coefficients, and the second representation is by their
evaluations over the Boolean hypercube {0,1}^n. Both representations are defined as Vectors of
length 2^n, where n is the number of variables. We will define operations on these
representations, and prove equivalence between them, and with the standard Mathlib definition of
multilinear polynomials, which is the type R⦃≤ 1⦄[X Fin n] (notation for
MvPolynomial.restrictDegree (Fin n) R 1).
TODOs #
- The abstract formula for
monoToLagrange(zeta formula) andlagrangeToMono(mobius formula)
CMlPolynomial n R is the type of multilinear polynomials in n variables over a ring R.
It is represented by its monomial coefficients as a Vector of length 2^n.
The indexing is little-endian (i.e. the least significant bit is the first bit).
Equations
Instances For
Equations
Instances For
CMlPolynomialEval n R is the type of multilinear polynomials in n variables over a ring R.
It is represented by its evaluations over the Boolean hypercube {0,1}^n,
i.e. Lagrange basis coefficients.
The indexing is little-endian (i.e. the least significant bit is the first bit).
Equations
Instances For
Equations
Instances For
Equations
Conform a list of coefficients to a CMlPolynomial with a given number of variables.
May either pad with zeros or truncate.
Equations
Instances For
Equations
Instances For
Add two CMlPolynomials
Equations
Instances For
Negation of a CMlPolynomial
Equations
Instances For
Scalar multiplication of a CMlPolynomial
Equations
Instances For
Scalar multiplication of a CMlPolynomial by a natural number
Equations
Instances For
Scalar multiplication of a CMlPolynomial by an integer
Equations
Instances For
Equations
Equations
The i-th element of monomialBasis w is the product of w[j] if the j-th bit of i is 1,
and 1 if the j-th bit of i is 0.
Equations
Instances For
Evaluate a CMlPolynomial at a point
Equations
Instances For
Equations
Instances For
Equations
Conform a list of coefficients to a CMlPolynomialEval with a given number of variables.
May either pad with zeros or truncate.
Equations
Instances For
Equations
Instances For
Add two CMlPolynomialEvals
Equations
Instances For
Negation of a CMlPolynomialEval
Equations
Instances For
Scalar multiplication of a CMlPolynomialEval
Equations
Instances For
Scalar multiplication of a CMlPolynomialEval by a natural number
Equations
Instances For
Scalar multiplication of a CMlPolynomialEval by an integer
Equations
Instances For
Equations
Equations
Lagrange (hypercube) basis at point w.
Returns the length-2^n vector v such that for any x ∈ {0,1}^n, letting
i = ∑_{j=0}^{n-1} x_j · 2^j (little‑endian indexing), we have
v[i] = ∏_{j < n} (x_j · w[j] + (1 - x_j) · (1 - w[j])).
Equivalently, for i : Fin (2^n),
v[i] = ∏_{j < n}, (if the j-th bit of i is 1 then w[j] else 1 - w[j]).
Equations
Instances For
The i-th element of lagrangeBasis w is the product of w[j] if the j-th bit of i is 1,
and 1 - w[j] if the j-th bit of i is 0.
Map a ring homomorphism over a CMlPolynomialEval
Equations
Instances For
Evaluate a CMlPolynomialEval at a point
Equations
Instances For
Evaluate a CMlPolynomialEval at a point using a ring homomorphism
Equations
Instances For
One level of the zeta‑transform (coefficient to evaluation).
This function performs the transformation for the j-th variable (corresponding to the j-th bit).
It iterates over all indices i in the boolean hypercube. If the j-th bit of i is 1,
it adds the value at the corresponding index with the j-th bit 0 (i - stride)
to the current value.
This effectively computes the partial sum along the j-th dimension, which corresponds to
evaluating the polynomial at $X_j = 1$ given its values at $X_j = 0$ (coefficients) and difference.
The stride is $2^j$, representing the distance between indices that differ only in the j-th bit.
Equations
Instances For
Full transform: coefficients → evaluations.
Equations
Instances For
One level of the inverse zeta‑transform (evaluation to coefficient).
This function performs the inverse transformation for the j-th variable.
It iterates over all indices i. If the j-th bit of i is 1, it subtracts the value
at the corresponding index with the j-th bit 0 (i - stride) from the current value.
This recovers the coefficient for the term involving $X_j$ from the evaluations.
The stride is $2^j$.
Equations
Instances For
Full inverse transform: evaluations → coefficients.
Equations
Instances For
The O(n^3) computable version of the Mobius Transform, serving as the spec.
TODO: prove equivalence between lagrangeToMono and lagrangeToMonoSpec
Equations
Instances For
Generates a list of indices representing a range of bit positions [l, r] in increasing order.
Used for optimized recursive transforms that operate on segments of variables.
Returns a list containing l, l+1, ..., r.
The result is used to fold over dimensions in monoToLagrangeSegment and lagrangeToMonoSegment.
Equations
Instances For
Performs the zeta-transform (coefficient to evaluation) on a segment of dimensions from l to r.
Iteratively applies monoToLagrangeLevel for each dimension in the range.
0 ≤ l ≤ r < n.
Equations
Instances For
Performs the inverse zeta-transform (evaluation to coefficient) on a segment of dimensions
from l to r.
Iteratively applies lagrangeToMonoLevel for each dimension in the range (in reverse order).
0 ≤ l ≤ r < n.
Equations
Instances For
The equivalence between the monomial basis representation (CMlPolynomial)
and the Lagrange basis representation (CMlPolynomialEval) of a multilinear polynomial.
The forward map is monoToLagrange (zeta transform) and the inverse is lagrangeToMono
(inverse zeta transform/Mobius transform).
Equations
Instances For
#eval Tests #
This section contains tests to verify the functionality of multilinear polynomial operations.