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 Mathlib.Algebra.Ring.IsFormallyReal |
| 4 | import TauCeti.NumberTheory.ModularForms.DedekindEta.LimitFormula |
| 5 | public import Lib.CM.Sigma.Basic |
| 6 | |
| 7 | /-! |
| 8 | # Kronecker's first limit formula |
| 9 | |
| 10 | `New.kronecker_limit` computes the first two terms at `s = 1` of the Epstein zeta function of a |
| 11 | lattice in `ℂ`, in terms of its area and of the discriminant `g₂³ - 27 g₃²`. The Epstein function is |
| 12 | not continued analytically: only real `s` with `1 < s < 2` occur, and a right derivative at `1`. |
| 13 | |
| 14 | The lattice is written as `a (ℤ τ + ℤ)` (`exists_lattice_eq_mul_tau`), and the statement is deduced |
| 15 | from Tau Ceti's limit formula `UpperHalfPlane.tendsto_epsteinZeta_sub` for `ℤ τ + ℤ`. Its constant |
| 16 | involves `UpperHalfPlane.logPeriod τ = log (4 π Im τ |η(τ)|⁴)`, which is |
| 17 | `log (area / π) + log |g₂³ - 27 g₃²| / 6` by `g₂_pow_three_sub_g₃_sq_eq_discriminant`. |
| 18 | |
| 19 | Notions from other files: |
| 20 | * `PeriodPair.area`: The area |Im(ω̄₁ω₂)| of the fundamental parallelogram spanned by the periods |
| 21 | ω₁, ω₂ of a period pair. |
| 22 | |
| 23 | ## Relation to the literature |
| 24 | |
| 25 | Known result: Kronecker's first limit formula. Here the real limit from the right is stated for any |
| 26 | lattice with the discriminant. In Tau Ceti's proof rows are compared with integrals by the mean |
| 27 | value theorem. See C. L. Siegel, On Advanced Analytic Number Theory, TIFR reprint, Chapter I, §1, |
| 28 | Theorem 1, p. 13. For a proof of this shape, see F. Chamizo, A simple evaluation of a theta value, |
| 29 | the Kronecker limit formula and a formula of Ramanujan, Ramanujan J. 59 (2022), |
| 30 | [§3, Proposition 1, p. 949](https://doi.org/10.1007/s11139-022-00586-0). |
| 31 | For the area-normalized sum (`k = 1`), take `Q(u,v) = |u − vτ|² / Im τ`. Then Chamizo's |
| 32 | `D = 4` and `z_Q = τ`, and reindexing by `(m,n) = (−v,u)` gives `UpperHalfPlane.epsteinZeta`. |
| 33 | -/ |
| 34 | |
| 35 | @[expose] public section |
| 36 | |
| 37 | open Complex Nat Equiv MeasureTheory Set Real Function Periodic ModularForm Filter Topology |
| 38 | |
| 39 | /-- If the lattice of `L` is `a (ℤ τ + ℤ)`, enumerated by `e`, then the logarithmic period of `τ` is |
| 40 | `log A - log π + log |g₂³ - 27 g₃²| / 6`, `A` being the area of `L`. This uses |
| 41 | `g₂³ - 27 g₃² = (2 π / a)^12 * q * ∏ (1 - q^(j+1))^24` and `|q| = exp (-2 π Im τ)`. -/ |
| 42 | private lemma New.logPeriod_eq_of_eq_mul_tau {L : PeriodPair} {a : ℂ} {τ : UpperHalfPlane} |
| 43 | {e : ℤ × ℤ ≃ L.lattice} (hL : ∀ p : ℤ × ℤ, (e p : ℂ) = a * (p.1 * τ + p.2)) (ha : a ≠ 0) |
| 44 | (h_area : L.area = ‖a‖ ^ 2 * τ.im) : |
| 45 | UpperHalfPlane.logPeriod τ = |
| 46 | Real.log L.area - Real.log π + Real.log ‖L.g₂ ^ 3 - 27 * L.g₃ ^ 2‖ / 6 := by |
| 47 | have hy := τ.im_pos |
| 48 | let P : ℂ := ∏' j : ℕ, (1 - eta_q j (τ : ℂ)) |
| 49 | have hP : P ≠ 0 := eta_tprod_ne_zero hy |
| 50 | have h_disc : Real.log ‖L.g₂ ^ 3 - 27 * L.g₃ ^ 2‖ = |
| 51 | 12 * (Real.log 2 + Real.log π - Real.log ‖a‖) - 2 * π * τ.im + 24 * Real.log ‖P‖ := by |
| 52 | rw [g₂_pow_three_sub_g₃_sq_eq_discriminant hL] |
| 53 | norm_num [discriminant, ModularForm.eta, P, hP, norm_exp, qParam, Real.log_mul, log_div, ha] |
| 54 | ring |
| 55 | rw [UpperHalfPlane.logPeriod_eq_log_tprod, h_disc, h_area, |
| 56 | Real.log_mul (by positivity) hy.ne', Real.log_pow, Real.log_mul (by norm_num) pi_ne_zero, |
| 57 | show (4 : ℝ) = 2 ^ 2 by norm_num, Real.log_pow] |
| 58 | push_cast |
| 59 | ring |
| 60 | |
| 61 | /-- If the lattice of `L` is `a (ℤ τ + ℤ)`, enumerated by `e`, the factor `‖a‖ ^ 2` cancels between |
| 62 | `‖e p‖ ^ 2` and the area: `‖e p‖ ^ 2 / k / A = (k Im τ / |p₁ τ + p₂|²)⁻¹`. -/ |
| 63 | private lemma New.norm_sq_div_area_eq_inv {L : PeriodPair} {a : ℂ} {τ : UpperHalfPlane} |
| 64 | {e : ℤ × ℤ ≃ L.lattice} (hL : ∀ p : ℤ × ℤ, (e p : ℂ) = a * (p.1 * τ + p.2)) (ha : a ≠ 0) |
| 65 | (h_area : L.area = ‖a‖ ^ 2 * τ.im) {k : ℝ} (hk : k ≠ 0) (p : ℤ × ℤ) : |
| 66 | ‖(e p : ℂ)‖ ^ 2 / k / L.area = (k * (τ.im / ‖(p.1 : ℂ) * τ + p.2‖ ^ 2))⁻¹ := by |
| 67 | rw [hL, norm_mul, mul_pow, h_area] |
| 68 | by_cases hw : ‖(p.1 : ℂ) * τ + p.2‖ = 0 |
| 69 | · simp [hw] |
| 70 | field_simp |
| 71 | |
| 72 | /-- Let `0 < k`, and let `F s = k ^ s * ((s - 1) * E s)` for `1 < s` and `F 1 = π * k`. If |
| 73 | `E s - π / (s - 1)` tends to `c` as `s` decreases to `1`, then `F` has the right derivative |
| 74 | `k * c + π * (Real.log k * k)` at `1`. -/ |
| 75 | private lemma New.hasDerivWithinAt_of_tendsto_sub_pi_div {F E : ℝ → ℝ} {k c : ℝ} (hk : 0 < k) |
| 76 | (hF : ∀ s : ℝ, 1 < s → F s = k ^ s * ((s - 1) * E s)) (hF_one : F 1 = π * k) |
| 77 | (hE : Tendsto (fun s ↦ E s - π / (s - 1)) (𝓝[>] 1) (𝓝 c)) : |
| 78 | HasDerivWithinAt F (k * c + π * (Real.log k * k)) (Ioi 1) 1 := by |
| 79 | -- the slope of `F` at `1` is `k ^ s (E s - π / (s - 1)) + π (k ^ s - k) / (s - 1)` |
| 80 | have hk_deriv : HasDerivAt (fun s : ℝ ↦ k ^ s) (Real.log k * 1 * k ^ (1 : ℝ)) 1 := |
| 81 | (hasDerivAt_id (1 : ℝ)).const_rpow hk |
| 82 | have h_lim := ((hk_deriv.continuousAt.continuousWithinAt (s := Ioi 1)).tendsto.mul hE).add |
| 83 | (((hasDerivWithinAt_iff_tendsto_slope' (by simp)).1 hk_deriv.hasDerivWithinAt).const_mul π) |
| 84 | have h_eq : (fun s ↦ k ^ s * (E s - π / (s - 1)) + π * slope (fun s : ℝ ↦ k ^ s) 1 s) |
| 85 | =ᶠ[𝓝[>] 1] slope F 1 := by |
| 86 | filter_upwards [self_mem_nhdsWithin] with s (hs : 1 < s) |
| 87 | simp only [slope_def_field, hF s hs, hF_one, rpow_one] |
| 88 | field [sub_ne_zero.2 hs.ne'] |
| 89 | rw [hasDerivWithinAt_iff_tendsto_slope' (by simp)] |
| 90 | convert h_lim.congr' h_eq using 2 |
| 91 | rw [rpow_one] |
| 92 | ring |
| 93 | |
| 94 | /-- **Kronecker's first limit formula.** Let `L` be a lattice of area `A` and discriminant |
| 95 | `Δ = g₂³ - 27 g₃²`, and let `k > 0`. There is a real function `F` with (a) `F 1 = π k`, (b) right |
| 96 | derivative `F 1 * (2 γ - log (A / (k π²)) - (log |Δ|) / 6)` at `1`, `γ` being Euler's constant, and |
| 97 | (c) `F s = (s - 1) ∑ (|l|² / (k A))^(-s)` for `1 < s < 2`. The sum is over all `l` in the lattice; |
| 98 | the term `l = 0` is `0`, since `0 ^ (-s) = 0` in Lean. For `k = 1` this is the expansion |
| 99 | `∑ (|l|² / A)^(-s) = π / (s - 1) + π (2 γ - log (A |Δ|^(1/6) / π²)) + o(1)` as `s` decreases to |
| 100 | `1`. -/ |
| 101 | lemma New.kronecker_limit (L : PeriodPair) (k : ℝ) (hk : 0 < k) : |
| 102 | ∃ F : ℝ → ℝ, |
| 103 | -- (a) the value at 1 |
| 104 | F 1 = π * k ∧ |
| 105 | -- (b) the right derivative at 1 |
| 106 | HasDerivWithinAt F |
| 107 | (F 1 * |
| 108 | (2 * eulerMascheroniConstant - Real.log (PeriodPair.area L / k / π ^ 2) - |
| 109 | Real.log ‖L.g₂ ^ 3 - 27 * L.g₃ ^ 2‖ / 6)) |
| 110 | (Ioi 1) 1 ∧ |
| 111 | -- (c) the series for 1 < s < 2 |
| 112 | ∀ s ∈ Ioo 1 2, |
| 113 | HasSum (fun l : L.lattice ↦ (s - 1) * (‖l.val‖ ^ 2 / k / L.area) ^ (-s)) (F s) := by |
| 114 | obtain ⟨a, τ, e, hL, ha, h_area⟩ := exists_lattice_eq_mul_tau L |
| 115 | have hA : 0 < L.area := area_pos L |
| 116 | let E := UpperHalfPlane.epsteinZeta τ |
| 117 | have h_period := logPeriod_eq_of_eq_mul_tau hL ha h_area |
| 118 | let F : ℝ → ℝ := Function.update (fun s ↦ k ^ s * ((s - 1) * E s)) 1 (π * k) |
| 119 | have hF (s : ℝ) (hs : 1 < s) : F s = k ^ s * ((s - 1) * E s) := |
| 120 | Function.update_of_ne hs.ne' _ _ |
| 121 | have hF_one : F 1 = π * k := Function.update_self _ _ _ |
| 122 | refine ⟨F, hF_one, ?_, fun s hs ↦ e.hasSum_iff.1 ?_⟩ |
| 123 | · -- the constant of `UpperHalfPlane.tendsto_epsteinZeta_sub` gives the right derivative |
| 124 | convert hasDerivWithinAt_of_tendsto_sub_pi_div hk hF hF_one |
| 125 | (UpperHalfPlane.tendsto_epsteinZeta_sub τ) using 1 |
| 126 | rw [hF_one, h_period, Real.log_div (by positivity) (by positivity), |
| 127 | Real.log_div hA.ne' hk.ne', Real.log_pow] |
| 128 | ring |
| 129 | · -- the factor `‖a‖ ^ 2` cancels between `‖l‖ ^ 2` and the area |
| 130 | rw [hF s hs.1, show k ^ s * ((s - 1) * E s) = (s - 1) * k ^ s * E s by ring] |
| 131 | refine ((UpperHalfPlane.hasSum_epsteinZeta τ hs.1).mul_left ((s - 1) * k ^ s)).congr_fun |
| 132 | fun p ↦ ?_ |
| 133 | change (s - 1) * (‖(e p : ℂ)‖ ^ 2 / k / L.area) ^ (-s) = _ |
| 134 | rw [norm_sq_div_area_eq_inv hL ha h_area hk.ne', rpow_neg (by positivity), |
| 135 | Real.inv_rpow (by positivity), inv_inv, Real.mul_rpow hk.le (by positivity)] |
| 136 | ring |