Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Top-level program tail: call FM and write the 2n-bit product

Proved
NLogN.main_tail

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

integer-multiplicationschonhage-strassen-tmturing-machines

Let n∈Nn\in\mathbb Nn∈N, sss a state, and a,b<2na,b<2^na,b<2n. Let N0=2∣n+1∣2+1N_0 = 2^{|n+1|_2+1}N0​=2∣n+1∣2​+1 (mainN0 n, where ∣⋅∣2|\cdot|_2∣⋅∣2​ is the bit length). Assume ARG is exactly [b,a][b,a][b,a], T1 and T2 are both exactly [2n][2^n][2n], PRM has N0N_0N0​, RN has 2N02^{N_0}2N0​ and RF has 2N0+12^{N_0}+12N0​+1 on top. Run, in the Schönhage–Strassen program ssProg, the statement: call procedure 111 (the FM procedure); shift T1 left by the ruler T2; write ARG with ruler T1. Then there is a final state ttt with

IRuns I ssProg (… ) s t (Φ(N0)+shlCost(n)+outRCost(2n)),t.out=s.out+ ⁣ ⁣+bin2n(ab),\mathrm{IRuns}\ I\ \mathrm{ssProg}\ (\dots)\ s\ t\ \big(\Phi(N_0)+\mathrm{shlCost}(n)+\mathrm{outRCost}(2n)\big),\qquad t.\mathrm{out} = s.\mathrm{out}\mathbin{+\!\!+}\mathrm{bin}_{2n}(ab),IRuns I ssProg (…) s t (Φ(N0​)+shlCost(n)+outRCost(2n)),t.out=s.out++bin2n​(ab),

where Φ\PhiΦ = fmPhi is the potential Φ(N)=22100 N ℓ(N) λ(N)\Phi(N)=2^{2100}\,N\,\ell(N)\,\lambda(N)Φ(N)=22100Nℓ(N)λ(N) (ℓ\ellℓ = bit length of NNN, λ\lambdaλ = bit length of ℓ4\ell^4ℓ4).

Since N0>2nN_0>2nN0​>2n, the residue ab mod (2N0+1)ab \bmod (2^{N_0}+1)abmod(2N0​+1) equals ababab, so the output is the 2n2n2n-bit product. The cost bound Φ(N0)\Phi(N_0)Φ(N0​) for the FM call is the potential-function bound proved by induction on the recursion; this lemma combines it with output to finish the top-level analysis.

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 c′≤cc' \le cc′≤c, so costs are upper bounds; the program text iprog and input I are arbitrary unless constrained. The input word III is arbitrary here because the tail performs no reads.

Preamble
-- 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
set_option maxHeartbeats 2000000
Formal statement
theorem NLogN.main_tail {I : List Sym} (n : ℕ) (s : IState NS) (a b : ℕ) (ha : a < 2 ^ n)
    (hb : b < 2 ^ n) (LP LN LF : List Item) (hA : s.G ARG = [.int (b : ℤ), .int (a : ℤ)])
    (hT1 : s.G T1 = [.int (2 ^ n)]) (hT2 : s.G T2 = [.int (2 ^ n)])
    (hP : s.G PRM = .int (mainN0 n) :: LP) (hN : s.G RN = .int (2 ^ mainN0 n) :: LN)
    (hF : s.G RF = .int (2 ^ mainN0 n + 1) :: LF) :
    ∃ t, IRuns I ssProg (.seq (.call 1) (.seq (.op (.shl T1 T2)) (.op (.write ARG T1)))) s t
      (fmPhi (mainN0 n) + shlCost n + outRCost (2 * n)) ∧ t.out = s.out ++ bin (2 * n) (a * b) := by sorry
Source
A. Schönhage, V. Strassen, Schnelle Multiplikation großer Zahlen, Computing 7 (1971), 281–292 (main theorem: O(n log n log log n) multitape TM multiplication). Lemma `NLogN.main_tail` of the Lean development NLogN/SSMain.lean (lines 183–214), written for the prove2.me integer-multiplication campaign.

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