Documentation

CslibFrontier.Computability.PolyTime.Int.Jet

Truncated univariate integer Taylor jet subtraction, congruences, and fold combinators #

Builds on Cslib.truncZJet, Cslib.polyAdd, and Cslib.mulZJet from CslibFrontier/Computability/PolyTime/ParityFactorEval.lean to provide truncated length-J addition, subtraction, scalar subtraction, Polynomial.X ^ J divisibility congruences, foldl product invariants, encIntBin bit-length bounds, and a plain ComputableInPolyTime product-fold combinator in ℤ[z] / (z ^ J).

All operations (Cslib.IntJet.add, Cslib.IntJet.sub, Cslib.IntJet.subConst, together with Cslib.truncZJet and Cslib.mulZJet) are total on arbitrary List ℤ inputs: missing entries read as 0 via List.getD _ 0, entries at indices ≥ J are truncated modulo z ^ J, and every output has exact length J.

Main definitions and results #

References #

def Cslib.IntJet.add (J : ℕ) (a b : List ℤ) :

Pointwise addition of two integer jets modulo z ^ J (exact length J), reusing Cslib.truncZJet and Cslib.polyAdd.

def Cslib.IntJet.sub (J : ℕ) (a b : List ℤ) :

Pointwise subtraction of two integer jets, zero-padded via getD _ 0 to exact length J.

def Cslib.IntJet.subConst (J : ℕ) (c : ℤ) (a : List ℤ) :

Subtract an integer jet a from a scalar constant c modulo z ^ J (exact length J).

@[simp]
theorem Cslib.IntJet.length_add (J : ℕ) (a b : List ℤ) :
(add J a b).length = J
@[simp]
theorem Cslib.IntJet.length_sub (J : ℕ) (a b : List ℤ) :
(sub J a b).length = J
@[simp]
theorem Cslib.IntJet.length_subConst (J : ℕ) (c : ℤ) (a : List ℤ) :
(subConst J c a).length = J
theorem Cslib.IntJet.length_foldl_mulZJet {α : Type u_1} (J : ℕ) (stepJet : α → List ℤ) (l : List α) {acc : List ℤ} (hacc : acc.length = J) :
(List.foldl (fun (s : List ℤ) (x : α) => mulZJet J s (stepJet x)) acc l).length = J

Folding Cslib.mulZJet J preserves exact length J whenever acc.length = J.

Cslib.mulZJet J a b is congruent to ofCoeffList a * ofCoeffList b modulo X ^ J.

theorem Cslib.IntJet.X_pow_dvd_foldl_mulZJet {α : Type u_1} (J : ℕ) (l : List α) (stepJet : α → List ℤ) (stepPoly : α → Polynomial ℤ) (hstep : ∀ x ∈ l, Polynomial.X ^ J ∣ Polynomial.ofCoeffList (stepJet x) - stepPoly x) (acc : List ℤ) (accPoly : Polynomial ℤ) (hacc : Polynomial.X ^ J ∣ Polynomial.ofCoeffList acc - accPoly) :
Polynomial.X ^ J ∣ Polynomial.ofCoeffList (List.foldl (fun (s : List ℤ) (x : α) => mulZJet J s (stepJet x)) acc l) - accPoly * (List.map stepPoly l).prod

Folding Cslib.mulZJet J over l preserves congruence modulo X ^ J.

Every entry a.getD k 0 has encIntBin bit-length at most coeffNorm1.size + 1.

theorem Cslib.IntJet.coeffNorm1_foldl_mulZJet_le {α : Type u_1} (J : ℕ) (l : List α) (stepJet : α → List ℤ) (bound : α → ℕ) (hstep : ∀ x ∈ l, (Polynomial.ofCoeffList (stepJet x)).coeffNorm1 ≤ bound x) (acc : List ℤ) :
(Polynomial.ofCoeffList (List.foldl (fun (s : List ℤ) (x : α) => mulZJet J s (stepJet x)) acc l)).coeffNorm1 ≤ (Polynomial.ofCoeffList acc).coeffNorm1 * (List.map bound l).prod

Submultiplicative Polynomial.coeffNorm1 bound across foldl of Cslib.mulZJet J.

Bit-size of (ofCoeffList a).coeffNorm1 is bounded linearly in (encList encIntBin a).length.

Encoded length of a : List ℤ is bounded by a.length * (2 * coeffNorm1.size + 3).

@[reducible, inline]

Encoding of a truncated univariate integer jet (List ℤ): the concatenation (encList) of its framed coefficients encoded by encIntBin (sign bit decide (z < 0) followed by the little-endian binary digits encNat z.natAbs).

theorem Cslib.IntJet.computableInPolyTime_foldl_mulZJet {γ α : Type} {encIn : γ ↪ List Bool} (encA : α ↪ List Bool) {J : γ → ℕ} {δ : γ → ℤ} {xs : γ → List α} (factor : ℕ → ℤ → α → List ℤ) (hJ : Turing.MultiTapeTM.ComputableInPolyTime J encIn Turing.MultiTapeTM.encUnary) (hδ : Turing.MultiTapeTM.ComputableInPolyTime δ encIn Turing.MultiTapeTM.encIntBin) (hxs : Turing.MultiTapeTM.ComputableInPolyTime xs encIn (Turing.MultiTapeTM.encList encA)) (hfac : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ((ℕ × ℤ) × List ℤ) × α) => match x with | (((J, δ), snd), a) => factor J δ a) (Turing.MultiTapeTM.encPair (Turing.MultiTapeTM.encPair (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encIntBin) encJet) encA) encJet) {K : γ → ℕ} (hK : Turing.MultiTapeTM.PolyBounded (fun (x : γ) => (encIn x).length) K) (hsz : ∀ (x : γ), ∀ a ∈ xs x, (Polynomial.ofCoeffList (factor (J x) (δ x) a)).coeffNorm1.size ≤ K x) :
Turing.MultiTapeTM.ComputableInPolyTime (fun (x : γ) => List.foldl (fun (acc : List ℤ) (a : α) => mulZJet (J x) acc (factor (J x) (δ x) a)) (truncZJet (J x) [1]) (xs x)) encIn encJet

Plain polynomial-time combinator for folding Cslib.mulZJet over xs from Cslib.truncZJet J [1], given a polynomial bound K on the bit-sizes of the step factors' ℓ₁ norms.