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.Analysis.Contour.Residue.LogDeriv |
| 4 | import TauCeti.Analysis.LaplaceTransform.Elementary |
| 5 | import TauCeti.NumberTheory.DirichletCharacter.Conductor |
| 6 | import TauCeti.NumberTheory.DirichletCharacter.LFunction.LogDeriv.Basic |
| 7 | import TauCeti.NumberTheory.DirichletCharacter.Quadratic |
| 8 | public import Mathlib.Analysis.Meromorphic.Basic |
| 9 | public import Mathlib.NumberTheory.DirichletCharacter.Orthogonality |
| 10 | import Mathlib.AlgebraicTopology.FundamentalGroupoid.SimplyConnected |
| 11 | import Mathlib.NumberTheory.LSeries.Nonvanishing |
| 12 | public import Lib.General.NumberTheory.ImaginaryQuadraticField |
| 13 | public import TauCeti.Analysis.LaplaceTransform.Basic |
| 14 | public import Mathlib.Analysis.Meromorphic.TrailingCoefficient |
| 15 | import TauCeti.Analysis.Contour.Residue.SimplePole |
| 16 | |
| 17 | /-! |
| 18 | # Quadratic twists, polar functions and logarithmic derivatives of Dirichlet L-functions |
| 19 | |
| 20 | This part shows that the twist of a Dirichlet character by the Legendre symbol of an odd prime not |
| 21 | dividing the modulus is not principal. It defines `New.IsPolar`, the condition that a Laplace-type |
| 22 | transform of an error term continues meromorphically with at most simple poles in the right |
| 23 | half-plane. It also expresses `∑ χ(n) Λ(n) n^{-s}` through the logarithmic derivative of |
| 24 | `New.entireL χ` and identifies the residues of that logarithmic derivative with the orders of the |
| 25 | zeros of `New.entireL χ`. |
| 26 | |
| 27 | ## Main definitions and results |
| 28 | |
| 29 | * `New.quadTwist_ne_one`: the twist of a character modulo `N` by the Legendre symbol `(·/d)`, for an |
| 30 | odd prime `d` prime to `N`, is not principal. |
| 31 | * `New.IsPolar`: `∫₀^∞ E(v) e^{(1-s)v} dv` (the Laplace transform `TauCeti.HasLaplace` of |
| 32 | `E(v) e^v`) converges for `re s > 2` and continues to a function of `s` meromorphic on `re s > 0` |
| 33 | with at most simple poles of residue (trailing coefficient) `r ρ` there. |
| 34 | * `New.isPolar_of_tendsto`: `IsPolar` from the limits of `(z - ρ) Φ(z)`. |
| 35 | * `New.LSeriesHasSum_mul_vonMangoldt`: `∑ χ(n) Λ(n) n^{-s}` in terms of the logarithmic derivative |
| 36 | of `New.entireL χ`. |
| 37 | * `New.tendsto_sub_mul_logDeriv_entireL_analyticOrderNatAt`: the residues of that logarithmic |
| 38 | derivative are the orders of the zeros of `New.entireL χ`. |
| 39 | |
| 40 | Notions from other files: |
| 41 | * `New.entireL`: The entire function equal to L(s, χ) if χ is not principal, and to the continuation |
| 42 | of (s − 1)L(s, χ) if χ is principal. |
| 43 | |
| 44 | ## Relation to the literature |
| 45 | |
| 46 | Known; see `Lib.Analytic.Landau` for sources. |
| 47 | -/ |
| 48 | |
| 49 | @[expose] public section |
| 50 | |
| 51 | open ArithmeticFunction DirichletCharacter Complex Set Filter MeasureTheory Metric ProbabilityTheory |
| 52 | Nat Topology ComplexOrder AnalyticOnNhd Real |
| 53 | |
| 54 | namespace New |
| 55 | |
| 56 | variable {N : ℕ} (χ : DirichletCharacter ℂ N) (d : ℕ) [Fact d.Prime] |
| 57 | |
| 58 | /-! ### The quadratic twist of a character -/ |
| 59 | |
| 60 | /-- The twist of `χ` by the Legendre symbol takes the value `χ(n) (n/d)` at an integer `n`. -/ |
| 61 | lemma quadTwist_apply (n : ℤ) : quadTwist χ d n = χ n * legendreSym d n := by |
| 62 | -- Both sides vanish unless `n` is prime to `N` and to `d`; then the change of level keeps values. |
| 63 | rw [show (legendreSym d n : ℂ) = (chiK d).ringHomComp (algebraMap ℤ ℂ) n from rfl] |
| 64 | by_cases h_cop : IsCoprime n (N * d : ℕ) |
| 65 | · rw [quadTwist, MulChar.mul_apply, changeLevel_eq_cast_of_dvd' _ _ h_cop, |
| 66 | changeLevel_eq_cast_of_dvd' _ _ h_cop] |
| 67 | · rw [(apply_eq_zero_iff (quadTwist χ d) n).2 h_cop, zero_eq_mul, apply_eq_zero_iff, |
| 68 | apply_eq_zero_iff] |
| 69 | rwa [Nat.cast_mul, IsCoprime.mul_right_iff, not_and_or] at h_cop |
| 70 | |
| 71 | /-- Twisting by the Legendre character of an odd prime coprime to the conductor multiplies the |
| 72 | conductor by that prime. -/ |
| 73 | lemma conductor_quadTwist (hd : d ≠ 2) (hχ : χ.conductor.Coprime d) : |
| 74 | (quadTwist χ d).conductor = χ.conductor * d := by |
| 75 | obtain rfl | hN := eq_zero_or_neZero N |
| 76 | · simp [conductor_eq_zero_iff_level_eq_zero.mpr] |
| 77 | have hε : (changeLevel (dvd_mul_left d N) |
| 78 | ((chiK d).ringHomComp (algebraMap ℤ ℂ))).conductor = d := |
| 79 | conductor_changeLevel_quadraticChar (by norm_num) hd _ |
| 80 | rw [quadTwist, conductor_mul_of_coprime, conductor_changeLevel, hε] |
| 81 | simpa only [conductor_changeLevel χ, hε] using hχ |
| 82 | |
| 83 | /-- For a Dirichlet character `χ` mod `N` and an odd prime `d` coprime to `N`, the twist of `χ` by |
| 84 | the Legendre symbol `(·/d)`, a character mod `N * d`, is not principal. -/ |
| 85 | lemma quadTwist_ne_one (hd : d ≠ 2) (hN : N.Coprime d) : quadTwist χ d ≠ 1 := by |
| 86 | have : NeZero N := ⟨fun h ↦ (Fact.out : d.Prime).ne_one (by simpa [h] using hN)⟩ |
| 87 | rw [ne_eq, eq_one_iff_conductor_eq_one, |
| 88 | conductor_quadTwist χ d hd (hN.of_dvd_left χ.conductor_dvd_level)] |
| 89 | simp [(Fact.out : d.Prime).ne_one] |
| 90 | |
| 91 | /-! ### Polar functions and Laplace integrals -/ |
| 92 | |
| 93 | /-- The transform `∫₀^∞ E(v) e^{(1-s)v} dv`, the Laplace transform of `E(v) e^v`, converges |
| 94 | absolutely for `re s > 2` and continues from there to a function `Φ` meromorphic on `re s > 0` |
| 95 | whose poles there are at most simple (order at least `-1`); for `re ρ > 0`, `r ρ` is the residue at |
| 96 | `ρ`, which is the trailing coefficient at a pole and `0` where there is no pole. For `E(v) = R(e^v)` |
| 97 | the transform is `∫₁^∞ R(y) y^{-s} dy`. -/ |
| 98 | def IsPolar (E : ℝ → ℝ) (r : ℂ → ℂ) : Prop := |
| 99 | ∃ Φ : ℂ → ℂ, MeromorphicOn Φ {s | 0 < s.re} ∧ |
| 100 | -- (a) `Φ` is the transform of `E` far to the right |
| 101 | (∀ s : ℂ, 2 < s.re → TauCeti.HasLaplace (fun v ↦ ((E v * Real.exp v : ℝ) : ℂ)) s (Φ s)) ∧ |
| 102 | -- (b) at most simple poles in `re ρ > 0`, with residues `r ρ` |
| 103 | ∀ ρ : ℂ, 0 < ρ.re → -1 ≤ meromorphicOrderAt Φ ρ ∧ |
| 104 | r ρ = if meromorphicOrderAt Φ ρ < 0 then meromorphicTrailingCoeffAt Φ ρ else 0 |
| 105 | |
| 106 | variable {E : ℝ → ℝ} [NeZero N] {s : ℂ} |
| 107 | |
| 108 | /-- If `E` is measurable and `|E v| ≤ C e^v` for `v ≥ 0`, the transform |
| 109 | `∫₀^∞ E(v) e^{(1-s)v} dv` converges for `re s > 2`. -/ |
| 110 | lemma integrableOn_laplace_of_abs_le {C : ℝ} (hE : Measurable E) |
| 111 | (hE_growth : ∀ v ≥ (0 : ℝ), |E v| ≤ C * Real.exp v) (hs : 2 < s.re) : |
| 112 | IntegrableOn (fun v : ℝ ↦ E v * Complex.exp ((1 - s) * v)) (Ioi 0) := by |
| 113 | -- The integrand is bounded by `C * exp ((2 - re s) * v)`, whose exponent is negative. |
| 114 | refine ((integrableOn_exp_mul_Ioi (sub_neg.2 hs) 0).const_mul C).mono' (by fun_prop) |
| 115 | (ae_restrict_of_forall_mem measurableSet_Ioi fun v hv ↦ ?_) |
| 116 | calc |
| 117 | ‖E v * cexp ((1 - s) * v)‖ = |E v| * ((1 - s.re) * v).exp := by simp [norm_exp] |
| 118 | _ ≤ C * v.exp * ((1 - s.re) * v).exp := by grw [hE_growth v hv.le] |
| 119 | _ = C * ((2 - s.re) * v).exp := by |
| 120 | rw [mul_assoc, ← Real.exp_add] |
| 121 | ring_nf |
| 122 | |
| 123 | /-- `IsPolar E r` from the residues, the constructor from the hypotheses that defined `IsPolar` |
| 124 | before it was stated in Tau Ceti's terms: let `E` be measurable with `|E v| ≤ C e^v` for `v ≥ 0`, |
| 125 | and let `Φ`, meromorphic on `re s > 0`, be the transform `∫₀^∞ E(v) e^{(1-s)v} dv` for `re s > 2`. |
| 126 | If `(z - ρ) Φ(z) → r ρ` at every `ρ` with `re ρ > 0`, then `IsPolar E r`. (`TauCeti.HasLaplace` |
| 127 | includes the integrability of the integrand, so in `IsPolar` measurability and the growth bound |
| 128 | are weakened to integrability of `E(v) e^{(1-s)v}` on `(0, ∞)` for `re s > 2`, not dropped.) -/ |
| 129 | lemma isPolar_of_tendsto {C : ℝ} {r Φ : ℂ → ℂ} (hE : Measurable E) |
| 130 | (hE_growth : ∀ v ≥ (0 : ℝ), |E v| ≤ C * Real.exp v) (hΦ : MeromorphicOn Φ {s | 0 < s.re}) |
| 131 | (hΦ_eq : ∀ s : ℂ, 2 < re s → Φ s = ∫ v : ℝ in Ioi 0, E v * Complex.exp ((1 - s) * v)) |
| 132 | (hΦ_res : ∀ ρ : ℂ, 0 < re ρ → Tendsto (fun z ↦ (z - ρ) * Φ z) (𝓝[≠] ρ) (𝓝 (r ρ))) : |
| 133 | IsPolar E r := by |
| 134 | have h_integrand (s : ℂ) (v : ℝ) : |
| 135 | Complex.exp (-s * v) • ((E v * Real.exp v : ℝ) : ℂ) = E v * Complex.exp ((1 - s) * v) := by |
| 136 | push_cast |
| 137 | rw [smul_eq_mul, show (1 - s) * v = -s * v + v by ring, Complex.exp_add] |
| 138 | ring |
| 139 | refine ⟨Φ, hΦ, fun s hs ↦ ?_, fun ρ hρ ↦ ?_⟩ |
| 140 | · simp only [TauCeti.hasLaplace_iff, h_integrand] |
| 141 | exact ⟨integrableOn_laplace_of_abs_le hE hE_growth hs, (hΦ_eq s hs).symm⟩ |
| 142 | -- Tau Ceti's residue API: the limit bounds the order below by `-1` and is the residue. |
| 143 | have h_order : -1 ≤ meromorphicOrderAt Φ ρ := |
| 144 | TauCeti.Contour.neg_one_le_meromorphicOrderAt_of_tendsto_sub_mul (hΦ_res ρ hρ) |
| 145 | have h_res := TauCeti.Contour.residue_eq_of_tendsto_sub_mul (hΦ ρ hρ) (hΦ_res ρ hρ) |
| 146 | refine ⟨h_order, ?_⟩ |
| 147 | rw [← h_res] |
| 148 | split_ifs with h_neg |
| 149 | · -- A pole of order at least `-1` is simple, and there the residue is the trailing coefficient. |
| 150 | obtain ⟨n, hn⟩ := WithTop.ne_top_iff_exists.1 h_neg.ne_top |
| 151 | have h_one : meromorphicOrderAt Φ ρ = (-1 : ℤ) := by |
| 152 | rw [← hn] at h_neg h_order ⊢ |
| 153 | have h_lt : n < 0 := by exact_mod_cast h_neg |
| 154 | have h_ge : (-1 : ℤ) ≤ n := WithTop.coe_le_coe.1 h_order |
| 155 | exact congrArg _ (show n = -1 by omega) |
| 156 | exact TauCeti.Contour.residue_eq_meromorphicTrailingCoeffAt_of_order_eq_neg_one h_one |
| 157 | · exact TauCeti.Contour.residue_eq_zero_of_meromorphicOrderAt_nonneg (not_lt.1 h_neg) |
| 158 | |
| 159 | /-- If the summands indexed by the characters modulo `q` have norm at most `C`, then subtracting |
| 160 | `1` from their sum and dividing by `q.totient` gives norm at most `C + 1`. -/ |
| 161 | lemma norm_sum_dirichletCharacter_sub_one_div_totient_le {q : ℕ} [NeZero q] |
| 162 | {f : DirichletCharacter ℂ q → ℂ} {C : ℝ} (hf : ∀ χ, ‖f χ‖ ≤ C) : |
| 163 | ‖((∑ χ, f χ) - 1) / (q.totient : ℂ)‖ ≤ C + 1 := by |
| 164 | have h_card : Fintype.card (DirichletCharacter ℂ q) = q.totient := by |
| 165 | rw [← Nat.card_eq_fintype_card, DirichletCharacter.card_eq_totient_of_hasEnoughRootsOfUnity] |
| 166 | have h_mean : ‖(∑ χ, f χ) / (q.totient : ℂ)‖ ≤ C := by |
| 167 | rw [← h_card, ← Fintype.expect_eq_sum_div_card] |
| 168 | exact (RCLike.norm_expect_le (K := ℂ)).trans |
| 169 | (Finset.expect_le ⟨1, Finset.mem_univ _⟩ fun χ _ ↦ hf χ) |
| 170 | have hφ : (1 : ℝ) ≤ q.totient := mod_cast Nat.totient_pos.2 (NeZero.pos q) |
| 171 | rw [sub_div] |
| 172 | refine norm_sub_le_of_le h_mean ?_ |
| 173 | simpa only [norm_div, norm_one, Complex.norm_natCast] using div_le_self zero_le_one hφ |
| 174 | |
| 175 | /-- For `re s > 0`, the Laplace transform of `t ^ k` at `s` is `k! / s ^ (k + 1)`. -/ |
| 176 | lemma laplace_pow {s : ℂ} (hs : 0 < s.re) (k : ℕ) : |
| 177 | ∫ t : ℝ in Ioi 0, t ^ k * Complex.exp (-s * t) = k ! / s ^ (k + 1) := by |
| 178 | simpa only [smul_eq_mul, mul_comm] using (TauCeti.hasLaplace_pow k hs).integral_eq |
| 179 | |
| 180 | /-! ### The logarithmic derivative of a Dirichlet L-function -/ |
| 181 | |
| 182 | @[fun_prop] |
| 183 | lemma analyticAt_entireL (s : ℂ) : AnalyticAt ℂ (entireL χ) s := by |
| 184 | refine Differentiable.analyticAt ?_ s |
| 185 | rw [entireL] |
| 186 | split_ifs with hχ |
| 187 | exacts [differentiable_LFunctionTrivChar₁ N, differentiable_LFunction hχ] |
| 188 | |
| 189 | /-- Away from `s = 1`, removing the possible pole preserves nonvanishing. -/ |
| 190 | lemma entireL_ne_zero_iff (hs : s ≠ 1) : entireL χ s ≠ 0 ↔ χ.LFunction s ≠ 0 := by |
| 191 | rw [entireL] |
| 192 | split_ifs with hχ |
| 193 | · subst χ |
| 194 | rw [LFunctionTrivChar₁, Function.update_of_ne hs, mul_ne_zero_iff] |
| 195 | exact and_iff_right (sub_ne_zero.2 hs) |
| 196 | · rfl |
| 197 | |
| 198 | /-- `entireL χ` has no zero in `re s ≥ 1`. -/ |
| 199 | lemma entireL_ne_zero (hs : 1 ≤ s.re) : entireL χ s ≠ 0 := by |
| 200 | obtain rfl | hs_ne := eq_or_ne s 1 |
| 201 | · rw [entireL] |
| 202 | split_ifs with hχ |
| 203 | · exact LFunctionTrivChar₁_apply_one_ne_zero N |
| 204 | · exact LFunction_ne_zero_of_one_le_re χ (.inl hχ) hs |
| 205 | · exact (entireL_ne_zero_iff χ hs_ne).2 (LFunction_ne_zero_of_one_le_re χ (.inr hs_ne) hs) |
| 206 | |
| 207 | /-- For `re s > 1`, the series `∑ χ(n) Λ(n) n^{-s}` has the sum `-L'/L(s, χ)`, written through |
| 208 | `entireL χ`, which is `L(s, χ)`, or `(s - 1) L(s, χ)` for principal `χ`. The term `1 / (s - 1)` is |
| 209 | present only for `χ = 1`. -/ |
| 210 | lemma LSeriesHasSum_mul_vonMangoldt (hs : 1 < s.re) : |
| 211 | LSeriesHasSum (fun n : ℕ ↦ χ n * Λ n) s |
| 212 | ((if χ = 1 then 1 else 0) / (s - 1) - logDeriv (entireL χ) s) := by |
| 213 | refine LSeriesHasSum_iff.2 ⟨χ.LSeriesSummable_twist_vonMangoldt hs, ?_⟩ |
| 214 | -- The series is `-L' / L`; for `χ = 1` the factor `s - 1` of `entireL` adds `1 / (s - 1)` to the |
| 215 | -- logarithmic derivative. |
| 216 | have hs_ne : s ≠ 1 := ne_of_apply_ne re hs.ne' |
| 217 | change LSeries ((fun n : ℕ ↦ χ n) * fun n : ℕ ↦ (Λ n : ℂ)) s = _ |
| 218 | rw [neg_eq_iff_eq_neg.mp (χ.logDeriv_LFunction_eq_neg_LSeries hs).symm, entireL] |
| 219 | obtain rfl | hχ := eq_or_ne χ 1 |
| 220 | · rw [ite_eq_left rfl, ite_eq_left rfl, logDeriv_apply, logDeriv_apply, |
| 221 | deriv_LFunctionTrivChar₁_apply_of_ne_one N hs_ne, LFunctionTrivChar₁, |
| 222 | Function.update_of_ne hs_ne, LFunctionTrivChar] |
| 223 | field [sub_ne_zero.2 hs_ne, LFunction_ne_zero_of_one_le_re 1 (.inr hs_ne) hs.le] |
| 224 | · simp [hχ] |
| 225 | |
| 226 | lemma analyticOrderAt_entireL_ne_top (s : ℂ) : analyticOrderAt (entireL χ) s ≠ ⊤ := by |
| 227 | -- An entire function of infinite order at a point is zero, but `entireL χ 1 ≠ 0`. |
| 228 | exact fun h_top ↦ entireL_ne_zero χ le_rfl |
| 229 | (congrFun ((analyticOrderAt_eq_top_iff_eq_zero s (by fun_prop)).1 h_top) 1) |
| 230 | |
| 231 | lemma analyticOrderNatAt_entireL_eq_zero_iff (s : ℂ) : |
| 232 | analyticOrderNatAt (entireL χ) s = 0 ↔ entireL χ s ≠ 0 := by |
| 233 | rw [← (analyticAt_entireL χ s).analyticOrderAt_eq_zero, |
| 234 | ← Nat.cast_analyticOrderNatAt (analyticOrderAt_entireL_ne_top χ s), Nat.cast_eq_zero] |
| 235 | |
| 236 | /-- The logarithmic derivative of `entireL χ`, which is `L(s, χ)`, or `(s - 1) L(s, χ)` for |
| 237 | principal `χ`, has at most a simple pole at `s`. Its residue is the order of vanishing of |
| 238 | `entireL χ` at `s`. -/ |
| 239 | lemma tendsto_sub_mul_logDeriv_entireL_analyticOrderNatAt (s : ℂ) : |
| 240 | Tendsto (fun z : ℂ ↦ (z - s) * logDeriv (entireL χ) z) (𝓝[≠] s) |
| 241 | (𝓝 (analyticOrderNatAt (entireL χ) s : ℂ)) := by |
| 242 | let n := analyticOrderNatAt (entireL χ) s |
| 243 | have h_ord : meromorphicOrderAt (entireL χ) s = ((n : ℤ) : WithTop ℤ) := by |
| 244 | rw [(analyticAt_entireL χ s).meromorphicOrderAt_eq, |
| 245 | ← Nat.cast_analyticOrderNatAt (analyticOrderAt_entireL_ne_top χ s)] |
| 246 | rfl |
| 247 | have h_meromorphic := (analyticAt_entireL χ s).meromorphicAt |
| 248 | rw [← Int.cast_natCast, |
| 249 | ← TauCeti.Contour.residue_logDeriv_eq_meromorphicOrderAt h_meromorphic h_ord] |
| 250 | exact TauCeti.Contour.tendsto_sub_mul_nhds_residue h_meromorphic.logDeriv |
| 251 | (TauCeti.Contour.neg_one_le_meromorphicOrderAt_logDeriv h_meromorphic) |
| 252 | |
| 253 | end New |