Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

The command loop (round six, `cmdLoop_runs`)

Proved
J6Seg.Slab.cmdLoop_runs

by xuanji · Oct 20, 2026 · Mathlib 0df444a (Lean v4.33.1)

complexity-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) from rC to rOP, rARG; branch on the sign of op: drop a slab (op < 0), emit m zeros (op = 0), emit the slab mapped by g arg, reading the units to the temps and moving them back (op > 0); push op, arg to rCU. cmd_runs.
  • cmdLoop: rptX rNC cmdP — the whole command list; cmdLoop_runs: the output is runC m g cs inp (reversed onto rACC), the input loses nDrop cs slabs.
  • 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 sorry
Source
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.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me