HvdH machine lemma ST.envP_spec (The recursive step, part 7: `envP` (environment + `exCore` + teardown))
ProvedNLogN.ST.envP_specThe following holds (Lean statement, in the scope of module NLogN.HSt7):
theorem NLogN.ST.envP_spec (M : MulSpec) {Φf Φm m kb mm Φ Bacc Qa Bq Bx CS CB Q : ℕ} {BS BB : ℕ → ℕ}
(q : Params) (hMB : MulBnd M (q.fn + 1) Φf) (hP : 1 ≤ q.P) (hK : q.K ≤ q.fn)
(hlo : q.logOuter ≤ q.fn) (hkb : q.logOuter ≤ kb) (hMm : MulBnd M m Φm)
(hcfg : EX.FwdCfgX M q kb mm Φ Bacc Qa Bq Bx CS CB m Q BS BB) (Bs : ℕ) (w : IState HS)
(hr : EnvRegs q kb w) (hn : EnvN q kb Bs)
(u v : List ℤ) (R RV : List Item) (mu : ℕ) (hu : w.G 0 = ints u ++ R) (hv : w.G 30 = ints v ++ RV)
(hul : u.length = q.S) (hvl : v.length = q.S)
(hDS : ∃ RD, w.G 39 = ints ((FW.descs q.outerAxes 1).flatMap FW.enc8) ++ RD)
(hxs : ∃ RS, w.G 1 = ints (EX.sl q) ++ RS) (hch : ∃ RC, w.G 28 = gints (chirpL q) ++ RC)
(hub : ∀ x ∈ u, zsz x ≤ mu) (hvb : ∀ x ∈ v, zsz x ≤ mu) (hmu : mu + (q.p - q.b) + 1 ≤ Q)
(inU : EX.FwdInX q (FWW.FwPre q) BS BB m Q (GL.exU q u))
(inV : EX.FwdInX q (FWW.FwPre q) BS BB m Q (GL.exU q v))
(inW : EX.FwdInX q (FWW.FwPre q) BS BB m Q (GL.exW q u v))
(hS2 : zsz ((q.S : ℤ) ^ 2) ≤ m) (hBQ : 2 * m + GL.exC q + q.p + 6 ≤ Q)
(hSQ : zsz ((2 * q.S : ℕ) : ℤ) ≤ Q) :
Spec M (envP q.K) w ((w.upd 30 RV).upd 0 (ints (exactConvL q u v) ++ R))
(EX.pwt (envL q.K) * 10 ^ 7 * (Bs + 2) ^ 2 + 1 +
(exCost q kb CS CB Bx Q Φf Φm + ((envV q kb).length * (2 * Bs + 2) + 1)))
Context. The lemma belongs to the part The recursive step, part 7: envP (environment + exCore + teardown).
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 16000000
theorem NLogN.ST.envP_spec (M : MulSpec) {Φf Φm m kb mm Φ Bacc Qa Bq Bx CS CB Q : ℕ} {BS BB : ℕ → ℕ}
(q : Params) (hMB : MulBnd M (q.fn + 1) Φf) (hP : 1 ≤ q.P) (hK : q.K ≤ q.fn)
(hlo : q.logOuter ≤ q.fn) (hkb : q.logOuter ≤ kb) (hMm : MulBnd M m Φm)
(hcfg : EX.FwdCfgX M q kb mm Φ Bacc Qa Bq Bx CS CB m Q BS BB) (Bs : ℕ) (w : IState HS)
(hr : EnvRegs q kb w) (hn : EnvN q kb Bs)
(u v : List ℤ) (R RV : List Item) (mu : ℕ) (hu : w.G 0 = ints u ++ R) (hv : w.G 30 = ints v ++ RV)
(hul : u.length = q.S) (hvl : v.length = q.S)
(hDS : ∃ RD, w.G 39 = ints ((FW.descs q.outerAxes 1).flatMap FW.enc8) ++ RD)
(hxs : ∃ RS, w.G 1 = ints (EX.sl q) ++ RS) (hch : ∃ RC, w.G 28 = gints (chirpL q) ++ RC)
(hub : ∀ x ∈ u, zsz x ≤ mu) (hvb : ∀ x ∈ v, zsz x ≤ mu) (hmu : mu + (q.p - q.b) + 1 ≤ Q)
(inU : EX.FwdInX q (FWW.FwPre q) BS BB m Q (GL.exU q u))
(inV : EX.FwdInX q (FWW.FwPre q) BS BB m Q (GL.exU q v))
(inW : EX.FwdInX q (FWW.FwPre q) BS BB m Q (GL.exW q u v))
(hS2 : zsz ((q.S : ℤ) ^ 2) ≤ m) (hBQ : 2 * m + GL.exC q + q.p + 6 ≤ Q)
(hSQ : zsz ((2 * q.S : ℕ) : ℤ) ≤ Q) :
Spec M (envP q.K) w ((w.upd 30 RV).upd 0 (ints (exactConvL q u v) ++ R))
(EX.pwt (envL q.K) * 10 ^ 7 * (Bs + 2) ^ 2 + 1 +
(exCost q kb CS CB Bx Q Φf Φm + ((envV q kb).length * (2 * Bs + 2) + 1))) := by sorry