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
fix: match the indicator means to their finite counts
Browse filesChecks
build Program · lake build and Comparator
Details
challenge Program · challenge files and build config
Details
+20 −15 ConditionalGoldbach/Proofs/ResidualAverage.lean View file
| @@ -28,7 +28,11 @@ def blockMean (u : ℕ → ℝ) (X : ℕ) : ℝ := prefixMean (fun j => u (X + j | ||
| 28 | 28 | |
| 29 | 29 | /-- The relative frequency of a set of indices in a finite prefix. -/ |
| 30 | 30 | def frequency (G : Set ℕ) (M : ℕ) : ℝ := |
| 31 | - (((range M).filter (· ∈ G)).card : ℝ) / M | |
| 31 | + prefixMean (fun j => if j ∈ G then 1 else 0) M | |
| 32 | + | |
| 33 | +theorem frequency_eq_card (G : Set ℕ) (M : ℕ) : | |
| 34 | + frequency G M = (((range M).filter (· ∈ G)).card : ℝ) / M := by | |
| 35 | + simp only [frequency, prefixMean, sum_boole] | |
| 32 | 36 | |
| 33 | 37 | /-- One set of positive even integers has relative natural density one, and along it the |
| 34 | 38 | nonnegative ratio is eventually below each positive threshold. -/ |
| @@ -46,14 +50,10 @@ private lemma prefixMean_mono {u v : ℕ → ℝ} (h : ∀ j, u j ≤ v j) (M : | ||
| 46 | 50 | |
| 47 | 51 | private lemma frequency_compl {G : Set ℕ} {M : ℕ} (hM : 0 < M) : |
| 48 | 52 | frequency Gᶜ M = 1 - frequency G M := by |
| 49 | - have h := (range M).card_filter_add_card_filter_not (fun j => j ∈ G) | |
| 50 | - rw [card_range] at h | |
| 51 | - have hr := congrArg (Nat.cast : ℕ → ℝ) h | |
| 52 | - push_cast at hr | |
| 53 | - unfold frequency | |
| 54 | - change _ / (M : ℝ) = 1 - _ / M | |
| 55 | - field_simp [show (M : ℝ) ≠ 0 by positivity] | |
| 56 | - linarith | |
| 53 | + have he (j : ℕ) : (if j ∈ Gᶜ then (1 : ℝ) else 0) = 1 - (if j ∈ G then 1 else 0) := by | |
| 54 | + by_cases hj : j ∈ G <;> simp [hj] | |
| 55 | + simp only [frequency, prefixMean, he, sum_sub_distrib, sum_const, card_range, nsmul_eq_mul, | |
| 56 | + mul_one, sub_div, div_self (Nat.cast_ne_zero.mpr hM.ne')] | |
| 57 | 57 | |
| 58 | 58 | private lemma frequency_compl_tendsto (G : Set ℕ) {l : ℝ} |
| 59 | 59 | (h : Tendsto (frequency G) atTop (𝓝 l)) : |
| @@ -74,7 +74,8 @@ private lemma extract_indices (u : ℕ → ℝ) (hu : ∀ j, 0 ≤ u j) | ||
| 74 | 74 | have hgpos (M : ℕ) : 0 < g M := by dsimp [g]; positivity |
| 75 | 75 | let G : Set ℕ := {j | ∃ M ≥ j, u j ≤ g M} |
| 76 | 76 | have hbad : Tendsto (frequency Gᶜ) atTop (𝓝 0) := by |
| 77 | - apply squeeze_zero (fun M => by unfold frequency; positivity) _ hg | |
| 77 | + apply squeeze_zero (fun M => prefixMean_nonneg | |
| 78 | + (u := fun j => if j ∈ Gᶜ then 1 else 0) (fun j => by split_ifs <;> norm_num) M) _ hg | |
| 78 | 79 | intro M |
| 79 | 80 | have hcount : ∑ j ∈ range M, (if j ∈ Gᶜ then g M else 0) ≤ ∑ j ∈ range M, u j := by |
| 80 | 81 | apply sum_le_sum |
| @@ -84,9 +85,12 @@ private lemma extract_indices (u : ℕ → ℝ) (hu : ∀ j, 0 ≤ u j) | ||
| 84 | 85 | · exact hu j |
| 85 | 86 | have hprod : frequency Gᶜ M * g M ≤ prefixMean u M := by |
| 86 | 87 | unfold frequency prefixMean |
| 87 | - rw [div_mul_eq_mul_div] | |
| 88 | + rw [div_mul_eq_mul_div, sum_mul] | |
| 88 | 89 | apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) |
| 89 | - simpa only [← sum_filter, sum_const, nsmul_eq_mul] using hcount | |
| 90 | + apply le_trans _ hcount | |
| 91 | + apply sum_le_sum | |
| 92 | + intro j _ | |
| 93 | + by_cases hj : j ∈ Gᶜ <;> simp [hj] | |
| 90 | 94 | have hs : prefixMean u M ≤ (g M) ^ 2 := by |
| 91 | 95 | rw [← Real.sq_sqrt (prefixMean_nonneg hu M)] |
| 92 | 96 | apply (sq_le_sq₀ (Real.sqrt_nonneg _) (hgpos M).le).mpr |
| @@ -139,7 +143,8 @@ theorem clippedMean_iff {r : ℕ → ℝ} (hr : ∀ N, 0 ≤ r N) : | ||
| 139 | 143 | hn (evenAt j) hjG (by unfold evenAt; omega) |
| 140 | 144 | · simpa [v, hjG] using hε |
| 141 | 145 | have hv2 : Tendsto (prefixMean fun j => v j ^ 2) atTop (𝓝 0) := by |
| 142 | - simpa [prefixMean, div_eq_inv_mul] using (hv.pow 2).cesaro | |
| 146 | + change Tendsto (fun M : ℕ => (∑ j ∈ range M, v j ^ 2) / M) atTop (𝓝 0) | |
| 147 | + simpa [div_eq_inv_mul] using (hv.pow 2).cesaro | |
| 143 | 148 | have hb : Tendsto (frequency Gᶜ) atTop (𝓝 0) := by |
| 144 | 149 | simpa using frequency_compl_tendsto G hd |
| 145 | 150 | apply squeeze_zero (prefixMean_nonneg hu) _ (by simpa using hv2.add hb) |
| @@ -149,8 +154,8 @@ theorem clippedMean_iff {r : ℕ → ℝ} (hr : ∀ N, 0 ≤ r N) : | ||
| 149 | 154 | apply prefixMean_mono |
| 150 | 155 | intro j |
| 151 | 156 | by_cases hj : j ∈ G |
| 152 | - · simpa [v, hj] using (min_le_right 1 (r (evenAt j) ^ 2)) | |
| 153 | - · simpa [v, hj] using (min_le_left 1 (r (evenAt j) ^ 2)) | |
| 157 | + · simp [v, u, hj] | |
| 158 | + · simp [v, u, hj] | |
| 154 | 159 | _ = _ := by simp [prefixMean, frequency, sum_add_distrib, add_div] |
| 155 | 160 | |
| 156 | 161 | /-- The untruncated dyadic block means also suffice. -/ |
