Lemma 10 controlled shift, self-contained IL program
ProvedNLogN.KIL.shiftArr_il_specLemma 10 controlled shift, self-contained IL program. For a layout on sh = A ++ Q :: C with target i at position |A|, coefficient u = 1 and controls before the target, shP (table generation, then rotP) computes shiftArr Λ i 1 c 0 xs on stack 0, restores every other stack, and costs O((|A| + 1)(V + 1)(Bb + 2) + (Bb + 2)^2).
The following holds (Lean statement, in the scope of module Solutions.KIL2Shift):
theorem NLogN.KIL.shiftArr_il_spec [NeZero Q] (i : Fin n) (c : Fin n → ZMod Q)
(hc : ∀ j, i ≤ j → c j = 0) (A C : Shape) (hsh : sh = A ++ Q :: C)
(hA : (Λ.pos i : ℕ) = A.length) (t : IState HS) (xs : List ℤ) (Bb : ℕ) (R : List Item)
(hlen : xs.length = AModel.vol sh) (hb : Bnd Bb xs) (hB1 : 1 ≤ AModel.vol C) (hQ1 : 1 ≤ Q)
(hP1 : 1 ≤ AModel.vol A) (hV : zsz ((AModel.vol A * (Q * AModel.vol C) : ℕ) : ℤ) ≤ Bb)
(hQ2 : zsz ((2 * Q : ℕ) : ℤ) ≤ Bb) (h0 : t.G 0 = ints xs ++ R) :
(shP Q (AModel.vol A) (AModel.vol C) (A.zip (csOf Λ c A))).ok t ∧
(shP Q (AModel.vol A) (AModel.vol C) (A.zip (csOf Λ c A))).run t =
t.upd 0 (ints (shiftArr Λ i 1 c 0 xs) ++ R) ∧
(shP Q (AModel.vol A) (AModel.vol C) (A.zip (csOf Λ c A))).cost t ≤
cShift A.length (AModel.vol A * (Q * AModel.vol C)) Bb
Context. The lemma belongs to the part KIL2: the Lemma 10 controlled shift, self-contained: shP = offset-table generator genP (stack 14), then the size parameters
vol A, Q, vol C pushed on stacks 1, 2, 4, then rotP, then the parameters popped.
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_Defs18.
-- OpenAI-preprint / κ-improvement development (integer-multiplication-kappa), generated by skeleton subtraction.
import Definitions.Def_IntMul_Kappa_K_Defs18
set_option autoImplicit false
set_option relaxedAutoImplicit false
set_option maxHeartbeats 1000000
set_option linter.unusedSimpArgs false
open NLogN
open NLogN.KIL
open IntMul RS AModel
variable {sh : Shape} {n Q : ℕ} (Λ : Layout sh n Q)
theorem NLogN.KIL.shiftArr_il_spec [NeZero Q] (i : Fin n) (c : Fin n → ZMod Q)
(hc : ∀ j, i ≤ j → c j = 0) (A C : Shape) (hsh : sh = A ++ Q :: C)
(hA : (Λ.pos i : ℕ) = A.length) (t : IState HS) (xs : List ℤ) (Bb : ℕ) (R : List Item)
(hlen : xs.length = AModel.vol sh) (hb : Bnd Bb xs) (hB1 : 1 ≤ AModel.vol C) (hQ1 : 1 ≤ Q)
(hP1 : 1 ≤ AModel.vol A) (hV : zsz ((AModel.vol A * (Q * AModel.vol C) : ℕ) : ℤ) ≤ Bb)
(hQ2 : zsz ((2 * Q : ℕ) : ℤ) ≤ Bb) (h0 : t.G 0 = ints xs ++ R) :
(shP Q (AModel.vol A) (AModel.vol C) (A.zip (csOf Λ c A))).ok t ∧
(shP Q (AModel.vol A) (AModel.vol C) (A.zip (csOf Λ c A))).run t =
t.upd 0 (ints (shiftArr Λ i 1 c 0 xs) ++ R) ∧
(shP Q (AModel.vol A) (AModel.vol C) (A.zip (csOf Λ c A))).cost t ≤
cShift A.length (AModel.vol A * (Q * AModel.vol C)) Bb := by sorry