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 | public import New.Reduction.Zeros.PrimeError |
| 4 | import Lib.Analytic.Landau |
| 5 | import Lib.Analytic.QuadraticTwist |
| 6 | |
| 7 | /-! |
| 8 | # The one-sided criterion for a zero-free half-plane |
| 9 | |
| 10 | `New.LFunction_ne_zero_of_primeRemainder_le`: an eventual upper bound `R_q(x) ≤ A * x ^ (β - 1)` for |
| 11 | the remainder of a sum over prime powers `≡ 1` mod `q` with weights depending on a prime `d`, for |
| 12 | all `d` of a suitable class, excludes zeros `s ≠ 1` of the `L(s, ψ)`, `ψ` mod `q`, in `re s > β`. |
| 13 | |
| 14 | For a single fixed prime, `New.sum_entireL_orders_eq_twisted_of_primeRemainder_le` first |
| 15 | compares the twisted and untwisted zero multiplicities in the half-plane. |
| 16 | |
| 17 | Notions from other files: |
| 18 | * `primeRemainder d q x`: the remainder `R_q(x) = ∑_{n ≤ x} λ(n) (1/n - 1/x) - log x / φ(q) - c_q`, |
| 19 | where `λ(n) = Λ(n) (1 - (n/d))` for `n ≡ 1` mod `q` and `0` otherwise, and `c_q` is a constant. |
| 20 | * `entireL ψ`: the entire function `L(s, ψ)`, times `s - 1` if `ψ` is principal. |
| 21 | * `quadTwist ψ d`: the product of `ψ` and the Legendre symbol `(·/d)`. |
| 22 | * `IsPolar E r`: the transform `∫₀^∞ E(v) e^{(1-s)v} dv` continues meromorphically, with at most |
| 23 | simple poles in `re s > 0` and residues `r`. |
| 24 | |
| 25 | ## Relation to the literature |
| 26 | |
| 27 | The hypotheses concern only the remainders, for all primes `d` of the class, and not the real zeros |
| 28 | of the `L(s, ψ)`. In the literature: a one-sided bound for a weighted sum over primes `≡ 1` modulo |
| 29 | `q` gives a zero-free half-plane if there are no real zeros. Related work: M. Suzuki, On variants of |
| 30 | Chebyshev's conjecture, arXiv 2411.07436, 2024; Montgomery–Vaughan, Multiplicative Number Theory I, |
| 31 | §15.1–15.2, 2007; Landau, Über einen Satz von Tschebyschef, 1905. |
| 32 | -/ |
| 33 | |
| 34 | @[expose] public section |
| 35 | |
| 36 | open Complex Filter Nat Real Set MeasureTheory Topology |
| 37 | |
| 38 | /-- For one prime with the one-sided remainder bound, suppose that on the real interval |
| 39 | `(β, 1)` the total order of the twisted zeros is at most the untwisted total. Then the |
| 40 | two totals agree at every complex point to the right of `β`, with multiplicities. -/ |
| 41 | theorem New.sum_entireL_orders_eq_twisted_of_primeRemainder_le |
| 42 | {q d : ℕ} [NeZero q] [Fact d.Prime] (hd : d % 8 = 7) (hcop : q.Coprime d) |
| 43 | {A β : ℝ} (hβ : 0 < β) |
| 44 | (hbound : ∀ᶠ x : ℝ in atTop, primeRemainder d q x ≤ A * x ^ (β - 1)) |
| 45 | (hreal : ∀ x : ℝ, β < x → x < 1 → |
| 46 | (∑ χ : DirichletCharacter ℂ q, analyticOrderNatAt (entireL (quadTwist χ d)) x) ≤ |
| 47 | ∑ χ : DirichletCharacter ℂ q, analyticOrderNatAt (entireL χ) x) |
| 48 | {ρ : ℂ} (hρ : β < ρ.re) : |
| 49 | (∑ χ : DirichletCharacter ℂ q, analyticOrderNatAt (entireL χ) ρ) = |
| 50 | ∑ χ : DirichletCharacter ℂ q, analyticOrderNatAt (entireL (quadTwist χ d)) ρ := by |
| 51 | let untwisted (s : ℂ) := ∑ χ : DirichletCharacter ℂ q, analyticOrderNatAt (entireL χ) s |
| 52 | let twisted (s : ℂ) := |
| 53 | ∑ χ : DirichletCharacter ℂ q, analyticOrderNatAt (entireL (quadTwist χ d)) s |
| 54 | have vanish (s : ℂ) (hs : 1 ≤ s.re) : untwisted s = 0 ∧ twisted s = 0 := by |
| 55 | constructor <;> exact Finset.sum_eq_zero fun χ _ ↦ |
| 56 | (analyticOrderNatAt_entireL_eq_zero_iff _ s).2 (entireL_ne_zero _ hs) |
| 57 | obtain rfl | hρ₁ := eq_or_ne ρ 1 |
| 58 | · exact (vanish 1 le_rfl).1.trans (vanish 1 le_rfl).2.symm |
| 59 | -- The difference of orders gives a nonnegative residue for real x > β. Landau's lemma |
| 60 | -- then makes the residue at ρ vanish, so the two orders agree there. |
| 61 | let r (s : ℂ) : ℂ := ((untwisted s : ℂ) - twisted s) / φ q / (s * (1 - s)) |
| 62 | have polar : IsPolar (fun v : ℝ ↦ primeRemainder d q v.exp) r := by |
| 63 | simpa [r, untwisted, twisted, Finset.sum_sub_distrib] using isPolar_primeRemainder hd hcop |
| 64 | have nonneg (x : ℝ) (hx : β < x) : 0 ≤ (r x).re := by |
| 65 | have eq : r x = (((untwisted x : ℝ) - twisted x) / φ q / (x * (1 - x)) : ℝ) := by simp [r] |
| 66 | rw [eq, ofReal_re] |
| 67 | obtain hx' | hx' := lt_or_ge x 1 |
| 68 | · have num : (twisted x : ℝ) ≤ untwisted x := by exact_mod_cast hreal x hx hx' |
| 69 | exact div_nonneg (div_nonneg (sub_nonneg.2 num) (by positivity)) |
| 70 | (mul_nonneg (hβ.trans hx).le (sub_nonneg.2 hx'.le)) |
| 71 | · obtain ⟨hu, ht⟩ := vanish x hx' |
| 72 | simp [hu, ht] |
| 73 | have exp_bound : ∀ᶠ v : ℝ in atTop, primeRemainder d q v.exp ≤ A * Real.exp ((β - 1) * v) := by |
| 74 | filter_upwards [tendsto_exp_atTop.eventually hbound] with v hv |
| 75 | rwa [mul_comm (β - 1) v, Real.exp_mul] |
| 76 | have hzero : r ρ = 0 := polar.landau hβ nonneg exp_bound hρ |
| 77 | have h₀ : ρ ≠ 0 := ne_zero_of_re_pos (hβ.trans hρ) |
| 78 | have eq : (untwisted ρ : ℂ) = twisted ρ := by |
| 79 | simpa [r, sub_eq_zero, h₀, sub_ne_zero.2 hρ₁.symm, NeZero.ne] using hzero |
| 80 | exact_mod_cast eq |
| 81 | |
| 82 | /-- **One-sided criterion.** Let `q₀` be a positive multiple of `8`, let `d₀ ≡ 7` mod `8` be prime |
| 83 | to `q₀`, and let `β > 1/2`. Suppose that for each prime `d ≡ d₀` mod `q₀` the remainder |
| 84 | `primeRemainder d q₀ x = ∑_{n ≤ x} λ(n) (1/n - 1/x) - log x / φ(q₀) - c` is at most |
| 85 | `A * x ^ (β - 1)` for some `A` and all large `x`. Here `λ(n) = Λ(n) (1 - (n/d))` for `n ≡ 1` mod |
| 86 | `q₀` and `0` otherwise, and `c` is the constant for which the remainder tends to `0`. Then |
| 87 | `L(ρ, ψ) ≠ 0` for every character `ψ` modulo `q₀` and every `ρ ≠ 1` with `re ρ > β`. -/ |
| 88 | theorem New.LFunction_ne_zero_of_primeRemainder_le {q₀ : ℕ} [NeZero q₀] (hq₀ : 8 ∣ q₀) {d₀ : ℕ} |
| 89 | (hd₀_mod : d₀ % 8 = 7) (hd₀_cop : d₀.Coprime q₀) {β : ℝ} (hβ : 1 / 2 < β) |
| 90 | (h_bound : ∀ d : Primes, (d : ℕ) ≡ d₀ [MOD q₀] → |
| 91 | ∃ A : ℝ, ∀ᶠ x : ℝ in atTop, primeRemainder d q₀ x ≤ A * x ^ (β - 1)) |
| 92 | (ψ : DirichletCharacter ℂ q₀) {ρ : ℂ} (hρ_ne : ρ ≠ 1) (hρ_re : β < ρ.re) : |
| 93 | ψ.LFunction ρ ≠ 0 := by |
| 94 | -- Choose a prime whose quadratic twists have no zero in the box containing ρ. |
| 95 | have h_mod (d : Primes) (hd : ((d : ℕ) : ZMod q₀) = d₀) : (d : ℕ) ≡ d₀ [MOD q₀] := |
| 96 | (ZMod.natCast_eq_natCast_iff d d₀ q₀).1 hd |
| 97 | have h_class (d : Primes) (hd : ((d : ℕ) : ZMod q₀) = d₀) : (d : ℕ) % 8 = 7 ∧ q₀.Coprime d := by |
| 98 | have h_mod_eight : (d : ℕ) % 8 = d₀ % 8 := (h_mod d hd).of_dvd hq₀ |
| 99 | exact ⟨h_mod_eight.trans hd₀_mod, Coprime.symm ((h_mod d hd).gcd_eq.trans hd₀_cop)⟩ |
| 100 | obtain ⟨d, hd, h_twist⟩ : ∃ d : Primes, ((d : ℕ) : ZMod q₀) = d₀ ∧ |
| 101 | ∀ (χ : DirichletCharacter ℂ q₀) (s : ℂ), |
| 102 | β ≤ re s → |im s| ≤ |ρ.im| → entireL (quadTwist χ d) s ≠ 0 := |
| 103 | exists_entireL_quadTwist_ne_zero |ρ.im| hβ ((ZMod.isUnit_iff_coprime d₀ q₀).2 hd₀_cop) h_class |
| 104 | obtain ⟨hd_mod, hd_cop⟩ := h_class d hd |
| 105 | -- The upper bound compares the total zero orders at this fixed prime. The chosen twists |
| 106 | -- contribute zero throughout the box, including its real points and the target ρ. |
| 107 | have twisted_order (s : ℂ) (hs : β ≤ s.re) (him : |s.im| ≤ |ρ.im|) : |
| 108 | (∑ χ : DirichletCharacter ℂ q₀, analyticOrderNatAt (entireL (quadTwist χ d)) s) = 0 := |
| 109 | Finset.sum_eq_zero fun χ _ ↦ |
| 110 | (analyticOrderNatAt_entireL_eq_zero_iff _ s).2 (h_twist χ s hs him) |
| 111 | obtain ⟨A, hA⟩ := h_bound d (h_mod d hd) |
| 112 | have counts := sum_entireL_orders_eq_twisted_of_primeRemainder_le hd_mod hd_cop |
| 113 | (by linarith : 0 < β) hA (fun x hx _ ↦ by |
| 114 | rw [twisted_order x hx.le (by simp)] |
| 115 | exact Nat.zero_le _) hρ_re |
| 116 | rw [twisted_order ρ hρ_re.le le_rfl] at counts |
| 117 | have h_entire : entireL ψ ρ ≠ 0 := (analyticOrderNatAt_entireL_eq_zero_iff ψ ρ).1 |
| 118 | (Finset.sum_eq_zero_iff.1 counts ψ (Finset.mem_univ ψ)) |
| 119 | exact (entireL_ne_zero_iff ψ hρ_ne).1 h_entire |