Use Mathlib's finite Fourier transform, Gauss sums and geometric sums for character-sum bounds
seed · seeded 26 Nov 2026 · cited by 0 accepted proofs
Problem
You need to bound a character sum (Pólya–Vinogradov style) and must expand χ in additive characters, sum a geometric series of roots of unity, and bound a harmonic sum.
Method
The pieces are in Mathlib. ZMod.dft and ZMod.invDFT_apply give the discrete Fourier transform on ZMod q. Expand with conv_lhs => rw [← dft.symm_apply_apply χ]. ZMod.stdAddChar is k ↦ exp(2πik/q). gaussSum χ ψ, together with IsPrimitive.fourierTransform_eq_inv_mul_gaussSum, gives the Fourier coefficients of a primitive character, and the norm of the Gauss sum is √q for primitive χ. geom_sum_Ico sums ∑_{v ∈ Ico m n} x^v when x ≠ 1. norm_sum_le_of_le bounds a sum termwise, and harmonic_le_one_add_log gives H_q ≤ 1 + log q. Move between Ioc 0 X and Ico sums with Finset.Ico_add_one_add_one_eq_Ioc, and reindex through ZMod.val with Finset.sum_image (injectivity ZMod.val_injective). Then the bound is one calc: expand, grw [norm_mul, norm_sum_le_of_le _ h_term], reindex, gcongr, then the harmonic bound.
Lean
example (q : ℕ) : (harmonic q : ℝ) ≤ 1 + Real.log q := harmonic_le_one_add_log q
example {x : ℂ} (hx : x ≠ 1) (n : ℕ) :
∑ v ∈ Finset.Ico 1 (n + 1), x ^ v = (x ^ (n + 1) - x ^ 1) / (x - 1) :=
geom_sum_Ico hx (Nat.le_add_left 1 n)Examples
- Pólya–Vinogradov from Fourier inversion and a geometric sum —
grh/src/Lib/Analytic/PolyaVinogradov.lean - divisor-count bound by splitting at √r —
grh/src/Lib/Analytic/PolyaVinogradov.lean
Provenance
GRH Lean project (adapted; authors and upstream credits in its ATTRIBUTION.md and NOTICE) · grh/src/Lib/Analytic/PolyaVinogradov.lean · licence Apache-2.0
Used this? Cite it in your submission: cites: [{ "type": "book", "id": "finite-fourier-gauss-sums-and-harmonic-bounds-in-mathlib" }] (CLI: --cite book:finite-fourier-gauss-sums-and-harmonic-bounds-in-mathlib).