Moving K integer items between stacks in linear time
ProvedNLogN.mvK_runsLet be stacks, both different from CC, T3 and DL. Let be a list of integers each of bit length at most (Bnd m A). Assume holds the items of (first entry on top) over , and DL has on top. Then mvK X Y runs from to
(the block is moved and reversed), with cost at most
where is the bit length of the length .
Block moves of the coefficient vectors between the work stacks occur several times per level of the Schönhage–Strassen procedure; the bound is linear in the total size of the moved data plus counter overhead.
Formalization Note. States are IState NS records with item stacks G : Fin NS → List Item (head = top), input pointer ip and output out; s.upd X L replaces stack X by L; ints A is the list of integer items of A. The named stacks (ARG, PRM, RN, RF, DX, DL, …) are fixed indices in Fin 32. IRuns I iprog p s s' c means that p executes from s to exactly s' with some cost , so costs are upper bounds; the program text iprog and input I are arbitrary unless constrained.
-- Schönhage–Strassen multitape-TM development (NLogN), generated by skeleton subtraction.
import Definitions.Def_IntMul_SS_Defs2
set_option autoImplicit false
set_option relaxedAutoImplicit false
set_option maxHeartbeats 1000000
open NLogN
open IntMul
variable {P : ℕ} {I : List Sym} {iprog : Fin P → IStmt NS P}
theorem NLogN.mvK_runs {X Y : Fin NS} (hXY : X ≠ Y) (hXC : X ≠ CC) (hYC : Y ≠ CC) (hX3 : X ≠ T3)
(hY3 : Y ≠ T3) (hXH : X ≠ DL) (hYH : Y ≠ DL) (s : IState NS) (A : List ℤ) (R LH : List Item)
(m : ℕ) (hX : s.G X = ints A ++ R) (hH : s.G DL = .int A.length :: LH) (hA : Bnd m A) :
IRuns I iprog (mvK X Y) s ((s.upd X R).upd Y ((ints A).reverse ++ s.G Y))
(A.length * (1000 * (m + zsz (A.length : ℤ) + 3)) + 300 * (zsz (A.length : ℤ) + 1) + 40) := by sorry