| | @@ -0,0 +1,312 @@ |
| 1 | +import ErdosSwarm.Erdos30HZ |
| 2 | +import ErdosSwarm.Erdos30SmoothedEnergy |
| 3 | +import ErdosSwarm.Erdos30Turan |
| 4 | + |
| 5 | +/-! |
| 6 | +# The Hou–Zhao transfer theorem for a single kernel |
| 7 | + |
| 8 | +We combine the boundary covering and smoothed energy bounds from Theorem 2.1 of |
| 9 | +Hou and Zhao (arXiv:2607.01169) and optimize the kernel width. |
| 10 | +-/ |
| 11 | + |
| 12 | +namespace ErdosSwarm.Erdos30 |
| 13 | + |
| 14 | +open Finset Filter |
| 15 | +open scoped Pointwise |
| 16 | + |
| 17 | +/-- A symmetric probability vector and boundary weights satisfying the covering conditions |
| 18 | +of Hou and Zhao. -/ |
| 19 | +structure HZCertificate where |
| 20 | + m : ℕ |
| 21 | + m_pos : 0 < m |
| 22 | + L : ℕ |
| 23 | + p : ℕ → ℝ |
| 24 | + w : ℕ → ℝ |
| 25 | + nonneg : ∀ i < m, 0 ≤ p i |
| 26 | + mass : ∑ i ∈ range m, p i = 1 |
| 27 | + symmetry : ∀ i < m, p (m - 1 - i) = p i |
| 28 | + cover : ∀ q ≤ L * m, 1 ≤ ∑ i ∈ range m, p i * boundaryWeight (L * m) w (q + i) |
| 29 | + |
| 30 | +noncomputable def HZCertificate.a (cert : HZCertificate) : ℝ := |
| 31 | + cert.m * ∑ i ∈ range cert.m, cert.p i ^ 2 |
| 32 | + |
| 33 | +noncomputable def HZCertificate.b (cert : HZCertificate) : ℝ := |
| 34 | + 1 + 2 * ((∑ j ∈ range (cert.L * cert.m), cert.w j ^ 2) / cert.m - cert.L) |
| 35 | + |
| 36 | +private theorem HZCertificate.a_pos (cert : HZCertificate) : 0 < cert.a := by |
| 37 | + unfold HZCertificate.a |
| 38 | + apply mul_pos (by exact_mod_cast cert.m_pos) |
| 39 | + obtain ⟨i, hi, hp⟩ : ∃ i ∈ range cert.m, cert.p i ≠ 0 := by |
| 40 | + by_contra! hz |
| 41 | + have := sum_eq_zero hz |
| 42 | + linarith [cert.mass] |
| 43 | + exact (sq_pos_of_ne_zero hp).trans_le |
| 44 | + (single_le_sum (fun j _ => sq_nonneg (cert.p j)) hi) |
| 45 | + |
| 46 | +/-- The finite master inequality of Hou and Zhao for a Sidon set in `[0,N)`. -/ |
| 47 | +theorem card_sq_le_certificate (cert : HZCertificate) {N h : ℕ} (hh : 0 < h) |
| 48 | + (hN : 2 * ((cert.L * cert.m) * h) ≤ N) {A : Finset ℕ} |
| 49 | + (hA : A ⊆ range N) (hS : IsSidon (A : Set ℕ)) : |
| 50 | + (A.card : ℝ) ^ 2 ≤ ((N : ℝ) - 1 + cert.b * ((cert.m : ℝ) * h)) * |
| 51 | + (1 + ((A.card : ℝ) - 1) * (cert.a / ((cert.m : ℝ) * h))) := by |
| 52 | + classical |
| 53 | + let H := cert.m * h |
| 54 | + let nz (n : ℕ) : ℤ := n |
| 55 | + have hnz : Function.Injective nz := fun x y e => by |
| 56 | + change (x : ℤ) = y at e |
| 57 | + exact_mod_cast e |
| 58 | + let S := (range H).image nz |
| 59 | + let J := (range (N + H - 1)).image nz |
| 60 | + let K (s : ℤ) := if 0 ≤ s then stepKernel cert.m h cert.p s.toNat else 0 |
| 61 | + let Q (n : ℤ) := table N cert.m h (cert.L * cert.m) cert.w n.toNat |
| 62 | + let u (n : ℤ) := ∑ a ∈ A, K (n - a) |
| 63 | + have hK (s : ℕ) : K (nz s) = stepKernel cert.m h cert.p s := by simp [K, nz] |
| 64 | + have hK0 (s : ℤ) : 0 ≤ K s := by |
| 65 | + unfold K |
| 66 | + split |
| 67 | + · exact stepKernel_nonneg cert.nonneg _ |
| 68 | + · exact le_rfl |
| 69 | + have hout : ∀ s ∉ S, K s = 0 := by |
| 70 | + intro s hs |
| 71 | + by_cases h0 : 0 ≤ s |
| 72 | + · have hh' : ¬ s.toNat < cert.m * h := fun hlt => |
| 73 | + hs (mem_image.mpr ⟨_, mem_range.mpr hlt, Int.toNat_of_nonneg h0⟩) |
| 74 | + simp only [K, if_pos h0, stepKernel, if_neg hh'] |
| 75 | + · simp [K, h0] |
| 76 | + have hsum : ∑ s ∈ S, K s = 1 := by |
| 77 | + rw [show S = (range H).image nz from rfl, sum_image hnz.injOn] |
| 78 | + simpa only [hK, H, sum_stepKernel hh] using cert.mass |
| 79 | + have hsq : ∑ s ∈ S, K s ^ 2 = cert.a / ((cert.m : ℝ) * h) := by |
| 80 | + rw [show S = (range H).image nz from rfl, sum_image hnz.injOn] |
| 81 | + simpa only [hK, H, HZCertificate.a] using sum_stepKernel_sq_normalized hh cert.m_pos cert.p |
| 82 | + have hQ : ∑ n ∈ J, Q n ^ 2 = (N : ℝ) - 1 + cert.b * ((cert.m : ℝ) * h) := by |
| 83 | + rw [show J = (range (N + H - 1)).image nz from rfl, sum_image hnz.injOn] |
| 84 | + simpa [Q, nz, H, HZCertificate.b] using |
| 85 | + (sum_table_sq_normalized (w := cert.w) hh cert.m_pos hN) |
| 86 | + have hshift {a : ℕ} (ha : a ∈ A) : S.image (fun s => nz a + s) ⊆ J := by |
| 87 | + intro n hn |
| 88 | + obtain ⟨s, hs, rfl⟩ := mem_image.mp hn |
| 89 | + obtain ⟨t, ht, rfl⟩ := mem_image.mp hs |
| 90 | + have ha' := mem_range.mp (hA ha) |
| 91 | + have ht' := mem_range.mp ht |
| 92 | + exact mem_image.mpr ⟨a + t, mem_range.mpr (by omega), Nat.cast_add a t⟩ |
| 93 | + have hlower : (A.card : ℝ) ≤ ∑ n ∈ J, Q n * u n := by |
| 94 | + simp only [u, mul_sum] |
| 95 | + rw [sum_comm, show (A.card : ℝ) = ∑ _a ∈ A, (1 : ℝ) by simp] |
| 96 | + apply sum_le_sum |
| 97 | + intro a ha |
| 98 | + have hc := table_cover (p := cert.p) (w := cert.w) hh hN (mem_range.mp (hA ha)) |
| 99 | + cert.mass cert.symmetry cert.cover |
| 100 | + refine hc.trans_eq ?_ |
| 101 | + rw [← sum_subset (hshift ha)] |
| 102 | + · rw [sum_image (fun _ _ _ _ e => add_left_cancel e), |
| 103 | + show S = (range H).image nz from rfl, sum_image hnz.injOn] |
| 104 | + apply sum_congr rfl |
| 105 | + intro s _ |
| 106 | + have haS : nz a + nz s - (a : ℤ) = nz s := by simp [nz] |
| 107 | + rw [haS, hK] |
| 108 | + have hcast : (nz a + nz s).toNat = a + s := by |
| 109 | + change ((a : ℤ) + (s : ℤ)).toNat = a + s |
| 110 | + rw [← Nat.cast_add, Int.toNat_natCast] |
| 111 | + dsimp only [Q] |
| 112 | + rw [hcast, mul_comm] |
| 113 | + · intro n _ hnot |
| 114 | + have hs : n - nz a ∉ S := fun hs => |
| 115 | + hnot (mem_image.mpr ⟨_, hs, by omega⟩) |
| 116 | + rw [hout _ hs, mul_zero] |
| 117 | + let T := A.image nz + S |
| 118 | + have hTJ : T ⊆ J := by |
| 119 | + intro n hn |
| 120 | + obtain ⟨a, ha, s, hs, rfl⟩ := mem_add.mp hn |
| 121 | + obtain ⟨x, hx, rfl⟩ := mem_image.mp ha |
| 122 | + exact hshift hx (mem_image_of_mem _ hs) |
| 123 | + have henergy : ∑ n ∈ J, u n ^ 2 ≤ |
| 124 | + 1 + ((A.card : ℝ) - 1) * (cert.a / ((cert.m : ℝ) * h)) := by |
| 125 | + rw [← sum_subset hTJ] |
| 126 | + · simpa only [T, u, nz, hsq] using smoothed_energy_le A hS S K hK0 hout hsum |
| 127 | + · intro n _ hn |
| 128 | + have hu : u n = 0 := sum_eq_zero fun a ha => hout _ fun hs => |
| 129 | + hn (mem_add.mpr ⟨nz a, mem_image_of_mem _ ha, n - nz a, hs, by omega⟩) |
| 130 | + simp [hu] |
| 131 | + have hcs := sum_mul_sq_le_sq_mul_sq J Q u |
| 132 | + rw [hQ] at hcs |
| 133 | + have hQ0 : 0 ≤ (N : ℝ) - 1 + cert.b * ((cert.m : ℝ) * h) := by |
| 134 | + rw [← hQ] |
| 135 | + exact sum_nonneg (fun _ _ => sq_nonneg _) |
| 136 | + exact (pow_le_pow_left₀ (Nat.cast_nonneg _) hlower 2).trans |
| 137 | + (hcs.trans (mul_le_mul_of_nonneg_left henergy hQ0)) |
| 138 | + |
| 139 | + |
| 140 | +private theorem h_sq_le_certificate (cert : HZCertificate) {N h : ℕ} (hh : 0 < h) |
| 141 | + (hN : 2 * ((cert.L * cert.m) * h) ≤ N) : |
| 142 | + (_root_.Erdos30.h N : ℝ) ^ 2 ≤ ((N : ℝ) - 1 + cert.b * ((cert.m : ℝ) * h)) * |
| 143 | + (1 + ((_root_.Erdos30.h N : ℝ) - 1) * (cert.a / ((cert.m : ℝ) * h))) := by |
| 144 | + obtain ⟨F, hF, hS, hc⟩ := exists_eq_h N |
| 145 | + have bounds {x : ℕ} (hx : x ∈ F) : 1 ≤ x ∧ x ≤ N := mem_Icc.mp (hF hx) |
| 146 | + let shift (x : ℕ) := x - 1 |
| 147 | + have hshift : Set.InjOn shift ↑F := by |
| 148 | + intro x hx y hy he |
| 149 | + have hx' := (bounds hx).1 |
| 150 | + have hy' := (bounds hy).1 |
| 151 | + dsimp [shift] at he |
| 152 | + omega |
| 153 | + have hsub : F.image shift ⊆ range N := by |
| 154 | + intro x hx |
| 155 | + obtain ⟨y, hy, rfl⟩ := mem_image.mp hx |
| 156 | + have := bounds hy |
| 157 | + exact mem_range.mpr (by dsimp [shift]; omega) |
| 158 | + have hS' : IsSidon (↑(F.image shift) : Set ℕ) := by |
| 159 | + intro x hx y hy z hz v hv he |
| 160 | + obtain ⟨x', hx', rfl⟩ := mem_image.mp hx |
| 161 | + obtain ⟨y', hy', rfl⟩ := mem_image.mp hy |
| 162 | + obtain ⟨z', hz', rfl⟩ := mem_image.mp hz |
| 163 | + obtain ⟨v', hv', rfl⟩ := mem_image.mp hv |
| 164 | + have he' : x' + z' = y' + v' := by |
| 165 | + dsimp [shift] at he |
| 166 | + have hx₀ := (bounds hx').1 |
| 167 | + have hy₀ := (bounds hy').1 |
| 168 | + have hz₀ := (bounds hz').1 |
| 169 | + have hv₀ := (bounds hv').1 |
| 170 | + omega |
| 171 | + rcases hS x' hx' y' hy' z' hz' v' hv' he' with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ |
| 172 | + · exact Or.inl ⟨rfl, rfl⟩ |
| 173 | + · exact Or.inr ⟨rfl, rfl⟩ |
| 174 | + simpa only [card_image_of_injOn hshift, hc] using card_sq_le_certificate cert hh hN hsub hS' |
| 175 | + |
| 176 | +/-- A certificate with positive boundary coefficient gives the Hou–Zhao upper bound |
| 177 | +on the largest Sidon subset of `{1, …, N}`. -/ |
| 178 | +theorem h_le_sqrt_add_certificate (cert : HZCertificate) (hb : 0 < cert.b) : |
| 179 | + ∃ C : ℝ, ∀ᶠ N : ℕ in atTop, |
| 180 | + (_root_.Erdos30.h N : ℝ) ≤ |
| 181 | + Real.sqrt N + Real.sqrt (cert.a * cert.b) * (N : ℝ) ^ (4⁻¹ : ℝ) + C := by |
| 182 | + let c := Real.sqrt (cert.a / cert.b) |
| 183 | + let d := Real.sqrt (cert.a * cert.b) |
| 184 | + let D := cert.b * (cert.m : ℝ) |
| 185 | + let M := D + 3 * d + 4 * d ^ 2 + 4 * D * d |
| 186 | + have hc : 0 < c := Real.sqrt_pos.2 (div_pos cert.a_pos hb) |
| 187 | + have hd : 0 ≤ d := Real.sqrt_nonneg _ |
| 188 | + have hD : 0 ≤ D := mul_nonneg hb.le (Nat.cast_nonneg _) |
| 189 | + have hM : 0 ≤ M := by dsimp [M]; positivity |
| 190 | + have hc_sq : c ^ 2 = cert.a / cert.b := Real.sq_sqrt (div_nonneg cert.a_pos.le hb.le) |
| 191 | + have ha : cert.a = cert.b * c ^ 2 := by |
| 192 | + rw [hc_sq] |
| 193 | + field_simp |
| 194 | + have hbc : cert.b * c = d := by |
| 195 | + have hs : (cert.b * c) ^ 2 = cert.a * cert.b := by |
| 196 | + rw [ha] |
| 197 | + ring |
| 198 | + rw [show d = Real.sqrt (cert.a * cert.b) from rfl, ← hs, |
| 199 | + Real.sqrt_sq (mul_nonneg hb.le hc.le)] |
| 200 | + let R := max 1 (2 * (cert.L : ℝ) * (c + cert.m)) |
| 201 | + refine ⟨M, eventually_atTop.2 ⟨⌈R ^ 4⌉₊, ?_⟩⟩ |
| 202 | + intro N hN |
| 203 | + let q : ℝ := (N : ℝ) ^ (4⁻¹ : ℝ) |
| 204 | + have hq4 : q ^ 4 = N := by |
| 205 | + rw [show q = _ from rfl, ← Real.rpow_natCast, |
| 206 | + ← Real.rpow_mul (Nat.cast_nonneg _)] |
| 207 | + norm_num |
| 208 | + have hR : 1 ≤ R := le_max_left _ _ |
| 209 | + have hq0 : 0 ≤ q := Real.rpow_nonneg (Nat.cast_nonneg _) _ |
| 210 | + have hRq : R ≤ q := by |
| 211 | + apply le_of_pow_le_pow_left₀ (by decide : (4 : ℕ) ≠ 0) hq0 |
| 212 | + rw [hq4] |
| 213 | + exact (Nat.le_ceil _).trans (by exact_mod_cast hN) |
| 214 | + have hq1 : 1 ≤ q := hR.trans hRq |
| 215 | + have hq : 0 < q := lt_of_lt_of_le zero_lt_one hq1 |
| 216 | + have hN1 : 1 ≤ N := by |
| 217 | + have : 1 ≤ q ^ 4 := one_le_pow₀ hq1 |
| 218 | + rw [hq4] at this |
| 219 | + exact_mod_cast this |
| 220 | + have hsqrt : Real.sqrt N = q ^ 2 := by |
| 221 | + rw [← hq4, show q ^ 4 = (q ^ 2) ^ 2 by ring] |
| 222 | + exact Real.sqrt_sq (sq_nonneg _) |
| 223 | + -- Choose the block width so the total width lies between c * q^3 and c * q^3 + m. |
| 224 | + let h := ⌈c * q ^ 3 / (cert.m : ℝ)⌉₊ |
| 225 | + have hm : (0 : ℝ) < cert.m := by exact_mod_cast cert.m_pos |
| 226 | + have hh : 0 < h := Nat.ceil_pos.mpr (by positivity) |
| 227 | + let H := (cert.m : ℝ) * h |
| 228 | + have hH : 0 < H := mul_pos hm (by exact_mod_cast hh) |
| 229 | + have hlo : c * q ^ 3 ≤ H := by |
| 230 | + simpa only [H, mul_comm (cert.m : ℝ) (h : ℝ)] using |
| 231 | + (div_le_iff₀ hm).mp (Nat.le_ceil (c * q ^ 3 / (cert.m : ℝ))) |
| 232 | + have hhi : H ≤ c * q ^ 3 + cert.m := by |
| 233 | + have ht := (lt_div_iff₀ hm).mp (by |
| 234 | + have := Nat.ceil_lt_add_one (show 0 ≤ c * q ^ 3 / (cert.m : ℝ) by positivity) |
| 235 | + linarith : (h : ℝ) - 1 < c * q ^ 3 / (cert.m : ℝ)) |
| 236 | + dsimp [H] |
| 237 | + linarith |
| 238 | + have hq3 : 1 ≤ q ^ 3 := one_le_pow₀ hq1 |
| 239 | + have hL : 2 * (cert.L : ℝ) * H ≤ N := by |
| 240 | + calc |
| 241 | + _ ≤ (2 * (cert.L : ℝ)) * ((c + cert.m) * q ^ 3) := by |
| 242 | + apply mul_le_mul_of_nonneg_left (hhi.trans ?_) (by positivity) |
| 243 | + nlinarith only [mul_le_mul_of_nonneg_left hq3 (show (0 : ℝ) ≤ cert.m by positivity)] |
| 244 | + _ = (2 * (cert.L : ℝ) * (c + cert.m)) * q ^ 3 := by ring |
| 245 | + _ ≤ q * q ^ 3 := mul_le_mul_of_nonneg_right |
| 246 | + ((le_max_right 1 _).trans hRq) (by positivity) |
| 247 | + _ = N := by rw [← hq4]; ring |
| 248 | + have hL' : 2 * ((cert.L * cert.m) * h) ≤ N := by |
| 249 | + exact_mod_cast (show 2 * (((cert.L : ℝ) * cert.m) * h) ≤ N by |
| 250 | + simpa only [H, mul_assoc] using hL) |
| 251 | + let k : ℝ := _root_.Erdos30.h N |
| 252 | + have hk0 : 0 ≤ k := Nat.cast_nonneg _ |
| 253 | + have hk : k ≤ q ^ 2 + 3 * q := by |
| 254 | + simpa only [hsqrt] using h_le_sqrt_add N hN1 |
| 255 | + let P := (N : ℝ) - 1 + cert.b * H |
| 256 | + have hP0 : 0 ≤ P := by |
| 257 | + have : (1 : ℝ) ≤ N := by exact_mod_cast hN1 |
| 258 | + dsimp [P] |
| 259 | + linarith [mul_pos hb hH] |
| 260 | + have hP : P ≤ q ^ 4 + d * q ^ 3 + D := by |
| 261 | + have ht := mul_le_mul_of_nonneg_left hhi hb.le |
| 262 | + have he : cert.b * (c * q ^ 3 + cert.m) = d * q ^ 3 + D := by |
| 263 | + rw [← hbc] |
| 264 | + dsimp only [D] |
| 265 | + ring |
| 266 | + rw [he] at ht |
| 267 | + dsimp only [P] |
| 268 | + linarith only [ht, hq4] |
| 269 | + have haH0 : 0 ≤ cert.a / H := div_nonneg cert.a_pos.le hH.le |
| 270 | + have haH : cert.a / H ≤ d / q ^ 3 := by |
| 271 | + calc |
| 272 | + _ ≤ cert.a / (c * q ^ 3) := |
| 273 | + div_le_div_of_nonneg_left cert.a_pos.le (by positivity) hlo |
| 274 | + _ = _ := by |
| 275 | + rw [ha, ← hbc] |
| 276 | + field_simp |
| 277 | + have hr : 1 + (k - 1) * (cert.a / H) ≤ 1 + d / q + 3 * d / q ^ 2 := by |
| 278 | + have hmul := mul_le_mul (show k - 1 ≤ q ^ 2 + 3 * q by linarith) |
| 279 | + haH haH0 (by positivity : 0 ≤ q ^ 2 + 3 * q) |
| 280 | + have he : (q ^ 2 + 3 * q) * (d / q ^ 3) = d / q + 3 * d / q ^ 2 := by |
| 281 | + field_simp |
| 282 | + linarith |
| 283 | + have hr0 : 0 ≤ 1 + d / q + 3 * d / q ^ 2 := by positivity |
| 284 | + have hmaster : k ^ 2 ≤ (q ^ 4 + d * q ^ 3 + D) * |
| 285 | + (1 + d / q + 3 * d / q ^ 2) := |
| 286 | + (h_sq_le_certificate cert hh hL').trans |
| 287 | + ((mul_le_mul_of_nonneg_left hr hP0).trans (mul_le_mul_of_nonneg_right hP hr0)) |
| 288 | + -- The two terms of degree three give the coefficient 2 * d in the squared bound. |
| 289 | + have hprod : (q ^ 4 + d * q ^ 3 + D) * (1 + d / q + 3 * d / q ^ 2) = |
| 290 | + q ^ 4 + 2 * d * q ^ 3 + (3 * d + d ^ 2) * q ^ 2 + |
| 291 | + 3 * d ^ 2 * q + D + D * d / q + 3 * D * d / q ^ 2 := by |
| 292 | + field_simp |
| 293 | + ring |
| 294 | + have hq2 : 1 ≤ q ^ 2 := one_le_pow₀ hq1 |
| 295 | + have hqq : q ≤ q ^ 2 := by nlinarith [mul_nonneg hq.le (sub_nonneg.mpr hq1)] |
| 296 | + have hrem : (3 * d + d ^ 2) * q ^ 2 + 3 * d ^ 2 * q + D + D * d / q + |
| 297 | + 3 * D * d / q ^ 2 ≤ M * q ^ 2 := by |
| 298 | + have h1 : D * d / q ≤ D * d := div_le_self (by positivity) hq1 |
| 299 | + have h2 : 3 * D * d / q ^ 2 ≤ 3 * D * d := div_le_self (by positivity) hq2 |
| 300 | + have h3 := mul_le_mul_of_nonneg_left hqq (by positivity : 0 ≤ 3 * d ^ 2) |
| 301 | + have h4 := mul_le_mul_of_nonneg_left hq2 (by positivity : 0 ≤ D + 4 * D * d) |
| 302 | + dsimp [M] |
| 303 | + nlinarith only [h1, h2, h3, h4] |
| 304 | + rw [hprod] at hmaster |
| 305 | + rw [hsqrt] |
| 306 | + apply le_of_pow_le_pow_left₀ (by decide : (2 : ℕ) ≠ 0) |
| 307 | + (by positivity : 0 ≤ q ^ 2 + d * q + M) |
| 308 | + change k ^ 2 ≤ _ |
| 309 | + nlinarith only [hmaster, hrem, mul_nonneg hM (by positivity : 0 ≤ d * q), sq_nonneg M, |
| 310 | + sq_nonneg (d * q), mul_nonneg hM (sq_nonneg q)] |
| 311 | + |
| 312 | +end ErdosSwarm.Erdos30 |