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 Mathlib.NumberTheory.LSeries.PrimesInAP |
| 4 | import Mathlib.MeasureTheory.Function.Floor |
| 5 | import Mathlib.NumberTheory.LSeries.Linearity |
| 6 | import Mathlib.NumberTheory.LSeries.SumCoeff |
| 7 | public import TauCeti.NumberTheory.ArithmeticDirichletSeries.Riesz.Basic |
| 8 | public import Lib.Analytic.EntireLFunction |
| 9 | import TauCeti.NumberTheory.ArithmeticDirichletSeries.Riesz.Laplace |
| 10 | |
| 11 | /-! |
| 12 | # A weighted prime-counting error term and its poles at zeros of L-functions |
| 13 | |
| 14 | Let `d` be a prime and `χ_K = (·/d)` the Legendre symbol. We study the remainder `R_q` of a weighted |
| 15 | sum over the prime powers `n ≡ 1` modulo `q` with `χ_K(n) ≠ 1`. Its Laplace transform sees the zeros |
| 16 | of the Dirichlet `L`-functions modulo `q` and of their twists by `χ_K`. |
| 17 | |
| 18 | * `New.lambdaKResidueClass`: the weight `λ(n) = Λ(n) (1 - χ_K(n))` on `n ≡ 1` modulo `q`; it is |
| 19 | nonnegative. |
| 20 | * `New.logDerivMean`: the mean `G_q` over the characters `ψ` modulo `q` of the differences of the |
| 21 | logarithmic derivatives of `New.entireL (New.quadTwist ψ d)` and `New.entireL ψ`, less `1 / φ(q)`. |
| 22 | * `New.primeRemainder`: `R_q(x) = ∑_{n ≤ x} λ(n) (1/n - 1/x) - log x / φ(q) - re G_q(1)`. |
| 23 | * `New.LSeriesHasSum_lambdaKResidueClass`: for odd `d` prime to `q`, the Dirichlet series of `λ` |
| 24 | converges absolutely to `s / (φ(q) (s - 1)) + G_q(s)` in `re s > 1`. |
| 25 | * `New.isPolar_primeRemainder`: for `d ≡ 7` modulo `8` prime to `q`, the transform of |
| 26 | `v ↦ R_q(e ^ v)` has at most simple poles in `re s > 0`, none at `1`, and at `s ≠ 1` with the |
| 27 | residue `(n(s) - n'(s)) / (φ(q) s (1 - s))`, where `n(s)` and `n'(s)` are the sums of the orders |
| 28 | at `s` of these `L`-functions and of their twists. |
| 29 | |
| 30 | Here `New.entireL ψ` is `L(s, ψ)`, times `s - 1` if `ψ` is principal, `New.quadTwist ψ d` is the |
| 31 | character `ψ χ_K`, and `New.chowlaSelbergConst d` is, for odd `d`, `γ - re L'/L(1, χ_K)`, with `γ` |
| 32 | Euler's constant. |
| 33 | |
| 34 | ## Relation to the literature |
| 35 | |
| 36 | The transform of a weighted prime sum in a residue class is computed by orthogonality of characters |
| 37 | and partial summation. Source: Davenport, Multiplicative Number Theory. |
| 38 | -/ |
| 39 | |
| 40 | @[expose] public section |
| 41 | |
| 42 | noncomputable section |
| 43 | |
| 44 | open ArithmeticFunction DirichletCharacter Complex Finset Filter MeasureTheory Nat Real Topology |
| 45 | vonMangoldt |
| 46 | |
| 47 | namespace New |
| 48 | |
| 49 | variable (d : ℕ) [Fact d.Prime] (q : ℕ) |
| 50 | |
| 51 | /-! ### The weights, their partial sums and the error term -/ |
| 52 | |
| 53 | /-- The weight `λ(n) = Λ(n) (1 - χ_K(n))` for `n ≡ 1` mod `q`, and `0` for other `n`. Here `Λ` is |
| 54 | the von Mangoldt function and `χ_K = chiK d` is the Legendre symbol `(·/d)`. -/ |
| 55 | def lambdaKResidueClass (n : ℕ) : ℝ := residueClass (1 : ZMod q) n * (1 - chiK d n) |
| 56 | |
| 57 | /-- The sum `y ^ (-r) ∑_{1 ≤ n ≤ y} λ(n) n ^ (r - 1)` with `λ = lambdaKResidueClass d q`, used for |
| 58 | `r = 0` and `r = 1`. -/ |
| 59 | def lambdaKSum (r : ℕ) (y : ℝ) : ℝ := |
| 60 | (∑ n ∈ Icc 1 ⌊y⌋₊, lambdaKResidueClass d q n / n * n ^ r) / y ^ r |
| 61 | |
| 62 | /-- The function `G_q` with `φ(q) G_q = (L_q^K)' / L_q^K - L_q' / L_q - 1` away from the zeros of |
| 63 | `L_q` and `L_q^K`, which are the products of the `entireL ψ` and of the `entireL (quadTwist ψ d)` |
| 64 | over all characters `ψ` mod `q`. For odd `d` prime to `q` and `re s > 1` it is |
| 65 | `∑ λ(n) n ^ (-s) - s / (φ(q) (s - 1))`. -/ |
| 66 | def logDerivMean [NeZero q] (s : ℂ) : ℂ := |
| 67 | (∑ ψ : DirichletCharacter ℂ q, |
| 68 | (logDeriv (entireL (quadTwist ψ d)) s - logDeriv (entireL ψ) s) - 1) / φ q |
| 69 | |
| 70 | /-- The remainder `R_q(x) = ∑_{n ≤ x} λ(n) (1/n - 1/x) - log x / φ(q) - c_q`, with |
| 71 | `λ = lambdaKResidueClass d q` and `c_q = re G_q(1)`, `G_q = logDerivMean d q`; see |
| 72 | `primeRemainder_eq_sum_posPart`. For odd `d` prime to `q` this is the constant for which |
| 73 | `R_q(x) → 0` as `x → ∞`, by `eventually_abs_primeRemainder_exp_le_inv_pow` in |
| 74 | `New.Reduction.Zeros.PrimeNumberTheorem` with `B = 1`. -/ |
| 75 | def primeRemainder [NeZero q] (x : ℝ) : ℝ := |
| 76 | lambdaKSum d q 0 x - lambdaKSum d q 1 x - x.log / φ q - re (logDerivMean d q 1) |
| 77 | |
| 78 | /-- For a prime `d`, the Legendre symbol `chiK d n = (n/d)` takes the values `0`, `1` and `-1`, so |
| 79 | `0 ≤ 1 - (n/d) ≤ 2`. -/ |
| 80 | lemma one_sub_chiK_mem_Icc (n : ℕ) : 1 - (chiK d n : ℝ) ∈ Set.Icc (0 : ℝ) 2 := by |
| 81 | obtain h_val | h_val | h_val : |
| 82 | legendreSym d n = 0 ∨ legendreSym d n = 1 ∨ legendreSym d n = -1 := |
| 83 | quadraticChar_isQuadratic (ZMod d) ((n : ℤ) : ZMod d) <;> |
| 84 | norm_num [chiK_eq_legendreSym, h_val] |
| 85 | |
| 86 | lemma lambdaKResidueClass_nonneg (n : ℕ) : 0 ≤ lambdaKResidueClass d q n := |
| 87 | mul_nonneg (residueClass_nonneg 1 n) (one_sub_chiK_mem_Icc d n).1 |
| 88 | |
| 89 | variable {d q} in |
| 90 | /-- For a prime `d` and any `q : ℕ`, the weight `lambdaKResidueClass d q n`, which is |
| 91 | `Λ(n) (1 - (n/d))` for `n ≡ 1` mod `q` and `0` otherwise, is at most `2 Λ(n)`, where |
| 92 | `Λ = vonMangoldt`. -/ |
| 93 | lemma lambdaKResidueClass_le_two_mul_vonMangoldt (n : ℕ) : |
| 94 | lambdaKResidueClass d q n ≤ 2 * vonMangoldt n := by |
| 95 | obtain ⟨h_chi_nonneg, h_chi_le⟩ := one_sub_chiK_mem_Icc d n |
| 96 | rw [lambdaKResidueClass, mul_comm 2] |
| 97 | exact mul_le_mul (residueClass_le 1 n) h_chi_le h_chi_nonneg vonMangoldt_nonneg |
| 98 | |
| 99 | lemma lambdaKResidueClass_le_two_mul (n : ℕ) : lambdaKResidueClass d q n ≤ 2 * n := |
| 100 | calc |
| 101 | lambdaKResidueClass d q n ≤ 2 * vonMangoldt n := lambdaKResidueClass_le_two_mul_vonMangoldt n |
| 102 | _ ≤ 2 * Real.log n := mul_le_mul_of_nonneg_left vonMangoldt_le_log zero_le_two |
| 103 | _ ≤ 2 * n := mul_le_mul_of_nonneg_left (Real.log_le_self n.cast_nonneg) zero_le_two |
| 104 | |
| 105 | /-- A bound of Mertens's type: `∑_{n ≤ N} Λ(n) / n ≤ 2 log N`. -/ |
| 106 | lemma sum_vonMangoldt_div_le (N : ℕ) : ∑ n ∈ Ioc 0 N, vonMangoldt n / n ≤ 2 * Real.log N := by |
| 107 | -- Use `N / n ≤ 2 ⌊N / n⌋` for `n ≤ N` and `∑ Λ(n) ⌊N / n⌋ = log N! ≤ N log N`. |
| 108 | obtain rfl | hN := N.eq_zero_or_pos |
| 109 | · simp |
| 110 | have h_floor (n : ℕ) (hn : n ∈ Ioc 0 N) : (N : ℝ) / n ≤ 2 * (N / n : ℕ) := by |
| 111 | obtain ⟨hn_pos, hn_le⟩ := mem_Ioc.1 hn |
| 112 | have h_one : (1 : ℝ) ≤ (N / n : ℕ) := mod_cast Nat.div_pos hn_le hn_pos |
| 113 | have h_lt : (N : ℝ) / n < (N / n : ℕ) + 1 := by |
| 114 | simpa [Nat.floor_div_eq_div] using Nat.lt_floor_add_one ((N : ℝ) / n) |
| 115 | linarith |
| 116 | refine le_of_mul_le_mul_left ?_ (Nat.cast_pos.2 hN) |
| 117 | calc (N : ℝ) * ∑ n ∈ Ioc 0 N, vonMangoldt n / n |
| 118 | ≤ ∑ n ∈ Ioc 0 N, vonMangoldt n * (2 * (N / n : ℕ)) := by |
| 119 | simp only [mul_sum, mul_div_left_comm (N : ℝ)] |
| 120 | exact sum_le_sum fun n hn ↦ mul_le_mul_of_nonneg_left (h_floor n hn) vonMangoldt_nonneg |
| 121 | _ = 2 * ∑ n ∈ Ioc 0 N, Real.log n := by |
| 122 | simp only [mul_left_comm _ (2 : ℝ), ← mul_sum, ← sum_Ioc_mul_zeta_eq_sum, |
| 123 | vonMangoldt_mul_zeta, log_apply] |
| 124 | _ ≤ 2 * ∑ _n ∈ Ioc 0 N, Real.log N := by gcongr with n hn <;> simp_all [mem_Ioc] |
| 125 | _ = N * (2 * Real.log N) := by simp [mul_left_comm] |
| 126 | |
| 127 | |
| 128 | /-- Growth of the partial sums. Let `d` be a prime, `q` any natural number, and |
| 129 | `λ = lambdaKResidueClass d q` the weight `Λ(n) (1 - (n/d))` on `n ≡ 1` mod `q` and `0` elsewhere, |
| 130 | with `(·/d)` the Legendre symbol. For every `r : ℕ` and real `v`, the sum `lambdaKSum d q r y = y ^ |
| 131 | (-r) ∑_{1 ≤ n ≤ y} λ(n) n ^ (r - 1)` at `y = e ^ v` has absolute value at most `2 e ^ v`. -/ |
| 132 | lemma abs_lambdaKSum_exp_le (r : ℕ) (v : ℝ) : |lambdaKSum d q r (rexp v)| ≤ 2 * rexp v := by |
| 133 | -- There are at most `exp v` terms, each at most `2 * exp v ^ r` since `0 ≤ λ(n) ≤ 2 n`. |
| 134 | have h_term (n : ℕ) (hn : n ∈ Icc 1 ⌊rexp v⌋₊) : |
| 135 | |lambdaKResidueClass d q n / n * n ^ r| ≤ 2 * rexp v ^ r := by |
| 136 | have hn_le : (n : ℝ) ≤ rexp v := (le_floor_iff (exp_nonneg v)).1 (mem_Icc.1 hn).2 |
| 137 | have h_div : lambdaKResidueClass d q n / n ≤ 2 := |
| 138 | div_le_of_le_mul₀ n.cast_nonneg zero_le_two (lambdaKResidueClass_le_two_mul d q n) |
| 139 | rw [abs_mul, abs_div, abs_pow, Nat.abs_cast, abs_of_nonneg (lambdaKResidueClass_nonneg d q n)] |
| 140 | gcongr |
| 141 | rw [lambdaKSum, abs_div, abs_pow, Real.abs_exp, div_le_iff₀ (by positivity), mul_assoc, |
| 142 | mul_left_comm] |
| 143 | calc |∑ n ∈ Icc 1 ⌊rexp v⌋₊, lambdaKResidueClass d q n / n * n ^ r| |
| 144 | ≤ ∑ _n ∈ Icc 1 ⌊rexp v⌋₊, 2 * rexp v ^ r := |
| 145 | (abs_sum_le_sum_abs _ _).trans (sum_le_sum h_term) |
| 146 | _ = ⌊rexp v⌋₊ * (2 * rexp v ^ r) := by simp |
| 147 | _ ≤ rexp v * (2 * rexp v ^ r) := |
| 148 | mul_le_mul_of_nonneg_right (floor_le (exp_nonneg v)) (by positivity) |
| 149 | |
| 150 | variable [NeZero q] |
| 151 | |
| 152 | /-- Let `d` be a prime and `χ_K = quadTwist 1 d` the Legendre symbol `(·/d)` as a complex character |
| 153 | mod `1 * d`. Let `E = entireL χ_K`, which is `L(s, χ_K)` if `d` is odd and `(s - 1) L(s, χ_K)` if |
| 154 | `d = 2`. For the modulus `q = 1`, `G₁ = logDerivMean d 1` is `E'/E - Z'/Z - 1` with |
| 155 | `Z(s) = (s - 1) ζ(s)`, and `re G₁(1) = -1 - γ + re E'/E(1)`. -/ |
| 156 | lemma re_logDerivMean_one_eq_add_re_logDeriv : (logDerivMean d 1 1).re = |
| 157 | -1 - eulerMascheroniConstant + (logDeriv (entireL (quadTwist (N := 1) 1 d)) 1).re := by |
| 158 | -- For the trivial character mod `1`, `entireL` is `(s - 1) ζ(s)`, whose logarithmic derivative at |
| 159 | -- `1` is `γ`. |
| 160 | have h_zeta : entireL (1 : DirichletCharacter ℂ 1) = riemannZeta₁ := by |
| 161 | have h_eq (s : ℂ) (hs : s ≠ 1) : (s - 1) * riemannZeta s = riemannZeta₁ s := by |
| 162 | rw [riemannZeta_eq_inv_sub_mul hs, mul_inv_cancel_left₀ (sub_ne_zero.2 hs)] |
| 163 | simpa [entireL, Function.update_eq_iff] using h_eq |
| 164 | have h_mean : (logDerivMean d 1 1).re = |
| 165 | (logDeriv (entireL (quadTwist (N := 1) 1 d)) 1).re - eulerMascheroniConstant - 1 := by |
| 166 | simp [logDerivMean, logDeriv, level_one, h_zeta] |
| 167 | linarith |
| 168 | |
| 169 | /-- For a prime `d` and the modulus `q = 1`, the value at `s = 1` of `G₁ = logDerivMean d 1` has |
| 170 | real part `-1 - chowlaSelbergConst d`. -/ |
| 171 | lemma re_logDerivMean_one : (logDerivMean d 1 1).re = -1 - chowlaSelbergConst d := by |
| 172 | rw [re_logDerivMean_one_eq_add_re_logDeriv, chowlaSelbergConst] |
| 173 | ring |
| 174 | |
| 175 | variable {d q} in |
| 176 | /-- For a character `ψ` mod `q` let `L_ψ = entireL ψ` be `L(s, ψ)`, times `s - 1` if `ψ` is |
| 177 | principal, and let `ψ' = quadTwist ψ d` be `ψ (·/d)`. The function `logDerivMean d q`, that is |
| 178 | `(∑_ψ (logDeriv L_ψ' - logDeriv L_ψ) - 1) / φ(q)`, is analytic at every point where no `L_ψ` and no |
| 179 | `L_ψ'` vanishes. -/ |
| 180 | lemma analyticAt_logDerivMean {s : ℂ} (h_char : ∀ ψ : DirichletCharacter ℂ q, entireL ψ s ≠ 0) |
| 181 | (h_twist : ∀ ψ : DirichletCharacter ℂ q, entireL (quadTwist ψ d) s ≠ 0) : |
| 182 | AnalyticAt ℂ (logDerivMean d q) s := by |
| 183 | unfold logDerivMean |
| 184 | fun_prop (disch := simp only [h_char, h_twist, ne_eq, not_false_eq_true]) [logDeriv] |
| 185 | |
| 186 | /-- The function `G_q = logDerivMean d q` is analytic in `re s ≥ 1`, where no `entireL χ` |
| 187 | vanishes. -/ |
| 188 | lemma analyticAt_logDerivMean_of_one_le_re {s : ℂ} (hs : 1 ≤ s.re) : |
| 189 | AnalyticAt ℂ (logDerivMean d q) s := |
| 190 | analyticAt_logDerivMean (fun ψ ↦ entireL_ne_zero ψ hs) |
| 191 | (fun ψ ↦ entireL_ne_zero (quadTwist ψ d) hs) |
| 192 | |
| 193 | variable {d q} in |
| 194 | /-- The normalized mean `G_q(s) / s` used in the prime remainder transform is analytic at a |
| 195 | nonzero point where all the entire L-functions and their quadratic twists are nonzero. -/ |
| 196 | lemma analyticAt_logDerivMean_div {s : ℂ} (hs : s ≠ 0) |
| 197 | (h_char : ∀ ψ : DirichletCharacter ℂ q, entireL ψ s ≠ 0) |
| 198 | (h_twist : ∀ ψ : DirichletCharacter ℂ q, entireL (quadTwist ψ d) s ≠ 0) : |
| 199 | AnalyticAt ℂ (fun z ↦ logDerivMean d q z / z) s := |
| 200 | (analyticAt_logDerivMean h_char h_twist).div analyticAt_id hs |
| 201 | |
| 202 | /-- The normalized mean `G_q(s) / s` is analytic throughout `1 ≤ re s`. -/ |
| 203 | lemma analyticAt_logDerivMean_div_of_one_le_re {s : ℂ} (hs : 1 ≤ s.re) : |
| 204 | AnalyticAt ℂ (fun z ↦ logDerivMean d q z / z) s := |
| 205 | (analyticAt_logDerivMean_of_one_le_re d q hs).div analyticAt_id |
| 206 | (ne_zero_of_re_pos (zero_lt_one.trans_le hs)) |
| 207 | |
| 208 | /-- Growth of the remainder: for a prime `d`, `q ≥ 1` and `v ≥ 0`, |
| 209 | `|R_q(e ^ v)| ≤ (|re G_q(1)| + 5) e ^ v`. -/ |
| 210 | lemma abs_primeRemainder_exp_le {v : ℝ} (hv : 0 ≤ v) : |
| 211 | |primeRemainder d q (rexp v)| ≤ (|re (logDerivMean d q 1)| + 5) * rexp v := by |
| 212 | have h_log : |v / φ q| ≤ rexp v := by |
| 213 | rw [abs_of_nonneg (by positivity)] |
| 214 | linarith only [div_le_self hv (mod_cast NeZero.one_le : (1 : ℝ) ≤ φ q), add_one_le_exp v] |
| 215 | set c : ℝ := re (logDerivMean d q 1) with hc |
| 216 | calc |
| 217 | |primeRemainder d q (rexp v)| |
| 218 | ≤ |lambdaKSum d q 0 (rexp v)| + |lambdaKSum d q 1 (rexp v)| + |v / φ q| + |c| := by |
| 219 | grw [primeRemainder, Real.log_exp, ← hc, abs_sub, abs_sub, abs_sub] |
| 220 | _ ≤ 2 * rexp v + 2 * rexp v + rexp v + |c| * rexp v := by |
| 221 | gcongr |
| 222 | exacts [abs_lambdaKSum_exp_le d q 0 v, abs_lambdaKSum_exp_le d q 1 v, |
| 223 | le_mul_of_one_le_right (abs_nonneg c) (one_le_exp hv)] |
| 224 | _ = (|c| + 5) * rexp v := by ring |
| 225 | |
| 226 | variable {d q} |
| 227 | |
| 228 | /-- The prime remainder is the normalized first Riesz sum of its quadratic weights |
| 229 | after subtracting the logarithmic main term and the constant at infinity. -/ |
| 230 | lemma primeRemainder_eq_normalized_rieszSum {y : ℝ} (hy : 0 < y) : |
| 231 | (primeRemainder d q y : ℂ) = |
| 232 | TauCeti.rieszSum (fun n ↦ (lambdaKResidueClass d q n : ℂ)) y / y - |
| 233 | (φ q : ℂ)⁻¹ * Real.log y - (logDerivMean d q 1).re := by |
| 234 | have weight (n : ℕ) (hn : n ∈ Icc 1 ⌊y⌋₊) (w : ℂ) : |
| 235 | w / n - w / n * n / y = w * ((y : ℂ) / n - 1) / y := by |
| 236 | have hn_pos : 0 < n := (mem_Icc.1 hn).1 |
| 237 | field [hn_pos.ne', hy.ne'] |
| 238 | simpa [primeRemainder, lambdaKSum, TauCeti.rieszSum_def, ← div_eq_inv_mul, sum_div, |
| 239 | ← sum_sub_distrib] using |
| 240 | (sum_congr (rfl : Icc 1 ⌊y⌋₊ = _) fun n hn ↦ weight n hn (lambdaKResidueClass d q n)) |
| 241 | |
| 242 | /-- Multiplying the positive part of a difference of reciprocals by a nonnegative scale is |
| 243 | the positive part of the corresponding scaled difference. -/ |
| 244 | private lemma mul_posPart_one_div_sub_one_div {a : ℝ} (ha : 0 ≤ a) (x z : ℝ) : |
| 245 | a * (1 / x - 1 / z)⁺ = (a / x - a / z)⁺ := by |
| 246 | simp [posPart_def, mul_max_of_nonneg, ha, mul_sub, div_eq_mul_inv] |
| 247 | |
| 248 | /-- In the remainder `primeRemainder d q z = ∑_{1 ≤ n ≤ z} λ(n) (1/n - 1/z) - log z / φ(q) - re |
| 249 | G_q(1)` with `z > 0`, the sum equals `∑_{1 ≤ n ≤ A} λ(n) (1/n - 1/z)⁺` for any integer `A ≥ ⌊z⌋`. -/ |
| 250 | lemma primeRemainder_eq_sum_posPart {A : ℕ} {z : ℝ} (hz_pos : 0 < z) (hz_le : ⌊z⌋₊ ≤ A) : |
| 251 | primeRemainder d q z = ∑ n ∈ Icc 1 A, |
| 252 | lambdaKResidueClass d q n * (1 / n - 1 / z)⁺ - z.log / φ q - |
| 253 | re (logDerivMean d q 1) := by |
| 254 | apply Complex.ofReal_injective |
| 255 | rw [primeRemainder_eq_normalized_rieszSum hz_pos, TauCeti.rieszSum_eq_sum_max_of_floor_le _ hz_le] |
| 256 | simp only [ofReal_sub, ofReal_div, ofReal_sum, ofReal_mul, ofReal_natCast] |
| 257 | rw [div_eq_inv_mul (Real.log z : ℂ), sub_left_inj, sub_left_inj, sum_div] |
| 258 | apply sum_congr rfl |
| 259 | intro n _ |
| 260 | have ramp : max (z / (n : ℝ) - 1) 0 = z * (1 / n - 1 / z)⁺ := by |
| 261 | rw [mul_posPart_one_div_sub_one_div hz_pos.le n z, div_self hz_pos.ne', posPart_def] |
| 262 | rw [ramp, Complex.ofReal_mul] |
| 263 | field_simp [Complex.ofReal_ne_zero.2 hz_pos.ne'] |
| 264 | |
| 265 | /-- In the remainder `primeRemainder d q z = ∑_{1 ≤ n ≤ z} λ(n) (1/n - 1/z) - log z / φ(q) - re |
| 266 | G_q(1)` with `z > 0`, the sum equals `A⁻¹ ∑_{1 ≤ n ≤ A} λ(n) (A/n - A/z)⁺` for any integer |
| 267 | `A ≥ z`. -/ |
| 268 | lemma primeRemainder_eq_sum (A : ℕ) {z : ℝ} (hz_pos : 0 < z) (hz_le : z ≤ A) : |
| 269 | primeRemainder d q z = ∑ n ∈ Icc 1 A, |
| 270 | lambdaKResidueClass d q n * (A / n - A / z)⁺ / A - z.log / φ q - |
| 271 | re (logDerivMean d q 1) := by |
| 272 | have hA : (0 : ℝ) < A := hz_pos.trans_le hz_le |
| 273 | simp [primeRemainder_eq_sum_posPart hz_pos (Nat.floor_le_of_le hz_le), |
| 274 | ← mul_posPart_one_div_sub_one_div hA.le, mul_div_assoc, hA.ne'] |
| 275 | |
| 276 | /-! ### The Dirichlet series and the Laplace transform -/ |
| 277 | |
| 278 | /-- Let `d` be an odd prime coprime to `q ≥ 1`, `χ_K = (·/d)` the Legendre symbol, and |
| 279 | `λ = lambdaKResidueClass d q` the weight `Λ(n) (1 - χ_K(n))` on `n ≡ 1` mod `q` and `0` elsewhere. |
| 280 | For `re s > 1`, the series `∑ λ(n) n ^ (-s)` converges absolutely to |
| 281 | `s / (φ(q) (s - 1)) + G_q(s)`. -/ |
| 282 | lemma LSeriesHasSum_lambdaKResidueClass (hd : d ≠ 2) (h_cop : q.Coprime d) {s : ℂ} |
| 283 | (hs : 1 < s.re) : |
| 284 | LSeriesHasSum (fun n : ℕ ↦ lambdaKResidueClass d q n) s |
| 285 | (s / (φ q * (s - 1)) + logDerivMean d q s) := by |
| 286 | -- Orthogonality of the characters mod `q` expresses `λ` through `ψ Λ - ψ χ_K Λ`. |
| 287 | let a (ψ : DirichletCharacter ℂ q) : ℕ → ℂ := |
| 288 | (fun n : ℕ ↦ ψ n * vonMangoldt n) - fun n : ℕ ↦ quadTwist ψ d n * vonMangoldt n |
| 289 | have h_orth (n : ℕ) : |
| 290 | (lambdaKResidueClass d q n : ℂ) = ((φ q : ℂ)⁻¹ • ∑ ψ : DirichletCharacter ℂ q, a ψ) n := by |
| 291 | have h_twist (ψ : DirichletCharacter ℂ q) : quadTwist ψ d n = ψ n * legendreSym d n := |
| 292 | mod_cast quadTwist_apply ψ d n |
| 293 | simp [a, lambdaKResidueClass, chiK_eq_legendreSym, residueClass_apply, h_twist, ← sum_mul, |
| 294 | field] |
| 295 | -- No twist is principal, so only `ψ = 1` contributes the term `1 / (s - 1)`. |
| 296 | let D (ψ : DirichletCharacter ℂ q) : ℂ := |
| 297 | logDeriv (entireL (quadTwist ψ d)) s - logDeriv (entireL ψ) s |
| 298 | have h_series (ψ : DirichletCharacter ℂ q) : |
| 299 | LSeriesHasSum (a ψ) s ((if ψ = 1 then 1 else 0) / (s - 1) + D ψ) := by |
| 300 | convert (LSeriesHasSum_mul_vonMangoldt ψ hs).sub |
| 301 | (LSeriesHasSum_mul_vonMangoldt (quadTwist ψ d) hs) |
| 302 | rw [ite_eq_right (quadTwist_ne_one ψ d hd h_cop)] |
| 303 | ring |
| 304 | have h_total : LSeriesHasSum (∑ ψ : DirichletCharacter ℂ q, a ψ) s (1 / (s - 1) + ∑ ψ, D ψ) := by |
| 305 | simpa [sum_add_distrib, ite_div] using LSeriesHasSum.sum (S := univ) fun ψ _ ↦ h_series ψ |
| 306 | have hs_sub_ne : s - 1 ≠ 0 := sub_ne_zero.2 (ne_of_apply_ne re hs.ne') |
| 307 | rw [LSeriesHasSum_congr _ _ (fun _ ↦ h_orth _)] |
| 308 | convert h_total.smul (φ q : ℂ)⁻¹ using 1 |
| 309 | unfold logDerivMean |
| 310 | field |
| 311 | |
| 312 | /-- For an odd prime `d` coprime to `q ≥ 1` and `re s > 1`, the Laplace transform of |
| 313 | `v ↦ R_q(e ^ v)` at `s - 1` is `(G_q(s) / s - re G_q(1)) / (s - 1)`. -/ |
| 314 | lemma integral_primeRemainder (hd : d ≠ 2) (h_cop : q.Coprime d) {s : ℂ} (hs : 1 < s.re) : |
| 315 | ∫ v : ℝ in Set.Ioi 0, primeRemainder d q (Real.exp v) * Complex.exp ((1 - s) * v) = |
| 316 | (logDerivMean d q s / s - re (logDerivMean d q 1)) / (s - 1) := by |
| 317 | let a (n : ℕ) : ℂ := lambdaKResidueClass d q n |
| 318 | have h_series : LSeriesHasSum a s _ := LSeriesHasSum_lambdaKResidueClass hd h_cop hs |
| 319 | have h_remainder (u : ℝ) : (primeRemainder d q (rexp u) : ℂ) = |
| 320 | TauCeti.rieszSum a (rexp u) / (rexp u : ℂ) - (φ q : ℂ)⁻¹ * u - |
| 321 | re (logDerivMean d q 1) := by |
| 322 | simpa only [Real.log_exp] using primeRemainder_eq_normalized_rieszSum (d := d) (q := q) |
| 323 | (Real.exp_pos u) |
| 324 | have h := (TauCeti.hasLaplace_normalized_riesz_remainder hs h_series.LSeriesSummable |
| 325 | (φ q : ℂ)⁻¹ (re (logDerivMean d q 1))).integral_eq |
| 326 | simp only [← h_remainder, neg_sub, smul_eq_mul, mul_comm (cexp _)] at h |
| 327 | rw [h, h_series.LSeries_eq] |
| 328 | have hs_ne : s ≠ 0 := ne_zero_of_re_pos (by linarith) |
| 329 | field |
| 330 | |
| 331 | /-- For an odd prime `d` coprime to `q ≥ 1`, the number `G_q(1)` is real, so it equals the constant |
| 332 | `re G_q(1)` subtracted in `primeRemainder d q`. Here `G_q = logDerivMean d q` is |
| 333 | `(∑_ψ (E_{ψ χ_K}' / E_{ψ χ_K} - E_ψ' / E_ψ) - 1) / φ(q)`, summed over the characters `ψ` mod `q`, |
| 334 | where `χ_K = (·/d)` is the Legendre symbol and `E_χ = entireL χ` is `L(s, χ)`, times `s - 1` if `χ` |
| 335 | is principal. -/ |
| 336 | lemma ofReal_re_logDerivMean_one (hd : d ≠ 2) (h_cop : q.Coprime d) : |
| 337 | ((logDerivMean d q 1).re : ℂ) = logDerivMean d q 1 := by |
| 338 | -- The transform is real on `(1, ∞)`, so its numerator is real at `1` by continuity. |
| 339 | let F (s : ℂ) : ℂ := logDerivMean d q s / s - re (logDerivMean d q 1) |
| 340 | have h_real (x : ℝ) (hx : 1 < x) : (F x).im = 0 := by |
| 341 | have h_eq : F x = |
| 342 | (∫ v : ℝ in .Ioi 0, primeRemainder d q (rexp v) * cexp ((1 - x : ℂ) * v)) * (x - 1) := by |
| 343 | rw [integral_primeRemainder hd h_cop (by simpa), |
| 344 | div_mul_cancel₀ _ (mod_cast (by linarith : 0 < x - 1).ne')] |
| 345 | rw [h_eq] |
| 346 | norm_cast |
| 347 | have hc : ContinuousAt (fun x : ℝ ↦ (F x).im) 1 := by |
| 348 | have hG := (analyticAt_logDerivMean_of_one_le_re d q (s := 1) (by simp)).continuousAt |
| 349 | dsimp only [F] |
| 350 | fun_prop (disch := norm_num) |
| 351 | have h_im : (F (1 : ℝ)).im = 0 := by |
| 352 | refine tendsto_nhds_unique_of_eventuallyEq (l := 𝓝[>] (1 : ℝ)) |
| 353 | hc.continuousWithinAt (g := fun _ : ℝ ↦ (0 : ℝ)) tendsto_const_nhds ?_ |
| 354 | filter_upwards [self_mem_nhdsWithin] with x hx using h_real x hx |
| 355 | exact Complex.ext (ofReal_re _) (by simpa [F, eq_comm] using h_im) |
| 356 | |
| 357 | /-! ### The poles of the Laplace transform -/ |
| 358 | |
| 359 | /-- Let `d` be a prime, `q ≥ 1`, `χ_K = (·/d)` the Legendre symbol, `quadTwist ψ d = ψ χ_K`, and let |
| 360 | `E_χ = entireL χ` be `L(s, χ)`, times `s - 1` if `χ` is principal. The function |
| 361 | `G_q = logDerivMean d q`, that is `(∑_ψ (E_{ψ χ_K}' / E_{ψ χ_K} - E_ψ' / E_ψ) - 1) / φ(q)` summed |
| 362 | over the characters `ψ` mod `q`, has at most a simple pole at `ρ`. Its residue is the mean over `ψ` |
| 363 | of `ord_ρ E_{ψ χ_K} - ord_ρ E_ψ`. -/ |
| 364 | lemma tendsto_sub_mul_logDerivMean (ρ : ℂ) : |
| 365 | Tendsto (fun z : ℂ ↦ (z - ρ) * logDerivMean d q z) (𝓝[≠] ρ) |
| 366 | (𝓝 ((∑ ψ : DirichletCharacter ℂ q, (analyticOrderNatAt (entireL (quadTwist ψ d)) ρ - |
| 367 | analyticOrderNatAt (entireL ψ) ρ : ℂ)) / φ q)) := by |
| 368 | have h_term (ψ : DirichletCharacter ℂ q) : Tendsto |
| 369 | (fun z : ℂ ↦ (z - ρ) * (logDeriv (entireL (quadTwist ψ d)) z - logDeriv (entireL ψ) z)) |
| 370 | (𝓝[≠] ρ) (𝓝 (analyticOrderNatAt (entireL (quadTwist ψ d)) ρ - |
| 371 | analyticOrderNatAt (entireL ψ) ρ)) := by |
| 372 | simpa only [mul_sub] using |
| 373 | (tendsto_sub_mul_logDeriv_entireL_analyticOrderNatAt (quadTwist ψ d) ρ).sub |
| 374 | (tendsto_sub_mul_logDeriv_entireL_analyticOrderNatAt ψ ρ) |
| 375 | have h_sub : Tendsto (fun z : ℂ ↦ z - ρ) (𝓝[≠] ρ) (𝓝 0) := |
| 376 | tendsto_sub_nhds_zero_iff.2 nhdsWithin_le_nhds |
| 377 | have h_eq (z : ℂ) : (z - ρ) * logDerivMean d q z = |
| 378 | (∑ ψ : DirichletCharacter ℂ q, (z - ρ) * |
| 379 | (logDeriv (entireL (quadTwist ψ d)) z - logDeriv (entireL ψ) z) - (z - ρ)) / φ q := by |
| 380 | simp [logDerivMean, ← mul_sum, field] |
| 381 | simpa only [h_eq, sub_zero] using |
| 382 | ((tendsto_finsetSum univ fun ψ _ ↦ h_term ψ).sub h_sub).div_const (φ q : ℂ) |
| 383 | |
| 384 | /-- Let `d` be a prime, `q ≥ 1`, `χ_K = (·/d)` the Legendre symbol, `quadTwist ψ d = ψ χ_K`, and let |
| 385 | `E_χ = entireL χ` be `L(s, χ)`, times `s - 1` if `χ` is principal. At `ρ ≠ 0, 1` and for any |
| 386 | constant `κ`, the function `(G_q(z) / z - κ) / (z - 1)` has at most a simple pole, of residue `∑_ψ |
| 387 | (ord_ρ E_ψ - ord_ρ E_{ψ χ_K}) / (φ(q) ρ (1 - ρ))`. -/ |
| 388 | lemma tendsto_logDerivMean_residue (κ : ℂ) {ρ : ℂ} (hρ₀ : ρ ≠ 0) (hρ₁ : ρ ≠ 1) : |
| 389 | Tendsto (fun z : ℂ ↦ (z - ρ) * ((logDerivMean d q z / z - κ) / (z - 1))) (𝓝[≠] ρ) |
| 390 | (𝓝 ((∑ ψ : DirichletCharacter ℂ q, |
| 391 | (analyticOrderNatAt (entireL ψ) ρ - analyticOrderNatAt (entireL (quadTwist ψ d)) ρ : ℂ)) / |
| 392 | φ q / (ρ * (1 - ρ)))) := by |
| 393 | -- The pole is that of `G_q`, with residue `m`; it is divided by `z (z - 1)`. |
| 394 | let m : ℂ := (∑ ψ : DirichletCharacter ℂ q, (analyticOrderNatAt (entireL (quadTwist ψ d)) ρ - |
| 395 | analyticOrderNatAt (entireL ψ) ρ : ℂ)) / φ q |
| 396 | have h_id : Tendsto (fun z : ℂ ↦ z) (𝓝[≠] ρ) (𝓝 ρ) := tendsto_id.mono_left nhdsWithin_le_nhds |
| 397 | have h_lim : Tendsto (fun z : ℂ ↦ ((z - ρ) * logDerivMean d q z / z - (z - ρ) * κ) / (z - 1)) |
| 398 | (𝓝[≠] ρ) (𝓝 ((m / ρ - (ρ - ρ) * κ) / (ρ - 1))) := |
| 399 | (((tendsto_sub_mul_logDerivMean ρ).div h_id hρ₀).sub ((h_id.sub_const ρ).mul_const κ)).div |
| 400 | (h_id.sub_const 1) (sub_ne_zero.2 hρ₁) |
| 401 | convert h_lim using 2 with z |
| 402 | · ring |
| 403 | · simp only [m, sum_sub_distrib] |
| 404 | field [sub_ne_zero.2 hρ₁, sub_ne_zero.2 hρ₁.symm] |
| 405 | |
| 406 | /-- **Poles.** Let `d ≡ 7 mod 8` be a prime coprime to `q ≥ 1`, `χ_K = (·/d)` the character of |
| 407 | `K = ℚ(√-d)`, and `R_q = primeRemainder d q`. The conclusion `IsPolar` says that the transform |
| 408 | `∫₀^∞ R_q(e ^ v) e ^ ((1 - s) v) dv` converges absolutely for `re s > 2` and continues from there to |
| 409 | a function meromorphic on `re s > 0` with at most simple poles there and the following residues. |
| 410 | It has no pole at `1`, where the formula below is a division by zero, of value `0`. The residue at |
| 411 | `s ≠ 1` is `∑_ψ (ord_s E_ψ - ord_s E_{ψ χ_K}) / (φ(q) s (1 - s))`, summed over the |
| 412 | characters `ψ` mod `q`, where `quadTwist ψ d = ψ χ_K` and `E_χ = entireL χ` is `L(s, χ)`, times |
| 413 | `s - 1` if `χ` is principal. -/ |
| 414 | lemma isPolar_primeRemainder (hd : d % 8 = 7) (h_cop : q.Coprime d) : |
| 415 | IsPolar (fun v : ℝ ↦ primeRemainder d q (Real.exp v)) fun s : ℂ ↦ |
| 416 | (∑ ψ : DirichletCharacter ℂ q, |
| 417 | (analyticOrderNatAt (entireL ψ) s - analyticOrderNatAt (entireL (quadTwist ψ d)) s : ℂ)) / |
| 418 | φ q / (s * (1 - s)) := by |
| 419 | -- The continuation is `F s / (s - 1)` with `F s = G_q(s) / s - c_q`, which vanishes at `1`. |
| 420 | have hd_ne : d ≠ 2 := by lia |
| 421 | let c : ℝ := re (logDerivMean d q 1) |
| 422 | let F (s : ℂ) : ℂ := logDerivMean d q s / s - c |
| 423 | have h_meas : Measurable fun v : ℝ ↦ primeRemainder d q (rexp v) := by |
| 424 | fun_prop [primeRemainder, lambdaKSum] |
| 425 | have h_mero : Meromorphic fun s : ℂ ↦ F s / (s - 1) := fun _ ↦ by fun_prop [logDerivMean] |
| 426 | have h_transform (s : ℂ) (hs : 2 < s.re) : F s / (s - 1) = |
| 427 | ∫ v : ℝ in Set.Ioi 0, primeRemainder d q (rexp v) * cexp ((1 - s) * v) := |
| 428 | (integral_primeRemainder hd_ne h_cop (one_lt_two.trans hs)).symm |
| 429 | have h_growth (v : ℝ) (hv : 0 ≤ v) : |primeRemainder d q (rexp v)| ≤ (|c| + 5) * rexp v := |
| 430 | abs_primeRemainder_exp_le d q hv |
| 431 | refine isPolar_of_tendsto h_meas h_growth (fun z _ ↦ h_mero z) h_transform fun ρ hρ ↦ ?_ |
| 432 | obtain rfl | hρ₁ := eq_or_ne ρ 1 |
| 433 | · have hF : AnalyticAt ℂ F 1 := |
| 434 | (analyticAt_logDerivMean_div_of_one_le_re d q one_re.ge).sub analyticAt_const |
| 435 | have hF_one : F 1 = 0 := by simp [F, c, ofReal_re_logDerivMean_one hd_ne h_cop] |
| 436 | have h_lim : Tendsto F (𝓝[≠] 1) (𝓝 0) := by |
| 437 | simpa [hF_one] using hF.continuousAt.continuousWithinAt.tendsto |
| 438 | simp only [sub_self, mul_zero, div_zero] |
| 439 | exact h_lim.congr' (eventually_nhdsWithin_of_forall fun z hz ↦ |
| 440 | (mul_div_cancel₀ (F z) (sub_ne_zero.2 hz)).symm) |
| 441 | · exact tendsto_logDerivMean_residue c (ne_zero_of_re_pos hρ) hρ₁ |
| 442 | |
| 443 | end New |
| 444 | |
| 445 | end |