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.ArithmeticFunction.VonMangoldt |
| 4 | import TauCeti.NumberTheory.LSeries.GaussianCutoff |
| 5 | public import Mathlib.NumberTheory.LSeries.PrimesInAP |
| 6 | import TauCeti.NumberTheory.LSeries.Term |
| 7 | import Mathlib.Algebra.Order.Star.Rat |
| 8 | import Mathlib.Algebra.Order.Star.Real |
| 9 | import Mathlib.Analysis.Complex.AbsMax |
| 10 | import Mathlib.Dynamics.Newton |
| 11 | import Mathlib.NumberTheory.LSeries.Linearity |
| 12 | import Mathlib.Order.CompletePartialOrder |
| 13 | public import Lib.Analytic.PrimeNumberTheorem.LFunctionGrowth |
| 14 | import Lib.Analytic.EntireLFunction |
| 15 | import Lib.Analytic.PrimeNumberTheorem.ZeroFreeRegion |
| 16 | |
| 17 | /-! |
| 18 | # Primes congruent to `1` modulo `M ^ k` with logarithm in a prescribed window |
| 19 | |
| 20 | Let `4 ∣ M` and let `A` be fixed. For large `W` there is a prime `p ≡ 1` modulo `M ^ k` with `log p` |
| 21 | in `[U, U + W]`, uniformly for `1 < k`, `M ^ k ≤ W ^ A` and `W ≤ U ≤ W ^ A` |
| 22 | (`New.exists_prime_modEq_one_log_mem`). |
| 23 | |
| 24 | The characters modulo `M ^ k` with trivial square come from the fixed modulus `M ^ 2`, so the |
| 25 | zero-free region gives a disc about `1` without zeros, uniformly in `k`. Newman's contour argument |
| 26 | on its boundary yields the prime. |
| 27 | |
| 28 | Notions from other files: |
| 29 | * `entireL χ` is `L(s, χ)`, times `s - 1` if `χ` is principal; |
| 30 | * `regularL χ` is `L(s, χ)`, times `(s - 1) / s` if `χ` is principal. |
| 31 | |
| 32 | ## Relation to the literature |
| 33 | |
| 34 | Known result: primes congruent to `1` modulo `M ^ k` with logarithm in a prescribed window. It is a |
| 35 | consequence of the Siegel–Walfisz theorem. Only one prime is found, in a long window, and only for |
| 36 | moduli that are powers of a fixed multiple of `4`. Source: Montgomery and Vaughan, Multiplicative |
| 37 | Number Theory I, 2007, Cor. 11.19. |
| 38 | -/ |
| 39 | |
| 40 | @[expose] public section |
| 41 | |
| 42 | /-! |
| 43 | ## Primes congruent to 1 mod M^k in a logarithmic window via Newman's method |
| 44 | -/ |
| 45 | |
| 46 | section AuxiliaryPrimes |
| 47 | |
| 48 | open ArithmeticFunction DirichletCharacter Complex Set Filter MeasureTheory LSeries Finset Real |
| 49 | Topology vonMangoldt Chebyshev Polynomial ZMod MulChar |
| 50 | |
| 51 | /-- If `4 ∣ M` and `2 ≤ k`, a character mod `M ^ k` whose square is trivial factors through modulus |
| 52 | `M ^ 2`, since every unit congruent to `1` mod `M ^ 2` is a square. -/ |
| 53 | lemma New.factorsThrough_sq_of_sq_eq_one {M k : ℕ} [NeZero M] (hM : 4 ∣ M) (hk : 2 ≤ k) |
| 54 | {χ : DirichletCharacter ℂ (M ^ k)} (hχ : χ ^ 2 = 1) : |
| 55 | χ.FactorsThrough (M ^ 2) := by |
| 56 | refine (χ.factorsThrough_iff_ker_unitsMap (pow_dvd_pow M hk)).mpr fun u hu ↦ ?_ |
| 57 | obtain ⟨m, hm⟩ := hM |
| 58 | obtain ⟨t, ht⟩ := (intCast_eq_intCast_iff_dvd_sub u.val.cast 1 (M ^ 2)).mp |
| 59 | (by simpa [unitsMap_def] using congrArg Units.val (MonoidHom.mem_ker.1 hu)) |
| 60 | -- Newton's iteration from `0` solves `c ^ 2 + c = -M * m * t`, so `(1 + 2 * c) ^ 2 = u`. |
| 61 | obtain ⟨c, ⟨-, hc⟩, -⟩ := existsUnique_nilpotent_sub_and_aeval_eq_zero (x := (0 : ZMod (M ^ k))) |
| 62 | (P := C ((M : ZMod (M ^ k)) * m * t) + X ^ 2 + X) |
| 63 | ⟨k, by simp [mul_pow, natCast_pow_eq_zero_of_le]⟩ (by simp) |
| 64 | replace ht := congrArg (Int.cast : ℤ → ZMod (M ^ k)) ht |
| 65 | simp at ht hc |
| 66 | have u_eq : (u : ZMod (M ^ k)) = (1 + 2 * c) ^ 2 := by |
| 67 | linear_combination -ht - 4 * hc - M * t * (by simp [hm] : (M : ZMod (M ^ k)) = 4 * m) |
| 68 | exact Units.ext <| by simpa [u_eq, ← pow_apply', hχ] using one_apply_coe u |
| 69 | |
| 70 | /-- If `4 ∣ M` and `2 ≤ k`, then for a character `χ` mod `M ^ k` with trivial square there is a |
| 71 | character `χ₀` mod `M ^ 2` with `regularL χ = regularL χ₀`, as the two moduli have the same prime |
| 72 | factors. Here `regularL χ` is `L(s, χ)`, times `(s - 1) / s` if `χ` is principal. -/ |
| 73 | lemma New.exists_regularL_eq_of_sq_eq_one {M k : ℕ} [NeZero M] (hM : 4 ∣ M) (hk : 2 ≤ k) |
| 74 | {χ : DirichletCharacter ℂ (M ^ k)} (hχ : χ ^ 2 = 1) : |
| 75 | ∃ χ₀ : DirichletCharacter ℂ (M ^ 2), regularL χ = regularL χ₀ := by |
| 76 | obtain ⟨h_dvd, χ₀, hχ₀⟩ := factorsThrough_sq_of_sq_eq_one hM hk hχ |
| 77 | have h_one : χ = 1 ↔ χ₀ = 1 := by rw [hχ₀, changeLevel_eq_one_iff] |
| 78 | have h_primes : (M ^ k).primeFactors = (M ^ 2).primeFactors := by |
| 79 | simp [Nat.primeFactors_pow M (show k ≠ 0 by lia), Nat.primeFactors_pow M two_ne_zero] |
| 80 | -- Changing the level multiplies by Euler factors at new primes, and there are none. |
| 81 | have h_LFunction {z : ℂ} (h : χ₀ ≠ 1 ∨ z ≠ 1) : χ.LFunction z = χ₀.LFunction z := by |
| 82 | rw [hχ₀, LFunction_changeLevel h_dvd χ₀ h, h_primes, Finset.prod_eq_one, mul_one] |
| 83 | simp +contextual [ZMod.isUnit_prime_iff_not_dvd] |
| 84 | have h_entire (z : ℂ) : entireL χ₀ z = entireL χ z := by |
| 85 | by_cases hχ₀_one : χ₀ = 1 |
| 86 | · subst χ₀ |
| 87 | by_cases hz : z = 1 <;> |
| 88 | simp [entireL, LFunctionTrivChar₁, LFunctionTrivChar, h_one.2 rfl, hz, h_primes, |
| 89 | ← h_LFunction] |
| 90 | · simp [entireL, hχ₀_one, mt h_one.1 hχ₀_one, h_LFunction (.inl hχ₀_one)] |
| 91 | exact ⟨χ₀, funext fun z ↦ by by_cases h : χ₀ = 1 <;> simp [regularL, ← h_entire, h_one, h]⟩ |
| 92 | |
| 93 | /-- For `4 ∣ M` and `A` fixed, for all large `X` the following holds for every `k > 1`, every |
| 94 | Dirichlet character `χ` mod `M ^ k` with `M ^ k ≤ X ^ A`, and every `s` with `|s - 1| ≤ 1 / X`: |
| 95 | `entireL χ s ≠ 0` and `|logDeriv (entireL χ) s| ≤ X`. Here `entireL χ` is the entire function equal |
| 96 | to `L(s, χ)` for non-principal `χ`, and to the continuation of `(s - 1) L(s, χ)` for principal `χ`. |
| 97 | No exceptional zero can occur, because the real characters come from the fixed modulus `M ^ 2`. -/ |
| 98 | lemma New.eventually_norm_logDeriv_entireL_le_near_one (A : ℕ) {M : ℕ} [NeZero M] (hM : 4 ∣ M) : |
| 99 | ∀ᶠ X : ℝ in atTop, ∀ k : ℕ, 1 < k → ∀ (χ : DirichletCharacter ℂ (M ^ k)) (s : ℂ), |
| 100 | (M : ℝ) ^ k ≤ X ^ A → ‖s - 1‖ ≤ X⁻¹ → entireL χ s ≠ 0 ∧ ‖logDeriv (entireL χ) s‖ ≤ X := by |
| 101 | -- Apply the zero-free region with `l = (A + 1) log X`, for which `e ^ l = X ^ (A + 1)`. |
| 102 | have h_log : Tendsto (fun X : ℝ ↦ (A + 1 : ℕ) * X.log) atTop atTop := |
| 103 | tendsto_log_atTop.const_mul_atTop (by positivity) |
| 104 | have h_inv : Tendsto (fun X : ℝ ↦ 1 / ((A + 1 : ℕ) * X.log)) atTop (𝓝 0) := |
| 105 | tendsto_const_nhds.div_atTop h_log |
| 106 | have h_small : (fun X : ℝ ↦ 2 * ((A + 1 : ℕ) * X.log) ^ 25) =o[atTop] id := by |
| 107 | simpa only [mul_pow, ← mul_assoc] using |
| 108 | (isLittleO_pow_log_id_atTop (n := 25)).const_mul_left (2 * ((A + 1 : ℕ) : ℝ) ^ 25) |
| 109 | filter_upwards [h_log.eventually_ge_atTop (10 ^ 10), h_small.eventuallyLE, eventually_ge_atTop 2, |
| 110 | h_inv.eventually (eventually_all.2 fun χ₀ : DirichletCharacter ℂ (M ^ 2) ↦ |
| 111 | eventually_le_norm_regularL χ₀)] with X hl h_pow hX h_near k hk χ s hq hs |
| 112 | set l : ℝ := (A + 1 : ℕ) * X.log with l_def |
| 113 | have hX_pos : 0 < X := by linarith |
| 114 | have hl_pow : 0 < l ^ 25 := pow_pos (by linarith) 25 |
| 115 | replace h_pow : 2 * l ^ 25 ≤ X := (le_abs_self _).trans (h_pow.trans_eq (abs_of_pos hX_pos)) |
| 116 | have h_exp : rexp l = X ^ A * X := by |
| 117 | rw [l_def, Real.exp_natCast_mul, Real.exp_log hX_pos, pow_succ] |
| 118 | have h_one : 1 ≤ X ^ A := one_le_pow₀ (by linarith) |
| 119 | have h_re_lower : 1 - 1 / l ^ 25 ≤ s.re := by |
| 120 | have h_inv_le : X⁻¹ ≤ 1 / l ^ 25 := by |
| 121 | simpa using inv_anti₀ hl_pow (show l ^ 25 ≤ X by linarith) |
| 122 | have h_re : |s.re - 1| ≤ X⁻¹ := by simpa using (abs_re_le_norm (s - 1)).trans hs |
| 123 | linarith [abs_le.1 h_re] |
| 124 | have h_norm : ‖s‖ ≤ 2 := by |
| 125 | linarith [norm_le_norm_sub_add s 1, norm_one (α := ℂ), |
| 126 | inv_le_one_of_one_le₀ (show 1 ≤ X by linarith)] |
| 127 | have h_level : ((M ^ k : ℕ) : ℝ) ≤ rexp l := by push_cast; nlinarith |
| 128 | have h_not_small : χ ^ 2 = 1 → ∀ z : ℂ, ‖z - 1‖ ≤ 1 / l → 1 / l ≤ ‖regularL χ z‖ := fun hχ ↦ by |
| 129 | obtain ⟨χ₀, h_eq⟩ := exists_regularL_eq_of_sq_eq_one hM hk hχ |
| 130 | simpa only [h_eq] using h_near χ₀ |
| 131 | exact (norm_logDeriv_entireL_le χ hl h_level h_not_small h_re_lower (by nlinarith)).imp_right |
| 132 | fun h_le ↦ h_le.trans h_pow |
| 133 | |
| 134 | /-- For `0 < re z` the Dirichlet series of `Λ` on the class `1` mod `q` has at `1 + z` the sum |
| 135 | `(1 - z * ∑ χ, L_χ'/L_χ (1 + z)) / φ(q) / z`. Here `L_χ = entireL χ` is `L(s, χ)` with the pole |
| 136 | removed. -/ |
| 137 | lemma New.hasSum_residueClass_one (q : ℕ) [NeZero q] {z : ℂ} (hz : 0 < z.re) : |
| 138 | LSeriesHasSum (fun n : ℕ ↦ residueClass (1 : ZMod q) n) (1 + z) |
| 139 | ((1 - z * ∑ χ : DirichletCharacter ℂ q, logDeriv (entireL χ) (1 + z)) / q.totient / z) := by |
| 140 | -- Use orthogonality of characters; the pole term `1 / z` comes from `χ = 1`. |
| 141 | have h_re : 1 < (1 + z).re := by simpa using hz |
| 142 | have h_coeff : (fun n : ℕ ↦ (residueClass (1 : ZMod q) n : ℂ)) = |
| 143 | (q.totient : ℂ)⁻¹ • ∑ χ : DirichletCharacter ℂ q, fun n : ℕ ↦ χ n * vonMangoldt n := by |
| 144 | ext n |
| 145 | simp [residueClass_apply] |
| 146 | have h_value : (1 - z * ∑ χ : DirichletCharacter ℂ q, logDeriv (entireL χ) (1 + z)) / q.totient / |
| 147 | z = (q.totient : ℂ)⁻¹ * ∑ χ : DirichletCharacter ℂ q, |
| 148 | ((if χ = 1 then 1 else 0) / (1 + z - 1) - logDeriv (entireL χ) (1 + z)) := by |
| 149 | simp [ite_div] |
| 150 | field_simp [ne_zero_of_re_pos hz] |
| 151 | rw [h_coeff, h_value] |
| 152 | exact (LSeriesHasSum.sum fun χ _ ↦ LSeriesHasSum_mul_vonMangoldt χ h_re).smul _ |
| 153 | |
| 154 | /-- There are `φ(q) ≥ 1` characters mod `q`, so `‖1 - ∑ χ, z * c χ‖ ≤ 2 φ(q)` if each term of the |
| 155 | sum has norm at most `1`. -/ |
| 156 | lemma New.norm_one_sub_mul_sum_div_totient_le {q : ℕ} [NeZero q] {z : ℂ} |
| 157 | {c : DirichletCharacter ℂ q → ℂ} (hc : ∀ χ : DirichletCharacter ℂ q, ‖z * c χ‖ ≤ 1) : |
| 158 | ‖(1 - z * ∑ χ : DirichletCharacter ℂ q, c χ) / q.totient‖ ≤ 2 := by |
| 159 | rw [Finset.mul_sum, ← norm_neg, neg_div', neg_sub] |
| 160 | simpa only [one_add_one_eq_two] using norm_sum_dirichletCharacter_sub_one_div_totient_le hc |
| 161 | |
| 162 | section Circle |
| 163 | |
| 164 | variable {a : ℕ → ℝ} {b : ℕ → ℂ} {F : ℂ → ℂ} {X U C : ℝ} |
| 165 | |
| 166 | /-- Let `a ≥ 0` have the Dirichlet series `F z / z` at `1 + z` for `0 < re z`, with `‖F‖ ≤ 2` on |
| 167 | `‖z‖ ≤ 1 / X`, and let the series of `b` at `3 / 4` have absolute sum `C ≤ X`, where `200 ≤ X` and |
| 168 | `X² ≤ U`. If on a set of `n` the terms of the series of `a` at `1 + z` are at most `e ^ E` times |
| 169 | the sum of those of `a` at `1 + 1 / U` and those of `b` at `3 / 4`, then this part of the series is |
| 170 | at most `3 U e ^ E`. -/ |
| 171 | lemma New.norm_le_of_term_le_majorant (ha : ∀ n : ℕ, 0 ≤ a n) |
| 172 | (h_series : ∀ z : ℂ, 0 < z.re → LSeriesHasSum (fun n : ℕ ↦ (a n : ℂ)) (1 + z) (F z / z)) |
| 173 | (hF : ∀ z : ℂ, ‖z‖ ≤ X⁻¹ → ‖F z‖ ≤ 2) (hC : HasSum (fun n : ℕ ↦ ‖term b (1 + -4⁻¹) n‖) C) |
| 174 | (hCX : C ≤ X) (hX : 200 ≤ X) (hU : X ^ 2 ≤ U) {z S : ℂ} {E : ℝ} {s : Set ℕ} |
| 175 | (hS : HasSum (fun n : s ↦ term (fun n : ℕ ↦ (a n : ℂ)) (1 + z) n) S) |
| 176 | (h_le : ∀ n ∈ s, ‖term (fun n : ℕ ↦ (a n : ℂ)) (1 + z) n‖ ≤ |
| 177 | rexp E * (‖term (fun n : ℕ ↦ (a n : ℂ)) (1 + (U⁻¹ : ℝ)) n‖ + ‖term b (1 + -4⁻¹) n‖)) : |
| 178 | ‖S‖ ≤ rexp E * (3 * U) := by |
| 179 | -- The whole series of `a` at `1 + 1 / U` is `U F (1 / U) ≤ 2 U`. |
| 180 | have hXU : X ≤ U := by nlinarith |
| 181 | have hU_pos : 0 < U := by linarith |
| 182 | have hX_pos' : 0 < X := by linarith |
| 183 | have h_norm : HasSum (fun n : ℕ ↦ (‖term (fun n : ℕ ↦ (a n : ℂ)) (1 + (U⁻¹ : ℝ)) n‖ : ℂ)) |
| 184 | (F (U⁻¹ : ℝ) / (U⁻¹ : ℝ)) := by |
| 185 | refine (h_series _ (by simpa using hU_pos)).congr_fun fun n ↦ ?_ |
| 186 | -- The order on `ℂ` is not in scope, so the two facts `0 ≤ _` in `ℂ` are left to `mod_cast`. |
| 187 | exact norm_of_nonneg' (mod_cast term_nonneg (mod_cast ha n) (1 + U⁻¹)) |
| 188 | have h_total : (F (U⁻¹ : ℝ) / (U⁻¹ : ℝ)).re ≤ 2 * U := by |
| 189 | have h_abs : ‖((U⁻¹ : ℝ) : ℂ)‖ = U⁻¹ := by simp [hU_pos.le] |
| 190 | grw [re_le_norm, norm_div, hF _ (h_abs.trans_le (inv_anti₀ hX_pos' hXU)), h_abs, div_inv_eq_mul] |
| 191 | have h_part : HasSum (s.indicator (term (fun n : ℕ ↦ (a n : ℂ)) (1 + z))) S := |
| 192 | hasSum_subtype_iff_indicator.1 hS |
| 193 | have h_bound (n : ℕ) : ‖s.indicator (term (fun n : ℕ ↦ (a n : ℂ)) (1 + z)) n‖ ≤ |
| 194 | rexp E * (‖term (fun n : ℕ ↦ (a n : ℂ)) (1 + (U⁻¹ : ℝ)) n‖ + ‖term b (1 + -4⁻¹) n‖) := by |
| 195 | rw [norm_indicator_eq_indicator_norm] |
| 196 | exact indicator_le' h_le (fun _ _ ↦ by positivity) n |
| 197 | calc |
| 198 | ‖S‖ ≤ rexp E * ((F (U⁻¹ : ℝ) / (U⁻¹ : ℝ)).re + C) := |
| 199 | h_part.norm_le_of_bounded (((hasSum_re h_norm).add hC).mul_left _) h_bound |
| 200 | _ ≤ rexp E * (3 * U) := by |
| 201 | gcongr |
| 202 | linarith |
| 203 | |
| 204 | /-- The bound on the circle in Newman's method. Let `a ≥ 0` have the Dirichlet series `F z / z` at |
| 205 | `1 + z` for `0 < re z` (here `term a s n` is the summand `a n / n ^ s`), with `‖F‖ ≤ 2` on |
| 206 | `‖z‖ ≤ 1 / X`. Let the series of `b` at `3 / 4` have absolute sum `C ≤ X`, let `200 ≤ X` and |
| 207 | `X² ≤ U`, and let `|a n| ≤ |b n|` whenever `log n` lies in `[U, U + X²]`. Then on `‖z‖ = 1 / X` we |
| 208 | have `‖F z - z P z‖ ≤ 3 U e ^ E`, where `P z` is the part with `n < e ^ U` of the series of `a` |
| 209 | and `E` is the real part of `2 - U z - X (1 + X z)² / 4`. -/ |
| 210 | lemma New.norm_sub_mul_sum_term_le (ha : ∀ n : ℕ, 0 ≤ a n) |
| 211 | (h_series : ∀ z : ℂ, 0 < z.re → LSeriesHasSum (fun n : ℕ ↦ (a n : ℂ)) (1 + z) (F z / z)) |
| 212 | (hF : ∀ z : ℂ, ‖z‖ ≤ X⁻¹ → ‖F z‖ ≤ 2) (hC : HasSum (fun n : ℕ ↦ ‖term b (1 + -4⁻¹) n‖) C) |
| 213 | (hCX : C ≤ X) (hX : 200 ≤ X) (hU : X ^ 2 ≤ U) |
| 214 | (h_window : ∀ n : ℕ, Real.log n ∈ Set.Icc U (U + X ^ 2) → ‖(a n : ℂ)‖ ≤ ‖b n‖) {z : ℂ} |
| 215 | (hz : ‖z‖ = X⁻¹) : |
| 216 | ‖F z - z * ∑ n ∈ .range ⌈rexp U⌉₊, term (fun n : ℕ ↦ (a n : ℂ)) (1 + z) n‖ ≤ |
| 217 | rexp (2 - U * z - 4⁻¹ * X * (1 + X * z) ^ 2 : ℂ).re * (3 * U) := by |
| 218 | have hX_pos : 0 < X := by linarith |
| 219 | have hU_pos : 0 < U := (pow_pos hX_pos 2).trans_le hU |
| 220 | have hz_small : ‖z‖ ≤ 200⁻¹ := hz.trans_le (inv_anti₀ (by simp) hX) |
| 221 | set E : ℝ := (2 - U * z - 4⁻¹ * X * (1 + X * z) ^ 2 : ℂ).re |
| 222 | set P : ℂ := ∑ n ∈ .range ⌈rexp U⌉₊, term (fun n : ℕ ↦ (a n : ℂ)) (1 + z) n |
| 223 | -- On the circle the Gaussian factor shifts the cut from `U` to a point `U + t` of the window. |
| 224 | have hz_scaled : ‖(X : ℂ) * z‖ = 1 := by |
| 225 | rw [norm_mul, Complex.norm_real, Real.norm_of_nonneg hX_pos.le, hz, mul_inv_cancel₀ hX_pos.ne'] |
| 226 | let t := TauCeti.LSeries.gaussianShift X z |
| 227 | obtain ⟨ht_nonneg, ht_le⟩ := TauCeti.LSeries.gaussianShift_mem_Icc hz_scaled.le |
| 228 | have hE : 2 - (U + t) * z.re ≤ E := by |
| 229 | have h_factor : (X : ℂ) / 4 = 4⁻¹ * X := by ring |
| 230 | simpa only [h_factor] using (TauCeti.LSeries.re_gaussian_eq hz_scaled U).ge |
| 231 | have h_unit : U * U⁻¹ = 1 := mul_inv_cancel₀ hU_pos.ne' |
| 232 | have h_shift : t * U⁻¹ ≤ 1 := (div_le_one hU_pos).2 (ht_le.trans hU) |
| 233 | have h_term_le_sum {n : ℕ} |
| 234 | (h_move : Real.log n * (U⁻¹ - z.re) ≤ (U + t) * (U⁻¹ - z.re)) : |
| 235 | ‖term (fun n : ℕ ↦ (a n : ℂ)) (1 + z) n‖ ≤ rexp E * |
| 236 | (‖term (fun n : ℕ ↦ (a n : ℂ)) (1 + (U⁻¹ : ℝ)) n‖ + ‖term b (1 + -4⁻¹) n‖) := by |
| 237 | refine (TauCeti.LSeries.norm_term_le_exp_mul _ (s := 1 + z) (w := 1 + (U⁻¹ : ℝ)) ?_).trans |
| 238 | (by gcongr; simp) |
| 239 | simp only [Complex.add_re, Complex.one_re, Complex.ofReal_re] |
| 240 | linarith only [h_move, h_unit, h_shift, hE] |
| 241 | rcases le_total z.re U⁻¹ with h_left | h_right |
| 242 | · -- If `re z ≤ 1 / U`, then `E ≥ 0`, and we bound `F` and the finite sum `P` separately. |
| 243 | have hU_re : U * z.re ≤ 1 := (mul_le_mul_of_nonneg_left h_left hU_pos.le).trans_eq h_unit |
| 244 | have ht_re : t * z.re ≤ 1 := (mul_le_mul_of_nonneg_left h_left ht_nonneg).trans h_shift |
| 245 | have hE_nonneg : 0 ≤ E := by linarith |
| 246 | have hP : ‖P‖ ≤ rexp E * (3 * U) := by |
| 247 | refine norm_le_of_term_le_majorant ha h_series hF hC hCX hX hU (Finset.hasSum ..) fun n hn ↦ |
| 248 | h_term_le_sum ?_ |
| 249 | have hn_lt : n < rexp U := Nat.lt_ceil.1 (mem_range.1 hn) |
| 250 | have h_log : Real.log n ≤ U := by |
| 251 | obtain rfl | hn_pos := n.eq_zero_or_pos |
| 252 | · simpa using hU_pos.le |
| 253 | · exact ((log_lt_iff_lt_exp (mod_cast hn_pos)).2 hn_lt).le |
| 254 | exact mul_le_mul_of_nonneg_right (by linarith) (sub_nonneg.2 h_left) |
| 255 | calc |
| 256 | ‖F z - z * P‖ ≤ ‖F z‖ + ‖z‖ * ‖P‖ := by grw [norm_sub_le, norm_mul] |
| 257 | _ ≤ 2 + 200⁻¹ * (rexp E * (3 * U)) := by grw [hF z hz.le, hz_small, hP] |
| 258 | _ ≤ rexp E * (3 * U) := by nlinarith only [E.one_le_exp hE_nonneg, hU, hX] |
| 259 | · -- If `re z ≥ 1 / U`, then `F z - z P` is `z` times the tail `n ≥ e ^ U` of the series. |
| 260 | have h_pos : 0 < z.re := (inv_pos.2 hU_pos).trans_le h_right |
| 261 | have h_tail : ‖F z / z - P‖ ≤ rexp E * (3 * U) := by |
| 262 | refine norm_le_of_term_le_majorant ha h_series hF hC hCX hX hU |
| 263 | (s := {n | n ∉ Finset.range ⌈rexp U⌉₊}) |
| 264 | ((Finset.hasSum_iff_compl _).1 (h_series z h_pos)) fun n hn ↦ ?_ |
| 265 | have hn_ge : rexp U ≤ n := Nat.ceil_le.1 (not_lt.1 (mt Finset.mem_range.2 hn)) |
| 266 | have h_log : U ≤ Real.log n := (le_log_iff_exp_le (U.exp_pos.trans_le hn_ge)).2 hn_ge |
| 267 | rcases le_total (Real.log n) (U + X ^ 2) with h_in | h_out |
| 268 | · -- In the window compare with the series of `b`. |
| 269 | have ht_re : t * z.re ≤ U * 200⁻¹ := |
| 270 | mul_le_mul (ht_le.trans hU) (z.re_le_norm.trans hz_small) h_pos.le hU_pos.le |
| 271 | have h_exponent_le : Real.log n * (-4⁻¹ - z.re) ≤ E := by |
| 272 | have h_move : Real.log n * (-4⁻¹ - z.re) ≤ U * (-4⁻¹ - z.re) := |
| 273 | mul_le_mul_of_nonpos_right h_log (by linarith) |
| 274 | linarith |
| 275 | grw [← norm_term_le (f := fun n : ℕ ↦ (a n : ℂ)) (g := b) _ (h_window n ⟨h_log, h_in⟩), |
| 276 | TauCeti.LSeries.norm_term_le_exp_mul _ (s := 1 + z) (w := 1 + -4⁻¹) |
| 277 | (by simpa [Complex.add_re] using h_exponent_le)] |
| 278 | simp [exp_pos] |
| 279 | · -- Beyond the window we have `log n ≥ U + X² ≥ U + t`. |
| 280 | exact h_term_le_sum (mul_le_mul_of_nonpos_right (by linarith) (sub_nonpos.2 h_right)) |
| 281 | calc |
| 282 | ‖F z - z * P‖ = ‖z * (F z / z - P)‖ := by |
| 283 | rw [mul_sub, mul_div_cancel₀ _ (ne_zero_of_re_pos h_pos)] |
| 284 | _ ≤ rexp E * (3 * U) := by grw [norm_mul, h_tail, show ‖z‖ ≤ 1 by linarith, one_mul] |
| 285 | |
| 286 | end Circle |
| 287 | |
| 288 | /-- The function `F z - z P z` of Newman's method is analytic on a disc on which no |
| 289 | `entireL χ (1 + z)` vanishes: here `F z = (1 - z * ∑ χ, L_χ'/L_χ (1 + z)) / φ(q)`, with |
| 290 | `L_χ = entireL χ`, and `P z` is the part with `n < N` of the Dirichlet series at `1 + z` of `Λ` on |
| 291 | the class `1` mod `q` (`residueClass`). -/ |
| 292 | lemma New.analyticOnNhd_sub_mul_sum_term (q : ℕ) [NeZero q] (N : ℕ) {r : ℝ} |
| 293 | (h_ne : ∀ z : ℂ, ‖z‖ ≤ r → ∀ χ : DirichletCharacter ℂ q, entireL χ (1 + z) ≠ 0) : |
| 294 | AnalyticOnNhd ℂ (fun z : ℂ ↦ |
| 295 | (1 - z * ∑ χ : DirichletCharacter ℂ q, logDeriv (entireL χ) (1 + z)) / q.totient - |
| 296 | z * ∑ n ∈ .range N, term (fun n : ℕ ↦ (residueClass (1 : ZMod q) n : ℂ)) (1 + z) n) |
| 297 | (Metric.closedBall 0 r) := by |
| 298 | intro z hz |
| 299 | have h_term (i : ℕ) : AnalyticAt ℂ |
| 300 | (fun s : ℂ ↦ term (fun n : ℕ ↦ (residueClass (1 : ZMod q) n : ℂ)) s i) (1 + z) := |
| 301 | Differentiable.analyticAt (fun s ↦ (hasDerivAt_term _ i s).differentiableAt) _ |
| 302 | fun_prop (disch := simp_all) [logDeriv] |
| 303 | |
| 304 | /-- Let `4 ∣ M` and let `A` be fixed. For all large `W` there is a prime `p ≡ 1` mod `M ^ k` with |
| 305 | `U ≤ log p ≤ U + W`, whenever `1 < k`, `M ^ k ≤ W ^ A` and `W ≤ U ≤ W ^ A`. This is a consequence |
| 306 | of the Siegel–Walfisz theorem, proved here directly by Newman's contour method. -/ |
| 307 | theorem New.exists_prime_modEq_one_log_mem (M A : ℕ) [NeZero M] (hM : 4 ∣ M) : |
| 308 | ∀ᶠ W : ℝ in atTop, ∀ k : ℕ, 1 < k → (M : ℝ) ^ k ≤ W ^ A → ∀ U : ℝ, U ∈ Set.Icc W (W ^ A) → |
| 309 | ∃ p : ℕ, p.Prime ∧ p ≡ 1 [MOD M ^ k] ∧ Real.log p ∈ Set.Icc U (U + W) := by |
| 310 | -- Write `W = X ^ 2`, `q = M ^ k`. Let `F z / z` be the Dirichlet series of `Λ` on `1 mod q` at |
| 311 | -- `1 + z`, and `P` its part with `n < e ^ U`. If the window has no prime, `F z - z P z` over |
| 312 | -- `exp (2 - U z - X (1 + X z)² / 4)` is at most `3 U` on `‖z‖ = 1 / X`, yet of size |
| 313 | -- `e ^ (X / 4 - 2) / φ(q)` at `0`. |
| 314 | let b (n : ℕ) : ℂ := ↑(if n.Prime then 0 else vonMangoldt n : ℝ) |
| 315 | have h_sum : Summable fun n ↦ ‖term b (1 + -4⁻¹) n‖ := by |
| 316 | refine (vonMangoldt.summable_nonprime_div_rpow (σ := (1 + -(4 : ℂ)⁻¹).re) |
| 317 | (by norm_num [Complex.inv_re, Complex.normSq_apply])).congr fun n ↦ ?_ |
| 318 | rw [norm_term_eq] |
| 319 | by_cases hn : n = 0 |
| 320 | · simp [hn] |
| 321 | simp [b, hn, apply_ite, abs_of_nonneg vonMangoldt_nonneg] |
| 322 | obtain ⟨C, hC⟩ := h_sum |
| 323 | -- Take `X` large: `q, U ≤ X ^ (2 * A)`, so `3 * U * q ≤ 3 * X ^ (4 * A) < e ^ (X / 4 - 2)`. |
| 324 | -- The substitution `W = X ^ 2` turns "for large `W`" into "for large `X = √W`". |
| 325 | rw [← comap_sqrt_atTop, eventually_comap] |
| 326 | filter_upwards [eventually_norm_logDeriv_entireL_le_near_one (2 * A) hM, |
| 327 | (tendsto_exp_mul_div_rpow_atTop ↑(4 * A) 4⁻¹ (by simp)).eventually_gt_atTop (.exp 2 * 3), |
| 328 | eventually_ge_atTop 200, eventually_ge_atTop C, eventually_gt_atTop 0] with |
| 329 | X h_free h_exp hX200 hXC hX W hW k hk hq U ⟨hWU, hU⟩ |
| 330 | obtain rfl : W = X ^ 2 := by rw [← hW, sq_sqrt (sqrt_pos.1 (hX.trans_eq hW.symm)).le] |
| 331 | have hU_pos : 0 < U := (pow_pos hX 2).trans_le hWU |
| 332 | set q : ℕ := M ^ k |
| 333 | simp only [← pow_mul, rpow_natCast, ← natCast_eq_natCast_iff, Nat.cast_one, |
| 334 | Set.mem_Icc] at hq hU h_exp ⊢ |
| 335 | have hq_cast : (q : ℝ) ≤ X ^ (2 * A) := by simpa [q] using hq |
| 336 | let a (n : ℕ) : ℂ := residueClass (1 : ZMod q) n |
| 337 | let F (z : ℂ) : ℂ := |
| 338 | (1 - z * ∑ χ : DirichletCharacter ℂ q, logDeriv (entireL χ) (1 + z)) / q.totient |
| 339 | have h_series (z : ℂ) (hz : 0 < z.re) : LSeriesHasSum a (1 + z) (F z / z) := |
| 340 | hasSum_residueClass_one q hz |
| 341 | -- For `‖z‖ ≤ 1 / X` each `z * logDeriv (entireL χ)` has norm at most `1`, so `‖F‖ ≤ 2`. |
| 342 | have h_disc {z : ℂ} (hz : ‖z‖ ≤ X⁻¹) (χ : DirichletCharacter ℂ q) : |
| 343 | entireL χ (1 + z) ≠ 0 ∧ ‖logDeriv (entireL χ) (1 + z)‖ ≤ X := |
| 344 | h_free k hk χ (1 + z) hq (by simpa) |
| 345 | have hF (z : ℂ) (hz : ‖z‖ ≤ X⁻¹) : ‖F z‖ ≤ 2 := norm_one_sub_mul_sum_div_totient_le fun χ ↦ by |
| 346 | grw [norm_mul, hz, (h_disc hz χ).2, inv_mul_cancel₀ hX.ne'] |
| 347 | by_contra h_none |
| 348 | let P (z : ℂ) : ℂ := ∑ n ∈ .range ⌈U.exp⌉₊, term a (1 + z) n |
| 349 | let G (z : ℂ) : ℂ := (F z - z * P z) / (2 - U * z - 4⁻¹ * X * (1 + X * z) ^ 2).exp |
| 350 | -- The maximum modulus principle bounds the value at zero by the bound on the circle. |
| 351 | suffices h_circle : ∀ z : ℂ, ‖z‖ = X⁻¹ → ‖G z‖ ≤ 3 * U by |
| 352 | have hG : AnalyticOnNhd ℂ G (Metric.closedBall 0 X⁻¹) := fun s hs ↦ |
| 353 | (analyticOnNhd_sub_mul_sum_term q ⌈U.exp⌉₊ (fun z hz χ ↦ (h_disc hz χ).1) s hs).div |
| 354 | (by fun_prop) (Complex.exp_ne_zero _) |
| 355 | have h_zero : ‖G 0‖ ≤ 3 * U := |
| 356 | norm_le_of_forall_mem_frontier_norm_le Metric.isBounded_ball |
| 357 | (hG.differentiableOn.diffContOnCl_ball le_rfl) |
| 358 | (fun z hz ↦ h_circle z (by simpa using Metric.frontier_ball_subset_sphere hz)) |
| 359 | (subset_closure (Metric.mem_ball_self (inv_pos.2 hX))) |
| 360 | have h_value : ‖G 0‖ = rexp (4⁻¹ * X) / rexp 2 / q.totient := by |
| 361 | simp [G, F, norm_exp, Real.exp_sub, field] |
| 362 | have h_large : 3 * U < rexp (4⁻¹ * X) / rexp 2 / q.totient := by |
| 363 | rw [lt_div_iff₀ (mod_cast Nat.totient_pos.2 (NeZero.pos q)), lt_div_iff₀ (exp_pos 2)] |
| 364 | calc |
| 365 | 3 * U * q.totient * rexp 2 ≤ 3 * X ^ (2 * A) * X ^ (2 * A) * rexp 2 := by |
| 366 | grw [Nat.totient_le, hq_cast, hU] |
| 367 | _ = rexp 2 * 3 * X ^ (4 * A) := by ring |
| 368 | _ < rexp (4⁻¹ * X) := (lt_div_iff₀ (by positivity)).1 h_exp |
| 369 | linarith |
| 370 | intro z hz |
| 371 | rw [norm_div, norm_exp, div_le_iff₀' (by bound)] |
| 372 | refine norm_sub_mul_sum_term_le (residueClass_nonneg _) h_series hF hC hXC hX200 hWU |
| 373 | (fun n hn ↦ ?_) hz |
| 374 | -- In the window no `n ≡ 1` is prime, so `Λ` on the class is at most `Λ` on the non-primes. |
| 375 | by_cases h_prime : n.Prime |
| 376 | · have h_class : (n : ZMod q) ≠ 1 := fun h ↦ h_none ⟨n, h_prime, h, hn⟩ |
| 377 | simp [residueClass, h_class] |
| 378 | · simpa [b, h_prime, abs_of_nonneg, residueClass_nonneg] using residueClass_le (1 : ZMod q) n |
| 379 | |
| 380 | end AuxiliaryPrimes |