The command loop (round six, `cmdLoop_runs`)
ProvedJ6Seg.Slab.cmdLoop_runscomplexity-theoryinteger-multiplicationkappa-improvement
The command loop.
The following holds (Lean statement, in the scope of module Solutions.J6SegILSlab3):
theorem J6Seg.Slab.cmdLoop_runs (H : UnitsOK (I := I) (iprog := iprog) lin OkU OkA KG g dr rd it bk cdr crd cit cbk)
(s : IState HS) (G : Fin HS → List ℤ) (hK : ∀ C CU OP ARG ACC, KG (skS G C CU OP ARG ACC)) (hA : G lA = []) (hC : G lC = []) (hD : G lD = [])
{m : ℕ} {LM : List ℤ} (hM : G rM = (m : ℤ) :: LM) (cs : List (ℤ × ℤ)) {LN : List ℤ}
(hN : G rNC = (cs.length : ℤ) :: LN) {Ba : ℕ} (hcs : CmdsOK OkA Ba cs) (n : ℕ)
(hV : VC n cs 0) (RC CU OP ARG ACC : List ℤ) (inp tmp : List U) (hlen : n * m ≤ inp.length)
(hok : ∀ u ∈ inp, OkU u) :
IRuns I iprog (cmdLoop dr rd it bk)
(encK s (lin inp tmp (skS G (flatC cs ++ RC) CU OP ARG ACC)))
(encK s (lin (inp.drop (nDrop cs * m)) tmp
(skS G RC ((flatC cs).reverse ++ CU) OP ARG ((runC m g cs inp).reverse ++ ACC))))
((cs.length + 1) * (cmdC m Ba (cdr + crd + cit + cbk) + 3000))
Context. B-line IL, B1 (streaming slab pass) §3: one command, the command loop, one block
The skeleton contents are kept in the form skS G C CU OP ARG ACC (control rC, used
commands rCU, current op rOP, current argument rARG, output rACC, over G).
cmdP: pop(op, arg)fromrCtorOP,rARG; branch on the sign ofop: drop a slab (op < 0), emitmzeros (op = 0), emit the slab mapped byg arg, reading the units to the temps and moving them back (op > 0); pushop,argtorCU.cmd_runs.cmdLoop:rptX rNC cmdP— the whole command list;cmdLoop_runs: the output isrunC m g cs inp(reversed ontorACC), the input losesnDrop csslabs.restLoop:rptX rNC (mv rCU rC; mv rCU rC)restores the control list.restLoop_runs.blockP = cmdLoop; restLoop:block_runs.
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*).
Preamble
-- Round-six κ development (integer-multiplication-kappa), generated by skeleton subtraction.
import Definitions.Def_IntMul_Kappa_R6_Defs64
set_option autoImplicit false
set_option relaxedAutoImplicit false
set_option maxHeartbeats 1000000
open J6Seg J6Seg.Slab
set_option maxRecDepth 20000
open IntMul NLogN NLogN.KIL Function
open NLogN.KFUU (lA lC lD)
open NLogN.KFT (cf3 rptX)
variable {U : Type*} {P : ℕ} {I : List Sym} {iprog : Fin P → IStmt HS P}
{lin : List U → List U → (Fin HS → List ℤ) → (Fin HS → List ℤ)} {OkU : U → Prop}
{OkA : ℤ → Prop} {KG : (Fin HS → List ℤ) → Prop} {g : ℤ → U → ℤ} {dr rd it bk : IStmt HS P}
{cdr crd cit cbk : ℕ}
Formal statement
theorem J6Seg.Slab.cmdLoop_runs (H : UnitsOK (I := I) (iprog := iprog) lin OkU OkA KG g dr rd it bk cdr crd cit cbk)
(s : IState HS) (G : Fin HS → List ℤ) (hK : ∀ C CU OP ARG ACC, KG (skS G C CU OP ARG ACC)) (hA : G lA = []) (hC : G lC = []) (hD : G lD = [])
{m : ℕ} {LM : List ℤ} (hM : G rM = (m : ℤ) :: LM) (cs : List (ℤ × ℤ)) {LN : List ℤ}
(hN : G rNC = (cs.length : ℤ) :: LN) {Ba : ℕ} (hcs : CmdsOK OkA Ba cs) (n : ℕ)
(hV : VC n cs 0) (RC CU OP ARG ACC : List ℤ) (inp tmp : List U) (hlen : n * m ≤ inp.length)
(hok : ∀ u ∈ inp, OkU u) :
IRuns I iprog (cmdLoop dr rd it bk)
(encK s (lin inp tmp (skS G (flatC cs ++ RC) CU OP ARG ACC)))
(encK s (lin (inp.drop (nDrop cs * m)) tmp
(skS G RC ((flatC cs).reverse ++ CU) OP ARG ((runC m g cs inp).reverse ++ ACC))))
((cs.length + 1) * (cmdC m Ba (cdr + crd + cit + cbk) + 3000)) := by sorrySource
S. Jain, round-six networks for the integer-multiplication κ-improvement campaign (https://github.com/Swapnil-jain/integer-mult-kappa, commit 5868dc7) and D. Colkitt, integer-mult-bounds (https://github.com/CrocSwap/integer-mult-bounds); target `IntMul.Kappa.jain_round6_framework`. Lean declaration `J6Seg.Slab.cmdLoop_runs`, Solutions/J6SegILSlab3.lean (lines 281–330) of the round-six development.