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.DirichletCharacter.LFunction.Bounds |
| 4 | import Mathlib.Algebra.Order.Star.Real |
| 5 | import Mathlib.Analysis.Complex.Hadamard |
| 6 | import Mathlib.Analysis.Complex.HalfPlane |
| 7 | import Mathlib.Order.CompletePartialOrder |
| 8 | public import Lib.General.NumberTheory.ImaginaryQuadraticField |
| 9 | import Lib.Analytic.EntireLFunction |
| 10 | |
| 11 | /-! |
| 12 | # Growth of Dirichlet L-functions near the line `re s = 1` |
| 13 | |
| 14 | Let `χ` be a character modulo `N`, and let `𝖿_χ(s)` (`regularL χ s`) be `L(s, χ)`, times |
| 15 | `(s - 1) / s` if `χ` is principal. The right-half-plane bound from Tau Ceti gives |
| 16 | `|𝖿_χ(s)| ≤ 8 N |s|` in `re s ≥ 1 / 2`, and the three-lines theorem improves this to |
| 17 | `|𝖿_χ(s)| ≤ l²` for `re s ≥ 1 - 1 / l` and `|s| ≤ 3 e^l`, whenever `l ≥ 10¹⁰` and `N ≤ e^l`. |
| 18 | |
| 19 | Notions from other files: |
| 20 | * `entireL χ`: the entire function equal to `L(s, χ)` if `χ` is not principal, and to the |
| 21 | continuation of `(s - 1) L(s, χ)` if it is. |
| 22 | |
| 23 | ## Relation to the literature |
| 24 | |
| 25 | Known result: the bound `L(s, χ) ≪ log (N |s|)` near `re s = 1` and away from the pole. It is proved |
| 26 | here for `𝖿_χ` and with a square in place of the first power. Source: Montgomery and Vaughan, |
| 27 | Multiplicative Number Theory I, 2007, Lemma 10.15. |
| 28 | -/ |
| 29 | |
| 30 | @[expose] public section |
| 31 | |
| 32 | noncomputable section |
| 33 | |
| 34 | open Complex Real Set Filter Topology MeasureTheory Metric Asymptotics DirichletCharacter |
| 35 | HadamardThreeLines |
| 36 | open scoped Classical |
| 37 | |
| 38 | namespace New |
| 39 | |
| 40 | variable {N : ℕ} [NeZero N] (χ : DirichletCharacter ℂ N) {s : ℂ} {l : ℝ} |
| 41 | |
| 42 | /-- `𝖿_χ(s)` is `L(s, χ)`, times `(s - 1) / s` if `χ` is principal. The entire function `entireL χ` |
| 43 | has the factor `s - 1` in that case; dividing by `s` keeps the size of `L(s, χ)` for large `|s|`. -/ |
| 44 | def regularL (s : ℂ) : ℂ := entireL χ s / if χ = 1 then s else 1 |
| 45 | |
| 46 | /-- `𝖿_χ` (`regularL χ`: `L(s, χ)`, times `(s - 1) / s` if `χ` is principal) is holomorphic in |
| 47 | `re s > 0`. -/ |
| 48 | lemma differentiableAt_regularL (hs : 0 < s.re) : DifferentiableAt ℂ (regularL χ) s := by |
| 49 | have h_denom_diff : DifferentiableAt ℂ (fun z : ℂ ↦ if χ = 1 then z else 1) s := by |
| 50 | split_ifs <;> fun_prop |
| 51 | have h_denom_ne : (if χ = 1 then s else 1) ≠ 0 := by |
| 52 | split_ifs |
| 53 | exacts [ne_zero_of_re_pos hs, one_ne_zero] |
| 54 | exact (analyticAt_entireL χ s).differentiableAt.div h_denom_diff h_denom_ne |
| 55 | |
| 56 | /-- In `re s > 1` the regularised function `𝖿_χ` (`regularL χ`) is `L(s, χ) (s - δ) / s`, with |
| 57 | `δ = 1` if `χ` is principal and `δ = 0` otherwise. -/ |
| 58 | lemma regularL_eq (hs : 1 < s.re) : |
| 59 | regularL χ s = LSeries (fun n : ℕ ↦ χ n) s / s * (s - if χ = 1 then 1 else 0) := by |
| 60 | have hs_zero : s ≠ 0 := ne_zero_of_re_pos (by linarith) |
| 61 | rw [regularL, entireL, ← χ.LFunction_eq_LSeries hs] |
| 62 | split_ifs with hχ |
| 63 | · rw [hχ, LFunctionTrivChar₁, Function.update_of_ne (ne_of_apply_ne re hs.ne')] |
| 64 | ring |
| 65 | · field |
| 66 | |
| 67 | /-- `|s - δ| ≤ |s|` in `re s ≥ 1 / 2`, where `δ` is `1` or `0` as the proposition `p` holds or |
| 68 | not (in the uses, `p` says that a character is principal). -/ |
| 69 | lemma norm_sub_ite_le {p : Prop} [Decidable p] (hs : 1 / 2 ≤ s.re) : |
| 70 | ‖s - if p then 1 else 0‖ ≤ ‖s‖ := by |
| 71 | rw [← sq_le_sq₀ (norm_nonneg _) (norm_nonneg _)] |
| 72 | split_ifs |
| 73 | · simp only [Complex.sq_norm, normSq_apply, sub_re, sub_im, one_re, one_im] |
| 74 | -- For `δ = 1` this is `(re s - 1)² ≤ (re s)²`. |
| 75 | linarith |
| 76 | · simp |
| 77 | |
| 78 | /-- For `re z ≥ 1 / 2`, the factor `‖z - 1‖ / ‖z‖` times the bound |
| 79 | `‖z - 1‖⁻¹ + 1 + ‖z‖ / re z` is at most `8 ‖z‖`. -/ |
| 80 | private lemma norm_sub_one_div_mul_le {z : ℂ} (hz : 1 / 2 ≤ z.re) (hz_pos : 0 < z.re) : |
| 81 | ‖z - 1‖ / ‖z‖ * (‖z - 1‖⁻¹ + 1 + ‖z‖ / z.re) ≤ 8 * ‖z‖ := by |
| 82 | rcases eq_or_ne z 1 with rfl | hz1 |
| 83 | · simp |
| 84 | have hz_norm : 1 / 2 ≤ ‖z‖ := hz.trans (re_le_norm z) |
| 85 | have h_sub : ‖z - 1‖ ≤ ‖z‖ := by simpa using norm_sub_ite_le (p := True) hz |
| 86 | have hz1_pos : 0 < ‖z - 1‖ := norm_pos_iff.mpr (sub_ne_zero.mpr hz1) |
| 87 | have h1_le : 1 / ‖z‖ ≤ 4 * ‖z‖ := by |
| 88 | rw [div_le_iff₀ (by linarith)] |
| 89 | nlinarith |
| 90 | have h2_le : ‖z - 1‖ / ‖z‖ ≤ 2 * ‖z‖ := by |
| 91 | rw [div_le_iff₀ (by linarith)] |
| 92 | nlinarith |
| 93 | have h3_le : ‖z - 1‖ / z.re ≤ 2 * ‖z‖ := by |
| 94 | rw [div_le_iff₀ hz_pos] |
| 95 | nlinarith |
| 96 | calc |
| 97 | ‖z - 1‖ / ‖z‖ * (‖z - 1‖⁻¹ + 1 + ‖z‖ / z.re) |
| 98 | = 1 / ‖z‖ + ‖z - 1‖ / ‖z‖ + ‖z - 1‖ / z.re := by |
| 99 | field_simp [hz1_pos.ne', (show (0 : ℝ) < ‖z‖ by linarith).ne', hz_pos.ne'] |
| 100 | _ ≤ 8 * ‖z‖ := by linarith |
| 101 | |
| 102 | /-- Linear growth bound: `|𝖿_χ(s)| ≤ 8 N |s|` in `re s ≥ 1 / 2`, where `𝖿_χ` (`regularL χ`) is |
| 103 | `L(s, χ)`, times `(s - 1) / s` if `χ` is principal, and `N` is the modulus of `χ`. -/ |
| 104 | lemma norm_regularL_le_linear (hs : 1 / 2 ≤ s.re) : ‖regularL χ s‖ ≤ 8 * N * ‖s‖ := by |
| 105 | have bound_ne {z : ℂ} (hz : 1 / 2 ≤ z.re) (hz1 : z ≠ 1) : |
| 106 | ‖regularL χ z‖ ≤ 8 * N * ‖z‖ := by |
| 107 | have hz_pos : 0 < z.re := by linarith |
| 108 | by_cases hχ : χ = 1 |
| 109 | · have h_eq : regularL χ z = (z - 1) / z * χ.LFunction z := by |
| 110 | simp [regularL, entireL, hχ, LFunctionTrivChar₁, Function.update_of_ne hz1] |
| 111 | ring |
| 112 | have h_inv := norm_sub_one_div_mul_le hz hz_pos |
| 113 | calc |
| 114 | ‖regularL χ z‖ = ‖z - 1‖ / ‖z‖ * ‖χ.LFunction z‖ := by rw [h_eq, norm_mul, norm_div] |
| 115 | _ ≤ ‖z - 1‖ / ‖z‖ * (N * (‖z - 1‖⁻¹ + 1 + ‖z‖ / z.re)) := by |
| 116 | gcongr |
| 117 | exact χ.norm_LFunction_le hz_pos (.inl hz1) |
| 118 | _ = N * (‖z - 1‖ / ‖z‖ * (‖z - 1‖⁻¹ + 1 + ‖z‖ / z.re)) := by ring |
| 119 | _ ≤ N * (8 * ‖z‖) := by gcongr |
| 120 | _ = 8 * N * ‖z‖ := by ring |
| 121 | · have h_eq : regularL χ z = χ.LFunction z := by simp [regularL, entireL, hχ] |
| 122 | calc |
| 123 | ‖regularL χ z‖ = ‖χ.LFunction z‖ := by rw [h_eq] |
| 124 | _ ≤ N * ‖z‖ / z.re := χ.norm_LFunction_le_level_mul_norm_div_re hχ hz_pos |
| 125 | _ ≤ N * ‖z‖ / (1 / 2) := by gcongr |
| 126 | _ ≤ 8 * N * ‖z‖ := by nlinarith [norm_nonneg z] |
| 127 | -- Extend the estimate from the punctured open half-plane by continuity. |
| 128 | have hs_closure : s ∈ closure ({z : ℂ | 1 / 2 < z.re} ∩ {1}ᶜ) := |
| 129 | closure_minimal |
| 130 | ((dense_compl_singleton (1 : ℂ)).open_subset_closure_inter (isOpen_re_gt (1 / 2))) |
| 131 | isClosed_closure (by simpa only [closure_setOfPred_lt_re, Set.mem_ofPred_eq] using hs) |
| 132 | exact ContinuousWithinAt.closure_le (g := fun z : ℂ ↦ 8 * N * ‖z‖) hs_closure |
| 133 | (differentiableAt_regularL χ (by linarith)).continuousAt.norm.continuousWithinAt |
| 134 | (by fun_prop) (fun z hz ↦ bound_ne (le_of_lt hz.1) hz.2) |
| 135 | |
| 136 | /-- For `l ≥ 1` and `re s > 1`, at distance at least `1 / l` from `1` if `χ` is principal, we have |
| 137 | `|L(s, χ)| ≤ 2 l |𝖿_χ(s)|`, where `𝖿_χ` (`regularL χ`) is `L(s, χ)`, times `(s - 1) / s` if `χ` is |
| 138 | principal. -/ |
| 139 | lemma norm_LSeries_le_mul_norm_regularL (hs : 1 < s.re) (hl : 1 ≤ l) |
| 140 | (h_far : χ = 1 → 1 / l ≤ ‖s - 1‖) : |
| 141 | ‖LSeries (fun n : ℕ ↦ χ n) s‖ ≤ 2 * l * ‖regularL χ s‖ := by |
| 142 | have hs_norm : 1 < ‖s‖ := hs.trans_le (re_le_norm s) |
| 143 | have norm_le : ‖s‖ ≤ 2 * l * ‖s - if χ = 1 then 1 else 0‖ := by |
| 144 | split_ifs with hχ |
| 145 | · have h_one : 1 ≤ ‖s - 1‖ * l := (div_le_iff₀ (by linarith)).1 (h_far hχ) |
| 146 | nlinarith [norm_nonneg (s - 1), norm_le_norm_sub_add s 1, norm_one (α := ℂ)] |
| 147 | · simpa using le_mul_of_one_le_left (norm_nonneg s) (by linarith : 1 ≤ 2 * l) |
| 148 | calc |
| 149 | ‖LSeries (χ ·) s‖ = ‖LSeries (χ ·) s‖ / ‖s‖ * ‖s‖ := by field |
| 150 | _ ≤ ‖LSeries (χ ·) s‖ / ‖s‖ * (2 * l * ‖s - if χ = 1 then 1 else 0‖) := by gcongr |
| 151 | _ = 2 * l * ‖regularL χ s‖ := by simp [regularL_eq χ hs]; ring |
| 152 | |
| 153 | /-- If `l ≥ 10¹⁰` and the modulus `N` is at most `e^l`, then `|𝖿_χ(s)| ≤ l²` for |
| 154 | `re s ≥ 1 - 1 / l` and `|s| ≤ 3 e^l`. Here `𝖿_χ` (`regularL χ`) is `L(s, χ)`, times |
| 155 | `(s - 1) / s` if `χ` is principal. -/ |
| 156 | lemma norm_regularL_le_sq (hl : 10 ^ 10 ≤ l) (hN : N ≤ rexp l) (h_re : 1 - 1 / l ≤ s.re) |
| 157 | (h_norm : ‖s‖ ≤ 3 * rexp l) : ‖regularL χ s‖ ≤ l ^ 2 := by |
| 158 | -- Apply the three-lines theorem to `g(z) = 𝖿_χ(z) / (z - s + 2)` on the strip |
| 159 | -- `a ≤ re z ≤ a + 1 / 3` whose right edge lies at `re s + 2 / l ≥ 1 + 1 / l`. The left edge, |
| 160 | -- where `|g| ≤ e^(3 l)`, has the weight `6 / l` at `s`. The denominator makes `g` bounded; it |
| 161 | -- has modulus at least `1` on the strip and is `2` at `s`. |
| 162 | have inv_pos : 0 < 1 / l := by positivity |
| 163 | have inv_le : 1 / l ≤ 1 / 6 := one_div_le_one_div_of_le (by norm_num) (by linarith) |
| 164 | have exp_ge : l + 1 ≤ rexp l := add_one_le_exp l |
| 165 | set a : ℝ := s.re + 2 * (1 / l) - 1 / 3 with ha |
| 166 | let g (z : ℂ) : ℂ := regularL χ z / (z - (s - 2)) |
| 167 | have denom_ge (z : ℂ) (hz : a ≤ z.re) : 1 ≤ ‖z - (s - 2)‖ := |
| 168 | le_trans (by simp; linarith) (re_le_norm _) |
| 169 | have g_le_exp_cube (z : ℂ) (hz : a ≤ z.re) : ‖g z‖ ≤ rexp l ^ 3 := by |
| 170 | have h_denom : 1 ≤ ‖z - (s - 2)‖ := denom_ge z hz |
| 171 | have hz_norm : ‖z‖ ≤ 4 * rexp l * ‖z - (s - 2)‖ := by |
| 172 | have h_exp : 3 ≤ rexp l := by linarith only [hl, exp_ge] |
| 173 | have h_center : ‖s - 2‖ ≤ 3 * rexp l + 2 := by |
| 174 | calc |
| 175 | ‖s - 2‖ ≤ ‖s‖ + ‖(2 : ℂ)‖ := norm_sub_le s 2 |
| 176 | _ ≤ 3 * rexp l + 2 := by |
| 177 | simpa only [Complex.norm_two] using add_le_add_left h_norm ‖(2 : ℂ)‖ |
| 178 | calc |
| 179 | ‖z‖ ≤ ‖z - (s - 2)‖ + ‖s - 2‖ := norm_le_norm_sub_add z (s - 2) |
| 180 | _ ≤ ‖z - (s - 2)‖ + (3 * rexp l + 2) := add_le_add_right h_center _ |
| 181 | _ ≤ ‖z - (s - 2)‖ + (3 * rexp l + 2) * ‖z - (s - 2)‖ := by |
| 182 | exact add_le_add_right |
| 183 | (le_mul_of_one_le_right (show 0 ≤ 3 * rexp l + 2 by positivity) h_denom) _ |
| 184 | _ = (3 * rexp l + 3) * ‖z - (s - 2)‖ := by ring |
| 185 | _ ≤ 4 * rexp l * ‖z - (s - 2)‖ := |
| 186 | mul_le_mul_of_nonneg_right (by linarith only [h_exp]) (norm_nonneg _) |
| 187 | rw [norm_div, div_le_iff₀ (by linarith)] |
| 188 | calc |
| 189 | ‖regularL χ z‖ ≤ 8 * N * ‖z‖ := norm_regularL_le_linear χ (by linarith) |
| 190 | _ ≤ 8 * rexp l * (4 * rexp l * ‖z - (s - 2)‖) := by gcongr |
| 191 | _ = 32 * rexp l ^ 2 * ‖z - (s - 2)‖ := by ring |
| 192 | _ ≤ rexp l ^ 3 * ‖z - (s - 2)‖ := by |
| 193 | gcongr |
| 194 | nlinarith [sq_nonneg (rexp l), mul_le_mul exp_ge exp_ge] |
| 195 | have right_edge (z : ℂ) (hz : z.re = a + 1 / 3) : ‖g z‖ ≤ 1 + l := by |
| 196 | have hz_norm : 0 < ‖z‖ := by linarith [re_le_norm z] |
| 197 | calc |
| 198 | ‖g z‖ ≤ ‖regularL χ z‖ := |
| 199 | (norm_div _ _).trans_le (div_le_self (norm_nonneg _) (denom_ge z (by linarith))) |
| 200 | _ ≤ ‖LSeries (χ ·) z‖ / ‖z‖ * ‖z‖ := by |
| 201 | rw [regularL_eq χ (by linarith), norm_mul, norm_div] |
| 202 | gcongr |
| 203 | exact norm_sub_ite_le (by linarith) |
| 204 | _ = ‖LSeries (χ ·) z‖ := div_mul_cancel₀ _ hz_norm.ne' |
| 205 | _ ≤ 1 + l := by |
| 206 | have h_re_right : 1 + 1 / l ≤ z.re := by linarith |
| 207 | exact χ.norm_LSeries_le_one_add (by linarith) h_re_right |
| 208 | have g_diff : DiffContOnCl ℂ g (verticalStrip a (a + 1 / 3)) := by |
| 209 | refine DifferentiableOn.diffContOnCl fun z hz ↦ ?_ |
| 210 | rw [verticalStrip, closure_preimage_re, closure_Ioo (by linarith)] at hz |
| 211 | obtain ⟨hz_left, -⟩ : a ≤ z.re ∧ z.re ≤ a + 1 / 3 := hz |
| 212 | have hz_pos : 0 < z.re := by linarith |
| 213 | have h_denom : z - (s - 2) ≠ 0 := norm_pos_iff.1 (one_pos.trans_le (denom_ge z hz_left)) |
| 214 | exact ((differentiableAt_regularL χ hz_pos).fun_div (by fun_prop) |
| 215 | h_denom).differentiableWithinAt |
| 216 | have weight : (s.re - a) / (a + 1 / 3 - a) = 1 - 6 / l := by rw [ha]; ring |
| 217 | have three_lines : ‖g s‖ ≤ (rexp l ^ 3) ^ (1 - (1 - 6 / l)) * (1 + l) ^ (1 - 6 / l) := by |
| 218 | have hs_strip : s ∈ verticalClosedStrip a (a + 1 / 3) := ⟨by linarith, by linarith⟩ |
| 219 | have g_bdd : BddAbove ((norm ∘ g) '' verticalClosedStrip a (a + 1 / 3)) := |
| 220 | ⟨rexp l ^ 3, forall_mem_image.2 fun z ⟨hz, _⟩ ↦ g_le_exp_cube z hz⟩ |
| 221 | rw [← weight] |
| 222 | exact norm_le_interp_of_mem_verticalClosedStrip' (by linarith) hs_strip g_diff g_bdd |
| 223 | (fun z hz ↦ g_le_exp_cube z hz.ge) right_edge |
| 224 | have left_factor : (rexp l ^ 3) ^ (1 - (1 - 6 / l)) ≤ 3 ^ 18 := by |
| 225 | have h_exp : ((3 : ℕ) * l) * (1 - (1 - 6 / l)) = (18 : ℕ) * 1 := by field |
| 226 | rw [← Real.exp_natCast_mul, ← Real.exp_mul, h_exp, Real.exp_natCast_mul] |
| 227 | exact pow_le_pow_left₀ (exp_nonneg 1) exp_one_lt_three.le 18 |
| 228 | have right_factor : (1 + l) ^ (1 - 6 / l) ≤ 1 + l := |
| 229 | rpow_le_self_of_one_le (by linarith) (sub_le_self 1 (by positivity)) |
| 230 | calc |
| 231 | ‖regularL χ s‖ = 2 * ‖g s‖ := by simp [g, mul_div_cancel₀] |
| 232 | _ ≤ 2 * (3 ^ 18 * (1 + l)) := by grw [three_lines, left_factor, right_factor] |
| 233 | _ ≤ l ^ 2 := by nlinarith |
| 234 | |
| 235 | /-- Cauchy's estimate: if `l ≥ 10¹⁰` and the modulus `N` is at most `e^l`, then `|𝖿_χ'(s)| ≤ 2 l³` |
| 236 | for `re s ≥ 1 - 1 / (2 l)` and `|s| ≤ 2 e^l`. Here `𝖿_χ` (`regularL χ`) is `L(s, χ)`, times |
| 237 | `(s - 1) / s` if `χ` is principal. -/ |
| 238 | lemma norm_deriv_regularL_le (hl : 10 ^ 10 ≤ l) (hN : N ≤ rexp l) (h_re : 1 - 1 / l / 2 ≤ s.re) |
| 239 | (h_norm : ‖s‖ ≤ 2 * rexp l) : ‖deriv (regularL χ) s‖ ≤ 2 * l ^ 3 := by |
| 240 | have inv_le : 1 / l ≤ 1 / 6 := one_div_le_one_div_of_le (by norm_num) (by linarith) |
| 241 | have disc {z : ℂ} (hz : z ∈ closedBall s (1 / l / 2)) : 1 - 1 / l ≤ z.re ∧ ‖z‖ ≤ 3 * rexp l := |
| 242 | ⟨by linarith [mem_closedBall_iff_norm.mp hz, neg_le_of_abs_le (abs_re_le_norm (z - s)), |
| 243 | sub_re z s], |
| 244 | by linarith [mem_closedBall_iff_norm.mp hz, norm_le_norm_sub_add z s, add_one_le_exp l]⟩ |
| 245 | refine ((norm_deriv_le_of_forall_mem_sphere_norm_le (by positivity) |
| 246 | (DifferentiableOn.diffContOnCl_ball (fun _ hz ↦ (differentiableAt_regularL χ |
| 247 | (by linarith [(disc hz).1])).differentiableWithinAt) subset_rfl) |
| 248 | fun _ hz ↦ norm_regularL_le_sq χ hl hN (disc (sphere_subset_closedBall hz)).1 |
| 249 | (disc (sphere_subset_closedBall hz)).2 : _ ≤ l ^ 2 / (1 / l / 2))).trans_eq (by field) |
| 250 | |
| 251 | end New |
| 252 | |
| 253 | end |