| | @@ -0,0 +1,162 @@ |
| 1 | +import ErdosSwarm.Erdos530Gap.WindowProfiles |
| 2 | + |
| 3 | +/-! |
| 4 | +# The five-window comparison for Erdős #530 |
| 5 | + |
| 6 | +The missing-tent estimate and the local count involve the same boundary |
| 7 | +profile. Subtracting it before applying Cauchy–Schwarz preserves the cross term |
| 8 | +in the row's squared integral. This is the discrete-to-integral inequality in |
| 9 | +the appendix of `experiments/erdos530/paper/gap.tex`. |
| 10 | +-/ |
| 11 | + |
| 12 | +namespace ErdosSwarm.Erdos530Gap |
| 13 | + |
| 14 | +open Finset MeasureTheory WindowAnalysis |
| 15 | + |
| 16 | +noncomputable section |
| 17 | + |
| 18 | +/-- Integrate the whole score-minus-boundary function against the smoothed |
| 19 | +density, and then transfer it back to the atoms. -/ |
| 20 | +private theorem correctedKernel_lower {M : ℕ} {S : Finset ℕ} (hS : S ⊆ host M) {τ κ z : ℝ} |
| 21 | + (hτ : 0 < τ) (hκ : κ = S.card / Real.sqrt M) (hκ' : κ ≤ 1) |
| 22 | + (hE : (∫ v, (density M S (τ / 10 ^ 10) v - κ) ^ 2 ∂unitVolume) ≤ (2001 / 1000) * τ) : |
| 23 | + let Φ := correctedKernel τ κ z |
| 24 | + κ * ((∫ v, Φ v ∂unitVolume) / τ) - |
| 25 | + (4 * Row.peak + 2 * Row.ramp 0 / 48) * (2 * (1 / 100000 : ℝ) ^ 2 + 3 / 100000) - |
| 26 | + Real.sqrt ((2001 / 1000) * Row.varianceBound τ κ z) ≤ atom M S Φ / τ := by |
| 27 | + let Φ := correctedKernel τ κ z |
| 28 | + let l := τ / 10 ^ 10 |
| 29 | + let f := density M S l |
| 30 | + obtain ⟨hΦ, hb⟩ := correctedKernel_movement (z := z) hS hτ hκ hκ' hE |
| 31 | + change MemLp Φ ⊤ unitVolume at hΦ |
| 32 | + have hc : MemLp (fun v => f v - κ) ⊤ unitVolume := (density_mem M S l).sub (memLp_const _) |
| 33 | + have cs := product_cauchy hc hΦ |
| 34 | + let I₂ := ∫ v, Φ v ^ 2 ∂unitVolume |
| 35 | + have hi : 0 ≤ I₂ := integral_nonneg (fun v => sq_nonneg (Φ v)) |
| 36 | + have var : Row.varianceBound τ κ z = I₂ / τ := by |
| 37 | + unfold I₂ Row.varianceBound |
| 38 | + rw [unit_integral] |
| 39 | + congr 1 |
| 40 | + apply intervalIntegral.integral_congr |
| 41 | + intro y _ |
| 42 | + dsimp only [Φ, correctedKernel, boundary] |
| 43 | + ring |
| 44 | + have cov : |∫ v, (f v - κ) * Φ v ∂unitVolume| ≤ τ * Real.sqrt ((2001 / 1000) * Row.varianceBound τ κ z) := by |
| 45 | + apply cs.trans |
| 46 | + change Real.sqrt (_ * I₂) ≤ _ |
| 47 | + calc |
| 48 | + _ ≤ Real.sqrt (((2001 / 1000) * τ) * I₂) := |
| 49 | + Real.sqrt_le_sqrt (mul_le_mul_of_nonneg_right hE hi) |
| 50 | + _ = _ := by |
| 51 | + rw [var, show ((2001 / 1000) * τ) * I₂ = τ ^ 2 * ((2001 / 1000) * (I₂ / τ)) by field_simp, |
| 52 | + Real.sqrt_mul (sq_nonneg τ), Real.sqrt_sq hτ.le] |
| 53 | + have split (v : ℝ) : f v * Φ v = (f v - κ) * Φ v + κ * Φ v := by ring |
| 54 | + have hf : (∫ v, f v * Φ v ∂unitVolume) = |
| 55 | + (∫ v, (f v - κ) * Φ v ∂unitVolume) + κ * (∫ v, Φ v ∂unitVolume) := by |
| 56 | + simp only [split, integral_add (product_integrable hc hΦ) ((hΦ.integrable le_top).const_mul κ), |
| 57 | + integral_const_mul] |
| 58 | + have hmove := (le_abs_self _).trans hb |
| 59 | + change (∫ v, f v * Φ v ∂unitVolume) - atom M S Φ ≤ _ at hmove |
| 60 | + rw [hf] at hmove |
| 61 | + dsimp only |
| 62 | + apply (le_div_iff₀ hτ).mpr |
| 63 | + have cancel : ((∫ v, Φ v ∂unitVolume) / τ) * τ = (∫ v, Φ v ∂unitVolume) := div_mul_cancel₀ _ hτ.ne' |
| 64 | + linarith only [(abs_le.mp cov).1, hmove, congrArg (κ * ·) cancel] |
| 65 | + |
| 66 | +private theorem normalized_missing {M : ℕ} (hM : 0 < M) {S : Finset ℕ} (hS : S ⊆ host M) |
| 67 | + (hsid : IsSidon (S : Set ℕ)) {τ κ : ℝ} (hτ : 0 < τ) (hτ' : τ ≤ 1 / 100) |
| 68 | + (hm : 10 ^ 14 / τ ^ 2 ≤ Real.sqrt M) (hk : κ = S.card / Real.sqrt M) |
| 69 | + (hlo : 1 - τ ≤ κ) (hhi : κ ≤ 1) : |
| 70 | + Row.missing M τ S / ((Real.sqrt M) ^ 2 * τ ^ 2) ≤ |
| 71 | + (70623 / 625) / (2 * 10 ^ 14) + 18785187 / 20000 + κ ^ 2 * (-48340875795333 / 16000000000) + |
| 72 | + κ / τ * atom M S (boundary τ) := by |
| 73 | + let m := Real.sqrt M |
| 74 | + have hm0 : 0 < m := Real.sqrt_pos.mpr (by exact_mod_cast hM) |
| 75 | + have hM' : (M : ℝ) = m ^ 2 := (Real.sq_sqrt (by positivity)).symm |
| 76 | + have heq : (S.card : ℝ) = κ * m := by rw [hk]; exact (div_mul_cancel₀ _ hm0.ne').symm |
| 77 | + have hsum : (∑ i ∈ S, boundary τ (Row.position M i)) = atom M S (boundary τ) * m := |
| 78 | + (div_mul_cancel₀ _ hm0.ne').symm |
| 79 | + have raw := missing_le hM hS hsid hτ hτ' |
| 80 | + rw [hM', heq, hsum] at raw |
| 81 | + have norm : Row.missing M τ S / (m ^ 2 * τ ^ 2) ≤ |
| 82 | + κ / (m * τ ^ 2) * (70623 / 625) / 2 + (1 - κ ^ 2) / (2 * τ) * (18785187 / 20000) + |
| 83 | + κ ^ 2 * (-48340875795333 / 16000000000) + κ / τ * atom M S (boundary τ) := by |
| 84 | + apply (div_le_iff₀ (by positivity)).mpr |
| 85 | + refine raw.trans_eq ?_ |
| 86 | + field_simp |
| 87 | + have hscale : 10 ^ 14 ≤ m * τ ^ 2 := (div_le_iff₀ (sq_pos_of_pos hτ)).mp hm |
| 88 | + have diag : κ / (m * τ ^ 2) ≤ 1 / 10 ^ 14 := by |
| 89 | + calc |
| 90 | + _ ≤ 1 / (m * τ ^ 2) := div_le_div_of_nonneg_right hhi (by positivity) |
| 91 | + _ ≤ _ := one_div_le_one_div_of_le (by norm_num) hscale |
| 92 | + have deficitTerm : (1 - κ ^ 2) / (2 * τ) ≤ 1 := by |
| 93 | + apply (div_le_iff₀ (by positivity)).mpr |
| 94 | + have h := sq_le_sq' (by linarith : -κ ≤ 1 - τ) hlo |
| 95 | + nlinarith only [h, sq_nonneg τ] |
| 96 | + exact norm.trans (by linarith only [diag, deficitTerm]) |
| 97 | + |
| 98 | +/-- The appendix's discrete-to-integral comparison for the fixed five-window |
| 99 | +row. Both endpoint ramps remain inside the same squared integrand as the local |
| 100 | +kernel. -/ |
| 101 | +theorem window_comparison {M x : ℕ} {τ : ℝ} {S : Finset ℕ} |
| 102 | + (hτ : 0 < τ) (hτ' : τ ≤ 1 / 100) (hm : 10 ^ 14 / τ ^ 2 ≤ Real.sqrt M) |
| 103 | + (hS : S ⊆ host M) (hsid : IsSidon (S : Set ℕ)) (hk : S.card = seedSize M τ) |
| 104 | + (hx : x ∈ exceptional M τ S) (hleft : 2 * x ≤ M + 1) : |
| 105 | + Row.lowerScore τ (S.card / Real.sqrt M) (Row.position M x) ≤ |
| 106 | + (Row.score M τ S x - Row.missing M τ S / (48 * τ * Real.sqrt M)) / |
| 107 | + (τ * Real.sqrt M) := by |
| 108 | + let m := Real.sqrt M |
| 109 | + let κ := S.card / m |
| 110 | + let z := Row.position M x |
| 111 | + let Φ := correctedKernel τ κ z |
| 112 | + have hx₁ := (mem_Icc.mp (mem_sdiff.mp (mem_filter.mp hx).1).1).1 |
| 113 | + have hM : 0 < M := by omega |
| 114 | + have hm₀ : 0 < m := Real.sqrt_pos.mpr (by exact_mod_cast hM) |
| 115 | + have hτm : 1 ≤ τ * m := by |
| 116 | + have hscale := (div_le_iff₀ (sq_pos_of_pos hτ)).mp hm |
| 117 | + have hsq : τ ^ 2 ≤ τ := by nlinarith only [mul_nonneg hτ.le (show 0 ≤ 1 - τ by linarith)] |
| 118 | + linarith only [hscale, mul_le_mul_of_nonneg_left hsq hm₀.le] |
| 119 | + have hlo : 1 - τ ≤ κ := (le_div_iff₀ hm₀).mpr (hk ▸ Nat.le_ceil _) |
| 120 | + have hhi : κ ≤ 1 := by |
| 121 | + have hc : (S.card : ℝ) < (1 - τ) * m + 1 := hk ▸ Nat.ceil_lt_add_one (mul_nonneg (by linarith) hm₀.le) |
| 122 | + exact (div_le_iff₀ hm₀).mpr (by linarith only [hc, hτm]) |
| 123 | + have hE := density_error hS hsid hτ hτ' hm hlo hhi |
| 124 | + have localBound := correctedKernel_lower (z := z) hS hτ (κ := κ) rfl hhi hE |
| 125 | + have Q := normalized_missing hM hS hsid hτ hτ' hm rfl hlo hhi |
| 126 | + have hΦ := (correctedKernel_movement (z := z) hS hτ (κ := κ) rfl hhi hE).1 |
| 127 | + change MemLp Φ ⊤ unitVolume at hΦ |
| 128 | + have hP : Integrable (boundary τ) unitVolume := by |
| 129 | + have h : Continuous (boundary τ) := by unfold boundary; fun_prop |
| 130 | + exact (h.intervalIntegrable 0 1).1 |
| 131 | + have mass : (∫ v, Φ v ∂unitVolume) / τ = Row.integralKernel τ z - κ / 48 * (512539084257 / 80000000) := by |
| 132 | + have pt (v : ℝ) : Row.localKernel τ z v = Φ v + κ / 48 * boundary τ v := by |
| 133 | + dsimp [Φ, correctedKernel]; ring |
| 134 | + have eq : (∫ v, Row.localKernel τ z v ∂unitVolume) = |
| 135 | + (∫ v, Φ v ∂unitVolume) + κ / 48 * (τ * (512539084257 / 80000000)) := by |
| 136 | + simp only [pt, integral_add (hΦ.integrable le_top) (hP.const_mul _), integral_const_mul] |
| 137 | + rw [unit_integral (boundary τ), boundary_integral hτ hτ'] |
| 138 | + unfold Row.integralKernel |
| 139 | + rw [← unit_integral, eq] |
| 140 | + field_simp |
| 141 | + ring |
| 142 | + have sample : atom M S Φ / τ = Row.score M τ S x / (τ * m) - (κ / τ * atom M S (boundary τ)) / 48 := by |
| 143 | + unfold atom Row.score |
| 144 | + simp only [Φ, correctedKernel, sum_sub_distrib, ← mul_sum, z] |
| 145 | + change _ / m / τ = _ / (τ * m) - (κ / τ * (_ / m)) / 48 |
| 146 | + field_simp |
| 147 | + change κ * ((∫ v, Φ v ∂unitVolume) / τ) - _ - _ ≤ atom M S Φ / τ at localBound |
| 148 | + rw [mass, sample] at localBound |
| 149 | + have rhs : (Row.score M τ S x - Row.missing M τ S / (48 * τ * m)) / (τ * m) = |
| 150 | + Row.score M τ S x / (τ * m) - (Row.missing M τ S / (m ^ 2 * τ ^ 2)) / 48 := by |
| 151 | + field_simp |
| 152 | + have hκ0 : 0 ≤ κ := by dsimp [κ]; positivity |
| 153 | + have hk2 : κ ^ 2 ≤ 1 := by nlinarith only [mul_nonneg hκ0 (sub_nonneg.mpr hhi), hhi] |
| 154 | + change Row.lowerScore τ κ z ≤ (Row.score M τ S x - Row.missing M τ S / (48 * τ * m)) / (τ * m) |
| 155 | + rw [rhs] |
| 156 | + unfold Row.lowerScore Row.smoothingError |
| 157 | + change Row.missing M τ S / (m ^ 2 * τ ^ 2) ≤ _ at Q |
| 158 | + linarith only [localBound, Q, hk2] |
| 159 | + |
| 160 | +end |
| 161 | + |
| 162 | +end ErdosSwarm.Erdos530Gap |