Documentation

CslibFrontier.Computability.PolyTime.GaloisRingInterpolation

Polynomials over (ℤ / 2 ^ p)[U] / (f) and Lagrange interpolation, on coefficient lists #

Polynomials in z over the coefficient ring A_p = (ℤ / 2 ^ p)[U] / (f) of CslibFrontier/Computability/PolyTime/GaloisRingArithmetic.lean are lists of coefficients, constant first, each a coefficient list of A_p (GaloisRingArith.pval).

Every operation is polynomial-time, with the precision in unary (GaloisRingArith.computableInPolyTime_interp and the rules before it).

This is the interpolation step of the contraction algorithm of [OAI26k] (Appendix D.4.4, p. 61), which recovers F (t + α z) modulo 2 ^ p_t from its values at M (2 L - 1) + 1 binary-coordinate lifts.

Main definitions #

Main results #

References #

noncomputable def Cslib.GaloisRingArith.pval (p : ℕ) (fl : List ℕ) (P : List (List ℕ)) :

The polynomial ∑ k, P_k z ^ k over A_p of a list of coefficient lists.

@[simp]
theorem Cslib.GaloisRingArith.val_nil {p : ℕ} {fl : List ℕ} :
val p fl [] = 0

The empty coefficient list has value zero.

def Cslib.GaloisRingArith.padd (p : ℕ) (fl : List ℕ) (P Q : List (List ℕ)) :

Coefficientwise sum, of length the longer length.

Scaling by an element of A_p.

Multiplication by z - v.

def Cslib.GaloisRingArith.peval (p : ℕ) (fl : List ℕ) (P : List (List ℕ)) (z : List ℕ) :

Evaluation at z by Horner's rule.

theorem Cslib.GaloisRingArith.pval_eq_sum_of_le {p : ℕ} {fl : List ℕ} (P : List (List ℕ)) {n : ℕ} (h : P.length ≤ n) :
pval p fl P = ∑ k ∈ Finset.range n, Polynomial.C (val p fl (P.getD k [])) * Polynomial.X ^ k

Extending a polynomial by zero coefficients does not change it.

theorem Cslib.GaloisRingArith.pval_padd {p : ℕ} {fl : List ℕ} (P Q : List (List ℕ)) :
pval p fl (padd p fl P Q) = pval p fl P + pval p fl Q

Addition is correct.

theorem Cslib.GaloisRingArith.pval_psmul {p : ℕ} {fl : List ℕ} (c : List ℕ) (P : List (List ℕ)) :
pval p fl (psmul p fl c P) = Polynomial.C (val p fl c) * pval p fl P

Scaling is correct.

theorem Cslib.GaloisRingArith.pval_pmulLinear {p : ℕ} {fl : List ℕ} (v : List ℕ) (P : List (List ℕ)) :
pval p fl (pmulLinear p fl v P) = (Polynomial.X - Polynomial.C (val p fl v)) * pval p fl P

Multiplication by z - v is correct.

theorem Cslib.GaloisRingArith.peval_eq {p : ℕ} {fl : List ℕ} (P : List (List ℕ)) (z : List ℕ) :
val p fl (peval p fl P z) = Polynomial.eval (val p fl z) (pval p fl P)

Evaluation is correct.

Lagrange interpolation #

def Cslib.GaloisRingArith.basisNum (p : ℕ) (fl : List ℕ) (v : List (List ℕ)) (i : ℕ) :

The numerator ∏_{j < n, j ≠ i} (z - v_j) of the i-th Lagrange basis polynomial.

def Cslib.GaloisRingArith.basisDen (p : ℕ) (fl : List ℕ) (v : List (List ℕ)) (i : ℕ) :

The denominator ∏_{j < n, j ≠ i} (v_i - v_j) of the i-th Lagrange basis polynomial.

Lagrange interpolation of the values y at the nodes v.

theorem Cslib.GaloisRingArith.pval_basisNum {p : ℕ} {fl : List ℕ} (v : List (List ℕ)) (i : ℕ) :
pval p fl (basisNum p fl v i) = ∏ j ∈ (Finset.range v.length).erase i, (Polynomial.X - Polynomial.C (val p fl (v.getD j [])))
theorem Cslib.GaloisRingArith.val_basisDen {p : ℕ} {fl : List ℕ} (v : List (List ℕ)) (i : ℕ) :
val p fl (basisDen p fl v i) = ∏ j ∈ (Finset.range v.length).erase i, (val p fl (v.getD i []) - val p fl (v.getD j []))
theorem Cslib.GaloisRingArith.pval_interp {p : ℕ} {fl : List ℕ} (v y : List (List ℕ)) :
pval p fl (interp p fl v y) = ∑ i ∈ Finset.range v.length, Polynomial.C (val p fl (y.getD i []) * val p fl (inv p fl (basisDen p fl v i))) * ∏ j ∈ (Finset.range v.length).erase i, (Polynomial.X - Polynomial.C (val p fl (v.getD j [])))

Interpolation is the Lagrange formula, with the computed inverses of the denominators.

