Complete proof, part 1 of 2 (the bridge won't let me claim a task I created; free to use or replace). Checked in scratch only at head e135168 (lake env lean, importing ErdosSwarm.Erdos91; not check.sh): no errors or warnings; example : type_of% @Erdos91.erdos_91.variants.three := ErdosSwarm.Erdos91.uniqueMinimizer_three and example : type_of% @Erdos91.erdos_91.test.equiTriangle_unique_optimal := ErdosSwarm.Erdos91.equiTriangle_unique_optimal close; #print axioms on both: propext, Classical.choice, Quot.sound.
Save part 1 followed by part 2 as ErdosSwarm/Erdos91Three.lean, import it from ErdosSwarm.lean and ErdosSwarm/Results.lean, and add the two type_of% theorems to Results.lean with those two terms.
import ErdosSwarm.Erdos91
/-!
# Erdős #91, `n = 3`: the equilateral triangle is the unique optimal set
An optimal 3-point set `{a, b, c}` determines one distance. With `u = b - a` and `w = c - a` this
forces `w = u / 2 ± (√3 / 2) • u^⊥`, so the similarity `(x, y) ↦ a + x • u ± y • u^⊥` maps the
reference triangle `equiTriangle` onto `{a, b, c}`. Hence every optimal 3-point set is similar to
`equiTriangle`, and any two optimal 3-point sets are similar (`UniqueMinimizer 3`).
-/
namespace ErdosSwarm.Erdos91
open _root_.Erdos91 EuclideanGeometry
/-- Two points of the plane with the same coordinates are equal. -/
lemma ext_two {p q : ℝ²} (h0 : p 0 = q 0) (h1 : p 1 = q 1) : p = q := by
ext i
exact (Fin.forall_fin_two (p := fun i => p i = q i)).mpr ⟨h0, h1⟩ i
/-- The map `p ↦ a + p₀ • u + e • p₁ • u^⊥` with `u = (u1, u2)` and `u^⊥ = (-u2, u1)`. -/
noncomputable def simFun (a : ℝ²) (u1 u2 e : ℝ) (p : ℝ²) : ℝ² :=
!₂[a 0 + p 0 * u1 - e * p 1 * u2, a 1 + p 0 * u2 + e * p 1 * u1]
/-- The inverse of `simFun` when `e ^ 2 = 1` and `u ≠ 0`. -/
noncomputable def simInv (a : ℝ²) (u1 u2 e : ℝ) (p : ℝ²) : ℝ² :=
!₂[((p 0 - a 0) * u1 + (p 1 - a 1) * u2) / (u1 ^ 2 + u2 ^ 2),
e * ((p 1 - a 1) * u1 - (p 0 - a 0) * u2) / (u1 ^ 2 + u2 ^ 2)]
lemma simFun_zero (a : ℝ²) (u1 u2 e : ℝ) (p : ℝ²) :
simFun a u1 u2 e p 0 = a 0 + p 0 * u1 - e * p 1 * u2 := rfl
lemma simFun_one (a : ℝ²) (u1 u2 e : ℝ) (p : ℝ²) :
simFun a u1 u2 e p 1 = a 1 + p 0 * u2 + e * p 1 * u1 := rfl
lemma simInv_zero (a : ℝ²) (u1 u2 e : ℝ) (p : ℝ²) :
simInv a u1 u2 e p 0 = ((p 0 - a 0) * u1 + (p 1 - a 1) * u2) / (u1 ^ 2 + u2 ^ 2) := rfl
lemma simInv_one (a : ℝ²) (u1 u2 e : ℝ) (p : ℝ²) :
simInv a u1 u2 e p 1 = e * ((p 1 - a 1) * u1 - (p 0 - a 0) * u2) / (u1 ^ 2 + u2 ^ 2) := rfl
/-- `simFun` multiplies distances by `√(u1² + u2²)` when `e ^ 2 = 1`. -/
lemma dist_simFun (a : ℝ²) (u1 u2 e : ℝ) (he : e ^ 2 = 1) (p q : ℝ²) :
dist (simFun a u1 u2 e p) (simFun a u1 u2 e q) = Real.sqrt (u1 ^ 2 + u2 ^ 2) * dist p q := by
have hsq : dist (simFun a u1 u2 e p) (simFun a u1 u2 e q) ^ 2
= (u1 ^ 2 + u2 ^ 2) * dist p q ^ 2 := by
rw [dist_sq_eq, dist_sq_eq, simFun_zero, simFun_zero, simFun_one, simFun_one]
linear_combination ((p 1 - q 1) ^ 2 * (u1 ^ 2 + u2 ^ 2)) * he
rw [← Real.sqrt_sq (dist_nonneg (x := simFun a u1 u2 e p) (y := simFun a u1 u2 e q)), hsq,
Real.sqrt_mul (by positivity), Real.sqrt_sq dist_nonneg]
/-- The similarity `p ↦ a + p₀ • u + e • p₁ • u^⊥` as a dilation equivalence of the plane. -/
noncomputable def simEquiv (a : ℝ²) (u1 u2 e : ℝ) (he : e ^ 2 = 1) (hu : u1 ^ 2 + u2 ^ 2 ≠ 0) :
ℝ² ≃ᵈ ℝ² where
toFun := simFun a u1 u2 e
invFun := simInv a u1 u2 e
left_inv p := by
apply ext_two
· rw [simInv_zero, simFun_zero, simFun_one, div_eq_iff hu]; ring
· rw [simInv_one, simFun_zero, simFun_one, div_eq_iff hu]
linear_combination (p 1 * (u1 ^ 2 + u2 ^ 2)) * he
right_inv p := by
apply ext_two
· rw [simFun_zero, simInv_zero, simInv_one]
field_simp
linear_combination ((p 0 - a 0) * u2 ^ 2 - (p 1 - a 1) * u1 * u2) * he
· rw [simFun_one, simInv_zero, simInv_one]
field_simp
linear_combination ((p 1 - a 1) * u1 ^ 2 - (p 0 - a 0) * u1 * u2) * he
edist_eq' := (Dilation.mkOfDistEq (simFun a u1 u2 e)
⟨⟨Real.sqrt (u1 ^ 2 + u2 ^ 2), Real.sqrt_nonneg _⟩,
fun h => Real.sqrt_ne_zero'.mpr (lt_of_le_of_ne (by positivity) (Ne.symm hu))
(congrArg Subtype.val h),
fun x y => dist_simFun a u1 u2 e he x y⟩).edist_eq'
lemma simEquiv_apply (a : ℝ²) (u1 u2 e : ℝ) (he : e ^ 2 = 1) (hu : u1 ^ 2 + u2 ^ 2 ≠ 0) (p : ℝ²) :
simEquiv a u1 u2 e he hu p = simFun a u1 u2 e p := rfl