| | @@ -1,16 +1,20 @@ |
| 1 | 1 | import ErdosSwarm.Erdos530Gap103.Data |
| 2 | 2 | |
| 3 | 3 | /-! |
| 4 | | −# The energy bound of §3 for the 102/103 upper bound in Erdős #530 |
| 4 | +# The charging lemmas of §3 for the 102/103 upper bound in Erdős #530 |
| 5 | 5 | |
| 6 | | −`missing_energy` is lemma 6 of the plan in `ErdosSwarm/Erdos530Gap103/Plan.lean` |
| 7 | | −(§3 of `experiments/erdos530/upper-new-cover/NOTES.md`, row `R = 32`): for a Sidon set |
| 8 | | −`S ⊆ [1, M]`, |
| 6 | +Lemmas 5 and 6 of the plan in `ErdosSwarm/Erdos530Gap103/Plan.lean` (§3 of |
| 7 | +`experiments/erdos530/upper-new-cover/NOTES.md`, row `R = 32`). Both are unconditional, but |
| 8 | +they are inputs of the plan, not bounds on `ℓ(N)`. |
| 9 | + |
| 10 | +## `missing_energy` |
| 11 | + |
| 12 | +For a Sidon set `S ⊆ [1, M]`, |
| 9 | 13 | |
| 10 | 14 | `2 Q + ∑_{a, a' ∈ S} W(u_a − u_a') ≤ M/32 + |S| W(0)`, |
| 11 | 15 | |
| 12 | 16 | where `Q` is the kernel weight of the positive integers up to `M` that are not differences |
| 13 | | −of `S`. It is unconditional, but it is one input of the plan, not a bound on `ℓ(N)`. |
| 17 | +of `S`. |
| 14 | 18 | |
| 15 | 19 | Proof. By Sidon uniqueness the ordered pairs `a' < a` of `S` correspond one to one to the |
| 16 | 20 | differences of `S`, so the double sum is `|S| W(0)` plus twice the kernel weight of the |
| | @@ -18,6 +22,26 @@ differences, and the left side is `|S| W(0) + 2 ∑_{d = 1}^{M} W(32 d/M)`. Each |
| 18 | 22 | tents of `W` is `max(0, 1 − d t)` at `d`, and `∑_{d = 1}^{n} max(0, 1 − d t) ≤ 1/(2t)`: |
| 19 | 23 | while `n t ≤ 1` the sum is `n − t n(n+1)/2`, and `1/(2t)` minus this is |
| 20 | 24 | `((1 − n t)² + n t²)/(2t)`; later terms vanish. So `∑_{d = 1}^{M} W(32 d/M) ≤ M/64`. |
| 25 | + |
| 26 | +## `second_occurrence` |
| 27 | + |
| 28 | +For `S ⊆ [1, M]`, outsiders `B ⊆ [1, M] \ S`, and a set `P ⊆ B × S` of incidences whose |
| 29 | +lengths `|x − a|` are not differences of `S` and in which two distinct incidences of equal |
| 30 | +length are `(x, a)` and `(g_x(a), g_x(x))`, |
| 31 | + |
| 32 | +`∑_{x ∈ B} ∑_{a ∈ S} (z(u_a − u_x) − v(u_a − u_x) ψ(u_{g_x(a)})) ≤ |
| 33 | + Q + c |B| (|B| − ∑_{y ∈ B} ψ(u_y)) + W(0) |(B × S) \ P|`. |
| 34 | + |
| 35 | +Proof. An incidence outside `P` costs at most `z ≤ W ≤ W(0)`. Group `P` by length `d`. A |
| 36 | +class has one or two elements, because a second incidence of the same length is determined |
| 37 | +by the first. A class of one costs at most `z(d) ≤ W(d)`. In a class `{(x, a), (y, b)}`, |
| 38 | +`y = g_x(a)` and `x = g_y(b)`, so its cost is |
| 39 | +`2 z(d) − v(d) ψ(u_y) − v(d) ψ(u_x) = W(d) + v(d)(1 − ψ(u_y)) + v(d)(1 − ψ(u_x))`, at most |
| 40 | +`W(d)` plus the charges `c (1 − ψ(u_y))` on `(x, a)` and `c (1 − ψ(u_x))` on `(y, b)` |
| 41 | +(`0 ≤ v ≤ c`, `ψ ≤ 1`). The lengths of `P` are not differences of `S` and lie in `[1, M]`, |
| 42 | +so the `W(d)` sum to at most `Q`. For a fixed `x` the charged points `g_x(a)` are distinct |
| 43 | +points of `B` (`g_x` is injective), so the charges on the row of `x` sum to at most |
| 44 | +`∑_{y ∈ B} c (1 − ψ(u_y))`, and there are `|B|` rows. The hypothesis `0 < M` is not used. |
| 21 | 45 | -/ |
| 22 | 46 | |
| 23 | 47 | namespace ErdosSwarm.Erdos530Gap103 |
| | @@ -192,4 +216,229 @@ theorem missing_energy {M : ℕ} {S : Finset ℕ} (hM : 0 < M) (hS : S ⊆ host |
| 192 | 216 | change 2 * missingWeight M S + ∑ p ∈ S ×ˢ S, f p ≤ _ |
| 193 | 217 | linarith |
| 194 | 218 | |
| 219 | +/-! ## The second occurrence -/ |
| 220 | + |
| 221 | +private theorem kernel_le_zero (y : ℝ) : kernel y ≤ kernel 0 := by |
| 222 | + have h1 : max 0 (1 - |y| / 7) ≤ 1 := max_le zero_le_one (by linarith only [abs_nonneg y]) |
| 223 | + have h2 : max 0 (1 - 24 * |y|) ≤ 1 := max_le zero_le_one (by linarith only [abs_nonneg y]) |
| 224 | + have h0 : kernel 0 = 17 / 25 / 7 + 8 / 25 * 24 := by norm_num [kernel] |
| 225 | + rw [h0] |
| 226 | + unfold kernel |
| 227 | + linarith only [h1, h2] |
| 228 | + |
| 229 | +private theorem vCharge_nonneg (y : ℝ) : 0 ≤ vCharge y := |
| 230 | + le_min (by linarith only [kernel_nonneg y]) (by norm_num [cCharge]) |
| 231 | + |
| 232 | +private theorem vCharge_le (y : ℝ) : vCharge y ≤ cCharge := min_le_right _ _ |
| 233 | + |
| 234 | +private theorem zScore_le_kernel (y : ℝ) : zScore y ≤ kernel y := by |
| 235 | + unfold zScore |
| 236 | + linarith only [show vCharge y ≤ kernel y / 2 from min_le_left _ _] |
| 237 | + |
| 238 | +/-- The kernel at the coordinate difference of an incidence depends only on its length. -/ |
| 239 | +private theorem kernel_coord_sub (M : ℕ) (a x : ℕ) : |
| 240 | + kernel (coord M a - coord M x) = kernel (32 * (((x : ℤ) - a).natAbs : ℝ) / M) := by |
| 241 | + have e : coord M (a : ℤ) - coord M (x : ℤ) = 32 * ((a : ℝ) - x) / M := by |
| 242 | + unfold coord |
| 243 | + push_cast |
| 244 | + ring |
| 245 | + have habs : (((x : ℤ) - a).natAbs : ℝ) = |(a : ℝ) - x| := by |
| 246 | + rw [Nat.cast_natAbs, Int.cast_abs, abs_sub_comm] |
| 247 | + push_cast |
| 248 | + rfl |
| 249 | + have h : |32 * ((a : ℝ) - x) / M| = |32 * |(a : ℝ) - x| / M| := by |
| 250 | + rw [abs_div, abs_div, abs_mul, abs_mul, abs_abs] |
| 251 | + unfold kernel |
| 252 | + rw [e, habs, h] |
| 253 | + |
| 254 | +private theorem iso_injective (g : Bool × ℤ) : Function.Injective (iso g) := by |
| 255 | + intro z z' h |
| 256 | + unfold iso at h |
| 257 | + split_ifs at h <;> omega |
| 258 | + |
| 259 | +/-- The cost of the incidence `p = (x, a)`. -/ |
| 260 | +private noncomputable def cost (M : ℕ) (g : ℕ → Bool × ℤ) (p : ℕ × ℕ) : ℝ := |
| 261 | + zScore (coord M p.2 - coord M p.1) - |
| 262 | + vCharge (coord M p.2 - coord M p.1) * psi (coord M (iso (g p.1) p.2)) |
| 263 | + |
| 264 | +/-- The charge `c (1 − ψ(u_y))` put on the incidence `(x, a)` when `y = g_x(a)` is a point |
| 265 | +of `B`. -/ |
| 266 | +private noncomputable def partnerCharge (M : ℕ) (g : ℕ → Bool × ℤ) (B : Finset ℕ) |
| 267 | + (p : ℕ × ℕ) : ℝ := |
| 268 | + if ∃ y ∈ B, (y : ℤ) = iso (g p.1) p.2 then |
| 269 | + cCharge * (1 - psi (coord M (iso (g p.1) p.2))) else 0 |
| 270 | + |
| 271 | +private theorem partnerCharge_nonneg (M : ℕ) (g : ℕ → Bool × ℤ) (B : Finset ℕ) (p : ℕ × ℕ) : |
| 272 | + 0 ≤ partnerCharge M g B p := by |
| 273 | + unfold partnerCharge |
| 274 | + split_ifs |
| 275 | + · exact mul_nonneg (by norm_num [cCharge]) (sub_nonneg.mpr (psi_le_one _)) |
| 276 | + · exact le_rfl |
| 277 | + |
| 278 | +/-- An incidence costs at most the kernel at its length. -/ |
| 279 | +private theorem cost_le_kernel (M : ℕ) (g : ℕ → Bool × ℤ) (p : ℕ × ℕ) : |
| 280 | + cost M g p ≤ kernel (32 * (((p.1 : ℤ) - p.2).natAbs : ℝ) / M) := by |
| 281 | + rw [← kernel_coord_sub] |
| 282 | + unfold cost |
| 283 | + linarith only [zScore_le_kernel (coord M p.2 - coord M p.1), |
| 284 | + mul_nonneg (vCharge_nonneg (coord M p.2 - coord M p.1)) |
| 285 | + (psi_nonneg (coord M (iso (g p.1) p.2)))] |
| 286 | + |
| 287 | +/-- An incidence whose partner's outsider is in `B` costs at most half the kernel at its |
| 288 | +length plus the partner charge. -/ |
| 289 | +private theorem cost_le_half (M : ℕ) (g : ℕ → Bool × ℤ) (B : Finset ℕ) (p : ℕ × ℕ) |
| 290 | + (h : ∃ y ∈ B, (y : ℤ) = iso (g p.1) p.2) : |
| 291 | + cost M g p ≤ kernel (32 * (((p.1 : ℤ) - p.2).natAbs : ℝ) / M) / 2 + |
| 292 | + partnerCharge M g B p := by |
| 293 | + rw [← kernel_coord_sub] |
| 294 | + unfold cost partnerCharge zScore |
| 295 | + rw [if_pos h] |
| 296 | + have h1 := mul_le_mul_of_nonneg_right (vCharge_le (coord M p.2 - coord M p.1)) |
| 297 | + (sub_nonneg.mpr (psi_le_one (coord M (iso (g p.1) p.2)))) |
| 298 | + linarith only [h1] |
| 299 | + |
| 300 | +/-- For a fixed outsider `x` the partner charges are carried by distinct points of `B`. -/ |
| 301 | +private theorem partnerCharge_row (M : ℕ) (g : ℕ → Bool × ℤ) (B S : Finset ℕ) (x : ℕ) : |
| 302 | + ∑ a ∈ S, partnerCharge M g B (x, a) ≤ ∑ y ∈ B, cCharge * (1 - psi (coord M y)) := by |
| 303 | + classical |
| 304 | + unfold partnerCharge |
| 305 | + rw [← sum_filter] |
| 306 | + have hcongr : ∀ a ∈ S.filter (fun a : ℕ => ∃ y ∈ B, (y : ℤ) = iso (g x) a), |
| 307 | + cCharge * (1 - psi (coord M (iso (g x) a))) = |
| 308 | + cCharge * (1 - psi (coord M ((iso (g x) a).toNat : ℤ))) := by |
| 309 | + intro a ha |
| 310 | + obtain ⟨y, -, hy⟩ := (mem_filter.mp ha).2 |
| 311 | + rw [Int.toNat_of_nonneg (by omega)] |
| 312 | + rw [sum_congr rfl hcongr, |
| 313 | + ← sum_image (f := fun y : ℕ => cCharge * (1 - psi (coord M (y : ℤ)))) |
| 314 | + (g := fun a : ℕ => (iso (g x) a).toNat)] |
| 315 | + · refine sum_le_sum_of_subset_of_nonneg ?_ fun y _ _ => |
| 316 | + mul_nonneg (by norm_num [cCharge]) (sub_nonneg.mpr (psi_le_one _)) |
| 317 | + intro y hy |
| 318 | + obtain ⟨a, ha, rfl⟩ := mem_image.mp hy |
| 319 | + obtain ⟨y, hyB, hy⟩ := (mem_filter.mp ha).2 |
| 320 | + have : (iso (g x) a).toNat = y := by omega |
| 321 | + rw [this] |
| 322 | + exact hyB |
| 323 | + · intro a ha a' ha' h |
| 324 | + obtain ⟨y, -, hy⟩ := (mem_filter.mp ha).2 |
| 325 | + obtain ⟨y', -, hy'⟩ := (mem_filter.mp ha').2 |
| 326 | + have h' : (iso (g x) a).toNat = (iso (g x) a').toNat := h |
| 327 | + have : iso (g x) a = iso (g x) a' := by omega |
| 328 | + exact_mod_cast iso_injective (g x) this |
| 329 | + |
| 330 | +/-- 5. §3 of the note, the second occurrence. No graph and no Sidon hypothesis: only the |
| 331 | +two conclusions of the incidence lemma. An incidence outside `P` costs at most `W(0)`. In |
| 332 | +`P` a length occurs once (cost `z ≤ W`, paid by `Q`) or twice (cost `W + 2v`: `W` paid by |
| 333 | +`Q`, and `v − vψ(u_y) ≤ c(1 − ψ(u_y))` at each of the two incidences, where `y = g_x(a)` is |
| 334 | +the partner's outsider). For fixed `x` the partners are distinct points of `B`, since `g_x` |
| 335 | +is injective. -/ |
| 336 | +theorem second_occurrence {M : ℕ} {S B : Finset ℕ} {P : Finset (ℕ × ℕ)} {g : ℕ → Bool × ℤ} |
| 337 | + (hM : 0 < M) (hS : S ⊆ host M) (hB : B ⊆ host M \ S) (hP : P ⊆ B ×ˢ S) |
| 338 | + (hD : ∀ p ∈ P, ∀ a ∈ S, ∀ a' ∈ S, ((a : ℤ) - a').natAbs ≠ ((p.1 : ℤ) - p.2).natAbs) |
| 339 | + (hg : ∀ p ∈ P, ∀ p' ∈ P, p ≠ p' → |
| 340 | + ((p.1 : ℤ) - p.2).natAbs = ((p'.1 : ℤ) - p'.2).natAbs → |
| 341 | + (p'.1 : ℤ) = iso (g p.1) p.2 ∧ (p'.2 : ℤ) = iso (g p.1) p.1) : |
| 342 | + ∑ x ∈ B, ∑ a ∈ S, (zScore (coord M a - coord M x) - |
| 343 | + vCharge (coord M a - coord M x) * psi (coord M (iso (g x) a))) ≤ |
| 344 | + missingWeight M S + cCharge * B.card * (B.card - ∑ y ∈ B, psi (coord M y)) + |
| 345 | + kernel 0 * ((B ×ˢ S) \ P).card := by |
| 346 | + classical |
| 347 | + -- `hM` is in the plan's statement but is not needed |
| 348 | + have _ := hM |
| 349 | + set len : ℕ × ℕ → ℕ := fun p => ((p.1 : ℤ) - p.2).natAbs with hlen |
| 350 | + set W : ℕ → ℝ := fun d => kernel (32 * (d : ℝ) / M) with hW |
| 351 | + -- incidences outside `P` |
| 352 | + have hout : ∑ p ∈ (B ×ˢ S) \ P, cost M g p ≤ kernel 0 * ((B ×ˢ S) \ P).card := by |
| 353 | + rw [mul_comm, ← nsmul_eq_mul] |
| 354 | + exact sum_le_card_nsmul _ _ _ fun p _ => (cost_le_kernel M g p).trans (kernel_le_zero _) |
| 355 | + -- incidences in `P`, one length at a time |
| 356 | + have hfibre : ∀ d ∈ P.image len, |
| 357 | + ∑ p ∈ P.filter (fun p => len p = d), cost M g p ≤ |
| 358 | + W d + ∑ p ∈ P.filter (fun p => len p = d), partnerCharge M g B p := by |
| 359 | + intro d hd |
| 360 | + obtain ⟨p, hp, hpd⟩ := mem_image.mp hd |
| 361 | + by_cases h : ∃ p' ∈ P, p' ≠ p ∧ len p' = d |
| 362 | + · obtain ⟨p', hp', hne, hpd'⟩ := h |
| 363 | + have h12 := hg p hp p' hp' hne.symm (hpd.trans hpd'.symm) |
| 364 | + have h21 := hg p' hp' p hp hne (hpd'.trans hpd.symm) |
| 365 | + have hfib : P.filter (fun q => len q = d) = {p, p'} := by |
| 366 | + ext q |
| 367 | + simp only [mem_filter, mem_insert, mem_singleton] |
| 368 | + constructor |
| 369 | + · rintro ⟨hq, hqd⟩ |
| 370 | + by_contra hcon |
| 371 | + rw [not_or] at hcon |
| 372 | + have h1 := hg p hp q hq (Ne.symm hcon.1) (hpd.trans hqd.symm) |
| 373 | + exact hcon.2 (Prod.ext (by exact_mod_cast h1.1.trans h12.1.symm) |
| 374 | + (by exact_mod_cast h1.2.trans h12.2.symm)) |
| 375 | + · rintro (rfl | rfl) |
| 376 | + · exact ⟨hp, hpd⟩ |
| 377 | + · exact ⟨hp', hpd'⟩ |
| 378 | + rw [hfib, sum_pair hne.symm, sum_pair hne.symm] |
| 379 | + have c1 := cost_le_half M g B p ⟨p'.1, (mem_product.mp (hP hp')).1, h12.1⟩ |
| 380 | + have c2 := cost_le_half M g B p' ⟨p.1, (mem_product.mp (hP hp)).1, h21.1⟩ |
| 381 | + have e1 : kernel (32 * (((p.1 : ℤ) - p.2).natAbs : ℝ) / M) = W d := by |
| 382 | + rw [hW, ← hpd] |
| 383 | + have e2 : kernel (32 * (((p'.1 : ℤ) - p'.2).natAbs : ℝ) / M) = W d := by |
| 384 | + rw [hW, ← hpd'] |
| 385 | + rw [e1] at c1 |
| 386 | + rw [e2] at c2 |
| 387 | + linarith only [c1, c2] |
| 388 | + · have hfib : P.filter (fun q => len q = d) = {p} := by |
| 389 | + ext q |
| 390 | + simp only [mem_filter, mem_singleton] |
| 391 | + constructor |
| 392 | + · rintro ⟨hq, hqd⟩ |
| 393 | + by_contra hcon |
| 394 | + exact h ⟨q, hq, hcon, hqd⟩ |
| 395 | + · rintro rfl |
| 396 | + exact ⟨hp, hpd⟩ |
| 397 | + rw [hfib, sum_singleton, sum_singleton] |
| 398 | + have c1 := cost_le_kernel M g p |
| 399 | + have e1 : kernel (32 * (((p.1 : ℤ) - p.2).natAbs : ℝ) / M) = W d := by |
| 400 | + rw [hW, ← hpd] |
| 401 | + rw [e1] at c1 |
| 402 | + linarith only [c1, partnerCharge_nonneg M g B p] |
| 403 | + have hin : ∑ p ∈ P, cost M g p ≤ |
| 404 | + ∑ d ∈ P.image len, W d + ∑ p ∈ P, partnerCharge M g B p := by |
| 405 | + rw [← sum_fiberwise_of_maps_to (g := len) (t := P.image len) |
| 406 | + (fun p hp => mem_image_of_mem _ hp) (cost M g), |
| 407 | + ← sum_fiberwise_of_maps_to (g := len) (t := P.image len) |
| 408 | + (fun p hp => mem_image_of_mem _ hp) (partnerCharge M g B), ← sum_add_distrib] |
| 409 | + exact sum_le_sum hfibre |
| 410 | + -- the lengths of `P` are not differences of `S` |
| 411 | + have hQ : ∑ d ∈ P.image len, W d ≤ missingWeight M S := by |
| 412 | + unfold missingWeight |
| 413 | + refine sum_le_sum_of_subset_of_nonneg ?_ fun d _ _ => kernel_nonneg _ |
| 414 | + intro d hd |
| 415 | + obtain ⟨p, hp, rfl⟩ := mem_image.mp hd |
| 416 | + obtain ⟨h1, h2⟩ := mem_product.mp (hP hp) |
| 417 | + obtain ⟨h1M, h1S⟩ := mem_sdiff.mp (hB h1) |
| 418 | + have hne : p.1 ≠ p.2 := fun h => h1S (h ▸ h2) |
| 419 | + have b1 := mem_Icc.mp h1M |
| 420 | + have b2 := mem_Icc.mp (hS h2) |
| 421 | + exact mem_filter.mpr ⟨mem_Icc.mpr ⟨by simp only [hlen]; omega, by simp only [hlen]; omega⟩, |
| 422 | + hD p hp⟩ |
| 423 | + -- the partner charges |
| 424 | + have hcharge : ∑ p ∈ P, partnerCharge M g B p ≤ |
| 425 | + cCharge * B.card * (B.card - ∑ y ∈ B, psi (coord M y)) := by |
| 426 | + calc ∑ p ∈ P, partnerCharge M g B p |
| 427 | + ≤ ∑ p ∈ B ×ˢ S, partnerCharge M g B p := |
| 428 | + sum_le_sum_of_subset_of_nonneg hP fun p _ _ => partnerCharge_nonneg M g B p |
| 429 | + _ = ∑ x ∈ B, ∑ a ∈ S, partnerCharge M g B (x, a) := sum_product _ _ _ |
| 430 | + _ ≤ ∑ _x ∈ B, ∑ y ∈ B, cCharge * (1 - psi (coord M y)) := |
| 431 | + sum_le_sum fun x _ => partnerCharge_row M g B S x |
| 432 | + _ = cCharge * B.card * (B.card - ∑ y ∈ B, psi (coord M y)) := by |
| 433 | + rw [sum_const, ← mul_sum, sum_sub_distrib, sum_const, nsmul_eq_mul, nsmul_eq_mul, |
| 434 | + mul_one] |
| 435 | + ring |
| 436 | + have hsplit : ∑ x ∈ B, ∑ a ∈ S, (zScore (coord M a - coord M x) - |
| 437 | + vCharge (coord M a - coord M x) * psi (coord M (iso (g x) a))) = |
| 438 | + ∑ p ∈ (B ×ˢ S) \ P, cost M g p + ∑ p ∈ P, cost M g p := by |
| 439 | + rw [sum_sdiff hP, sum_product] |
| 440 | + rfl |
| 441 | + rw [hsplit] |
| 442 | + linarith only [hout, hin, hQ, hcharge] |
| 443 | + |
| 195 | 444 | end ErdosSwarm.Erdos530Gap103 |