Documentation

CslibFrontier.Computability.TreeEval.Ary.Packed.Interpolation

Modular Lagrange basis evaluation #

A Lagrange basis weight for the alphabet 0, …, s-1 is evaluated by a counter and a single modular accumulator. Inverses use the existing Fermat power routine. This executable procedure does not materialize a list of alphabet symbols or polynomial coefficients.

Main definitions #

Main results #

References #

One factor of a Lagrange basis weight, with the diagonal factor replaced by one. unitInv p (v-1) inverts the nonzero residue v when p is prime.

The parameter (p,a,x), counter and accumulator used by basis evaluation. The zero-modulus branch makes every noninitial accumulator bounded even on malformed parameters.

Evaluate the basis weight by exactly s counter steps.

theorem Cslib.TreeEval.Ary.Packed.iterate_basisStep_counter (p a x n : ℕ) :
(basisStep^[n] ((p, a, x), 0, 1 % p)).1 = (p, a, x) ∧ (basisStep^[n] ((p, a, x), 0, 1 % p)).2.1 = n

The counter enumerates the alphabet without storing its elements.

Every intermediate accumulator fits within the modulus plus one, including malformed zero-modulus inputs and the initial accumulator.

theorem Cslib.TreeEval.Ary.Packed.basisWeight_lt {p : ℕ} (hp : 0 < p) (n a x : ℕ) :
basisWeight p n a x < p

A positive modulus keeps the initial and every subsequent accumulator reduced.

theorem Cslib.TreeEval.Ary.Packed.cast_basisFactor {p : ℕ} [Fact (Nat.Prime p)] {a j : ℕ} (h : j ≠ a → ↑a ≠ ↑j) (x : ℕ) :
↑(basisFactor p a j x) = if j = a then 1 else (↑x - ↑j) * (↑a - ↑j)⁻¹

A scalar factor agrees with the corresponding field quotient, unless j is another symbol with the residue of a.

theorem Cslib.TreeEval.Ary.Packed.cast_basisWeight {p : ℕ} [Fact (Nat.Prime p)] {s : ℕ} (a : Fin s) (x : ℕ) :
↑(basisWeight p s (↑a) x) = Polynomial.eval (↑x) (Lagrange.basis Finset.univ (fun (j : Fin s) => ↑↑j) a)

The counter procedure evaluates the finite-grid Lagrange basis polynomial for any alphabet size s: when another symbol in 0, …, s - 1 collides with a modulo p, both the basis polynomial and the product of modular factors vanish.