Riemann hypothesis: the Lean proof, cleaned up together
The 2026 Lean proof of the Riemann hypothesis and GRH, machine-checked by others, not refereed, no word from Clay; cleaned up together: more readable, faster to build, the theorems unchanged

| 1 | module |
| 2 | |
| 3 | import TauCeti.NumberTheory.ArithmeticFunction.Zeta |
| 4 | import TauCeti.NumberTheory.DirichletCharacter.PolyaVinogradov |
| 5 | import TauCeti.NumberTheory.Divisors |
| 6 | public import Mathlib.NumberTheory.DirichletCharacter.Basic |
| 7 | public import Lib.Speed |
| 8 | import Lib.Analytic.ZeroSymmetry |
| 9 | |
| 10 | /-! |
| 11 | # The Pólya–Vinogradov bound for initial intervals |
| 12 | |
| 13 | For a non-principal character mod `q`, every partial sum of its values is at most |
| 14 | `2 √q (1 + log q)` in absolute value. |
| 15 | |
| 16 | * `New.polya_vinogradov`: the Pólya–Vinogradov inequality. |
| 17 | |
| 18 | ## Relation to the literature |
| 19 | |
| 20 | Known result: the Pólya–Vinogradov inequality for sums of a non-principal Dirichlet character. It is |
| 21 | proved here for initial intervals only, with the explicit bound `2 √q (1 + log q)`. The case of a |
| 22 | general character is reduced to the primitive character that induces it, using Tau Ceti's |
| 23 | inequality for the characters induced from a primitive one, and a divisor-count bound. Source: |
| 24 | Pólya 1918, Vinogradov 1918; Davenport, Multiplicative Number Theory; Montgomery–Vaughan Thm 9.18. |
| 25 | -/ |
| 26 | |
| 27 | @[expose] public section |
| 28 | |
| 29 | open Complex Finset DirichletCharacter Real ZMod ArithmeticFunction Moebius NeZero Nat |
| 30 | |
| 31 | namespace New |
| 32 | |
| 33 | variable {q : ℕ} [NeZero q] {χ : DirichletCharacter ℂ q} |
| 34 | |
| 35 | open scoped ArithmeticFunction.omega in |
| 36 | /-- The **Pólya–Vinogradov inequality** for initial intervals: for a non-principal Dirichlet |
| 37 | character `χ` mod `q` one has `|∑_{1 ≤ v ≤ X} χ v| ≤ 2 √q (1 + log q)` for all `X`. -/ |
| 38 | theorem polya_vinogradov (hχ : χ ≠ 1) (X : ℕ) : |
| 39 | ‖∑ v ∈ Ioc 0 X, χ v‖ ≤ 2 * √q * (1 + Real.log q) := by |
| 40 | -- Apply Tau Ceti's bound for the primitive `ψ` mod `M` that induces `χ`. |
| 41 | obtain ⟨M, hMq, ψ, _, hψ, h_ind⟩ := exists_isPrimitive_changeLevel_eq χ |
| 42 | obtain ⟨r, hr⟩ := exists_eq_mul_right_of_dvd hMq |
| 43 | have hψ₀ : ψ ≠ 1 := fun h ↦ hχ (by rw [← h_ind, h, changeLevel_one]) |
| 44 | have hM_pos : (0 : ℝ) < M := Nat.cast_pos.mpr (NeZero.pos M) |
| 45 | have hM_le : (M : ℝ) ≤ q := mod_cast le_of_dvd (NeZero.pos q) hMq |
| 46 | have hr0 : r ≠ 0 := right_ne_zero_of_mul (hr.symm.trans_ne (NeZero.ne q)) |
| 47 | -- `2 ^ ω r` is at most the number of divisors of `r`, which is at most `2 √r` |
| 48 | have h_two_pow : (2 : ℝ) ^ ω r ≤ 2 * √r := by |
| 49 | grw [← nat_sqrt_le_real_sqrt] |
| 50 | exact_mod_cast (pow_cardDistinctFactors_le_zeta_pow 2 hr0).trans |
| 51 | (((zeta_pow_succ_apply_le_card_divisors_pow 1 r).trans_eq (pow_one _)).trans |
| 52 | (card_divisors_le_two_mul_sqrt r)) |
| 53 | have hqM : q / M = r := by rw [hr, Nat.mul_div_cancel_left _ (NeZero.pos M)] |
| 54 | have hsq : √(q : ℝ) = √M * √r := by rw [hr, Nat.cast_mul, Real.sqrt_mul hM_pos.le] |
| 55 | have h := norm_sum_Icc_changeLevel_le ψ hψ hψ₀ hMq X |
| 56 | rw [hqM] at h |
| 57 | have hM_one : 1 ≤ M := NeZero.pos M |
| 58 | have hlog : Real.log M ≤ Real.log q := Real.log_le_log hM_pos hM_le |
| 59 | have hlog₀ : 0 ≤ Real.log M := Real.log_nonneg (mod_cast hM_one) |
| 60 | calc ‖∑ v ∈ Ioc 0 X, χ v‖ |
| 61 | = ‖∑ n ∈ Icc 1 X, changeLevel hMq ψ n‖ := by |
| 62 | have h_Icc : Ioc 0 X = Icc 1 X := by ext; simp; omega |
| 63 | simp [h_Icc, ← h_ind] |
| 64 | _ ≤ 2 ^ ω r * (√M * (1 + Real.log M)) := h |
| 65 | _ ≤ 2 * √r * (√M * (1 + Real.log q)) := |
| 66 | mul_le_mul h_two_pow (mul_le_mul_of_nonneg_left (by linarith) (Real.sqrt_nonneg _)) |
| 67 | (mul_nonneg (Real.sqrt_nonneg _) (by linarith)) (by positivity) |
| 68 | _ = 2 * √q * (1 + Real.log q) := by rw [hsq]; ring |
| 69 | |
| 70 | end New |