HvdH machine lemma ST.tailP_spec (The recursive step, part 5: the tail (`crtOut`, `evalDigits`, result) )
ProvedNLogN.ST.tailP_specThe following holds (Lean statement, in the scope of module NLogN.HSt5):
theorem NLogN.ST.tailP_spec (M : MulSpec) (q : Params) (sl : List ℕ) (h : CR.CrtOK sl) (t : IState HS)
(w : List ℤ) (S Mo kb b : ℕ) (R28 R0 L1 L2 R3 LT L33 L31 : List Item)
(hS : sl.prod = S) (hw : w.length = S) (hM : Mo ≤ S) (hkb : S ≤ 2 ^ kb)
(h28 : t.G 28 = gints (chirpL q) ++ R28) (h9 : t.G 9 = .int (q.tdims.prod : ℤ) :: LT)
(h0 : t.G 0 = ints w ++ R0) (h1 : t.G 1 = .int S :: L1) (h2 : t.G 2 = .int kb :: L2)
(h3 : t.G 3 = natInts (CR.keyL sl) ++ R3) (h33 : t.G 33 = .int Mo :: L33)
(h31 : t.G 31 = .int (2 ^ b) :: L31) (B : ℕ)
(hc : ∀ x ∈ crtOut sl Mo w, 0 ≤ x ∧ x < 2 ^ B) (hb1 : 1 ≤ b) (hbB : b + 1 ≤ B)
(hpB : q.p + 1 ≤ B) (hTB : 2 * q.tdims.prod < 2 ^ B) (hSB : S < 2 ^ B) (hwB : Bnd B w)
(hkbB : kb < 2 ^ B) (BE : ℕ) (hEB : zsz (evalDigits b (crtOut sl Mo w)) ≤ BE) :
Spec M tailP t (((((((t.upd 28 R28).upd 0 R0).upd 3 R3).upd 1 L1).upd 2 L2)).upd Top.XR
(.int (evalDigits b (crtOut sl Mo w)) :: t.G Top.XR))
(tailCost q.tdims.prod S Mo kb b B + (4000 * (BE + 2) + (2 * BE + 2)))
Context. The lemma belongs to the part The recursive step, part 5: the tail (crtOut, evalDigits, result) and the final pops.
Formalization Note. This is a lemma of the Lean development NLogN, a multitape-Turing-machine implementation of the Harvey–van der Hoeven integer multiplication algorithm, used in the proof of NLogN.FIN.theorem_1_1_nlogn : IntMul.MulTimeBound fun n => n * Real.log n. All names refer to the definition bundles IntMul_HvdH_M_Defs1–IntMul_HvdH_M_Defs8 (namespace NLogN), built on the platform model Def_IntMul_MultitapeModel and the published reference Def_IntMul_HvdH_MachineRef. The machine layer: IState HS is a state of 64 item stacks; RM programs have a semantics p.run s, a definedness predicate p.ok M s and a cost p.cost M s relative to a multiplication spec M : MulSpec; zsz z is the bit length of .
-- Harvey–van der Hoeven multitape-TM development (NLogN), generated by skeleton subtraction. import Definitions.Def_IntMul_HvdH_M_Defs8 set_option autoImplicit false set_option relaxedAutoImplicit false set_option maxHeartbeats 1000000 set_option linter.unusedSimpArgs false set_option linter.unusedVariables false set_option linter.unreachableTactic false set_option linter.unusedTactic false open NLogN open NLogN.ST open IntMul NLogN IntMul.HvdH IntMul.HvdH.Ref open NLogN.FW (Spec) set_option maxHeartbeats 8000000
theorem NLogN.ST.tailP_spec (M : MulSpec) (q : Params) (sl : List ℕ) (h : CR.CrtOK sl) (t : IState HS)
(w : List ℤ) (S Mo kb b : ℕ) (R28 R0 L1 L2 R3 LT L33 L31 : List Item)
(hS : sl.prod = S) (hw : w.length = S) (hM : Mo ≤ S) (hkb : S ≤ 2 ^ kb)
(h28 : t.G 28 = gints (chirpL q) ++ R28) (h9 : t.G 9 = .int (q.tdims.prod : ℤ) :: LT)
(h0 : t.G 0 = ints w ++ R0) (h1 : t.G 1 = .int S :: L1) (h2 : t.G 2 = .int kb :: L2)
(h3 : t.G 3 = natInts (CR.keyL sl) ++ R3) (h33 : t.G 33 = .int Mo :: L33)
(h31 : t.G 31 = .int (2 ^ b) :: L31) (B : ℕ)
(hc : ∀ x ∈ crtOut sl Mo w, 0 ≤ x ∧ x < 2 ^ B) (hb1 : 1 ≤ b) (hbB : b + 1 ≤ B)
(hpB : q.p + 1 ≤ B) (hTB : 2 * q.tdims.prod < 2 ^ B) (hSB : S < 2 ^ B) (hwB : Bnd B w)
(hkbB : kb < 2 ^ B) (BE : ℕ) (hEB : zsz (evalDigits b (crtOut sl Mo w)) ≤ BE) :
Spec M tailP t (((((((t.upd 28 R28).upd 0 R0).upd 3 R3).upd 1 L1).upd 2 L2)).upd Top.XR
(.int (evalDigits b (crtOut sl Mo w)) :: t.G Top.XR))
(tailCost q.tdims.prod S Mo kb b B + (4000 * (BE + 2) + (2 * BE + 2))) := by sorry