Round-six lemma `uloop_runs`
ProvedNLogN.KFC.uloop_runsAn auxiliary lemma of the round-six development, published as a separate node because its proof is long or shared.
The following holds (Lean statement, in the scope of module Solutions.KFCBase):
theorem NLogN.KFC.uloop_runs {C D : Fin HS} (hCD : C ≠ D) (n : ℕ) (T : ℕ → IState HS) (LC LD : List Item)
(hLC : NM LC) (hLD : NM LD) (c : ℕ) (b : IStmt HS Pp)
(hb : ∀ k < n, ∀ LC' LD', IRuns I iprog b (cf (T k) C D LC' LD') (cf (T (k + 1)) C D LC' LD') c) :
IRuns I iprog (uloop C D b) (cf (T 0) C D (marks n ++ LC) LD)
(cf (T n) C D (marks n ++ LC) LD) (n * (c + 64) + 60)
Context. KFC base: fine-cost item-language loops
Item-language (IStmt) building blocks whose per-element cost is O(1 + zsz a) for the moved
entry a, with no binary loop counter per element:
mvW X Y: move integers fromXtoYuntil the top ofXis not an integer (delimiter-driven, cost(76 w + 131)per entry of bit size≤ w);uloop C D b: runbonce per mark on the unary counterC(the marks are moved toDand then moved back, so the counter is restored); overhead64per iteration;mvB X Y C D: move exactlynintegers,n= number of marks onC;toU A X K K2: pushnmarks onX, wheren ≥ 0is the integer on top ofA(binary counter, costO((n+1)(zsz n + 2)); superseded by the linearKFCUnary.toUL, which the programs use);clrM X: drop all marks on top ofX.
Formalization Note. Part of the Lean formalization of the round-six κ-improvement (integer-multiplication-kappa campaign, target IntMul.Kappa.jain_round6_framework). The statement is copied verbatim from the Lean development; the platform node carries the same declaration name. Definitions it mentions live in the IntMul_Kappa_R6_Defs* bundles (on top of the published κ bundles IntMul_Kappa_K_Defs*).
-- Round-six κ development (integer-multiplication-kappa), generated by skeleton subtraction.
import Definitions.Def_IntMul_Kappa_K_Defs33
import Definitions.Def_IntMul_Kappa_R6_Defs1
import Mathlib
import Definitions.Def_IntMul_HvdH_M_Defs8
import Definitions.Def_IntMul_MultitapeModel
set_option autoImplicit false
set_option relaxedAutoImplicit false
set_option maxHeartbeats 1000000
open NLogN NLogN.KFC
open IntMul
variable {Pp : ℕ} {I : List Sym} {iprog : Fin Pp → IStmt HS Pp}
theorem NLogN.KFC.uloop_runs {C D : Fin HS} (hCD : C ≠ D) (n : ℕ) (T : ℕ → IState HS) (LC LD : List Item)
(hLC : NM LC) (hLD : NM LD) (c : ℕ) (b : IStmt HS Pp)
(hb : ∀ k < n, ∀ LC' LD', IRuns I iprog b (cf (T k) C D LC' LD') (cf (T (k + 1)) C D LC' LD') c) :
IRuns I iprog (uloop C D b) (cf (T 0) C D (marks n ++ LC) LD)
(cf (T n) C D (marks n ++ LC) LD) (n * (c + 64) + 60) := by sorry