| | @@ -0,0 +1,220 @@ |
| 1 | +import ErdosSwarm.Erdos588Uniform |
| 2 | + |
| 3 | +/-! |
| 4 | +# Erdős #588: quadratically many three-point lines on the cubic `y = x³` |
| 5 | + |
| 6 | +Three points `(a, a³)`, `(b, b³)`, `(c, c³)` with distinct abscissae are collinear exactly when |
| 7 | +`a + b + c = 0`, and no line meets the cubic in four points. Taking the integer abscissae |
| 8 | +`-3k, …, 3k` gives `6k + 1` points with no four on a line, and the `k²` pairs |
| 9 | +`1 ≤ a ≤ k < b ≤ 2k` give `k²` different lines with exactly three of the points |
| 10 | +(`(a, a³)`, `(b, b³)` and `(-a-b, (-a-b)³)`). Hence `f₃(6k + 1) ≥ k²` |
| 11 | +(`sq_le_numLinesWithPointsMax_three`), so `f₃(n)` is not `o(n²)` |
| 12 | +(`not_isLittleO_numLinesWithPointsMax_three`): the restriction `k ≥ 4` in Erdős #588 is needed. |
| 13 | + |
| 14 | +The constant is not optimal: this gives `f₃(n) ≥ n²/36 - O(n)` along `n = 6k + 1`, whereas the |
| 15 | +truth is `n²/6 + O(n)` (Sylvester; Burr–Grünbaum–Sloane), which needs a cubic whose group has |
| 16 | +finite subgroups. |
| 17 | +-/ |
| 18 | + |
| 19 | +open EuclideanGeometry Filter Asymptotics |
| 20 | + |
| 21 | +namespace ErdosSwarm.Erdos588 |
| 22 | + |
| 23 | +/-- The point `(t, t³)` of the cubic `y = x³`. -/ |
| 24 | +noncomputable def cubicPoint (t : ℝ) : ℝ² := !₂[t, t ^ 3] |
| 25 | + |
| 26 | +@[simp] theorem cubicPoint_apply_zero (t : ℝ) : cubicPoint t 0 = t := rfl |
| 27 | + |
| 28 | +@[simp] theorem cubicPoint_apply_one (t : ℝ) : cubicPoint t 1 = t ^ 3 := rfl |
| 29 | + |
| 30 | +theorem cubicPoint_injective : Function.Injective cubicPoint := fun s t h ↦ by |
| 31 | + simpa using congrArg (fun p : ℝ² ↦ p 0) h |
| 32 | + |
| 33 | +/-- A point of the cubic lies on the line through `(a, a³)` and `(b, b³)`, `a ≠ b`, exactly when |
| 34 | +its abscissa is `a`, `b` or `-a - b`. -/ |
| 35 | +theorem cubicPoint_mem_line_iff {a b x : ℝ} (hab : a ≠ b) : |
| 36 | + cubicPoint x ∈ line[ℝ, cubicPoint a, cubicPoint b] ↔ x = a ∨ x = b ∨ x = -a - b := by |
| 37 | + have hba : b - a ≠ 0 := sub_ne_zero.2 hab.symm |
| 38 | + rw [mem_affineSpan_pair_iff_exists_lineMap_eq] |
| 39 | + constructor |
| 40 | + · rintro ⟨r, hr⟩ |
| 41 | + have h0 : r * (b - a) + a = x := by |
| 42 | + simpa [AffineMap.lineMap_apply] using congrArg (fun p : ℝ² ↦ p 0) hr |
| 43 | + have h1 : r * (b ^ 3 - a ^ 3) + a ^ 3 = x ^ 3 := by |
| 44 | + simpa [AffineMap.lineMap_apply] using congrArg (fun p : ℝ² ↦ p 1) hr |
| 45 | + have h : (x - a) * ((x - b) * (x - (-a - b))) = 0 := by |
| 46 | + linear_combination (a ^ 2 + a * b + b ^ 2) * h0 - h1 |
| 47 | + rcases mul_eq_zero.1 h with h | h |
| 48 | + · exact Or.inl (sub_eq_zero.1 h) |
| 49 | + · rcases mul_eq_zero.1 h with h | h |
| 50 | + · exact Or.inr (Or.inl (sub_eq_zero.1 h)) |
| 51 | + · exact Or.inr (Or.inr (sub_eq_zero.1 h)) |
| 52 | + · intro h |
| 53 | + refine ⟨(x - a) / (b - a), ?_⟩ |
| 54 | + ext i |
| 55 | + fin_cases i |
| 56 | + · simp [AffineMap.lineMap_apply] |
| 57 | + field_simp |
| 58 | + ring |
| 59 | + · simp only [AffineMap.lineMap_apply, vsub_eq_sub, vadd_eq_add, Fin.mk_one, PiLp.add_apply, |
| 60 | + PiLp.smul_apply, PiLp.sub_apply, cubicPoint_apply_one, smul_eq_mul] |
| 61 | + rcases h with rfl | rfl | rfl |
| 62 | + · simp |
| 63 | + · field_simp |
| 64 | + ring |
| 65 | + · field_simp |
| 66 | + ring |
| 67 | + |
| 68 | +/-- The `2m + 1` points `(a, a³)` with `a` an integer, `|a| ≤ m`. -/ |
| 69 | +def cubicSet (m : ℕ) : Set ℝ² := (fun a : ℤ ↦ cubicPoint a) '' Set.Icc (-(m : ℤ)) m |
| 70 | + |
| 71 | +theorem mem_cubicSet {m : ℕ} {p : ℝ²} : |
| 72 | + p ∈ cubicSet m ↔ ∃ a : ℤ, a ∈ Set.Icc (-(m : ℤ)) m ∧ cubicPoint a = p := Iff.rfl |
| 73 | + |
| 74 | +theorem cubicSet_finite (m : ℕ) : (cubicSet m).Finite := (Set.finite_Icc _ _).image _ |
| 75 | + |
| 76 | +theorem cubicSet_ncard (m : ℕ) : (cubicSet m).ncard = 2 * m + 1 := by |
| 77 | + have hinj : Function.Injective (fun a : ℤ ↦ cubicPoint a) := |
| 78 | + fun a b h ↦ Int.cast_injective (cubicPoint_injective h) |
| 79 | + rw [cubicSet, Set.ncard_image_of_injective _ hinj, ← Finset.coe_Icc, Set.ncard_coe_finset, |
| 80 | + Int.card_Icc] |
| 81 | + omega |
| 82 | + |
| 83 | +/-- No line contains four points of the cubic. -/ |
| 84 | +theorem cubicSet_nonCollinearFor (m : ℕ) : NonCollinearFor 4 (cubicSet m) := by |
| 85 | + intro A hA hfin hcard hcol |
| 86 | + obtain ⟨p, q, hp, hq, hpq⟩ := (Set.one_lt_ncard_iff hfin).1 (by omega) |
| 87 | + obtain ⟨a, -, rfl⟩ := mem_cubicSet.1 (hA hp) |
| 88 | + obtain ⟨b, -, rfl⟩ := mem_cubicSet.1 (hA hq) |
| 89 | + have hab : (a : ℝ) ≠ b := fun h ↦ hpq (by rw [h]) |
| 90 | + have hsub : A ⊆ ({cubicPoint a, cubicPoint b, cubicPoint (-a - b)} : Finset ℝ²) := by |
| 91 | + intro r hr |
| 92 | + obtain ⟨c, -, rfl⟩ := mem_cubicSet.1 (hA hr) |
| 93 | + have := (cubicPoint_mem_line_iff hab).1 (hcol.mem_affineSpan_of_mem_of_ne hp hq hr hpq) |
| 94 | + rcases this with h | h | h <;> simp [h] |
| 95 | + have h3 := Set.ncard_le_ncard hsub (Finset.finite_toSet _) |
| 96 | + rw [Set.ncard_coe_finset] at h3 |
| 97 | + have := Finset.card_le_three (a := cubicPoint a) (b := cubicPoint b) (c := cubicPoint (-a - b)) |
| 98 | + omega |
| 99 | + |
| 100 | +/-- For integers `1 ≤ a ≤ k < b ≤ 2k`, the line through `(a, a³)` and `(b, b³)` contains exactly |
| 101 | +three points of `cubicSet (3 * k)`. -/ |
| 102 | +theorem line_mem_linesWithPointsFor {k : ℕ} {a b : ℤ} (ha : a ∈ Set.Icc (1 : ℤ) k) |
| 103 | + (hb : b ∈ Set.Icc ((k : ℤ) + 1) (2 * k)) : |
| 104 | + line[ℝ, cubicPoint a, cubicPoint b] ∈ linesWithPointsFor 3 (cubicSet (3 * k)) := by |
| 105 | + obtain ⟨ha1, ha2⟩ := ha |
| 106 | + obtain ⟨hb1, hb2⟩ := hb |
| 107 | + have hab : (a : ℝ) ≠ b := fun h ↦ by |
| 108 | + have : a = b := Int.cast_injective h |
| 109 | + omega |
| 110 | + have hmem : ∀ c : ℤ, c ∈ Set.Icc (-((3 * k : ℕ) : ℤ)) ((3 * k : ℕ) : ℤ) → |
| 111 | + cubicPoint c ∈ cubicSet (3 * k) := fun c hc ↦ ⟨c, hc, rfl⟩ |
| 112 | + have hSa : cubicPoint a ∈ cubicSet (3 * k) := hmem a ⟨by push_cast; omega, by push_cast; omega⟩ |
| 113 | + have hSb : cubicPoint b ∈ cubicSet (3 * k) := hmem b ⟨by push_cast; omega, by push_cast; omega⟩ |
| 114 | + have hSc : cubicPoint ((-a - b : ℤ) : ℝ) ∈ cubicSet (3 * k) := |
| 115 | + hmem (-a - b) ⟨by push_cast; omega, by push_cast; omega⟩ |
| 116 | + refine ⟨⟨_, hSa, _, hSb, fun h ↦ hab (cubicPoint_injective h), rfl⟩, ?_⟩ |
| 117 | + have hset : (line[ℝ, cubicPoint a, cubicPoint b] : Set ℝ²) ∩ cubicSet (3 * k) = |
| 118 | + {cubicPoint a, cubicPoint b, cubicPoint ((-a - b : ℤ) : ℝ)} := by |
| 119 | + ext p |
| 120 | + simp only [Set.mem_inter_iff, SetLike.mem_coe, Set.mem_insert_iff, Set.mem_singleton_iff] |
| 121 | + constructor |
| 122 | + · rintro ⟨hL, hp⟩ |
| 123 | + obtain ⟨c, -, rfl⟩ := mem_cubicSet.1 hp |
| 124 | + rcases (cubicPoint_mem_line_iff hab).1 hL with h | h | h |
| 125 | + · exact Or.inl (by rw [h]) |
| 126 | + · exact Or.inr (Or.inl (by rw [h])) |
| 127 | + · exact Or.inr (Or.inr (by rw [h]; push_cast; rfl)) |
| 128 | + · rintro (rfl | rfl | rfl) |
| 129 | + · exact ⟨(cubicPoint_mem_line_iff hab).2 (Or.inl rfl), hSa⟩ |
| 130 | + · exact ⟨(cubicPoint_mem_line_iff hab).2 (Or.inr (Or.inl rfl)), hSb⟩ |
| 131 | + · exact ⟨(cubicPoint_mem_line_iff hab).2 (Or.inr (Or.inr (by push_cast; rfl))), hSc⟩ |
| 132 | + rw [hset, Set.ncard_eq_three] |
| 133 | + refine ⟨_, _, _, ?_, ?_, ?_, rfl⟩ |
| 134 | + · exact fun h ↦ hab (cubicPoint_injective h) |
| 135 | + · intro h |
| 136 | + have : a = -a - b := Int.cast_injective (cubicPoint_injective h) |
| 137 | + omega |
| 138 | + · intro h |
| 139 | + have : b = -a - b := Int.cast_injective (cubicPoint_injective h) |
| 140 | + omega |
| 141 | + |
| 142 | +/-- The `6k + 1` integer points of the cubic with `|a| ≤ 3k` span at least `k²` lines with |
| 143 | +exactly three of them. -/ |
| 144 | +theorem sq_le_ncard_linesWithPointsFor_cubicSet (k : ℕ) : |
| 145 | + k ^ 2 ≤ (linesWithPointsFor 3 (cubicSet (3 * k))).ncard := by |
| 146 | + classical |
| 147 | + set T : Finset (ℤ × ℤ) := Finset.Icc (1 : ℤ) k ×ˢ Finset.Icc ((k : ℤ) + 1) (2 * k) with hT |
| 148 | + set f : ℤ × ℤ → AffineSubspace ℝ ℝ² := fun ab ↦ line[ℝ, cubicPoint ab.1, cubicPoint ab.2] |
| 149 | + with hf |
| 150 | + have hTmem : ∀ ab ∈ T, ab.1 ∈ Set.Icc (1 : ℤ) k ∧ ab.2 ∈ Set.Icc ((k : ℤ) + 1) (2 * k) := by |
| 151 | + intro ab hab |
| 152 | + simpa [hT, Finset.mem_product] using hab |
| 153 | + have hS := cubicSet_finite (3 * k) |
| 154 | + have hfin : (linesWithPointsFor 3 (cubicSet (3 * k))).Finite := by |
| 155 | + refine (hS.image2 (fun p q ↦ affineSpan ℝ {p, q}) hS).subset ?_ |
| 156 | + rintro L ⟨⟨p, hp, q, hq, -, rfl⟩, -⟩ |
| 157 | + exact ⟨p, hp, q, hq, rfl⟩ |
| 158 | + have hsub : f '' (T : Set (ℤ × ℤ)) ⊆ linesWithPointsFor 3 (cubicSet (3 * k)) := by |
| 159 | + rintro L ⟨ab, hab, rfl⟩ |
| 160 | + exact line_mem_linesWithPointsFor (hTmem ab hab).1 (hTmem ab hab).2 |
| 161 | + have hinj : Set.InjOn f (T : Set (ℤ × ℤ)) := by |
| 162 | + rintro ⟨a, b⟩ hab ⟨a', b'⟩ hab' h |
| 163 | + obtain ⟨⟨ha1, ha2⟩, ⟨hb1, hb2⟩⟩ := hTmem _ hab |
| 164 | + obtain ⟨⟨ha1', ha2'⟩, ⟨hb1', hb2'⟩⟩ := hTmem _ hab' |
| 165 | + simp only at ha1 ha2 hb1 hb2 ha1' ha2' hb1' hb2' |
| 166 | + have hne : (a : ℝ) ≠ b := fun h ↦ by |
| 167 | + have : a = b := Int.cast_injective h |
| 168 | + omega |
| 169 | + have h1 : cubicPoint a' ∈ line[ℝ, cubicPoint a, cubicPoint b] := by |
| 170 | + have : cubicPoint a' ∈ f (a', b') := left_mem_affineSpan_pair _ _ _ |
| 171 | + rwa [← h] at this |
| 172 | + have h2 : cubicPoint b' ∈ line[ℝ, cubicPoint a, cubicPoint b] := by |
| 173 | + have : cubicPoint b' ∈ f (a', b') := right_mem_affineSpan_pair _ _ _ |
| 174 | + rwa [← h] at this |
| 175 | + have ea : a' = a := by |
| 176 | + rcases (cubicPoint_mem_line_iff hne).1 h1 with e | e | e |
| 177 | + · exact_mod_cast e |
| 178 | + · have : a' = b := by exact_mod_cast e |
| 179 | + omega |
| 180 | + · have : a' = -a - b := by exact_mod_cast e |
| 181 | + omega |
| 182 | + have eb : b' = b := by |
| 183 | + rcases (cubicPoint_mem_line_iff hne).1 h2 with e | e | e |
| 184 | + · have : b' = a := by exact_mod_cast e |
| 185 | + omega |
| 186 | + · exact_mod_cast e |
| 187 | + · have : b' = -a - b := by exact_mod_cast e |
| 188 | + omega |
| 189 | + rw [ea, eb] |
| 190 | + calc k ^ 2 = T.card := by |
| 191 | + rw [hT, Finset.card_product, Int.card_Icc, Int.card_Icc, |
| 192 | + show ((k : ℤ) + 1 - 1).toNat = k by omega, |
| 193 | + show (2 * (k : ℤ) + 1 - (k + 1)).toNat = k by omega, sq] |
| 194 | + _ = (f '' (T : Set (ℤ × ℤ))).ncard := by |
| 195 | + rw [hinj.ncard_image, Set.ncard_coe_finset] |
| 196 | + _ ≤ _ := Set.ncard_le_ncard hsub hfin |
| 197 | + |
| 198 | +/-- `f₃(6k + 1) ≥ k²`, for the upstream `Erdos588.numLinesWithPointsMax`. -/ |
| 199 | +theorem sq_le_numLinesWithPointsMax_three (k : ℕ) : |
| 200 | + k ^ 2 ≤ _root_.Erdos588.numLinesWithPointsMax 3 (6 * k + 1) := by |
| 201 | + have h := ncard_le_numLinesWithPointsMax 3 (cubicSet (3 * k)) (cubicSet_finite _) |
| 202 | + (cubicSet_nonCollinearFor _) |
| 203 | + rw [cubicSet_ncard, show 2 * (3 * k) + 1 = 6 * k + 1 by ring] at h |
| 204 | + exact (sq_le_ncard_linesWithPointsFor_cubicSet k).trans h |
| 205 | + |
| 206 | +/-- `f₃(n)` is not `o(n²)`: the restriction `k ≥ 4` in Erdős #588 is necessary. -/ |
| 207 | +theorem not_isLittleO_numLinesWithPointsMax_three : |
| 208 | + ¬ (fun n : ℕ ↦ (_root_.Erdos588.numLinesWithPointsMax 3 n : ℝ)) =o[atTop] |
| 209 | + (fun n : ℕ ↦ (n : ℝ) ^ 2) := by |
| 210 | + intro h |
| 211 | + obtain ⟨N, hN⟩ := eventually_atTop.1 (h.bound (show (0 : ℝ) < 1 / 100 by norm_num)) |
| 212 | + have h1 := hN (6 * (N + 1) + 1) (by omega) |
| 213 | + simp only [Real.norm_natCast, norm_pow] at h1 |
| 214 | + have h2 : (((N + 1) ^ 2 : ℕ) : ℝ) ≤ _root_.Erdos588.numLinesWithPointsMax 3 (6 * (N + 1) + 1) := by |
| 215 | + exact_mod_cast sq_le_numLinesWithPointsMax_three (N + 1) |
| 216 | + push_cast at h1 h2 |
| 217 | + have hN0 : (0 : ℝ) ≤ N := Nat.cast_nonneg N |
| 218 | + nlinarith [mul_nonneg hN0 hN0] |
| 219 | + |
| 220 | +end ErdosSwarm.Erdos588 |