Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

O(n log n) multitape multiplication from any recursive step satisfying StepOK

Proved
NLogN.Top.hv_mulTimeBound

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

harvey-van-der-hoeven-tminteger-multiplicationturing-machines

Let st be a recursive step (an RM program) satisfying StepOK st n₀ lin calls: on inputs a,b<2Na,b<2^Na,b<2N with N≥n0N \ge n_0N≥n0​ it pushes a⋅ba\cdot ba⋅b, it costs at most lin(N)+∑(c,m)∈calls(N)c Φ(m)\mathrm{lin}(N)+\sum_{(c,m)\in \mathrm{calls}(N)} c\,Φ(m)lin(N)+∑(c,m)∈calls(N)​cΦ(m) when every recursive multiplication of mmm-bit numbers costs at most Φ(m)Φ(m)Φ(m), all recursive sizes mmm are <N<N<N, and its procedure calls are the fixed DIF/DIT/bit-length procedures. Let T′(N)=(N+1)(zsz(N)+2)T'(N) = (N+1)(\mathrm{zsz}(N)+2)T′(N)=(N+1)(zsz(N)+2) (≈Nlog⁡N\approx N\log N≈NlogN). Suppose there are constants KKK and D≥1D\ge 1D≥1 such that for all N≥n0N \ge n_0N≥n0​

  • topCost(n0,N)+lin(N)+2≤K T′(N)\mathrm{topCost}(n_0,N)+\mathrm{lin}(N)+2 \le K\,T'(N)topCost(n0​,N)+lin(N)+2≤KT′(N) (the non-recursive work is O(Nlog⁡N)O(N\log N)O(NlogN)), and
  • D∑(c,m)∈calls(N)c T′(m)+T′(N)≤D T′(N)D\sum_{(c,m)\in\mathrm{calls}(N)} c\,T'(m) + T'(N) \le D\,T'(N)D∑(c,m)∈calls(N)​cT′(m)+T′(N)≤DT′(N) (the recursive calls leave room for the linear term).

Then integer multiplication is possible on a multitape Turing machine in time O(nlog⁡n)O(n\log n)O(nlogn): MulTimeBound (fun n => n * log n) holds, in the sense of the platform model Def_IntMul_MultitapeModel.

Formalization Note. The machine is hvMachine n₀ st, compiled from a five-procedure item-language program (main routine, the multiplication procedure mulRM n₀ st which uses schoolbook multiplication below n0n_0n0​ bits and st above, DIF, DIT, bit length). This is the conditional top level of the Harvey–van der Hoeven machine: proving Theorem 1.1 reduces to exhibiting such a step. The machine layer: IState HS is a state with 646464 stacks of items (Item = integer or mark), an input position and an output; RM programs (straight-line register code RS, loops rep, conditionals, calls of the multiplication procedure through a MulSpec MMM giving its domain and cost) have a functional semantics p.run s, a definedness predicate p.ok M s and a cost p.cost M s; Spec M p s s' c abbreviates p.ok M s ∧ p.run s = s' ∧ p.cost M s ≤ c. ints L / gints U push an integer list / a list of pairs as items (head = top); zsz z is the bit length of ∣z∣|z|∣z∣. MulBnd M m Φ says the multiplication procedure accepts all pairs of integers of bit length ≤m\le m≤m at cost ≤Φ\le Φ≤Φ. Register names (GU, CR, KB, XN, …) are fixed stack indices.

Preamble
-- Harvey–van der Hoeven multitape-TM development (NLogN), generated by skeleton subtraction.

import Definitions.Def_IntMul_HvdH_M_Defs4

set_option autoImplicit false
set_option relaxedAutoImplicit false
set_option maxHeartbeats 1000000

set_option linter.unusedSimpArgs false
open NLogN
open NLogN.Top
open IntMul NLogN
Formal statement
theorem NLogN.Top.hv_mulTimeBound {n₀ : ℕ} {st : RM} {lin : ℕ → ℕ} {calls : ℕ → List (ℕ × ℕ)}
    (hst : StepOK st n₀ lin calls) (K D : ℕ) (hD : 1 ≤ D)
    (hL : ∀ N, n₀ ≤ N → topCost n₀ N + lin N + 2 ≤ K * TT' N)
    (hR : ∀ N, n₀ ≤ N → D * ((calls N).map fun q => q.1 * TT' q.2).sum + TT' N ≤ D * TT' N) :
    MulTimeBound fun n => (n : ℝ) * Real.log n := by sorry
Source
D. Harvey, J. van der Hoeven, Integer multiplication in time O(n log n), Ann. of Math. 193 (2021), 563–617 (Theorem 1.1: multitape Turing machine multiplication in O(n log n)). Lemma `NLogN.Top.hv_mulTimeBound` of the Lean development NLogN/HTopFinal.lean (lines 67–80), 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