Lean / 24805ab5c95d / source
Lean readerSolution.lean (submission 24805ab5c95d)
Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports FormalConjectures.ErdosProblems.«503», which it does not have: you can read it there, but it will not check. Build the project itself to check it.
A proof of the atlas conjecture ErdosProblems/503#Erdos503.erdos_503.variants.lower_bound, submitted here and checked by our kernel replay.
import FormalConjectures.ErdosProblems.«503»/-!# Alweiss's lower bound for Erdős problem 503The indicator vectors of the two-element subsets lie in an affine hyperplaneand realize only two distances between distinct points.Source: https://www.erdosproblems.com/forum/thread/503-/open Finsetopen scoped BigOperators EuclideanGeometrynamespace Erdos503-- Alweiss's coordinate-pair construction, as recorded in the discussion of Erdős #503.private def pairIndicator {n : ℕ} (s : Finset (Fin (n + 1))) :EuclideanSpace ℝ (Fin (n + 1)) :=WithLp.toLp 2 (fun i => if i ∈ s then 1 else 0)private theorem sum_pairIndicator {n : ℕ} (s : Finset (Fin (n + 1))) :(∑ i, pairIndicator s i) = (s.card : ℝ) := bychange (∑ i : Fin (n + 1), if i ∈ s then (1 : ℝ) else 0) = _rw [Finset.sum_boole, Finset.filter_univ_mem]private theorem pairIndicator_injective {n : ℕ} :Function.Injective (pairIndicator (n := n)) := byintro s t hext ihave hi := congrArg (fun x : EuclideanSpace ℝ (Fin (n + 1)) => x i) hchange (if i ∈ s then (1 : ℝ) else 0) = (if i ∈ t then 1 else 0) at hiby_cases hs : i ∈ s <;> by_cases ht : i ∈ t <;> simp_allprivate theorem dist_pairIndicator_sq {n : ℕ} (s t : Finset (Fin (n + 1))) :dist (pairIndicator s) (pairIndicator t) ^ 2 =(s.card : ℝ) + (t.card : ℝ) - 2 * ((s ∩ t).card : ℝ) := byrw [dist_eq_norm, EuclideanSpace.real_norm_sq_eq]calc_ = ∑ i, (pairIndicator s i + pairIndicator t i - 2 * pairIndicator (s ∩ t) i) := byapply Finset.sum_congr rflintro i _change ((if i ∈ s then (1 : ℝ) else 0) - (if i ∈ t then 1 else 0)) ^ 2 =(if i ∈ s then 1 else 0) + (if i ∈ t then 1 else 0) -2 * (if i ∈ s ∩ t then 1 else 0)by_cases hs : i ∈ s <;> by_cases ht : i ∈ t <;>norm_num [hs, ht, Finset.mem_inter]_ = _ := byrw [Finset.sum_sub_distrib, Finset.sum_add_distrib, ← Finset.mul_sum]rw [sum_pairIndicator, sum_pairIndicator, sum_pairIndicator]private theorem pairIntersection_lt_two {n : ℕ}(s t : {s : Finset (Fin (n + 1)) // s.card = 2}) (hst : s ≠ t) :(s.val ∩ t.val).card < 2 := byhave hproper : s.val ∩ t.val ⊂ s.val := byrefine Finset.ssubset_iff_subset_ne.mpr ⟨Finset.inter_subset_left, ?_⟩intro happly hstapply Subtype.extapply Finset.eq_of_subset_of_card_le· intro i hihave hm : i ∈ s.val ∩ t.val := h.symm ▸ hiexact (Finset.mem_inter.mp hm).2· rw [s.property, t.property]simpa only [s.property] using Finset.card_lt_card hpropertheorem solution (n : ℕ) :∃ m ∈ {(A.ncard) | (A : Set (ℝ^n)) (_hA : A.IsIsosceles)}, (n + 1).choose 2 ≤ m := byclassicalby_cases hn : n = 0· subst nhave hA : ({0} : Set (ℝ^0)).IsIsosceles := byexact ⟨⟨0, Set.mem_singleton _⟩, Set.triplewise_singleton _⟩exact ⟨({0} : Set (ℝ^0)).ncard, ⟨{0}, hA, rfl⟩, by simp⟩let E := EuclideanSpace ℝ (Fin (n + 1))let coordinateSum : E →ₗ[ℝ] ℝ :={ toFun := fun x => ∑ i, x imap_add' := fun x y => Finset.sum_add_distribmap_smul' := fun r x => Finset.mul_sum _ _ _ |>.symm }let origin := pairIndicator ({0} : Finset (Fin (n + 1))) +pairIndicator ({0} : Finset (Fin (n + 1)))have hsurj : Function.Surjective coordinateSum := byintro rrefine ⟨r • pairIndicator ({0} : Finset (Fin (n + 1))), ?_⟩rw [LinearMap.map_smul]change r • (∑ i, pairIndicator ({0} : Finset (Fin (n + 1))) i) = rsimp [sum_pairIndicator]have hdim : Module.finrank ℝ coordinateSum.ker = n := byhave hr := coordinateSum.finrank_range_add_finrank_kerrw [LinearMap.range_eq_top.mpr hsurj, finrank_top, Module.finrank_self] at hrhave hE : Module.finrank ℝ E = n + 1 := finrank_euclideanSpace_finomegalet e : coordinateSum.ker ≃ₗᵢ[ℝ] (ℝ^n) :=((stdOrthonormalBasis ℝ coordinateSum.ker).reindex (finCongr hdim)).reprlet P := {s : Finset (Fin (n + 1)) // s.card = 2}let point : P → coordinateSum.ker := fun s =>⟨pairIndicator s.val - origin, byrw [LinearMap.mem_ker, map_sub]change (∑ i, pairIndicator s.val i) - (∑ i, origin i) = 0norm_num [origin, Finset.sum_add_distrib, sum_pairIndicator, s.property]⟩let f : P → (ℝ^n) := e ∘ pointhave hf : Function.Injective f := byintro s t hhave hp := congrArg (fun x : coordinateSum.ker => (x : E)) (e.injective h)change pairIndicator s.val - origin = pairIndicator t.val - origin at hpexact Subtype.ext (pairIndicator_injective (sub_left_injective hp))have hcard : (Set.range f).ncard = (n + 1).choose 2 := byrw [Set.ncard_range_of_injective hf, Nat.card_eq_fintype_card]simp [P]have hdist (s t : P) :dist (f s) (f t) ^ 2 = 4 - 2 * ((s.val ∩ t.val).card : ℝ) := bychange dist (e (point s)) (e (point t)) ^ 2 = _rw [e.isometry.dist_eq]change dist (pairIndicator s.val - origin) (pairIndicator t.val - origin) ^ 2 = _rw [dist_sub_right, dist_pairIndicator_sq, s.property, t.property]norm_numhave hA : (Set.range f).IsIsosceles := byrefine ⟨?_, ?_⟩· have ht : ((Finset.univ : Finset (Fin (n + 1))).powersetCard 2).Nonempty :=Finset.powersetCard_nonempty.mpr (by simp; omega)obtain ⟨s, hs⟩ := htexact ⟨f ⟨s, (Finset.mem_powersetCard.mp hs).2⟩, Set.mem_range_self _⟩· intro x hx y hy z hz hxy hyz hxzobtain ⟨s, rfl⟩ := hxobtain ⟨t, rfl⟩ := hyobtain ⟨u, rfl⟩ := hzhave hst := pairIntersection_lt_two s t (fun h => hxy (congrArg f h))have htu := pairIntersection_lt_two t u (fun h => hyz (congrArg f h))have hus := pairIntersection_lt_two u s (fun h => hxz (congrArg f h.symm))have sameDist (a b c d : P) (h : (a.val ∩ b.val).card = (c.val ∩ d.val).card) :dist (f a) (f b) = dist (f c) (f d) := byapply (sq_eq_sq₀ dist_nonneg dist_nonneg).mprw [hdist, hdist, h]have twoEqual :(s.val ∩ t.val).card = (t.val ∩ u.val).card ∨(t.val ∩ u.val).card = (u.val ∩ s.val).card ∨(u.val ∩ s.val).card = (s.val ∩ t.val).card := by omegarcases twoEqual with h | h | h· exact Or.inl (sameDist s t t u h)· exact Or.inr (Or.inl (sameDist t u u s h))· exact Or.inr (Or.inr (sameDist u s s t h))exact ⟨(Set.range f).ncard, ⟨Set.range f, hA, rfl⟩, hcard.ge⟩end Erdos503