| | @@ -0,0 +1,92 @@ |
| 1 | +import ErdosSwarm.Erdos530Gap428.Data |
| 2 | + |
| 3 | +/-! |
| 4 | +# The two coin outcomes for a pair of points in Erdős #530 |
| 5 | + |
| 6 | +Section 1 of `experiments/erdos530/upper-smaller-k/NOTES.md` lets one side of a cut |
| 7 | +use every seed witness. The coin chooses which side. Across both choices, a fixed |
| 8 | +ordered pair of distinct points contributes at most two common signed shifts to the |
| 9 | +exceptional-set count. The original exceptional-set argument is in Lemma 4.3 of |
| 10 | +[Phal and Gemini](https://github.com/shubhamphal/erdos-530/blob/42a01f6/paper/erdos_530.tex). |
| 11 | +-/ |
| 12 | + |
| 13 | +namespace ErdosSwarm.Erdos530Gap428 |
| 14 | + |
| 15 | +open Finset |
| 16 | + |
| 17 | +private lemma shift_witness {S : Finset ℕ} {left : ℕ → Bool} {free : Bool} {x : ℕ} {d : ℤ} |
| 18 | + (hd : d ∈ shifts S left free x) : |
| 19 | + ∃ a ∈ S, (left x = free ∨ left a = left x) ∧ |
| 20 | + (if left x then (a : ℤ) - x else (x : ℤ) - a) = d := by |
| 21 | + obtain ⟨a, ha, had⟩ := mem_image.mp hd |
| 22 | + exact ⟨a, (mem_filter.mp ha).1, (mem_filter.mp ha).2, had⟩ |
| 23 | + |
| 24 | +/-- On the same side, the nonzero difference of the two points determines |
| 25 | +the ordered pair of seed witnesses for each coin outcome. -/ |
| 26 | +private lemma same_side_card_le_one {S : Finset ℕ} (hsid : IsSidon (S : Set ℕ)) |
| 27 | + {left : ℕ → Bool} {x y : ℕ} (hxy : x ≠ y) (hside : left x = left y) (free : Bool) : |
| 28 | + (shifts S left free x ∩ shifts S left free y).card ≤ 1 := by |
| 29 | + apply card_le_one.mpr |
| 30 | + intro d hd e he |
| 31 | + obtain ⟨a, ha, _, had⟩ := shift_witness (mem_inter.mp hd).1 |
| 32 | + obtain ⟨b, hb, _, hbd⟩ := shift_witness (mem_inter.mp hd).2 |
| 33 | + obtain ⟨c, hc, _, hce⟩ := shift_witness (mem_inter.mp he).1 |
| 34 | + obtain ⟨k, hk, _, hke⟩ := shift_witness (mem_inter.mp he).2 |
| 35 | + cases hx : left x <;> |
| 36 | + simp [← hside, hx] at had hbd hce hke <;> |
| 37 | + rcases hsid a ha c hc k hk b hb (by omega) with ⟨_, _⟩ | ⟨_, _⟩ <;> omega |
| 38 | + |
| 39 | +/-- The distinct seed points occurring in representations of `n` as a seed sum. -/ |
| 40 | +private def summands (S : Finset ℕ) (n : ℕ) : Finset ℕ := |
| 41 | + S.filter fun a => ∃ b ∈ S, a + b = n |
| 42 | + |
| 43 | +private lemma summands_card_le_two {S : Finset ℕ} (hsid : IsSidon (S : Set ℕ)) (n : ℕ) : |
| 44 | + (summands S n).card ≤ 2 := by |
| 45 | + rcases (summands S n).eq_empty_or_nonempty with hempty | ⟨a, ha⟩ |
| 46 | + · simp [hempty] |
| 47 | + obtain ⟨ha, b, hb, hab⟩ := mem_filter.mp ha |
| 48 | + refine (card_le_card (t := {a, b}) ?_).trans card_le_two |
| 49 | + intro c hc |
| 50 | + obtain ⟨hc, k, hk, hck⟩ := mem_filter.mp hc |
| 51 | + rcases hsid c hc a ha k hk b hb (hck.trans hab.symm) with h | h |
| 52 | + · simp [h.1] |
| 53 | + · simp [h.1] |
| 54 | + |
| 55 | +/-- When the side of `y` is free, a common shift is determined by a summand |
| 56 | +of `x + y` on the restricted side of `x`. -/ |
| 57 | +private lemma restricted_card_le (S : Finset ℕ) (left : ℕ → Bool) {x y : ℕ} |
| 58 | + (hside : left x ≠ left y) : |
| 59 | + (shifts S left (left y) x ∩ shifts S left (left y) y).card ≤ |
| 60 | + ((summands S (x + y)).filter fun a => left a = left x).card := by |
| 61 | + let offset (a : ℕ) : ℤ := if left x then (a : ℤ) - x else (x : ℤ) - a |
| 62 | + refine (card_le_card (t := ((summands S (x + y)).filter |
| 63 | + fun a => left a = left x).image offset) ?_).trans card_image_le |
| 64 | + intro d hd |
| 65 | + obtain ⟨a, ha, hallowed, had⟩ := shift_witness (mem_inter.mp hd).1 |
| 66 | + obtain ⟨b, hb, _, hbd⟩ := shift_witness (mem_inter.mp hd).2 |
| 67 | + have hsum : a + b = x + y := by |
| 68 | + cases hx : left x <;> cases hy : left y <;> simp [hx, hy] at hside had hbd <;> omega |
| 69 | + exact mem_image.mpr ⟨a, mem_filter.mpr ⟨mem_filter.mpr ⟨ha, b, hb, hsum⟩, |
| 70 | + hallowed.resolve_left hside⟩, had⟩ |
| 71 | + |
| 72 | +/-- For any fixed cut, the sum of the two coin outcomes for a pair is at most two. |
| 73 | +On opposite sides, the outcomes charge disjoint subsets of the same unordered |
| 74 | +seed pair. A repeated summand belongs to just one of these subsets. -/ |
| 75 | +theorem fair_coin_pair (S : Finset ℕ) (hsid : IsSidon (S : Set ℕ)) |
| 76 | + (left : ℕ → Bool) {x y : ℕ} (hxy : x ≠ y) : |
| 77 | + (shifts S left true x ∩ shifts S left true y).card + |
| 78 | + (shifts S left false x ∩ shifts S left false y).card ≤ 2 := by |
| 79 | + by_cases hside : left x = left y |
| 80 | + · exact Nat.add_le_add (same_side_card_le_one hsid hxy hside true) |
| 81 | + (same_side_card_le_one hsid hxy hside false) |
| 82 | + have hxBound := restricted_card_le S left hside |
| 83 | + have hyBound := restricted_card_le S left (Ne.symm hside) |
| 84 | + rw [inter_comm, Nat.add_comm y x] at hyBound |
| 85 | + have hpartition := card_filter_add_card_filter_not (s := summands S (x + y)) |
| 86 | + (fun a => left a = true) |
| 87 | + simp only [Bool.eq_false_eq_not_eq_true] at hpartition |
| 88 | + have htotal := summands_card_le_two hsid (x + y) |
| 89 | + cases hx : left x <;> cases hy : left y <;> |
| 90 | + simp [hx, hy] at hside hxBound hyBound <;> omega |
| 91 | + |
| 92 | +end ErdosSwarm.Erdos530Gap428 |