theorem Cslib.GaloisRingArith.eval_pval_interp {p : ℕ} {fl : List ℕ} (v y : List (List ℕ)) (hinv : ∀ i < v.length, val p fl (basisDen p fl v i) * val p fl (inv p fl (basisDen p fl v i)) = 1) {k : ℕ} (hk : k < v.length) :
Polynomial.eval (val p fl (v.getD k [])) (pval p fl (interp p fl v y)) = val p fl (y.getD k [])

Interpolation takes the given values at the nodes, given correct inverses of the denominators.

Sizes #

A coefficient list is small when it has e coordinates below 2 ^ (p + 1): reduced coordinates and the unit both are.

theorem Cslib.GaloisRingArith.small_of_lt {p : ℕ} {fl c : List ℕ} (hlen : c.length = fl.length) (hlt : ∀ a ∈ c, a < 2 ^ p) :
Small p fl c
theorem Cslib.GaloisRingArith.small_add {p : ℕ} {fl : List ℕ} (c d : List ℕ) :
Small p fl (add p fl c d)
theorem Cslib.GaloisRingArith.small_mul {p : ℕ} {fl : List ℕ} (c d : List ℕ) :
Small p fl (mul p fl c d)
theorem Cslib.GaloisRingArith.small_sub {p : ℕ} {fl : List ℕ} (c d : List ℕ) :
Small p fl (sub p fl c d)
theorem Cslib.GaloisRingArith.small_one {p : ℕ} {fl : List ℕ} :
Small p fl (one fl)
@[reducible, inline]

Polynomials in z over A_p as lists of coefficients, constant first, each coefficient its coefficient list with entries in binary: the concatenation of the framed coefficients, each the concatenation of its framed entries, each encoded by encNat.

@[reducible, inline]

Lists of elements of A_p, such as interpolation nodes or values, each element its coefficient list with entries in binary: the concatenation of the framed elements, each the concatenation of its framed entries, each encoded by encNat. This is the layout of encPoly; the name records the role.

theorem Cslib.GaloisRingArith.length_encPoly_le {p : ℕ} {fl : List ℕ} {P : List (List ℕ)} {n : ℕ} (hlen : P.length ≤ n) (h : ∀ c ∈ P, Small p fl c) :
(encPoly P).length ≤ n * (2 * (fl.length * (2 * (p + 1) + 1)) + 1)

A list of small coefficient lists of length at most n is at most n (2 e (2 p + 3) + 1) long.

@[simp]
theorem Cslib.GaloisRingArith.length_padd {p : ℕ} {fl : List ℕ} (P Q : List (List ℕ)) :
(padd p fl P Q).length = max P.length Q.length
@[simp]
theorem Cslib.GaloisRingArith.length_psmul {p : ℕ} {fl : List ℕ} (c : List ℕ) (P : List (List ℕ)) :
(psmul p fl c P).length = P.length
@[simp]
theorem Cslib.GaloisRingArith.length_pmulLinear {p : ℕ} {fl : List ℕ} (v : List ℕ) (P : List (List ℕ)) :
(pmulLinear p fl v P).length = P.length + 1
theorem Cslib.GaloisRingArith.small_of_mem_padd {p : ℕ} {fl : List ℕ} {P Q : List (List ℕ)} {c : List ℕ} (h : c ∈ padd p fl P Q) :
Small p fl c
theorem Cslib.GaloisRingArith.small_of_mem_psmul {p : ℕ} {fl c' : List ℕ} {P : List (List ℕ)} {c : List ℕ} (h : c ∈ psmul p fl c' P) :
Small p fl c
theorem Cslib.GaloisRingArith.small_of_mem_pmulLinear {p : ℕ} {fl v : List ℕ} {P : List (List ℕ)} {c : List ℕ} (h : c ∈ pmulLinear p fl v P) :
Small p fl c
theorem Cslib.GaloisRingArith.length_basisNum_le {p : ℕ} {fl : List ℕ} (v : List (List ℕ)) (i : ℕ) :
(basisNum p fl v i).length ≤ v.length + 1
theorem Cslib.GaloisRingArith.small_of_mem_basisNum {p : ℕ} {fl : List ℕ} {v : List (List ℕ)} {i : ℕ} {c : List ℕ} (h : c ∈ basisNum p fl v i) :
Small p fl c

Polynomial time #

Addition of polynomials is polynomial-time, with the precision in unary.

theorem Cslib.GaloisRingArith.polyBounded_polyLength {α : Type} {encIn : α ↪ List Bool} {p : α → ℕ} {fl : α → List ℕ} {n : α → ℕ} (hp : Turing.MultiTapeTM.ComputableInPolyTime p encIn Turing.MultiTapeTM.encUnary) (hfl : Turing.MultiTapeTM.ComputableInPolyTime fl encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat)) (hn : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (encIn x).length) n) :
Turing.MultiTapeTM.PolyBounded (fun (x : α) => (encIn x).length) fun (x : α) => n x * (2 * ((fl x).length * (2 * (p x + 1) + 1)) + 1)

The bound n (2 e (2 (p + 1) + 1) + 1) of length_encPoly_le, on the encoding of at most n small coefficient lists, is polynomially bounded when n is.

Lagrange numerators are polynomial-time, with the precision and the index in unary.

Lagrange interpolation is polynomial-time, with the precision in unary and the nodes and values as lists of coefficient lists.