FM preprocessing: cut into pieces, twist, and forward-transform one input
ProvedNLogN.fmPrep_runsLet pD have body difBody pD. Let with , , , , ; write and . Let be an integer with and bit length at most . Assume ARG has on top (over ), DX , and the rulers on DL, on RM, on RQ, on DE, on RN, on RF. Then fmPrep pD runs from to the state where is popped from ARG and
with cost at most .
Here are the signed -bit pieces of (least significant first), twists the -th piece by mod (with , which turns cyclic into negacyclic convolution), and is the forward decimation-in-frequency FFT with root . This is applied to each of the two factors.
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.fmPrep_runs (pD : Fin P) (hPD : iprog pD = difBody pD) (s : IState NS) (N n M Q k : ℕ)
(x : ℤ) (LA R LL LM LQ LE LN LF : List Item) (hn : 1 ≤ n) (hKQ : 2 ^ k * Q = n)
(hM : M ≤ n) (hQ : Q ≤ n) (hkn : k + 1 ≤ n) (hx : x.natAbs < 2 ^ (2 ^ k * M))
(hxN : zsz x ≤ N)
(hA : s.G ARG = .int x :: LA) (hDL : s.G DL = .int (2 ^ k) :: LL) (hX : s.G DX = R)
(hRM : s.G RM = .int (2 ^ M) :: LM) (hRQ : s.G RQ = .int (2 ^ Q) :: LQ)
(hDE : s.G DE = .int (2 ^ (2 * Q)) :: LE)
(hN : s.G RN = .int (2 ^ n) :: LN) (hF : s.G RF = .int (2 ^ n + 1) :: LF) :
IRuns I iprog (fmPrep pD) s
((s.upd ARG LA).upd DX
(ints (difZ (2 ^ n + 1) (2 * Q) k (wtZ (2 ^ n + 1) Q 0 (pcs M (2 ^ k) x))) ++ R))
(prepCost N n k) := by sorry