Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

The machine program fwP computes the Fermat-ring convolution fermatW

Proved
NLogN.FW.fwP_spec

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

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

Let qqq be HvdH parameters with P≥1P\ge 1P≥1, K≤fnK \le f_nK≤fn​, logOuter≤fn\mathrm{logOuter} \le f_nlogOuter≤fn​, logOuter≤kb\mathrm{logOuter}\le kblogOuter≤kb, and let MMM be a multiplication spec that multiplies (fn+1)(f_n+1)(fn​+1)-bit integers at cost ≤Φm\le Φ_m≤Φm​. Let U,VU, VU,V be lists of 2logOuter⋅r2^{\mathrm{logOuter}}\cdot r2logOuter⋅r Gaussian integers (r=2er = 2^er=2e) with all coordinates of absolute value <2P<2^P<2P, stored as item lists on stacks GU and VI, and let the constant registers hold their prescribed values (2P2^P2P, rrr, 22rP2^{2rP}22rP, 2fn+12^{f_n}+12fn​+1, 2fn2^{f_n}2fn​, 2logOuter2^{\mathrm{logOuter}}2logOuter, kbkbkb, K−1K-1K−1, 2fn−logOuter2^{f_n-\mathrm{logOuter}}2fn​−logOuter, and the encoded axis descriptors of the outer axes). Then the program fwP runs from sss (calling the multiplication procedure for the pointwise products), consumes UUU and VVV, and pushes fermatW q U V — the cyclic convolution of the published reference computed by Kronecker packing into the Fermat ring Z/(2fn+1)\mathbb Z/(2^{f_n}+1)Z/(2fn​+1), forward DIF transforms, pointwise products, DIT transform and unpacking — onto OUT, with cost at most fwCost q kb Φm.

Formalization Note. 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
set_option linter.unusedVariables false
open NLogN
open NLogN.FW
open IntMul IntMul.HvdH NLogN
set_option maxHeartbeats 1000000
Formal statement
theorem NLogN.FW.fwP_spec (M : MulSpec) {Φm : ℕ} (q : Ref.Params) (kb : ℕ) (hMB : MulBnd M (q.fn + 1) Φm)
    (hP : 1 ≤ q.P) (hK : q.K ≤ q.fn) (hlo : q.logOuter ≤ q.fn) (hkb : q.logOuter ≤ kb)
    (s : IState HS) (U V : List (ℤ × ℤ))
    (RU RV Rs LCR LCM LRW LFR LKB LKN LKR LXN LXF LNN LKBR LNAX LSH : List Item)
    (hUl : U.length = 2 ^ q.logOuter * q.r) (hVl : V.length = 2 ^ q.logOuter * q.r)
    (hUb : ∀ z ∈ U, |z.1| < 2 ^ q.P ∧ |z.2| < 2 ^ q.P)
    (hVb : ∀ z ∈ V, |z.1| < 2 ^ q.P ∧ |z.2| < 2 ^ q.P)
    (hU : s.G GU = gints U ++ RU) (hV : s.G VI = gints V ++ RV)
    (hCR : s.G CR = .int (2 ^ q.P) :: LCR) (hCM : s.G CM = .int (q.r : ℤ) :: LCM)
    (hRW : s.G RW = .int (2 ^ (2 * q.r * q.P)) :: LRW) (hFR : s.G FR = .int (2 ^ q.fn + 1) :: LFR)
    (hKB : s.G KB = .int (2 ^ q.P) :: LKB) (hKN : s.G KN = .int (2 ^ q.fn) :: LKN)
    (hKR : s.G KR = .int (q.r : ℤ) :: LKR)
    (hXN : s.G NLogN.FW.XN = .int (2 ^ q.fn) :: LXN) (hXF : s.G XF = .int (2 ^ q.fn + 1) :: LXF)
    (hNN : s.G NN = .int ((2 ^ q.logOuter : ℕ) : ℤ) :: LNN) (hKBR : s.G KBR = .int kb :: LKBR)
    (hNAX : s.G NAX = .int ((q.K - 1 : ℕ) : ℤ) :: LNAX)
    (hAXS : s.G AXS = ints ((descs q.outerAxes 1).flatMap enc8) ++ Rs)
    (hSH : s.G SH = .int (2 ^ (q.fn - q.logOuter)) :: LSH) :
    Spec M fwP s (((s.upd GU RU).upd VI RV).upd OUT (gints (Ref.fermatW q U V) ++ s.G OUT))
      (fwCost q kb Φm) := 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.FW.fwP_spec` of the Lean development NLogN/HFW10.lean (lines 137–355), 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