Documentation

CslibFrontier.Computability.TreeEval.Ary.Packed.GateInterpolation

Counter evaluation of a packed gate extension #

The grid is numbered by its base-s digits. A coordinate counter multiplies modular Lagrange weights; an assignment counter sums the weighted table entries. Neither loop constructs a list of assignments or a truth table. The caller supplies the table entry at one assignment index.

Main definitions #

Main results #

References #

This file proves functional correctness and accumulator bounds. The table supplier is an explicit parameter, without an assumed native resource bound. Its query implementation and the native certificate for the complete loop remain separate obligations.

One coordinate of the assignment index, in least-significant-first order.

Multiply one coordinate's basis weight into the accumulator.

Weight one grid assignment by scanning coordinates with one product accumulator.

theorem Cslib.TreeEval.Ary.Packed.gridWeightStep_counters (p s k : ℕ) (x : List ℕ) (n : ℕ) :
((gridWeightStep p s x)^[n] (0, k, 1 % p)).1 = n ∧ ((gridWeightStep p s x)^[n] (0, k, 1 % p)).2.1 = k / s ^ n

The coordinate counter advances while the assignment is consumed one digit at a time. Only division by s is computed at a step; no large power is materialized.

theorem Cslib.TreeEval.Ary.Packed.gridWeight_lt {p : ℕ} (hp : 0 < p) (s n k : ℕ) (x : List ℕ) :
gridWeight p s n k x < p

A positive modulus keeps every product accumulator reduced.

def Cslib.TreeEval.Ary.Packed.gridSumStep (p s n : ℕ) (table : ℕ → ℕ) (x : List ℕ) (st : ℕ × ℕ) :

One assignment's contribution, with the table queried at its current index only.

def Cslib.TreeEval.Ary.Packed.interpolateGrid (p s n : ℕ) (table : ℕ → ℕ) (x : List ℕ) :

Evaluate the interpolation by scanning all s^n assignments with one sum accumulator.

theorem Cslib.TreeEval.Ary.Packed.interpolateGrid_lt {p : ℕ} (hp : 0 < p) (s n : ℕ) (table : ℕ → ℕ) (x : List ℕ) :
interpolateGrid p s n table x < p

Every sum accumulator remains a reduced residue, independently of table entries.

theorem Cslib.TreeEval.Ary.Packed.cast_interpolateGrid {p : ℕ} [Fact (Nat.Prime p)] {s n : ℕ} (hs : 0 < s) (h : Fin s ↪ ZMod p) (hh : ∀ (a : Fin s), h a = ↑↑a) (table : ℕ → ℕ) (x : List ℕ) :
↑(interpolateGrid p s n table x) = Code.lowDegreeExtension h (fun (a : Fin n → Fin s) => ↑(table ↑(finFunctionFinEquiv a))) fun (i : Fin n) => ↑(x.getD (↑i) 0)

The streamed modular sum is exactly the finite-grid low-degree extension. The table is indexed by Mathlib's existing base-s numbering of tuples; no additional gate model is used.