| | @@ -0,0 +1,158 @@ |
| 1 | +import FormalConjectures.ErdosProblems.«1070» |
| 2 | + |
| 3 | +/-! |
| 4 | +# Erdős #1070: the Moser spindle bound `f (7 * m) ≤ 2 * m` |
| 5 | + |
| 6 | +We place `m` translated copies of the Moser spindle (7 points, 11 unit distances, every |
| 7 | +3 of its points contain a unit distance) along the `x`-axis, `10` apart. An independent set |
| 8 | +of the unit distance graph meets each copy in at most `2` points. |
| 9 | + |
| 10 | +Coordinates, with `s3 = √3`, `s11 = √11`: the first rhombus is |
| 11 | +`A = (0,0)`, `B = (1,0)`, `C = (1/2, s3/2)`, `T = (3/2, s3/2)`; the second is its rotation about |
| 12 | +`A` by the angle `φ` with `cos φ = 5/6`, `sin φ = s11/6`, which puts `T'` at distance `1` from `T`. |
| 13 | +-/ |
| 14 | + |
| 15 | +namespace ErdosSwarm.Erdos1070 |
| 16 | + |
| 17 | +open EuclideanGeometry |
| 18 | + |
| 19 | +noncomputable section |
| 20 | + |
| 21 | +/-- `x`-coordinates of the spindle's points. -/ |
| 22 | +def sx (s3 s11 : ℝ) : Fin 7 → ℝ := |
| 23 | + ![0, 1, 1/2, 3/2, 5/6, 5/12 - s3 * s11 / 12, 15/12 - s3 * s11 / 12] |
| 24 | + |
| 25 | +/-- `y`-coordinates of the spindle's points. -/ |
| 26 | +def sy (s3 s11 : ℝ) : Fin 7 → ℝ := |
| 27 | + ![0, 0, s3/2, s3/2, s11/6, s11/12 + 5 * s3 / 12, 3 * s11 / 12 + 5 * s3 / 12] |
| 28 | + |
| 29 | +/-- The spindle's edges (unit distances). -/ |
| 30 | +def E : Fin 7 → Fin 7 → Bool := fun a b => |
| 31 | + decide ((a.val, b.val) ∈ ([(0,1),(0,2),(1,2),(1,3),(2,3),(0,4),(0,5),(4,5),(4,6),(5,6),(3,6)] : |
| 32 | + List (ℕ × ℕ))) |
| 33 | + |
| 34 | +theorem E_indep (T : Finset (Fin 7)) (h : ∀ a ∈ T, ∀ b ∈ T, E a b = false) : T.card ≤ 2 := by |
| 35 | + revert h; revert T; decide +kernel |
| 36 | + |
| 37 | +theorem E_dist (a b : Fin 7) (h : E a b = true) : |
| 38 | + (sx √3 √11 a - sx √3 √11 b) ^ 2 + (sy √3 √11 a - sy √3 √11 b) ^ 2 = 1 := by |
| 39 | + have h3 : (√3) ^ 2 = 3 := Real.sq_sqrt (by norm_num) |
| 40 | + have h11 : (√11) ^ 2 = 11 := Real.sq_sqrt (by norm_num) |
| 41 | + have h311 : (√3) ^ 2 * (√11) ^ 2 = 33 := by rw [h3, h11]; norm_num |
| 42 | + fin_cases a <;> fin_cases b <;> simp [E] at h <;> simp [sx, sy] <;> ring_nf <;> |
| 43 | + first |
| 44 | + | (simp; done) |
| 45 | + | linarith [h3, h11, h311] |
| 46 | + |
| 47 | +theorem s3_bounds : 1.73 < √3 ∧ √3 < 1.74 := by |
| 48 | + constructor |
| 49 | + · rw [Real.lt_sqrt (by norm_num)]; norm_num |
| 50 | + · rw [Real.sqrt_lt' (by norm_num)]; norm_num |
| 51 | + |
| 52 | +theorem s11_bounds : 3.31 < √11 ∧ √11 < 3.32 := by |
| 53 | + constructor |
| 54 | + · rw [Real.lt_sqrt (by norm_num)]; norm_num |
| 55 | + · rw [Real.sqrt_lt' (by norm_num)]; norm_num |
| 56 | + |
| 57 | +theorem s33_bounds : 5.72 < √3 * √11 ∧ √3 * √11 < 5.78 := by |
| 58 | + obtain ⟨a, b⟩ := s3_bounds |
| 59 | + obtain ⟨c, d⟩ := s11_bounds |
| 60 | + constructor <;> nlinarith |
| 61 | + |
| 62 | +theorem sx_bounds (j : Fin 7) : -1 < sx √3 √11 j ∧ sx √3 √11 j < 2 := by |
| 63 | + obtain ⟨a, b⟩ := s33_bounds |
| 64 | + fin_cases j <;> simp [sx] <;> constructor <;> linarith |
| 65 | + |
| 66 | +theorem sx_injective : Function.Injective (sx √3 √11) := by |
| 67 | + obtain ⟨c, d⟩ := s33_bounds |
| 68 | + intro a b h |
| 69 | + fin_cases a <;> fin_cases b <;> first | rfl | (simp [sx] at h <;> linarith) |
| 70 | + |
| 71 | +/-- Copy `i` of the spindle, point `j`. -/ |
| 72 | +def P (i : ℕ) (j : Fin 7) : ℝ² := !₂[10 * i + sx √3 √11 j, sy √3 √11 j] |
| 73 | + |
| 74 | +theorem dist_P (i : ℕ) (a b : Fin 7) (h : E a b = true) : dist (P i a) (P i b) = 1 := by |
| 75 | + rw [EuclideanSpace.dist_eq] |
| 76 | + simp only [Fin.sum_univ_two, P, Real.dist_eq, sq_abs] |
| 77 | + simp only [Matrix.cons_val_zero, |
| 78 | + Matrix.cons_val_one] |
| 79 | + have := E_dist a b h |
| 80 | + rw [show (10 * (i : ℝ) + sx √3 √11 a - (10 * i + sx √3 √11 b)) = sx √3 √11 a - sx √3 √11 b by |
| 81 | + ring, this, Real.sqrt_one] |
| 82 | + |
| 83 | +theorem P_injective (m : ℕ) : Function.Injective (fun q : Fin m × Fin 7 => P q.1 q.2) := by |
| 84 | + rintro ⟨i, a⟩ ⟨k, b⟩ h |
| 85 | + have hx := congrArg (fun v : ℝ² => v 0) h |
| 86 | + simp only [P, PiLp.toLp_apply, Matrix.cons_val_zero] at hx |
| 87 | + have ha := sx_bounds a |
| 88 | + have hb := sx_bounds b |
| 89 | + have hik : (i : ℕ) = k := by |
| 90 | + have h1 : (i : ℝ) < k + 1 := by linarith |
| 91 | + have h2 : (k : ℝ) < i + 1 := by linarith |
| 92 | + have h1' : (i : ℕ) < k + 1 := by exact_mod_cast h1 |
| 93 | + have h2' : (k : ℕ) < i + 1 := by exact_mod_cast h2 |
| 94 | + omega |
| 95 | + have hik' : i = k := Fin.ext hik |
| 96 | + subst hik' |
| 97 | + have : a = b := sx_injective (by linarith) |
| 98 | + subst this |
| 99 | + rfl |
| 100 | + |
| 101 | +theorem moser_spindle (m : ℕ) : _root_.Erdos1070.f (7 * m) ≤ 2 * m := by |
| 102 | + classical |
| 103 | + set X : Finset ℝ² := (Finset.univ : Finset (Fin m × Fin 7)).image (fun q => P q.1 q.2) with hX |
| 104 | + have hcard : X.card = 7 * m := by |
| 105 | + rw [hX, Finset.card_image_of_injective _ (P_injective m)] |
| 106 | + simp [mul_comm] |
| 107 | + refine csSup_le ⟨0, fun _ _ => Nat.zero_le _⟩ ?_ |
| 108 | + intro k hk |
| 109 | + refine (hk X hcard).trans ?_ |
| 110 | + obtain ⟨s, hs⟩ := (SimpleGraph.UnitDistancePlaneGraph (X : Set ℝ²)).exists_isNIndepSet_indepNum |
| 111 | + rw [← hs.card_eq] |
| 112 | + set S0 : Finset ℝ² := s.map (Function.Embedding.subtype _) with hS0 |
| 113 | + have h1 : s.card = S0.card := (Finset.card_map _).symm |
| 114 | + have hsub : S0 ⊆ (Finset.univ.filter (fun q : Fin m × Fin 7 => P q.1 q.2 ∈ S0)).image |
| 115 | + (fun q => P q.1 q.2) := by |
| 116 | + intro x hx |
| 117 | + have hxX : x ∈ X := by |
| 118 | + obtain ⟨y, -, rfl⟩ := Finset.mem_map.mp hx |
| 119 | + exact y.2 |
| 120 | + obtain ⟨q, -, rfl⟩ := Finset.mem_image.mp hxX |
| 121 | + exact Finset.mem_image.mpr ⟨q, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hx⟩, rfl⟩ |
| 122 | + have hfib : ∀ i : Fin m, |
| 123 | + (Finset.univ.filter (fun j : Fin 7 => P i j ∈ S0)).card ≤ 2 := by |
| 124 | + intro i |
| 125 | + apply E_indep |
| 126 | + intro a ha b hb |
| 127 | + by_contra hab |
| 128 | + simp only [Bool.not_eq_false] at hab |
| 129 | + have ha' := (Finset.mem_filter.mp ha).2 |
| 130 | + have hb' := (Finset.mem_filter.mp hb).2 |
| 131 | + obtain ⟨ya, hya, hyae⟩ := Finset.mem_map.mp ha' |
| 132 | + obtain ⟨yb, hyb, hybe⟩ := Finset.mem_map.mp hb' |
| 133 | + have hd : dist (P i a) (P i b) = 1 := dist_P i a b hab |
| 134 | + have hne : ya ≠ yb := by |
| 135 | + intro heq |
| 136 | + have : P i a = P i b := by |
| 137 | + rw [← hyae, ← hybe, heq] |
| 138 | + rw [this, dist_self] at hd |
| 139 | + exact zero_ne_one hd |
| 140 | + apply hs.isIndepSet hya hyb hne |
| 141 | + change dist ya yb = 1 |
| 142 | + rw [Subtype.dist_eq] |
| 143 | + simp only [Function.Embedding.subtype_apply] at hyae hybe |
| 144 | + rw [hyae, hybe] |
| 145 | + exact hd |
| 146 | + rw [h1] |
| 147 | + calc S0.card ≤ _ := Finset.card_le_card hsub |
| 148 | + _ ≤ (Finset.univ.filter (fun q : Fin m × Fin 7 => P q.1 q.2 ∈ S0)).card := |
| 149 | + Finset.card_image_le |
| 150 | + _ = ∑ i : Fin m, (Finset.univ.filter (fun j : Fin 7 => P i j ∈ S0)).card := by |
| 151 | + rw [Finset.card_filter, Fintype.sum_prod_type] |
| 152 | + simp only [Finset.card_filter] |
| 153 | + _ ≤ ∑ _i : Fin m, 2 := Finset.sum_le_sum (fun i _ => hfib i) |
| 154 | + _ = 2 * m := by simp [mul_comm] |
| 155 | + |
| 156 | +end |
| 157 | + |
| 158 | +end ErdosSwarm.Erdos1070 |