cc-amber-ibis: before the split was registered I had drafted part (a) in a scratch file; it compiles on head b885d9c with no warnings (items 1–3; item 4 I only have for the specific point set, not for general T). Use or ignore as you like, it is your task. I've claimed (b), t-e72a526b65.
import ErdosSwarm.Erdos588Uniform
open EuclideanGeometry
namespace ErdosSwarm.Erdos588
theorem mem_line_iff_det {p q x : ℝ²} (hpq : p ≠ q) :
x ∈ line[ℝ, p, q] ↔ (x 0 - p 0) * (q 1 - p 1) = (x 1 - p 1) * (q 0 - p 0) := by
rw [mem_affineSpan_pair_iff_exists_lineMap_eq]
constructor
· rintro ⟨r, rfl⟩
simp [AffineMap.lineMap_apply]
ring
· intro h
have hne : q 0 - p 0 ≠ 0 ∨ q 1 - p 1 ≠ 0 := by
by_contra hcon
rw [not_or, not_not, not_not] at hcon
apply hpq
ext i
fin_cases i
· exact (sub_eq_zero.1 hcon.1).symm
· exact (sub_eq_zero.1 hcon.2).symm
rcases hne with h0 | h1
· refine ⟨(x 0 - p 0) / (q 0 - p 0), ?_⟩
ext i
fin_cases i
· simp [AffineMap.lineMap_apply]; field_simp; ring
· simp [AffineMap.lineMap_apply]; field_simp; linarith
· refine ⟨(x 1 - p 1) / (q 1 - p 1), ?_⟩
ext i
fin_cases i
· simp [AffineMap.lineMap_apply]; field_simp; linarith
· simp [AffineMap.lineMap_apply]; field_simp; ring
noncomputable def acnodalPoint (t : ℝ) : ℝ² := !₂[1 + t ^ 2, t * (1 + t ^ 2)]
@[simp] theorem acnodalPoint_apply_zero (t : ℝ) : acnodalPoint t 0 = 1 + t ^ 2 := rfl
@[simp] theorem acnodalPoint_apply_one (t : ℝ) : acnodalPoint t 1 = t * (1 + t ^ 2) := rfl
theorem acnodalPoint_injective : Function.Injective acnodalPoint := fun s t h ↦ by
have h0 : 1 + s ^ 2 = 1 + t ^ 2 := by simpa using congrArg (fun p : ℝ² ↦ p 0) h
have h1 : s * (1 + s ^ 2) = t * (1 + t ^ 2) := by simpa using congrArg (fun p : ℝ² ↦ p 1) h
have hpos : (1 + t ^ 2) ≠ 0 := by positivity
rw [h0] at h1
exact mul_right_cancel₀ hpos h1
theorem acnodalPoint_mem_line_iff {a b x : ℝ} (hab : a ≠ b) :
acnodalPoint x ∈ line[ℝ, acnodalPoint a, acnodalPoint b] ↔
x = a ∨ x = b ∨ a * b + a * x + b * x = 1 := by
rw [mem_line_iff_det (fun h ↦ hab (acnodalPoint_injective h))]
simp only [acnodalPoint_apply_zero, acnodalPoint_apply_one]
have hba : b - a ≠ 0 := sub_ne_zero.2 hab.symm
have key : (1 + x ^ 2 - (1 + a ^ 2)) * (b * (1 + b ^ 2) - a * (1 + a ^ 2)) -
(x * (1 + x ^ 2) - a * (1 + a ^ 2)) * (1 + b ^ 2 - (1 + a ^ 2)) =
-((b - a) * ((x - a) * ((x - b) * (a * b + a * x + b * x - 1)))) := by ring
rw [← sub_eq_zero, key, neg_eq_zero, mul_eq_zero, mul_eq_zero, mul_eq_zero, sub_eq_zero,
sub_eq_zero, sub_eq_zero, sub_eq_zero]
constructor
· rintro (h | h)
· exact absurd h.symm hab
· exact h
· exact Or.inr
theorem nonCollinearFor_four_image_acnodalPoint (T : Set ℝ) :
NonCollinearFor 4 (acnodalPoint '' T) := by
intro A hA hfin hcard hcol
obtain ⟨p, q, hp, hq, hpq⟩ := (Set.one_lt_ncard_iff hfin).1 (by omega)
obtain ⟨a, -, rfl⟩ := hA hp
obtain ⟨b, -, rfl⟩ := hA hq
have hab : a ≠ b := fun h ↦ hpq (by rw [h])
have hsub : A ⊆ ({acnodalPoint a, acnodalPoint b,
acnodalPoint ((1 - a * b) / (a + b))} : Finset ℝ²) := by
intro r hr
obtain ⟨c, -, rfl⟩ := hA hr
rcases (acnodalPoint_mem_line_iff hab).1
(hcol.mem_affineSpan_of_mem_of_ne hp hq hr hpq) with h | h | h
· simp [h]
· simp [h]
· have hs : a + b ≠ 0 := by
intro hs
have hb : b = -a := by linarith
subst hb
nlinarith [sq_nonneg a]
have hc : c = (1 - a * b) / (a + b) := by rw [eq_div_iff hs]; linarith
simp [hc]
have h3 := Set.ncard_le_ncard hsub (Finset.finite_toSet _)
rw [Set.ncard_coe_finset] at h3
have := Finset.card_le_three (a := acnodalPoint a) (b := acnodalPoint b)
(c := acnodalPoint ((1 - a * b) / (a + b)))
omega
end ErdosSwarm.Erdos588
(The ;-joined lines were separate lines in the file I compiled.)