| | @@ -0,0 +1,207 @@ |
| 1 | +import ErdosSwarm.Erdos588 |
| 2 | +import ErdosSwarm.Erdos588Acnodal |
| 3 | +import ErdosSwarm.Erdos588Count |
| 4 | +import ErdosSwarm.Erdos588Monotone |
| 5 | +import ErdosSwarm.Erdos588Tangent |
| 6 | +import ErdosSwarm.Erdos588Uniform |
| 7 | + |
| 8 | +/-! |
| 9 | +# Erdős #588 at `k = 3`: the sharp bound `n² - 3n ≤ 6 f₃(n) ≤ n² - n` |
| 10 | + |
| 11 | +Part (c2) of the plan for the sharp three-point-line bound (Sylvester; Burr–Grünbaum–Sloane). |
| 12 | +It assembles |
| 13 | + |
| 14 | +* part (a), `Erdos588Acnodal`: on the acnodal cubic `P(t) = (1 + t², t (1 + t²))` no four points |
| 15 | + are collinear, and `P(x)` lies on the line through `P(a) ≠ P(b)` iff `x ∈ {a, b}` or |
| 16 | + `a b + a x + b x = 1`; |
| 17 | +* part (b), `Erdos588Tangent`: for `t_j = tan (π/6 + (n + 1)π/(3n) + jπ/n)` the last condition |
| 18 | + is `n ∣ i + j + l + 1`, and `t` is injective on `j < n`; |
| 19 | +* part (c1), `Erdos588Count`: at least `n² - 3n` ordered pairs `(i, j)` of different indices |
| 20 | + below `n` have their third index `sylvesterThird n i j` different from both. |
| 21 | + |
| 22 | +The configuration is `sylvesterSet n = {P(t_j) : j < n}`: `n` points, no four on a line. Every |
| 23 | +good ordered pair spans a line with exactly three points of it, and a line arises from at most |
| 24 | +six ordered pairs, so there are at least `(n² - 3n)/6` three-point lines: |
| 25 | + |
| 26 | +* `sq_sub_le_six_mul_numLinesWithPointsMax_three`: `n² - 3n ≤ 6 f₃(n)` for every `n`; |
| 27 | +* `six_mul_numLinesWithPointsMax_three_le`: `6 f₃(n) ≤ n (n - 1)` (the accepted pair count); |
| 28 | +* `sylvester_isBigO`: `f₃(n) - n²/6 = O(n)`, the Formal Conjectures variant `sylvester`; |
| 29 | +* `three_lower_eventually`: the Formal Conjectures variant `three_lower`. |
| 30 | + |
| 31 | +Here `f₃ = Erdos588.numLinesWithPointsMax 3` is the upstream function. These are solved variants |
| 32 | +at `k = 3`; nothing is proved about the open case `k ≥ 4`. |
| 33 | +-/ |
| 34 | + |
| 35 | +open EuclideanGeometry Real |
| 36 | +open scoped Finset |
| 37 | + |
| 38 | +namespace ErdosSwarm.Erdos588 |
| 39 | + |
| 40 | +/-- The `j`-th point of the configuration: parameter `t_j = tan θ_j` on the acnodal cubic. -/ |
| 41 | +noncomputable def sylvesterPoint (n j : ℕ) : ℝ² := acnodalPoint (sylvesterParam n j) |
| 42 | + |
| 43 | +theorem sylvesterPoint_eq_iff {n i j : ℕ} (hi : i < n) (hj : j < n) : |
| 44 | + sylvesterPoint n i = sylvesterPoint n j ↔ i = j := |
| 45 | + ⟨fun h ↦ (sylvesterParam_eq_iff hi hj).1 (acnodalPoint_injective h), fun h ↦ by rw [h]⟩ |
| 46 | + |
| 47 | +/-- **Collinearity criterion.** For `i ≠ j`, the `l`-th point lies on the line through the `i`-th |
| 48 | +and `j`-th points exactly when `l ∈ {i, j}` or `n ∣ i + j + l + 1`. -/ |
| 49 | +theorem sylvesterPoint_mem_line_iff {n i j l : ℕ} (hi : i < n) (hj : j < n) (hl : l < n) |
| 50 | + (hij : i ≠ j) : |
| 51 | + sylvesterPoint n l ∈ line[ℝ, sylvesterPoint n i, sylvesterPoint n j] ↔ |
| 52 | + l = i ∨ l = j ∨ n ∣ i + j + l + 1 := by |
| 53 | + have hab : sylvesterParam n i ≠ sylvesterParam n j := |
| 54 | + fun h ↦ hij ((sylvesterParam_eq_iff hi hj).1 h) |
| 55 | + unfold sylvesterPoint |
| 56 | + rw [acnodalPoint_mem_line_iff hab, sylvesterParam_eq_iff hl hi, sylvesterParam_eq_iff hl hj, |
| 57 | + sylvesterParam_mul_add_eq_one_iff (by omega) i j l] |
| 58 | + |
| 59 | +/-- The `n` points `sylvesterPoint n j`, `j < n`. -/ |
| 60 | +noncomputable def sylvesterSet (n : ℕ) : Set ℝ² := sylvesterPoint n '' Set.Iio n |
| 61 | + |
| 62 | +theorem sylvesterSet_finite (n : ℕ) : (sylvesterSet n).Finite := (Set.finite_Iio n).image _ |
| 63 | + |
| 64 | +theorem sylvesterSet_ncard (n : ℕ) : (sylvesterSet n).ncard = n := by |
| 65 | + have hinj : Set.InjOn (sylvesterPoint n) (Set.Iio n) := |
| 66 | + fun i hi j hj h ↦ (sylvesterPoint_eq_iff hi hj).1 h |
| 67 | + rw [sylvesterSet, hinj.ncard_image, ← Finset.coe_Iio, Set.ncard_coe_finset, Nat.card_Iio] |
| 68 | + |
| 69 | +theorem sylvesterSet_nonCollinearFor (n : ℕ) : NonCollinearFor 4 (sylvesterSet n) := by |
| 70 | + refine NonCollinearFor.subset ?_ (acnodal_nonCollinearFor Set.univ) |
| 71 | + rintro p ⟨j, -, rfl⟩ |
| 72 | + exact ⟨_, trivial, rfl⟩ |
| 73 | + |
| 74 | +theorem sylvesterSet_eq_image_acnodalPoint (n : ℕ) : |
| 75 | + sylvesterSet n = acnodalPoint '' (sylvesterParam n '' Set.Iio n) := |
| 76 | + (Set.image_image acnodalPoint (sylvesterParam n) (Set.Iio n)).symm |
| 77 | + |
| 78 | +/-- For a good ordered pair `(i, j)`, the line through points `i` and `j` contains exactly three |
| 79 | +points of the configuration: `i`, `j` and `sylvesterThird n i j` (part (a)'s three-point lines at |
| 80 | +part (b)'s parameters). -/ |
| 81 | +theorem line_mem_linesWithPointsFor_sylvesterSet {n : ℕ} {x : ℕ × ℕ} (hx : x ∈ goodPairs n) : |
| 82 | + line[ℝ, sylvesterPoint n x.1, sylvesterPoint n x.2] ∈ |
| 83 | + linesWithPointsFor 3 (sylvesterSet n) := by |
| 84 | + obtain ⟨i, j⟩ := x |
| 85 | + obtain ⟨hi, hj, hij, h1, h2⟩ := mem_goodPairs.1 hx |
| 86 | + simp only at hi hj hij h1 h2 ⊢ |
| 87 | + have hn : 0 < n := by omega |
| 88 | + have hl : sylvesterThird n i j < n := sylvesterThird_lt hn i j |
| 89 | + rw [sylvesterSet_eq_image_acnodalPoint] |
| 90 | + exact acnodal_line_mem_linesWithPointsFor (Set.mem_image_of_mem _ (Set.mem_Iio.2 hi)) |
| 91 | + (Set.mem_image_of_mem _ (Set.mem_Iio.2 hj)) (Set.mem_image_of_mem _ (Set.mem_Iio.2 hl)) |
| 92 | + (fun h ↦ hij ((sylvesterParam_eq_iff hi hj).1 h)) |
| 93 | + (fun h ↦ h1 ((sylvesterParam_eq_iff hi hl).1 h).symm) |
| 94 | + (fun h ↦ h2 ((sylvesterParam_eq_iff hj hl).1 h).symm) |
| 95 | + ((sylvesterParam_mul_add_eq_one_iff hn i j _).2 |
| 96 | + ((dvd_add_iff_eq_sylvesterThird i j hl).2 rfl)) |
| 97 | + |
| 98 | +/-- **The count.** The `n` points span at least `(n² - 3n)/6` lines with exactly three of them: |
| 99 | +there are at least `n² - 3n` good ordered pairs, and each line comes from at most six. -/ |
| 100 | +theorem sq_le_six_mul_ncard_linesWithPointsFor_sylvesterSet (n : ℕ) : |
| 101 | + n ^ 2 ≤ 6 * (linesWithPointsFor 3 (sylvesterSet n)).ncard + 3 * n := by |
| 102 | + classical |
| 103 | + set f : ℕ × ℕ → AffineSubspace ℝ ℝ² := |
| 104 | + fun x ↦ line[ℝ, sylvesterPoint n x.1, sylvesterPoint n x.2] with hf |
| 105 | + have h1 := sq_le_card_goodPairs_add n |
| 106 | + have hfiber : ∀ L ∈ (goodPairs n).image f, #{x ∈ goodPairs n | f x = L} ≤ 6 := by |
| 107 | + intro L hL |
| 108 | + obtain ⟨⟨i, j⟩, hijG, rfl⟩ := Finset.mem_image.1 hL |
| 109 | + obtain ⟨hi, hj, hij, -, -⟩ := mem_goodPairs.1 hijG |
| 110 | + simp only at hi hj hij |
| 111 | + set T : Finset ℕ := {i, j, sylvesterThird n i j} with hT |
| 112 | + have hsub : {x ∈ goodPairs n | f x = f (i, j)} ⊆ T.offDiag := by |
| 113 | + intro x hx |
| 114 | + obtain ⟨hxG, hfx⟩ := Finset.mem_filter.1 hx |
| 115 | + obtain ⟨hx1, hx2, hx12, -, -⟩ := mem_goodPairs.1 hxG |
| 116 | + have m1 : sylvesterPoint n x.1 ∈ f (i, j) := by |
| 117 | + rw [← hfx] |
| 118 | + exact left_mem_affineSpan_pair _ _ _ |
| 119 | + have m2 : sylvesterPoint n x.2 ∈ f (i, j) := by |
| 120 | + rw [← hfx] |
| 121 | + exact right_mem_affineSpan_pair _ _ _ |
| 122 | + have t1 : x.1 ∈ T := by |
| 123 | + rcases (sylvesterPoint_mem_line_iff hi hj hx1 hij).1 m1 with h | h | h |
| 124 | + · simp [hT, h] |
| 125 | + · simp [hT, h] |
| 126 | + · simp [hT, (dvd_add_iff_eq_sylvesterThird i j hx1).1 h] |
| 127 | + have t2 : x.2 ∈ T := by |
| 128 | + rcases (sylvesterPoint_mem_line_iff hi hj hx2 hij).1 m2 with h | h | h |
| 129 | + · simp [hT, h] |
| 130 | + · simp [hT, h] |
| 131 | + · simp [hT, (dvd_add_iff_eq_sylvesterThird i j hx2).1 h] |
| 132 | + exact Finset.mem_offDiag.2 ⟨t1, t2, hx12⟩ |
| 133 | + have hT3 : #T ≤ 3 := Finset.card_le_three |
| 134 | + have hoff : #T.offDiag ≤ 6 := by |
| 135 | + rw [Finset.offDiag_card] |
| 136 | + have : #T * #T ≤ 3 * #T := Nat.mul_le_mul_right _ hT3 |
| 137 | + omega |
| 138 | + exact (Finset.card_le_card hsub).trans hoff |
| 139 | + have h2 : #(goodPairs n) ≤ 6 * #((goodPairs n).image f) := |
| 140 | + Finset.card_le_mul_card_image (goodPairs n) 6 hfiber |
| 141 | + have h3 : #((goodPairs n).image f) ≤ (linesWithPointsFor 3 (sylvesterSet n)).ncard := by |
| 142 | + rw [← Set.ncard_coe_finset] |
| 143 | + refine Set.ncard_le_ncard ?_ (finite_linesWithPointsFor 3 (sylvesterSet_finite n)) |
| 144 | + intro L hL |
| 145 | + obtain ⟨x, hxG, rfl⟩ := Finset.mem_image.1 (Finset.mem_coe.1 hL) |
| 146 | + exact line_mem_linesWithPointsFor_sylvesterSet hxG |
| 147 | + omega |
| 148 | + |
| 149 | +/-- `n² ≤ 6 f₃(n) + 3n` for every `n`, for the upstream `Erdos588.numLinesWithPointsMax`. -/ |
| 150 | +theorem sq_le_six_mul_numLinesWithPointsMax_three_add (n : ℕ) : |
| 151 | + n ^ 2 ≤ 6 * _root_.Erdos588.numLinesWithPointsMax 3 n + 3 * n := by |
| 152 | + have h := ncard_le_numLinesWithPointsMax 3 (sylvesterSet n) (sylvesterSet_finite n) |
| 153 | + (sylvesterSet_nonCollinearFor n) |
| 154 | + rw [sylvesterSet_ncard] at h |
| 155 | + have := sq_le_six_mul_ncard_linesWithPointsFor_sylvesterSet n |
| 156 | + omega |
| 157 | + |
| 158 | +/-- **Sharp lower bound for three-point lines**: `f₃(n) ≥ (n² - 3n)/6` for every `n` (natural |
| 159 | +subtraction). -/ |
| 160 | +theorem sq_sub_le_six_mul_numLinesWithPointsMax_three (n : ℕ) : |
| 161 | + n ^ 2 - 3 * n ≤ 6 * _root_.Erdos588.numLinesWithPointsMax 3 n := by |
| 162 | + have := sq_le_six_mul_numLinesWithPointsMax_three_add n |
| 163 | + omega |
| 164 | + |
| 165 | +/-- `6 f₃(n) ≤ n(n - 1)`: the pair-counting upper bound at `k = 3`. -/ |
| 166 | +theorem six_mul_numLinesWithPointsMax_three_le (n : ℕ) : |
| 167 | + 6 * _root_.Erdos588.numLinesWithPointsMax 3 n ≤ n * (n - 1) := by |
| 168 | + have hreal := numLinesWithPointsMax_le_of_forall 3 n ((n * (n - 1) : ℕ) / 6 : ℝ) (by positivity) |
| 169 | + fun S hSn hS _ ↦ by |
| 170 | + have h := ncard_linesWithPointsFor_mul_le 3 hS |
| 171 | + rw [hSn] at h |
| 172 | + rw [le_div_iff₀ (by norm_num)] |
| 173 | + exact_mod_cast h |
| 174 | + rw [le_div_iff₀ (by norm_num)] at hreal |
| 175 | + have : _root_.Erdos588.numLinesWithPointsMax 3 n * 6 ≤ n * (n - 1) := by exact_mod_cast hreal |
| 176 | + omega |
| 177 | + |
| 178 | +/-- Sylvester: `f₃(n) = n²/6 + O(n)`; in fact `-n/2 ≤ f₃(n) - n²/6 ≤ 0` for every `n`. -/ |
| 179 | +theorem sylvester_isBigO : |
| 180 | + (fun n : ℕ ↦ (_root_.Erdos588.numLinesWithPointsMax 3 n : ℝ) - (n : ℝ) ^ 2 / 6) =O[Filter.atTop] |
| 181 | + (fun n : ℕ ↦ (n : ℝ)) := by |
| 182 | + refine Asymptotics.IsBigO.of_bound 1 (Filter.Eventually.of_forall fun n ↦ ?_) |
| 183 | + have hlo : ((n ^ 2 : ℕ) : ℝ) ≤ ((6 * _root_.Erdos588.numLinesWithPointsMax 3 n + 3 * n : ℕ) : ℝ) := |
| 184 | + by exact_mod_cast sq_le_six_mul_numLinesWithPointsMax_three_add n |
| 185 | + have hup : ((6 * _root_.Erdos588.numLinesWithPointsMax 3 n : ℕ) : ℝ) ≤ ((n * n : ℕ) : ℝ) := by |
| 186 | + exact_mod_cast (six_mul_numLinesWithPointsMax_three_le n).trans |
| 187 | + (Nat.mul_le_mul_left n (Nat.sub_le n 1)) |
| 188 | + push_cast at hlo hup |
| 189 | + have hn : (0 : ℝ) ≤ n := Nat.cast_nonneg n |
| 190 | + rw [Real.norm_eq_abs, Real.norm_eq_abs, abs_of_nonneg hn, one_mul, abs_le] |
| 191 | + constructor <;> nlinarith |
| 192 | + |
| 193 | +/-- `f₃(n) ≥ (1/6 - ε) n²` eventually, for every `ε > 0`. -/ |
| 194 | +theorem three_lower_eventually : |
| 195 | + ∀ ε > (0 : ℝ), ∀ᶠ n : ℕ in Filter.atTop, |
| 196 | + (1 / 6 - ε) * (n : ℝ) ^ 2 ≤ (_root_.Erdos588.numLinesWithPointsMax 3 n : ℝ) := by |
| 197 | + intro ε hε |
| 198 | + filter_upwards [Filter.eventually_ge_atTop ⌈1 / (2 * ε)⌉₊] with n hn |
| 199 | + have hlo : ((n ^ 2 : ℕ) : ℝ) ≤ ((6 * _root_.Erdos588.numLinesWithPointsMax 3 n + 3 * n : ℕ) : ℝ) := |
| 200 | + by exact_mod_cast sq_le_six_mul_numLinesWithPointsMax_three_add n |
| 201 | + push_cast at hlo |
| 202 | + have hn' : 1 / (2 * ε) ≤ (n : ℝ) := (Nat.le_ceil _).trans (by exact_mod_cast hn) |
| 203 | + rw [div_le_iff₀ (by positivity)] at hn' |
| 204 | + have hn0 : (0 : ℝ) ≤ n := Nat.cast_nonneg n |
| 205 | + nlinarith [mul_nonneg hn0 hn0] |
| 206 | + |
| 207 | +end ErdosSwarm.Erdos588 |