Documentation

CslibFrontier.Logics.RealArithmetic.FormulaGatePolynomial

Substituting bivariate coordinates into indexed formula gates #

This adapts the per-gate polynomial in LeanCanny.ETR.FormulaAtomPolynomials.family at lean-canny revision 970f28a5ecefc1327402ade16c068aa4b1b2c183 to the frontier term source. Evaluating both variables recovers the original term evaluated at the specialized coordinates. The term budget bounds both degrees of the substituted polynomial and the growth of its coefficient norm. With a radix above the inner degree bound, Kronecker substitution recovers a bivariate coefficient by reading one univariate coefficient. The executable gate query evaluates the substituted polynomial modulo a positive modulus when supplied the specialized coordinate values.

Substitute integer bivariate coordinate polynomials for the variables of an indexed gate term. The coefficient variable is the first variable and the outer variable is the second.

theorem Cslib.Logic.RealArithmetic.aevalAeval_formulaWordGatePolynomial (word : List Bool) (index : ℕ) (coordinates : Fin word.length → Polynomial (Polynomial ℤ)) (x y : ℝ) :
(Polynomial.aevalAeval x y) (formulaWordGatePolynomial word index coordinates) = Term.eval (fun (i : Fin word.length) => (Polynomial.aevalAeval x y) (coordinates i)) (formulaWordGateTerm word index)

Evaluating the substituted polynomial at a real pair gives the gate term evaluated at the corresponding real coordinates.

theorem Cslib.Logic.RealArithmetic.formulaWordGatePolynomial_degree_bounds (word : List Bool) (index : ℕ) (coordinates : Fin word.length → Polynomial (Polynomial ℤ)) {outer inner : ℕ} (houter : ∀ (i : Fin word.length), (coordinates i).natDegree ≤ outer) (hinner : ∀ (i : Fin word.length), (Polynomial.Bivariate.swap (coordinates i)).natDegree ≤ inner) :
have budget := formulaWordGateTermBudget word; have p := formulaWordGatePolynomial word index coordinates; p.natDegree ≤ budget * outer ∧ (Polynomial.Bivariate.swap p).natDegree ≤ budget * inner

Substitution bounds the degree in each variable by the corresponding coordinate degree times the formula's gate-term budget. Swapping the variables exposes the coefficient variable as the outer variable.

theorem Cslib.Logic.RealArithmetic.formulaWordGatePolynomial_bivariateCoeffNorm1_le (word : List Bool) (index : ℕ) (coordinates : Fin word.length → Polynomial (Polynomial ℤ)) {M : ℕ} (hM : 1 ≤ M) (hcoordinates : ∀ (i : Fin word.length), (coordinates i).bivariateCoeffNorm1 ≤ M) :
have budget := formulaWordGateTermBudget word; (formulaWordGatePolynomial word index coordinates).bivariateCoeffNorm1 ≤ (2 * M) ^ budget

The formula's gate-term budget bounds the coefficient norm after substitution, uniformly over gate indices. Each coordinate must have bivariate coefficient norm at most M ≥ 1.

theorem Cslib.Logic.RealArithmetic.coeff_aeval_kronecker_formulaWordGateTerm (word : List Bool) (index : ℕ) (coordinates : Fin word.length → Polynomial (Polynomial ℤ)) {inner radix : ℕ} (hinner : ∀ (k : Fin word.length), (Polynomial.Bivariate.swap (coordinates k)).natDegree ≤ inner) (hradix : formulaWordGateTermBudget word * inner < radix) (i j : ℕ) (hi : i < radix) :
((MvPolynomial.aeval fun (k : Fin word.length) => Polynomial.eval (Polynomial.X ^ radix) (coordinates k)) (formulaWordGateTerm word index).toPolynomial).coeff (i + radix * j) = ((formulaWordGatePolynomial word index coordinates).coeff j).coeff i

A radix larger than the gate-term budget times the coordinate inner degree bound lets a univariate substitution recover the gate's coefficient at inner index i and outer index j, for i < radix. This is the polynomial identity used by LeanCanny.ETR.BivariateTermReader.coefficient_eq at the revision above.

theorem Cslib.Logic.RealArithmetic.formulaWordGateResidue_eq_aevalAeval (word : List Bool) (index : ℕ) (coordinates : Fin word.length → Polynomial (Polynomial ℤ)) {p : ℕ} (hp : 0 < p) (point : List ℕ) (x y : ZMod p) (hpoint : ∀ (k : Fin word.length), ↑(point[↑k]?.getD 0) = (Polynomial.aevalAeval x y) (coordinates k)) :
formulaWordGateResidue word index p point = ((Polynomial.aevalAeval x y) (formulaWordGatePolynomial word index coordinates)).val

The encoded gate query computes the canonical residue of bivariate specialization from coordinate values in the supplied list. Missing entries have value zero. This is the evaluation step for the indexed family in LeanCanny.ETR.FormulaAtomPolynomials.family at the revision above.