Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Exact multidimensional cyclic convolution over a Fermat ring

Proved
IntMul.HvdH.fermConv_eq

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

integer-multiplication

Let d≥0d\ge0d≥0, r,P≥1r,P\ge1r,P≥1 and e1,…,ed≥1e_1,\dots,e_d\ge1e1​,…,ed​≥1 with ti=2eit_i=2^{e_i}ti​=2ei​ dividing 2r2r2r. Put T=∏iti=2∑eiT=\prod_i t_i=2^{\sum e_i}T=∏i​ti​=2∑ei​ and F=22rP+1F=2^{2rP}+1F=22rP+1. Let x,yx,yx,y be integer arrays on the box [0,t1)×⋯×[0,td)×[0,r)[0,t_1)\times\cdots\times[0,t_d)\times[0,r)[0,t1​)×⋯×[0,td​)×[0,r) with all entries of absolute value at most MMM, where

2 T2 r M2<2P.2\,T^2\,r\,M^2<2^P.2T2rM2<2P.

The algorithm fermConv packs each row along the last axis as an integer ∑cxk,c 2Pc\sum_c x_{k,c}\,2^{Pc}∑c​xk,c​2Pc reduced mod FFF. It applies the synthetic transform X^(m)=∑k∏iωimikiX(k) mod F\hat X(m)=\sum_k \prod_i \omega_i^{m_ik_i} X(k)\bmod FX^(m)=∑k​∏i​ωimi​ki​​X(k)modF with ωi=2P⋅4r/ti\omega_i=2^{P\cdot 4r/t_i}ωi​=2P⋅4r/ti​ (a principal tit_iti​-th root of unity mod FFF). It multiplies pointwise mod FFF, applies the inverse transform, takes the balanced residue, unpacks 2r2r2r base-2P2^P2P digits, folds digits ccc and c+rc+rc+r, and divides by TTT. For every in-box index j=(j′,jd+1)j=(j',j_{d+1})j=(j′,jd+1​) it returns exactly the cyclic convolution

∑k∈∏i[0,ti)∑c<rxk,c  y(j′−k) mod t,  (jd+1−c) mod r.\sum_{k\in\prod_i[0,t_i)}\sum_{c<r} x_{k,c}\;y_{(j'-k)\bmod t,\;(j_{d+1}-c)\bmod r}.k∈∏i​[0,ti​)∑​c<r∑​xk,c​y(j′−k)modt,(jd+1​−c)modr​.

This is the exact convolution step in a machine implementation of Theorem 3.1 of Harvey–van der Hoeven: the complex convolution of fixed-point Gaussian integers is computed without error, and only one rounding is needed at the end.

Preamble
import Definitions.Def_IntMul_HvdH_FermConv
Formal statement
namespace IntMul.HvdH
theorem fermConv_eq {d : ℕ} (P r : ℕ) (e : Fin d → ℕ) (hr : 1 ≤ r) (hP : 1 ≤ P)
    (he1 : ∀ i, 1 ≤ e i) (he : ∀ i, 2 ^ e i ∣ 2 * r)
    (x y : (Fin (d + 1) → ℕ) → ℤ) (M : ℤ) (hM0 : 0 ≤ M)
    (hx : ∀ z : Fin (d + 1) → ℕ, (∀ i : Fin d, z i.castSucc < 2 ^ e i) → z (Fin.last d) < r → |x z| ≤ M)
    (hy : ∀ z : Fin (d + 1) → ℕ, (∀ i : Fin d, z i.castSucc < 2 ^ e i) → z (Fin.last d) < r → |y z| ≤ M)
    (hPM : 2 * (2 ^ (∑ i, e i)) ^ 2 * r * M ^ 2 < (2 : ℤ) ^ P)
    (j : Fin (d + 1) → ℕ) (hj : ∀ i : Fin d, j i.castSucc < 2 ^ e i) (hc : j (Fin.last d) < r) :
    fermConv P r e x y j =
      ∑ k ∈ Fintype.piFinset (fun i : Fin d => Finset.range (2 ^ e i)), ∑ c ∈ Finset.range r,
        x (Fin.snoc (fun i => k i) c) *
          y (Fin.snoc (fun i => (j i.castSucc + 2 ^ e i - k i) % 2 ^ e i)
            ((j (Fin.last d) + r - c) % r)) := by sorry
end IntMul.HvdH
Source
Harvey, van der Hoeven, Integer multiplication in time O(n log n), Annals of Math. 193 (2021), https://hal.science/hal-02070778, §3 (variant with exact convolution over a Fermat ring)

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