goldbach-spectral-bridge
Li and Liu's GRH + S ⇒ Goldbach in Lean, checked against the paper by Comparator: clean it up together, and settle S
| 1 | module |
| 2 | |
| 3 | public import Mathlib.NumberTheory.Chebyshev |
| 4 | public import ConditionalGoldbach.Proofs.Weights |
| 5 | |
| 6 | /-! Removal of pairs containing a proper prime power from the weighted correlation. -/ |
| 7 | @[expose] public section |
| 8 | |
| 9 | set_option autoImplicit false |
| 10 | noncomputable section |
| 11 | open scoped BigOperators ComplexConjugate Topology ContDiff |
| 12 | open MeasureTheory Filter Set Complex |
| 13 | namespace ConditionalGoldbach |
| 14 | attribute [local instance] Classical.propDecidable |
| 15 | |
| 16 | /-- The part of the original weighted correlation with at least one nonprime entry. |
| 17 | The original range, coprimality filter, and both weights are retained. -/ |
| 18 | def badGoldbachMass (N : ℕ) (φ : ℝ → ℝ) : ℝ := |
| 19 | (N : ℝ)⁻¹ * ∑ n ∈ Finset.range (N + 1), |
| 20 | if (0 < n ∧ n < N ∧ Nat.Coprime (n * (N - n)) N) ∧ |
| 21 | (¬n.Prime ∨ ¬(N - n).Prime) then |
| 22 | mangoldt n * mangoldt (N - n) * φ (n / N) * φ ((N - n : ℕ) / N) |
| 23 | else 0 |
| 24 | |
| 25 | theorem mangoldt_le_log_of_le {n N : ℕ} (hN : 0 < N) (hn : n ≤ N) : |
| 26 | mangoldt n ≤ Real.log N := by |
| 27 | by_cases hzero : n = 0 |
| 28 | · subst n |
| 29 | simpa [mangoldt] using Real.log_nonneg (show (1 : ℝ) ≤ N by exact_mod_cast hN) |
| 30 | · have hnpos : 0 < n := Nat.pos_of_ne_zero hzero |
| 31 | exact ArithmeticFunction.vonMangoldt_le_log.trans |
| 32 | (Real.log_le_log (by exact_mod_cast hnpos) (by exact_mod_cast hn)) |
| 33 | |
| 34 | theorem sum_nonprime_mangoldt_eq_psi_sub_theta (N : ℕ) : |
| 35 | (∑ n ∈ Finset.range (N + 1), if ¬n.Prime then mangoldt n else 0) = |
| 36 | Chebyshev.psi N - Chebyshev.theta N := by |
| 37 | rw [Chebyshev.psi_sub_theta_eq_sum_not_prime, Nat.floor_natCast, Finset.sum_filter] |
| 38 | change (∑ n ∈ Finset.range (N + 1), if ¬n.Prime then mangoldt n else 0) = |
| 39 | ∑ n ∈ Finset.Ioc 0 N, if ¬n.Prime then mangoldt n else 0 |
| 40 | symm |
| 41 | apply Finset.sum_subset |
| 42 | · intro n hn |
| 43 | exact Finset.mem_range.mpr (Nat.lt_succ_of_le (Finset.mem_Ioc.mp hn).2) |
| 44 | · intro n hn hnot |
| 45 | have hn0 : n = 0 := by |
| 46 | simp only [Finset.mem_range, Finset.mem_Ioc, not_and] at hn hnot |
| 47 | omega |
| 48 | subst n |
| 49 | simp [mangoldt] |
| 50 | |
| 51 | theorem badGoldbachMass_le_psi_sub_theta (N : ℕ) (hN : 0 < N) |
| 52 | (φ : ℝ → ℝ) (hφ : IsWeight φ) : |
| 53 | badGoldbachMass N φ ≤ (2 * Real.log N / N) * |
| 54 | (Chebyshev.psi N - Chebyshev.theta N) := by |
| 55 | have hNpos : (0 : ℝ) < N := by exact_mod_cast hN |
| 56 | have hlog : 0 ≤ Real.log N := Real.log_nonneg (by exact_mod_cast hN) |
| 57 | have hterm (n : ℕ) (hn : n ∈ Finset.range (N + 1)) : |
| 58 | (if (0 < n ∧ n < N ∧ Nat.Coprime (n * (N - n)) N) ∧ |
| 59 | (¬n.Prime ∨ ¬(N - n).Prime) then |
| 60 | mangoldt n * mangoldt (N - n) * φ (n / N) * φ ((N - n : ℕ) / N) |
| 61 | else 0) ≤ |
| 62 | Real.log N * (if ¬n.Prime then mangoldt n else 0) + |
| 63 | Real.log N * (if ¬(N - n).Prime then mangoldt (N - n) else 0) := by |
| 64 | have hnle : n ≤ N := Nat.le_of_lt_succ (Finset.mem_range.mp hn) |
| 65 | have hvn : 0 ≤ mangoldt n := ArithmeticFunction.vonMangoldt_nonneg |
| 66 | have hvm : 0 ≤ mangoldt (N - n) := ArithmeticFunction.vonMangoldt_nonneg |
| 67 | have hnlog := mangoldt_le_log_of_le hN hnle |
| 68 | have hmlog := mangoldt_le_log_of_le hN (Nat.sub_le N n) |
| 69 | have hprod : 0 ≤ mangoldt n * mangoldt (N - n) := mul_nonneg hvn hvm |
| 70 | have hweight : mangoldt n * mangoldt (N - n) * φ (n / N) * |
| 71 | φ ((N - n : ℕ) / N) ≤ mangoldt n * mangoldt (N - n) := by |
| 72 | calc |
| 73 | _ ≤ mangoldt n * mangoldt (N - n) * φ (n / N) := |
| 74 | mul_le_of_le_one_right (mul_nonneg hprod (hφ.nonneg _)) (hφ.le_one _) |
| 75 | _ ≤ _ := mul_le_of_le_one_right hprod (hφ.le_one _) |
| 76 | have hleft : mangoldt n * mangoldt (N - n) * φ (n / N) * |
| 77 | φ ((N - n : ℕ) / N) ≤ Real.log N * mangoldt n := by |
| 78 | exact hweight.trans (by nlinarith) |
| 79 | have hright : mangoldt n * mangoldt (N - n) * φ (n / N) * |
| 80 | φ ((N - n : ℕ) / N) ≤ Real.log N * mangoldt (N - n) := by |
| 81 | exact hweight.trans (mul_le_mul_of_nonneg_right hnlog hvm) |
| 82 | have hnpart : 0 ≤ Real.log N * (if ¬n.Prime then mangoldt n else 0) := by |
| 83 | split_ifs <;> positivity |
| 84 | have hmpart : 0 ≤ Real.log N * (if ¬(N - n).Prime then mangoldt (N - n) else 0) := by |
| 85 | split_ifs <;> positivity |
| 86 | by_cases h : (0 < n ∧ n < N ∧ Nat.Coprime (n * (N - n)) N) ∧ |
| 87 | (¬n.Prime ∨ ¬(N - n).Prime) |
| 88 | · rw [ite_eq_left h] |
| 89 | rcases h.2 with hnp | hmp |
| 90 | · simpa only [ite_eq_left hnp] using le_add_of_le_of_nonneg hleft hmpart |
| 91 | · simpa only [ite_eq_left hmp] using le_add_of_nonneg_of_le hnpart hright |
| 92 | · rw [ite_eq_right h] |
| 93 | exact add_nonneg hnpart hmpart |
| 94 | have hreflect : (∑ n ∈ Finset.range (N + 1), |
| 95 | if ¬(N - n).Prime then mangoldt (N - n) else 0) = |
| 96 | ∑ n ∈ Finset.range (N + 1), if ¬n.Prime then mangoldt n else 0 := by |
| 97 | simpa using Finset.sum_range_reflect |
| 98 | (fun n => if ¬n.Prime then mangoldt n else 0) (N + 1) |
| 99 | unfold badGoldbachMass |
| 100 | calc |
| 101 | _ ≤ (N : ℝ)⁻¹ * ∑ n ∈ Finset.range (N + 1), |
| 102 | (Real.log N * (if ¬n.Prime then mangoldt n else 0) + |
| 103 | Real.log N * (if ¬(N - n).Prime then mangoldt (N - n) else 0)) := |
| 104 | mul_le_mul_of_nonneg_left (Finset.sum_le_sum hterm) (inv_nonneg.mpr hNpos.le) |
| 105 | _ = _ := by |
| 106 | rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum, hreflect, |
| 107 | sum_nonprime_mangoldt_eq_psi_sub_theta] |
| 108 | ring |
| 109 | |
| 110 | theorem badGoldbachMass_le_sqrt (N : ℕ) (hN : 0 < N) |
| 111 | (φ : ℝ → ℝ) (hφ : IsWeight φ) : |
| 112 | badGoldbachMass N φ ≤ 4 * Real.log N ^ 2 / Real.sqrt N := by |
| 113 | have hNpos : (0 : ℝ) < N := by exact_mod_cast hN |
| 114 | have hN1 : (1 : ℝ) ≤ N := by exact_mod_cast hN |
| 115 | have hlog : 0 ≤ Real.log N := Real.log_nonneg hN1 |
| 116 | have hsqrt : 0 < Real.sqrt N := Real.sqrt_pos.mpr hNpos |
| 117 | calc |
| 118 | _ ≤ (2 * Real.log N / N) * (Chebyshev.psi N - Chebyshev.theta N) := |
| 119 | badGoldbachMass_le_psi_sub_theta N hN φ hφ |
| 120 | _ ≤ (2 * Real.log N / N) * (2 * Real.sqrt N * Real.log N) := |
| 121 | mul_le_mul_of_nonneg_left (Chebyshev.psi_sub_theta_le hN1) |
| 122 | (div_nonneg (mul_nonneg (by norm_num) hlog) hNpos.le) |
| 123 | _ = _ := by |
| 124 | field_simp |
| 125 | have hs := congrArg (fun x : ℝ => 4 * Real.log N ^ 2 * x) (Real.sq_sqrt hNpos.le) |
| 126 | nlinarith only [hs] |
| 127 | |
| 128 | |
| 129 | theorem goldbach_le_badGoldbachMass_add_primePairCount (N : ℕ) (hN : 0 < N) |
| 130 | (φ : ℝ → ℝ) (hφ : IsWeight φ) : |
| 131 | goldbach N φ ≤ badGoldbachMass N φ + |
| 132 | (Real.log N ^ 2 / N) * (PrimePairCount N : ℝ) := by |
| 133 | have hNpos : (0 : ℝ) < N := by exact_mod_cast hN |
| 134 | have hlog : 0 ≤ Real.log N := Real.log_nonneg (by exact_mod_cast hN) |
| 135 | let good : ℕ → Prop := fun n => n.Prime ∧ (N - n).Prime ∧ |
| 136 | (N : ℝ) / 3 ≤ n ∧ (n : ℝ) ≤ 2 * N / 3 |
| 137 | have hind (n : ℕ) : 0 ≤ (if good n then Real.log N ^ 2 else 0) := by |
| 138 | split_ifs <;> positivity |
| 139 | have hterm (n : ℕ) (hn : n ∈ Finset.range (N + 1)) : |
| 140 | (if 0 < n ∧ n < N ∧ Nat.Coprime (n * (N - n)) N then |
| 141 | mangoldt n * mangoldt (N - n) * φ (n / N) * φ ((N - n : ℕ) / N) |
| 142 | else 0) ≤ |
| 143 | (if (0 < n ∧ n < N ∧ Nat.Coprime (n * (N - n)) N) ∧ |
| 144 | (¬n.Prime ∨ ¬(N - n).Prime) then |
| 145 | mangoldt n * mangoldt (N - n) * φ (n / N) * φ ((N - n : ℕ) / N) |
| 146 | else 0) + (if good n then Real.log N ^ 2 else 0) := by |
| 147 | by_cases hc : 0 < n ∧ n < N ∧ Nat.Coprime (n * (N - n)) N |
| 148 | · rw [ite_eq_left hc] |
| 149 | by_cases hb : ¬n.Prime ∨ ¬(N - n).Prime |
| 150 | · rw [ite_eq_left ⟨hc, hb⟩] |
| 151 | exact le_add_of_nonneg_right (hind n) |
| 152 | · have hbad : ¬((0 < n ∧ n < N ∧ Nat.Coprime (n * (N - n)) N) ∧ |
| 153 | (¬n.Prime ∨ ¬(N - n).Prime)) := fun h => hb h.2 |
| 154 | rw [ite_eq_right hbad, zero_add] |
| 155 | by_cases hz : φ ((n : ℝ) / N) = 0 |
| 156 | · simp only [hz, mul_zero, zero_mul] |
| 157 | exact hind n |
| 158 | · have hs := hφ.mem_support_interval hz |
| 159 | have hg : good n := by |
| 160 | have hp : n.Prime ∧ (N - n).Prime := by tauto |
| 161 | refine ⟨hp.1, hp.2, ?_, ?_⟩ |
| 162 | · have hh := (le_div_iff₀ hNpos).mp hs.1 |
| 163 | linarith |
| 164 | · have hh := (div_le_iff₀ hNpos).mp hs.2 |
| 165 | linarith |
| 166 | rw [ite_eq_left hg] |
| 167 | have hnle : n ≤ N := Nat.le_of_lt_succ (Finset.mem_range.mp hn) |
| 168 | have hvn : 0 ≤ mangoldt n := ArithmeticFunction.vonMangoldt_nonneg |
| 169 | have hvm : 0 ≤ mangoldt (N - n) := ArithmeticFunction.vonMangoldt_nonneg |
| 170 | have hnlog := mangoldt_le_log_of_le hN hnle |
| 171 | have hmlog := mangoldt_le_log_of_le hN (Nat.sub_le N n) |
| 172 | have hprod : 0 ≤ mangoldt n * mangoldt (N - n) := mul_nonneg hvn hvm |
| 173 | calc |
| 174 | _ ≤ mangoldt n * mangoldt (N - n) * φ (n / N) := |
| 175 | mul_le_of_le_one_right (mul_nonneg hprod (hφ.nonneg _)) (hφ.le_one _) |
| 176 | _ ≤ mangoldt n * mangoldt (N - n) := |
| 177 | mul_le_of_le_one_right hprod (hφ.le_one _) |
| 178 | _ ≤ Real.log N * Real.log N := |
| 179 | mul_le_mul hnlog hmlog hvm hlog |
| 180 | _ = _ := by ring |
| 181 | · rw [ite_eq_right hc, ite_eq_right (fun h => hc h.1), zero_add] |
| 182 | exact hind n |
| 183 | have hcount : (∑ n ∈ Finset.range (N + 1), if good n then Real.log N ^ 2 else 0) = |
| 184 | (PrimePairCount N : ℝ) * Real.log N ^ 2 := by |
| 185 | rw [← Finset.sum_filter] |
| 186 | simp only [Finset.sum_const, nsmul_eq_mul] |
| 187 | rfl |
| 188 | unfold goldbach badGoldbachMass |
| 189 | calc |
| 190 | _ ≤ (N : ℝ)⁻¹ * ∑ n ∈ Finset.range (N + 1), |
| 191 | ((if (0 < n ∧ n < N ∧ Nat.Coprime (n * (N - n)) N) ∧ |
| 192 | (¬n.Prime ∨ ¬(N - n).Prime) then |
| 193 | mangoldt n * mangoldt (N - n) * φ (n / N) * φ ((N - n : ℕ) / N) |
| 194 | else 0) + (if good n then Real.log N ^ 2 else 0)) := |
| 195 | mul_le_mul_of_nonneg_left (Finset.sum_le_sum hterm) (inv_nonneg.mpr hNpos.le) |
| 196 | _ = _ := by |
| 197 | rw [Finset.sum_add_distrib, mul_add, hcount] |
| 198 | ring |
| 199 | |
| 200 | |
| 201 | end ConditionalGoldbach |
