Generic counted loop
ProvedNLogN.KFM.genLoop_runGeneric counted loop.
The following holds (Lean statement, in the scope of module Solutions.KFMS0):
theorem NLogN.KFM.genLoop_run (i a : Fin HS) (n : Ex HS) (body : RS) (s : IState HS) (N : ℕ)
(G : ℕ → ℤ → ℤ) (a0 : ℤ) (La : List Item) (hia : i ≠ a) (hi56 : i.val < 56)
(hn : n.Clean) (hnok : n.ok s) (hN : n.eval s = N) (hw : i ∉ body.writes)
(ha : s.G a = .int a0 :: La)
(hb : ∀ k < N, body.ok (lpSt s i a La N k (accSeq G a0 k)) ∧
body.run (lpSt s i a La N k (accSeq G a0 k)) =
(lpSt s i a La N k (accSeq G a0 k)).upd a (.int (G k (accSeq G a0 k)) :: La)) :
(rep i n body).ok s ∧ (rep i n body).run s = s.upd a (.int (accSeq G a0 N) :: La)
Context. The lemma belongs to the part KFM S0: generic counted loops of register programs (RS.rep) for the setup arithmetic.
Formalization Note. This lemma belongs to the item-language (IL) layer of the integer-multiplication-kappa campaign: tape-level programs (register programs over 64 item stacks of the NLogN multitape framework, definition bundles IntMul_HvdH_M_Defs1–IntMul_HvdH_M_Defs8) that implement the data-movement primitives of the OpenAI preprint Integer multiplication below (field moves, row split/merge, shifts, the uniform Proposition 11 interchange, Lemma 12 with fine -per-element costs, Gaussian record primitives, Proposition 14 pieces) with exact list denotations from the array-model bundles IntMul_Kappa_K_Defs* and explicit cost bounds. All names refer to the definition bundles up to IntMul_Kappa_K_Defs22.
-- OpenAI-preprint / κ-improvement development (integer-multiplication-kappa), generated by skeleton subtraction. import Definitions.Def_IntMul_Kappa_K_Defs22 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.unusedSectionVars false open NLogN open NLogN.KFM open IntMul RS
theorem NLogN.KFM.genLoop_run (i a : Fin HS) (n : Ex HS) (body : RS) (s : IState HS) (N : ℕ)
(G : ℕ → ℤ → ℤ) (a0 : ℤ) (La : List Item) (hia : i ≠ a) (hi56 : i.val < 56)
(hn : n.Clean) (hnok : n.ok s) (hN : n.eval s = N) (hw : i ∉ body.writes)
(ha : s.G a = .int a0 :: La)
(hb : ∀ k < N, body.ok (lpSt s i a La N k (accSeq G a0 k)) ∧
body.run (lpSt s i a La N k (accSeq G a0 k)) =
(lpSt s i a La N k (accSeq G a0 k)).upd a (.int (G k (accSeq G a0 k)) :: La)) :
(rep i n body).ok s ∧ (rep i n body).run s = s.upd a (.int (accSeq G a0 N) :: La) := by sorry