import Mathlib/-!# Unit distances in convex polygons: complete formalisationSingle-file formalisation of 96-97.tex by Liam Kruer, Jensen Kohlmeyer, andLiam Price. All construction lemmas, quantitative results, corollaries, andthe disproofs of Erdos problems 96, 97, and the general fixed-k conjectureare included below. The only import is Mathlib.Main entry points in namespace Proof:* main_theorem and main_quantitative (explicit absolute constant C = 7)* finite_construction_plane and threshold_configuration_plane* convex_unit_distances_omega and eventual_minimum_degree* bounded_size_minimum_degree and explicit_erdos_97_counterexample* erdos_96_false, erdos_97_false, and erdos_97_general_falseThe final section checks the transitive axiom dependencies of 33 results,permitting only propext, Classical.choice, and Quot.sound.Checked with Lean v4.33.1 and the Mathlib version used by this project.-/set_option maxHeartbeats 1600000set_option maxRecDepth 4000/- The following compatibility definitions reproduce the relevant geometryinterfaces of FormalConjecturesForMathlib.Geometry.Metric and Geometry.2d.Those sources are Copyright 2025 The Formal Conjectures Authors and licensedunder the Apache License, Version 2.0:https://www.apache.org/licenses/LICENSE-2.0They are included here so this file requires no Formal Conjectures imports. -/scoped[EuclideanGeometry] notation "ℝ²" => EuclideanSpace ℝ (Fin 2)noncomputable def unitDistNum {X : Type*} [MetricSpace X] (s : Finset X) : ℕ := byclassicalexact (s.sym2.filter fun p => dist p.out.1 p.out.2 = 1).cardnamespace EuclideanGeometryopen scoped EuclideanGeometrydef ConvexIndep (S : Set ℝ²) : Prop :=∀ a ∈ S, a ∉ convexHull ℝ (S \ {a})end EuclideanGeometry/-! ## Source: Definitions.lean -/section Combined_Definitions/-!Definitions used by the Formal Conjectures statements of Erdős problems 96 and 97.The definitions below reproduce the relevant definitions from those problem files;no conjecture declaration or unproved theorem is imported.-/open EuclideanGeometryopen scoped EuclideanGeometrynamespace Erdos96noncomputable def convexUnitDistanceCounts (n : ℕ) : Set ℕ :={unitDistNum points | (points : Finset ℝ²) (_ : points.card = n) (_ : ConvexIndep points)}noncomputable def maxConvexUnitDistances (n : ℕ) : ℕ :=sSup (convexUnitDistanceCounts n)end Erdos96namespace Erdos97def HasNEquidistantPointsAt (n : ℕ) (A : Finset ℝ²) (p : ℝ²) : Prop :=∃ r : ℝ, r > 0 ∧ (A.filter fun q ↦ dist p q = r).card ≥ ndef HasNEquidistantPointsOn (n : ℕ) (A B : Finset ℝ²) : Prop :=∀ p ∈ B, HasNEquidistantPointsAt n A pdef HasNEquidistantProperty (n : ℕ) (A : Finset ℝ²) : Prop :=HasNEquidistantPointsOn n A Adef HasNUnitDistancePointsAt (n : ℕ) (A : Finset ℝ²) (p : ℝ²) : Prop :=(A.filter fun q ↦ dist p q = 1).card ≥ ndef HasNUnitDistancePointsOn (n : ℕ) (A B : Finset ℝ²) : Prop :=∀ p ∈ B, HasNUnitDistancePointsAt n A pdef HasNUnitDistanceProperty (n : ℕ) (A : Finset ℝ²) : Prop :=HasNUnitDistancePointsOn n A Aend Erdos97end Combined_Definitions/-! ## Source: Erdos96.lean -/section Combined_Erdos96/-!# Superlinearly many unit distances in convex positionAuthors: Liam Kruer <kruerl@purdue.edu>Jensen Kohlmeyer <jenwin@purdue.edu>OpenAI Codex provided substantial assistance with the mathematical exploration,construction, proofs, formalization, verification, and manuscript preparation.The authors are responsible for the content.Proof of the original counterexample and the negation of Erdős problem 96.The conjectures' definitions above do not import unproved statements.-/open _root_.Erdos96/- ## Angle -/section OriginalAngle/- Calculus of the angle subtended by a unit chord at the origin. -/namespace Proofnoncomputable def chordCos (r s : ℝ) : ℝ := (r ^ 2 + s ^ 2 - 1) / (2 * r * s)noncomputable def chordCosLeft (r s : ℝ) : ℝ := (r ^ 2 - s ^ 2 + 1) / (2 * r ^ 2 * s)noncomputable def chordCosMixed (r s : ℝ) : ℝ := -(r ^ 2 + s ^ 2 + 1) / (2 * r ^ 2 * s ^ 2)noncomputable def chordAngle (r s : ℝ) : ℝ := Real.arccos (chordCos r s)theorem chordCos_comm (r s : ℝ) : chordCos r s = chordCos s r := byunfold chordCoscongr 1 <;> ringtheorem hasDerivAt_chordCos_left {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0) :HasDerivAt (fun x => chordCos x s) (chordCosLeft r s) r := byhave hnum := (((hasDerivAt_id r).pow 2).add_const (s ^ 2)).sub_const 1have hden := ((hasDerivAt_id r).const_mul 2).mul_const sconvert! hnum.div hden (mul_ne_zero (mul_ne_zero two_ne_zero hr) hs) using 1dsimp only [id_eq, Pi.pow_apply]unfold chordCosLeftfield_simp [hr, hs]ringtheorem hasDerivAt_chordCos_right {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0) :HasDerivAt (chordCos r) (chordCosLeft s r) s := bysimpa only [chordCos_comm] using hasDerivAt_chordCos_left hs hrtheorem hasDerivAt_chordCosLeft_right {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0) :HasDerivAt (chordCosLeft r) (chordCosMixed r s) s := byhave hnum := (((hasDerivAt_id s).pow 2).const_sub (r ^ 2)).add_const 1have hden := (hasDerivAt_id s).const_mul (2 * r ^ 2)convert! hnum.div hden (mul_ne_zero (mul_ne_zero two_ne_zero (pow_ne_zero 2 hr)) hs) using 1dsimp only [id_eq, Pi.pow_apply]unfold chordCosMixedfield_simp [hr, hs]ringtheorem chordCos_mixed_identity {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0) :-(chordCosMixed r s * (1 - chordCos r s ^ 2) +chordCos r s * chordCosLeft r s * chordCosLeft s r) = 1 / (r ^ 2 * s ^ 2) := byunfold chordCosMixed chordCos chordCosLeftfield_simp [hr, hs]ringnoncomputable def chordAngleLeft (r s : ℝ) : ℝ :=-chordCosLeft r s / Real.sqrt (1 - chordCos r s ^ 2)theorem chord_discriminant_pos {r s : ℝ}(hl : -1 < chordCos r s) (hu : chordCos r s < 1) :0 < 1 - chordCos r s ^ 2 := bynlinariththeorem hasDerivAt_chordAngle_left {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0)(hl : -1 < chordCos r s) (hu : chordCos r s < 1) :HasDerivAt (fun x => chordAngle x s) (chordAngleLeft r s) r := byconvert! (Real.hasDerivAt_arccos (ne_of_gt hl) (ne_of_lt hu)).comp r(hasDerivAt_chordCos_left hr hs) using 1unfold chordAngleLeftringtheorem hasDerivAt_chordAngleLeft_right {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0)(hl : -1 < chordCos r s) (hu : chordCos r s < 1) :HasDerivAt (chordAngleLeft r)(1 / (r ^ 2 * s ^ 2 * Real.sqrt (1 - chordCos r s ^ 2) ^ 3)) s := byhave hq := chord_discriminant_pos hl huhave hsqrt : Real.sqrt (1 - chordCos r s ^ 2) ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr hq)have hsquare := Real.sq_sqrt hq.lehave hnum := (hasDerivAt_chordCosLeft_right hr hs).neghave hden := (((hasDerivAt_chordCos_right hr hs).pow 2).const_sub 1).sqrt (ne_of_gt hq)convert! hnum.div hden hsqrt using 1have hid := chordCos_mixed_identity hr hsdsimp only [id_eq, Pi.pow_apply, Pi.neg_apply, Nat.cast_ofNat, Nat.reduceSub, pow_one, one_mul, mul_one]field_simp [hr, hs, hsqrt] at hid ⊢rw [hsquare]linear_combination -hidtheorem chordAngle_mixed_positive {r s : ℝ} (hr : r ≠ 0) (hs : s ≠ 0)(hl : -1 < chordCos r s) (hu : chordCos r s < 1) :0 < deriv (chordAngleLeft r) s := byrw [(hasDerivAt_chordAngleLeft_right hr hs hl hu).deriv]have := Real.sqrt_pos.mpr (chord_discriminant_pos hl hu)positivityend Proofend OriginalAngle/- ## GenericAngles -/section OriginalGenericAngles/- Local separation of finite linear combinations of edge angles. -/namespace Proofopen Set Filteropen scoped Topologydef ChordFeasible (r s : ℝ) : Prop :=r ≠ 0 ∧ s ≠ 0 ∧ -1 < chordCos r s ∧ chordCos r s < 1theorem chordAngle_rectangle_strict {a b c d : ℝ} (hab : a < b) (hcd : c < d)(hf : ∀ x ∈ Icc a b, ∀ y ∈ Icc c d, ChordFeasible x y) :0 < chordAngle b d - chordAngle a d - chordAngle b c + chordAngle a c := byhave hm : ∀ x ∈ Icc a b, chordAngleLeft x c < chordAngleLeft x d := byintro x hxhave hmono : StrictMonoOn (chordAngleLeft x) (Icc c d) := byapply strictMonoOn_of_deriv_pos (convex_Icc c d)· intro y hyobtain ⟨hr, hs, hl, hu⟩ := hf x hx y hyexact (hasDerivAt_chordAngleLeft_right hr hs hl hu).continuousAt.continuousWithinAt· intro y hyobtain ⟨hr, hs, hl, hu⟩ := hf x hx y (interior_subset hy)exact chordAngle_mixed_positive hr hs hl huexact hmono ⟨le_rfl, hcd.le⟩ ⟨hcd.le, le_rfl⟩ hcdhave hder : ∀ x ∈ Icc a b,HasDerivAt (fun t => chordAngle t d - chordAngle t c)(chordAngleLeft x d - chordAngleLeft x c) x := byintro x hxobtain ⟨hrd, hsd, hld, hud⟩ := hf x hx d ⟨hcd.le, le_rfl⟩obtain ⟨hrc, hsc, hlc, huc⟩ := hf x hx c ⟨le_rfl, hcd.le⟩exact (hasDerivAt_chordAngle_left hrd hsd hld hud).sub(hasDerivAt_chordAngle_left hrc hsc hlc huc)have hmono : StrictMonoOn (fun t => chordAngle t d - chordAngle t c) (Icc a b) := byapply strictMonoOn_of_deriv_pos (convex_Icc a b)· intro x hxexact (hder x hx).continuousAt.continuousWithinAt· intro x hxrw [(hder x (interior_subset hx)).deriv]exact sub_pos.mpr (hm x (interior_subset hx))have hh := hmono ⟨le_rfl, hab.le⟩ ⟨hab.le, le_rfl⟩ hablinarithnoncomputable def matrixSum {L P : Type*} [Fintype L] [Fintype P](f : L → P → ℝ → ℝ → ℝ) (r : L → ℝ) (s : P → ℝ) : ℝ :=∑ i, ∑ j, f i j (r i) (s j)theorem matrix_rectangle {L P : Type*} [Fintype L] [Fintype P][DecidableEq L] [DecidableEq P] (f : L → P → ℝ → ℝ → ℝ)(r : L → ℝ) (s : P → ℝ) (i : L) (j : P) (x y : ℝ) :matrixSum f (Function.update r i x) (Function.update s j y) -matrixSum f r (Function.update s j y) -matrixSum f (Function.update r i x) s + matrixSum f r s =f i j x y - f i j (r i) y - f i j x (s j) + f i j (r i) (s j) := bylet g := fun a b => f a b (Function.update r i x a) (Function.update s j y b) -f a b (r a) (Function.update s j y b) -f a b (Function.update r i x a) (s b) + f a b (r a) (s b)have he : matrixSum f (Function.update r i x) (Function.update s j y) -matrixSum f r (Function.update s j y) -matrixSum f (Function.update r i x) s + matrixSum f r s = ∑ a, ∑ b, g a b := bysimp only [matrixSum, g, Finset.sum_add_distrib, Finset.sum_sub_distrib]rw [he, Finset.sum_eq_single i]· rw [Finset.sum_eq_single j]· simp [g]· intro b _ hbjsimp [g, Function.update_of_ne hbj]· simp· intro a _ haiapply Finset.sum_eq_zerointro b _simp [g, Function.update_of_ne hai]· simptheorem finite_avoidance {X K Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [T1Space Y] [Zero Y](f : K → X → Y) (U : Set X) (hU : IsOpen U) (hne : U.Nonempty)(hc : ∀ k, ContinuousOn (f k) U)(hnc : ∀ k, ∀ V : Set X, V ⊆ U → IsOpen V → V.Nonempty → ∃ x ∈ V, f k x ≠ 0)(s : Finset K) : ∃ x ∈ U, ∀ k ∈ s, f k x ≠ 0 := byclassicalsuffices ∃ V : Set X, V ⊆ U ∧ IsOpen V ∧ V.Nonempty ∧∀ x ∈ V, ∀ k ∈ s, f k x ≠ 0 byobtain ⟨V, hVU, hVo, ⟨x, hx⟩, hv⟩ := thisexact ⟨x, hVU hx, hv x hx⟩induction s using Finset.induction_on with| empty => exact ⟨U, subset_rfl, hU, hne, by simp⟩| @insert k s hks ih =>obtain ⟨V, hVU, hVo, hVne, hV⟩ := ihobtain ⟨x, hx, hkx⟩ := hnc k V hVU hVo hVnerefine ⟨V ∩ (f k) ⁻¹' ({0}ᶜ), inter_subset_left.trans hVU,(hc k |>.mono hVU).isOpen_inter_preimage hVo isClosed_singleton.isOpen_compl,⟨x, hx, hkx⟩, ?_⟩intro y hy j hjrcases Finset.mem_insert.mp hj with rfl | hj· exact hy.2· exact hV y hy.1 j hjtheorem coordinate_rectangle {L P : Type*} [DecidableEq L] [DecidableEq P]{U : Set ((L → ℝ) × (P → ℝ))} (hU : IsOpen U) {z : (L → ℝ) × (P → ℝ)}(hz : z ∈ U) (i : L) (j : P) :∃ b d : ℝ, z.1 i < b ∧ z.2 j < d ∧∀ x ∈ Icc (z.1 i) b, ∀ y ∈ Icc (z.2 j) d,(Function.update z.1 i x, Function.update z.2 j y) ∈ U := bylet F := fun xy : ℝ × ℝ => (Function.update z.1 i xy.1, Function.update z.2 j xy.2)have hF : Continuous F := by unfold F; fun_prophave hmem : (z.1 i, z.2 j) ∈ F ⁻¹' U := by simpa [F] using hzobtain ⟨A, hA, B, hB, hAB⟩ := mem_nhds_prod_iff.mp ((hU.preimage hF).mem_nhds hmem)obtain ⟨a, b, hab, hAsub⟩ := mem_nhds_iff_exists_Ioo_subset.mp hAobtain ⟨c, d, hcd, hBsub⟩ := mem_nhds_iff_exists_Ioo_subset.mp hBrefine ⟨(z.1 i + b) / 2, (z.2 j + d) / 2, by linarith [hab.2], by linarith [hcd.2], ?_⟩intro x hx y hychange (x, y) ∈ F ⁻¹' Uapply hABconstructor· apply hAsubconstructor <;> linarith [hab.1, hab.2, hx.1, hx.2]· apply hBsubconstructor <;> linarith [hcd.1, hcd.2, hy.1, hy.2]theorem angle_sum_not_constant {L P : Type*} [Fintype L] [Fintype P][DecidableEq L] [DecidableEq P] (c : L → P → ℝ) (i : L) (j : P) (hc : c i j ≠ 0)(U : Set ((L → ℝ) × (P → ℝ))) (hU : IsOpen U) (hne : U.Nonempty)(hf : ∀ z ∈ U, ChordFeasible (z.1 i) (z.2 j)) (k : ℝ) :∃ z ∈ U, matrixSum (fun a b x y => c a b * chordAngle x y) z.1 z.2 ≠ k := byby_contra hnonepush Not at hnoneobtain ⟨z, hz⟩ := hneobtain ⟨b, d, hb, hd, hrect⟩ := coordinate_rectangle hU hz i jhave hfeas : ∀ x ∈ Icc (z.1 i) b, ∀ y ∈ Icc (z.2 j) d, ChordFeasible x y := byintro x hx y hysimpa using hf _ (hrect x hx y hy)have hpositive := chordAngle_rectangle_strict hb hd hfeashave h00 := hnone z hzhave h11 := hnone _ (hrect b ⟨hb.le, le_rfl⟩ d ⟨hd.le, le_rfl⟩)have h01 := hnone _ (hrect (z.1 i) ⟨le_rfl, hb.le⟩ d ⟨hd.le, le_rfl⟩)have h10 := hnone _ (hrect b ⟨hb.le, le_rfl⟩ (z.2 j) ⟨le_rfl, hd.le⟩)simp only [Function.update_eq_self] at h01 h10have hid := matrix_rectangle (fun a b x y => c a b * chordAngle x y) z.1 z.2 i j b drw [h00, h11, h01, h10] at hidhave hzero : c i j * (chordAngle b d - chordAngle (z.1 i) d -chordAngle b (z.2 j) + chordAngle (z.1 i) (z.2 j)) = 0 := by linear_combination -hidexact (mul_ne_zero hc (ne_of_gt hpositive)) hzerotheorem weighted_angles_continuousAt {L P : Type*} [Fintype L] [Fintype P](c : L → P → ℝ) (z : (L → ℝ) × (P → ℝ))(hr : ∀ i, z.1 i ≠ 0) (hs : ∀ j, z.2 j ≠ 0) :ContinuousAt (fun u => matrixSum (fun i j x y => c i j * chordAngle x y) u.1 u.2) z := byunfold matrixSum chordAngle chordCosfun_prop (disch := aesop)theorem finite_angle_avoidance {L P K : Type*} [Fintype L] [Fintype P][DecidableEq L] [DecidableEq P](c : K → L → P → ℝ) (offset : K → ℝ) (U : Set ((L → ℝ) × (P → ℝ)))(hU : IsOpen U) (hne : U.Nonempty)(hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0))(hc : ∀ k, ∃ i j, c k i j ≠ 0)(hfeas : ∀ k i j, c k i j ≠ 0 → ∀ z ∈ U, ChordFeasible (z.1 i) (z.2 j))(s : Finset K) : ∃ z ∈ U, ∀ k ∈ s,matrixSum (fun i j x y => c k i j * chordAngle x y) z.1 z.2 ≠ offset k := bylet f := fun (k : K) (z : (L → ℝ) × (P → ℝ)) =>matrixSum (fun i j x y => c k i j * chordAngle x y) z.1 z.2 - offset khave hcont : ∀ k, ContinuousOn (f k) U := byintro k z hzexact ((weighted_angles_continuousAt (c k) z (hnz z hz).1 (hnz z hz).2).subcontinuousAt_const).continuousWithinAthave hnc : ∀ k, ∀ V : Set ((L → ℝ) × (P → ℝ)),V ⊆ U → IsOpen V → V.Nonempty → ∃ z ∈ V, f k z ≠ 0 := byintro k V hVU hVo hVneobtain ⟨i, j, hij⟩ := hc kobtain ⟨z, hz, hh⟩ := angle_sum_not_constant (c k) i j hij V hVo hVne(fun z hz => hfeas k i j hij z (hVU hz)) (offset k)exact ⟨z, hz, sub_ne_zero.mpr hh⟩obtain ⟨z, hz, hh⟩ := finite_avoidance f U hU hne hcont hnc sexact ⟨z, hz, fun k hk => sub_ne_zero.mp (hh k hk)⟩end Proofend OriginalGenericAngles/- ## SeedAlgebra -/section OriginalSeedAlgebra/- Polynomial identities for the two classes of incidence seeds. -/namespace Proofnoncomputable sectiondef lineC (x t : ℝ) : ℝ := x ^ 2 + t / 2def pointD (x t : ℝ) : ℝ := -x ^ 2 + t / 2def lineSeed (ε x t : ℝ) : ℂ := ⟨ε * x, -1 / 2 + ε ^ 2 * lineC x t⟩def pointSeed (ε x t : ℝ) : ℂ := ⟨-ε * x, 1 / 2 + ε ^ 2 * pointD x t⟩def support (a b : ℂ) : ℝ := a.re * (b.re - a.re) + a.im * (b.im - a.im)theorem line_support_identity (ε x t y u : ℝ) :support (lineSeed ε x t) (lineSeed ε y u) =ε ^ 2 * (-(y - x) ^ 2 / 2 - (u - t) / 4) +ε ^ 4 * lineC x t * (lineC y u - lineC x t) := bysimp only [support, lineSeed, lineC]ringtheorem point_support_identity (ε x t y u : ℝ) :support (pointSeed ε x t) (pointSeed ε y u) =ε ^ 2 * (-(y - x) ^ 2 / 2 + (u - t) / 4) +ε ^ 4 * pointD x t * (pointD y u - pointD x t) := bysimp only [support, pointSeed, pointD]ringtheorem line_normSq (ε x t : ℝ) :Complex.normSq (lineSeed ε x t) =1 / 4 - ε ^ 2 * t / 2 + ε ^ 4 * (lineC x t) ^ 2 := bysimp only [Complex.normSq_apply, lineSeed, lineC]ringtheorem point_normSq (ε x t : ℝ) :Complex.normSq (pointSeed ε x t) =1 / 4 + ε ^ 2 * t / 2 + ε ^ 4 * (pointD x t) ^ 2 := bysimp only [Complex.normSq_apply, pointSeed, pointD]ringtheorem incidence_distance_identity (ε x t y u : ℝ)(h : u - t = (y - x) ^ 2) :Complex.normSq (pointSeed ε y u - lineSeed ε x t) =1 + ε ^ 4 * (pointD y u - lineC x t) ^ 2 := bysimp only [Complex.normSq_apply, Complex.sub_re, Complex.sub_im,pointSeed, lineSeed, pointD, lineC]linear_combination ε ^ 2 * htheorem signed_digit_margin {x t : ℝ}(h : |t| < (50 / 27 : ℝ) * x ^ 2) :-x ^ 2 / 2 - t / 4 < -x ^ 2 / 27 ∧-x ^ 2 / 2 + t / 4 < -x ^ 2 / 27 := byrcases abs_lt.mp h with ⟨hl, hu⟩constructor <;> linarithendend Proofend OriginalSeedAlgebra/- ## RadialGeometry -/section OriginalRadialGeometry/- Strict radial support, rotations, and their convexity consequences. -/namespace Proofopen scoped InnerProductSpacetheorem support_eq_inner (a b : ℂ) : support a b = ⟪a, b - a⟫_ℝ := bysimp only [support, Complex.inner, Complex.mul_re, Complex.sub_re,Complex.sub_im, Complex.conj_re, Complex.conj_im]ringtheorem support_eq_normSq (a b : ℂ) :2 * support a b = Complex.normSq b - Complex.normSq a - Complex.normSq (b - a) := bysimp only [support, Complex.normSq_apply, Complex.sub_re, Complex.sub_im]ringtheorem support_negative_of_equal_norm {a b : ℂ} (hne : a ≠ b)(hnorm : ‖a‖ = ‖b‖) : support a b < 0 := byhave heq : Complex.normSq a = Complex.normSq b := bysimpa only [Complex.normSq_eq_norm_sq] using congrArg (fun r : ℝ => r ^ 2) hnormhave hp : 0 < Complex.normSq (b - a) := Complex.normSq_pos.mpr (sub_ne_zero.mpr hne.symm)have := support_eq_normSq a blinariththeorem convexIndependent_of_support {ι : Type*} (p : ι → ℂ)(h : ∀ i j, i ≠ j → support (p i) (p j) < 0) : ConvexIndependent ℝ p := byintro s i hiby_contra hnothave hs : p '' s ⊆ {z : ℂ | ⟪p i, z⟫_ℝ < ⟪p i, p i⟫_ℝ} := byrintro z ⟨j, hj, rfl⟩have hij : i ≠ j := fun he => hnot (he.symm ▸ hj)have hh := h i j hijrw [support_eq_inner, inner_sub_right] at hhexact sub_neg.mp hhhave hc : Convex ℝ {z : ℂ | ⟪p i, z⟫_ℝ < ⟪p i, p i⟫_ℝ} :=convex_halfSpace_lt ((innerₗ ℂ) (p i)).isLinear _have hz := (convexHull_min hs hc) hiexact lt_irrefl _ (show ⟪p i, p i⟫_ℝ < ⟪p i, p i⟫_ℝ from hz)theorem support_mul (a b w : ℂ) :support (a * w) (b * w) = Complex.normSq w * support a b := bysimp only [support, Complex.mul_re, Complex.mul_im, Complex.normSq_apply]ringtheorem norm_subset_prod {ι : Type*} (s : Finset ι) (w : ι → ℂ)(hw : ∀ i ∈ s, ‖w i‖ = 1) : ‖∏ i ∈ s, w i‖ = 1 := byrw [norm_prod]exact Finset.prod_eq_one hwtheorem norm_prod_sub_one_le {ι : Type*} (s : Finset ι) (w : ι → ℂ)(hw : ∀ i ∈ s, ‖w i‖ = 1) :‖(∏ i ∈ s, w i) - 1‖ ≤ ∑ i ∈ s, ‖w i - 1‖ := byclassicalinduction s using Finset.induction_on with| empty => simp| @insert i s hi ih =>rw [Finset.prod_insert hi, Finset.sum_insert hi]have hwi := hw i (Finset.mem_insert_self i s)have hws : ∀ j ∈ s, ‖w j‖ = 1 := fun j hj => hw j (Finset.mem_insert_of_mem hj)calc‖w i * (∏ j ∈ s, w j) - 1‖ =‖w i * ((∏ j ∈ s, w j) - 1) + (w i - 1)‖ := by congr 1; ring_ ≤ ‖w i * ((∏ j ∈ s, w j) - 1)‖ + ‖w i - 1‖ := norm_add_le _ __ = ‖(∏ j ∈ s, w j) - 1‖ + ‖w i - 1‖ := by rw [norm_mul, hwi, one_mul]_ ≤ ‖w i - 1‖ + ∑ j ∈ s, ‖w j - 1‖ := by linarith [ih hws]theorem support_change_same_norm (a b a' b' : ℂ) (hn : ‖a'‖ = ‖a‖) :|support a' b' - support a b| ≤‖a' - a‖ * ‖b'‖ + ‖a‖ * ‖b' - b‖ := byhave he : support a' b' - support a b =⟪a' - a, b'⟫_ℝ + ⟪a, b' - b⟫_ℝ := bysimp only [support_eq_inner, inner_sub_left, inner_sub_right,real_inner_self_eq_norm_sq, hn]ringrw [he]exact (abs_add_le _ _).trans (add_le_add (abs_real_inner_le_norm _ _) (abs_real_inner_le_norm _ _))theorem rotated_support_bound {a b u v : ℂ} {H : ℝ}(ha : ‖a‖ ≤ 1) (hb : ‖b‖ ≤ 1) (hu : ‖u‖ = 1) (hv : ‖v‖ = 1)(hU : ‖u - 1‖ ≤ H) (hV : ‖v - 1‖ ≤ H) :support (a * u) (b * v) ≤ support a b + 2 * H := byhave hH : 0 ≤ H := (norm_nonneg _).trans hUhave hau : ‖a * u‖ = ‖a‖ := by rw [norm_mul, hu, mul_one]have hbv : ‖b * v‖ = ‖b‖ := by rw [norm_mul, hv, mul_one]have hdiffa : ‖a * u - a‖ ≤ H := byrw [← mul_sub_one, norm_mul]exact (mul_le_mul ha hU (norm_nonneg _) (by norm_num)).trans_eq (one_mul H)have hdiffb : ‖b * v - b‖ ≤ H := byrw [← mul_sub_one, norm_mul]exact (mul_le_mul hb hV (norm_nonneg _) (by norm_num)).trans_eq (one_mul H)have hh := support_change_same_norm a b (a * u) (b * v) haurw [hbv] at hhhave h1 : ‖a * u - a‖ * ‖b‖ ≤ H := byexact (mul_le_mul hdiffa hb (norm_nonneg _) hH).trans_eq (mul_one H)have h2 : ‖a‖ * ‖b * v - b‖ ≤ H := byexact (mul_le_mul ha hdiffb (norm_nonneg _) (by norm_num)).trans_eq (one_mul H)have := le_abs_self (support (a * u) (b * v) - support a b)linarithend Proofend OriginalRadialGeometry/- ## Amplification -/section OriginalAmplification/- Amplification by products of unit complex numbers. -/namespace Proofnoncomputable sectiondef subsetProduct {E : Type*} (w : E → ℂ) (S : Finset E) : ℂ := ∏ e ∈ S, w edef rotatedCopy {I E : Type*} (b : I → ℂ) (w : E → ℂ) (x : I × Finset E) : ℂ :=b x.1 * subsetProduct w x.2theorem subsetProduct_norm {E : Type*} (w : E → ℂ) (hw : ∀ e, ‖w e‖ = 1)(S : Finset E) : ‖subsetProduct w S‖ = 1 :=norm_subset_prod S w (fun e _ => hw e)theorem subsetProduct_close {E : Type*} [Fintype E] (w : E → ℂ)(hw : ∀ e, ‖w e‖ = 1) (S : Finset E) :‖subsetProduct w S - 1‖ ≤ ∑ e, ‖w e - 1‖ := byclassicalrefine (norm_prod_sub_one_le S w (fun e _ => hw e)).trans ?_exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ S)(fun e _ _ => norm_nonneg (w e - 1))theorem rotatedCopy_injective {I E : Type*} (b : I → ℂ) (w : E → ℂ)(hb : ∀ i, b i ≠ 0) (hn : Function.Injective (fun i => ‖b i‖))(hw : ∀ e, ‖w e‖ = 1) (hprod : Function.Injective (subsetProduct w)) :Function.Injective (rotatedCopy b w) := byrintro ⟨i, S⟩ ⟨j, T⟩ hehave hnorm := congrArg norm hesimp only [rotatedCopy, norm_mul, subsetProduct_norm w hw, mul_one] at hnormhave hij := hn hnormsubst jhave hST := hprod (mul_left_cancel₀ (hb i) he)exact Prod.ext rfl hSTtheorem rotatedCopy_convexIndependent {I E : Type*} [Fintype E](b : I → ℂ) (w : E → ℂ) (hb : ∀ i, b i ≠ 0)(hn : Function.Injective (fun i => ‖b i‖)) (hb1 : ∀ i, ‖b i‖ ≤ 1)(hw : ∀ e, ‖w e‖ = 1) (hprod : Function.Injective (subsetProduct w))(hsupport : ∀ i j, i ≠ j → support (b i) (b j) < -2 * ∑ e, ‖w e - 1‖) :ConvexIndependent ℝ (rotatedCopy b w) := byapply convexIndependent_of_supportrintro ⟨i, S⟩ ⟨j, T⟩ hneby_cases hij : i = j· subst japply support_negative_of_equal_norm· exact fun h => hne (rotatedCopy_injective b w hb hn hw hprod h)· simp only [rotatedCopy, norm_mul, subsetProduct_norm w hw]· have hbound := rotated_support_bound (hb1 i) (hb1 j)(subsetProduct_norm w hw S) (subsetProduct_norm w hw T)(subsetProduct_close w hw S) (subsetProduct_close w hw T)dsimp [rotatedCopy]linarith [hsupport i j hij]theorem rotatedCopy_unit_edge {I E : Type*} [DecidableEq E](b : I → ℂ) (w : E → ℂ) (hw : ∀ e, ‖w e‖ = 1)(i j : I) (e : E) (he : ‖b i - b j * w e‖ = 1)(S : Finset E) (hS : e ∉ S) :dist (rotatedCopy b w (i, S)) (rotatedCopy b w (j, insert e S)) = 1 := bysimp only [rotatedCopy, subsetProduct, Finset.prod_insert hS, dist_eq_norm]rw [show b i * (∏ f ∈ S, w f) - b j * (w e * ∏ f ∈ S, w f) =(b i - b j * w e) * ∏ f ∈ S, w f by ring]rw [norm_mul, he, norm_subset_prod S w (fun f _ => hw f), one_mul]endend Proofend OriginalAmplification/- ## GenericRotations -/section OriginalGenericRotations/- Distinct subset products of correction rotations in every feasible open radius set. -/namespace Proofopen Set Filteropen scoped Topologynoncomputable sectiondef edgeAngleSum {L P E : Type*} [Fintype E] (l : E → L) (p : E → P)(a : E → ℝ) (z : (L → ℝ) × (P → ℝ)) : ℝ :=∑ e, a e * chordAngle (z.1 (l e)) (z.2 (p e))theorem edge_angle_rectangle {L P E : Type*} [Fintype E][DecidableEq L] [DecidableEq P] [DecidableEq E](l : E → L) (p : E → P) (hij : Function.Injective (fun e => (l e, p e)))(a : E → ℝ) (r : L → ℝ) (s : P → ℝ) (e : E) (x y : ℝ) :edgeAngleSum l p a (Function.update r (l e) x, Function.update s (p e) y) -edgeAngleSum l p a (r, Function.update s (p e) y) -edgeAngleSum l p a (Function.update r (l e) x, s) + edgeAngleSum l p a (r, s) =a e * (chordAngle x y - chordAngle (r (l e)) y - chordAngle x (s (p e)) +chordAngle (r (l e)) (s (p e))) := bylet g := fun f => a f * (chordAngle (Function.update r (l e) x (l f)) (Function.update s (p e) y (p f)) -chordAngle (r (l f)) (Function.update s (p e) y (p f)) -chordAngle (Function.update r (l e) x (l f)) (s (p f)) + chordAngle (r (l f)) (s (p f)))have he : edgeAngleSum l p a (Function.update r (l e) x, Function.update s (p e) y) -edgeAngleSum l p a (r, Function.update s (p e) y) -edgeAngleSum l p a (Function.update r (l e) x, s) + edgeAngleSum l p a (r, s) = ∑ f, g f := bysimp only [g, edgeAngleSum, mul_add, mul_sub, Finset.sum_add_distrib, Finset.sum_sub_distrib]rw [he, Finset.sum_eq_single e]· simp [g]· intro f _ hfeby_cases hl : l f = l e· have hp : p f ≠ p e := fun hh => hfe (hij (Prod.ext hl hh))simp [g, Function.update_of_ne hp]· simp [g, Function.update_of_ne hl]· simptheorem edge_angle_sum_not_constant {L P E : Type*} [Fintype E][DecidableEq L] [DecidableEq P] [DecidableEq E](l : E → L) (p : E → P) (hij : Function.Injective (fun e => (l e, p e)))(a : E → ℝ) (e : E) (ha : a e ≠ 0)(U : Set ((L → ℝ) × (P → ℝ))) (hU : IsOpen U) (hne : U.Nonempty)(hf : ∀ z ∈ U, ChordFeasible (z.1 (l e)) (z.2 (p e))) (k : ℝ) :∃ z ∈ U, edgeAngleSum l p a z ≠ k := byby_contra hnonepush Not at hnoneobtain ⟨z, hz⟩ := hneobtain ⟨b, d, hb, hd, hrect⟩ := coordinate_rectangle hU hz (l e) (p e)have hfeas : ∀ x ∈ Icc (z.1 (l e)) b, ∀ y ∈ Icc (z.2 (p e)) d, ChordFeasible x y := byintro x hx y hysimpa using hf _ (hrect x hx y hy)have hpositive := chordAngle_rectangle_strict hb hd hfeashave h00 := hnone z hzhave h11 := hnone _ (hrect b ⟨hb.le, le_rfl⟩ d ⟨hd.le, le_rfl⟩)have h01 := hnone _ (hrect (z.1 (l e)) ⟨le_rfl, hb.le⟩ d ⟨hd.le, le_rfl⟩)have h10 := hnone _ (hrect b ⟨hb.le, le_rfl⟩ (z.2 (p e)) ⟨le_rfl, hd.le⟩)simp only [Function.update_eq_self] at h01 h10have hid := edge_angle_rectangle l p hij a z.1 z.2 e b drw [h00, h11, h01, h10] at hidhave hzero : a e * (chordAngle b d - chordAngle (z.1 (l e)) d -chordAngle b (z.2 (p e)) + chordAngle (z.1 (l e)) (z.2 (p e))) = 0 := by linarithexact mul_ne_zero ha (ne_of_gt hpositive) hzerotheorem edge_angles_continuousAt {L P E : Type*} [Fintype E](l : E → L) (p : E → P) (a : E → ℝ) (z : (L → ℝ) × (P → ℝ))(hr : ∀ i, z.1 i ≠ 0) (hs : ∀ j, z.2 j ≠ 0) : ContinuousAt (edgeAngleSum l p a) z := byunfold edgeAngleSum chordAngle chordCosfun_prop (disch := aesop)def subsetDifference {E : Type*} [DecidableEq E] (S T : Finset E) (e : E) : ℝ :=(if e ∈ S then 1 else 0) - (if e ∈ T then 1 else 0)theorem subsetDifference_sum {E : Type*} [Fintype E] [DecidableEq E](S T : Finset E) (f : E → ℝ) :∑ e, subsetDifference S T e * f e = (∑ e ∈ S, f e) - ∑ e ∈ T, f e := bysimp [subsetDifference, sub_mul, ite_mul, Finset.sum_sub_distrib]theorem subsetDifference_nonzero {E : Type*} [DecidableEq E]{S T : Finset E} (hne : S ≠ T) : ∃ e, subsetDifference S T e ≠ 0 := byby_contra hhpush Not at hhapply hneext ehave he := hh eby_cases hS : e ∈ S <;> by_cases hT : e ∈ T <;> simp_all [subsetDifference]def phaseRotations {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)(z : (L → ℝ) × (P → ℝ)) (e : E) : ℂ :=Complex.exp (((θ e - chordAngle (z.1 (l e)) (z.2 (p e)) : ℝ) : ℂ) * Complex.I)theorem phaseRotations_norm {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)(z : (L → ℝ) × (P → ℝ)) (e : E) : ‖phaseRotations l p θ z e‖ = 1 := byexact Complex.norm_exp_ofReal_mul_I _theorem exp_phase_small_injective {x y : ℝ} (hsmall : |x - y| < Real.pi)(he : Complex.exp ((x : ℂ) * Complex.I) = Complex.exp ((y : ℂ) * Complex.I)) : x = y := byhave hexp : Complex.exp (((x - y : ℝ) : ℂ) * Complex.I) = Complex.exp 0 := byrw [Complex.ofReal_sub, sub_mul, Complex.exp_sub, he, div_self (Complex.exp_ne_zero _), Complex.exp_zero]have hxy := abs_lt.mp hsmallhave hh := Complex.exp_inj_of_neg_pi_lt_of_le_pi(x := ((x - y : ℝ) : ℂ) * Complex.I) (y := 0)(by simpa using hxy.1) (by simpa using hxy.2.le)(by simpa using neg_neg_of_pos Real.pi_pos) (by simpa using Real.pi_pos.le) hexphave := congrArg Complex.im hhexact sub_eq_zero.mp (by simpa using this)theorem subsetProduct_phase {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)(z : (L → ℝ) × (P → ℝ)) (S : Finset E) :subsetProduct (phaseRotations l p θ z) S =Complex.exp (((∑ e ∈ S, (θ e - chordAngle (z.1 (l e)) (z.2 (p e))) : ℝ) : ℂ) * Complex.I) := byunfold subsetProduct phaseRotationsrw [← Complex.exp_sum]congr 1simp [Complex.ofReal_sum, Finset.sum_sub_distrib, sub_mul, Finset.sum_mul]def relationPhase {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)(S T : Finset E) (z : (L → ℝ) × (P → ℝ)) : ℝ :=(∑ e ∈ S, (θ e - chordAngle (z.1 (l e)) (z.2 (p e)))) -∑ e ∈ T, (θ e - chordAngle (z.1 (l e)) (z.2 (p e)))theorem relationPhase_eq {L P E : Type*} [Fintype E] [DecidableEq E](l : E → L) (p : E → P) (θ : E → ℝ) (S T : Finset E) (z : (L → ℝ) × (P → ℝ)) :relationPhase l p θ S T z =(∑ e, subsetDifference S T e * θ e) - edgeAngleSum l p (subsetDifference S T) z := byunfold relationPhase edgeAngleSumrw [← Finset.sum_sub_distrib, ← subsetDifference_sum S T]apply Finset.sum_congr rflintro e _ringtheorem relationPhase_exp {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)(S T : Finset E) (z : (L → ℝ) × (P → ℝ))(he : subsetProduct (phaseRotations l p θ z) S = subsetProduct (phaseRotations l p θ z) T) :Complex.exp (((relationPhase l p θ S T z : ℝ) : ℂ) * Complex.I) = 1 := byunfold relationPhaserw [Complex.ofReal_sub, sub_mul, Complex.exp_sub,← subsetProduct_phase l p θ z S, ← subsetProduct_phase l p θ z T, he]apply div_selfrw [subsetProduct_phase]exact Complex.exp_ne_zero _theorem phaseRotations_continuousAt {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)(z : (L → ℝ) × (P → ℝ)) (hr : ∀ i, z.1 i ≠ 0) (hs : ∀ j, z.2 j ≠ 0) (e : E) :ContinuousAt (fun u => phaseRotations l p θ u e) z := byunfold phaseRotations chordAngle chordCosfun_prop (disch := aesop)theorem subset_products_separate {L P E : Type*} [Fintype E][DecidableEq L] [DecidableEq P] [DecidableEq E](l : E → L) (p : E → P) (hij : Function.Injective (fun e => (l e, p e)))(θ : E → ℝ) (U : Set ((L → ℝ) × (P → ℝ))) (hU : IsOpen U) (hne : U.Nonempty)(hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0))(hf : ∀ e, ∀ z ∈ U, ChordFeasible (z.1 (l e)) (z.2 (p e)))(S T : Finset E) (hST : S ≠ T) :∃ z ∈ U, subsetProduct (phaseRotations l p θ z) S ≠ subsetProduct (phaseRotations l p θ z) T := byby_contra hnonepush Not at hnoneobtain ⟨e, he⟩ := subsetDifference_nonzero hSTobtain ⟨z₀, hz₀⟩ := hnelet φ := relationPhase l p θ S Thave hc : ContinuousOn φ U := byintro z hzhave hh : ContinuousAt (fun u => (∑ e, subsetDifference S T e * θ e) -edgeAngleSum l p (subsetDifference S T) u) z :=continuousAt_const.sub (edge_angles_continuousAt l p (subsetDifference S T) z (hnz z hz).1 (hnz z hz).2)change ContinuousWithinAt φ U zrw [show φ = fun u => (∑ e, subsetDifference S T e * θ e) -edgeAngleSum l p (subsetDifference S T) u by funext u; exact relationPhase_eq l p θ S T u]exact hh.continuousWithinAtlet V := U ∩ (fun z => |φ z - φ z₀|) ⁻¹' Iio Real.pihave hVo : IsOpen V :=(hc.sub continuousOn_const).abs.isOpen_inter_preimage hU isOpen_Iiohave hVne : V.Nonempty := ⟨z₀, hz₀, by simpa using Real.pi_pos⟩have hVU : V ⊆ U := inter_subset_lefthave hconstant : ∀ z ∈ V, edgeAngleSum l p (subsetDifference S T) z =(∑ e, subsetDifference S T e * θ e) - φ z₀ := byintro z hzhave h1 := relationPhase_exp l p θ S T z (hnone z (hVU hz))have h0 := relationPhase_exp l p θ S T z₀ (hnone z₀ hz₀)have hphase : φ z = φ z₀ := exp_phase_small_injective hz.2 (h1.trans h0.symm)rw [show φ z = (∑ e, subsetDifference S T e * θ e) -edgeAngleSum l p (subsetDifference S T) z from relationPhase_eq l p θ S T z] at hphaselinarithobtain ⟨z, hz, hh⟩ := edge_angle_sum_not_constant l p hij (subsetDifference S T) e he V hVo hVne(fun z hz => hf e z (hVU hz)) ((∑ e, subsetDifference S T e * θ e) - φ z₀)exact hh (hconstant z hz)theorem exists_injective_subsetProducts {L P E : Type*} [Fintype E][DecidableEq L] [DecidableEq P] [DecidableEq E](l : E → L) (p : E → P) (hij : Function.Injective (fun e => (l e, p e)))(θ : E → ℝ) (U : Set ((L → ℝ) × (P → ℝ))) (hU : IsOpen U) (hne : U.Nonempty)(hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0))(hf : ∀ e, ∀ z ∈ U, ChordFeasible (z.1 (l e)) (z.2 (p e))) :∃ z ∈ U, Function.Injective (subsetProduct (phaseRotations l p θ z)) := byclassicallet K := {st : Finset E × Finset E // st.1 ≠ st.2}let f := fun (k : K) (z : (L → ℝ) × (P → ℝ)) =>subsetProduct (phaseRotations l p θ z) k.val.1 - subsetProduct (phaseRotations l p θ z) k.val.2have hc : ∀ k, ContinuousOn (f k) U := byintro k z hzhave hrot := phaseRotations_continuousAt l p θ z (hnz z hz).1 (hnz z hz).2apply ContinuousAt.continuousWithinAtunfold f subsetProductfun_prophave hnc : ∀ k, ∀ V : Set ((L → ℝ) × (P → ℝ)),V ⊆ U → IsOpen V → V.Nonempty → ∃ z ∈ V, f k z ≠ 0 := byintro k V hVU hVo hVneobtain ⟨z, hz, hh⟩ := subset_products_separate l p hij θ V hVo hVne(fun z hz => hnz z (hVU hz)) (fun e z hz => hf e z (hVU hz)) k.val.1 k.val.2 k.propertyexact ⟨z, hz, sub_ne_zero.mpr hh⟩obtain ⟨z, hz, hh⟩ := finite_avoidance f U hU hne hc hnc Finset.univrefine ⟨z, hz, ?_⟩intro S T heqby_contra hSTexact hh (⟨(S, T), hST⟩ : K) (Finset.mem_univ _) (sub_eq_zero.mpr heq)endend Proofend OriginalGenericRotations/- ## CorrectionAlgebra -/section OriginalCorrectionAlgebra/- Exact algebraic correction of a fourth-order error in a unit distance. -/namespace Proofnoncomputable sectiondef correctionRadicand (ε t M q : ℝ) : ℝ :=t ^ 2 - ε ^ 2 * M ^ 2 * q - ε ^ 6 * M ^ 4 / 4def chordNumerator (ε t M : ℝ) (q : ℂ) : ℂ :=⟨q.re + ε ^ 4 * M ^ 2 / 2, -ε * Real.sqrt (correctionRadicand ε t M q.re)⟩def correction (ε t M : ℝ) (q : ℂ) : ℂ := chordNumerator ε t M q / qdef correctionCoefficient (ε t M : ℝ) (q : ℂ) : ℂ :=(⟨ε * M ^ 2 / 2,M ^ 2 * (q.re + ε ^ 4 * M ^ 2 / 4) /(Real.sqrt (correctionRadicand ε t M q.re) - t)⟩ : ℂ) / qtheorem chordNumerator_normSq (ε t M : ℝ) (q : ℂ)(him : q.im = ε * t) (hF : 0 ≤ correctionRadicand ε t M q.re) :Complex.normSq (chordNumerator ε t M q) = Complex.normSq q := byhave hs := Real.sq_sqrt hFsimp only [chordNumerator, Complex.normSq_apply]rw [him]dsimp [correctionRadicand] at hs ⊢linear_combination ε ^ 2 * hstheorem correction_norm (ε t M : ℝ) (q : ℂ) (hq : q ≠ 0)(him : q.im = ε * t) (hF : 0 ≤ correctionRadicand ε t M q.re) :‖correction ε t M q‖ = 1 := byhave hh : Complex.normSq (correction ε t M q) = 1 := byrw [correction, Complex.normSq_div, chordNumerator_normSq ε t M q him hF]exact div_self (ne_of_gt (Complex.normSq_pos.mpr hq))rw [Complex.normSq_eq_norm_sq] at hhnlinarith [norm_nonneg (correction ε t M q)]theorem correction_cubic_identity (ε t M : ℝ) (q : ℂ) (hq : q ≠ 0)(him : q.im = ε * t) (hF : 0 ≤ correctionRadicand ε t M q.re)(hden : Real.sqrt (correctionRadicand ε t M q.re) - t ≠ 0) :correction ε t M q - 1 = (ε : ℂ) ^ 3 * correctionCoefficient ε t M q := byhave hs := Real.sq_sqrt hFhave he : chordNumerator ε t M q - q = (ε : ℂ) ^ 3 *(⟨ε * M ^ 2 / 2,M ^ 2 * (q.re + ε ^ 4 * M ^ 2 / 4) /(Real.sqrt (correctionRadicand ε t M q.re) - t)⟩ : ℂ) := byapply Complex.ext· simp only [chordNumerator, Complex.sub_re, Complex.mul_re, ← Complex.ofReal_pow,Complex.ofReal_re, Complex.ofReal_im, zero_mul, sub_zero]ring· simp only [chordNumerator, Complex.sub_im, Complex.mul_im,← Complex.ofReal_pow, Complex.ofReal_re, Complex.ofReal_im, zero_mul, add_zero]rw [him]rw [← mul_div_assoc]apply (eq_div_iff hden).mprdsimp [correctionRadicand] at hs ⊢linear_combination -ε * hsunfold correction correctionCoefficientrw [← div_self hq, ← sub_div, he, mul_div_assoc]theorem correction_unit_distance (a b : ℂ) (ε t M : ℝ)(hq : starRingEnd ℂ a * b ≠ 0)(him : (starRingEnd ℂ a * b).im = ε * t)(hF : 0 ≤ correctionRadicand ε t M (starRingEnd ℂ a * b).re)(hdist : Complex.normSq (b - a) = 1 + ε ^ 4 * M ^ 2) :‖a - b * correction ε t M (starRingEnd ℂ a * b)‖ = 1 := bylet q := starRingEnd ℂ a * blet w := correction ε t M qhave hw : ‖w‖ = 1 := correction_norm ε t M q hq him hFhave hz : starRingEnd ℂ a * (b * w) = chordNumerator ε t M q := bychange starRingEnd ℂ a * (b * (chordNumerator ε t M q / q)) = _rw [← mul_assoc]exact mul_div_cancel₀ _ hqhave hreal : (a * starRingEnd ℂ (b * w)).re = q.re + ε ^ 4 * M ^ 2 / 2 := byhave hh := congrArg Complex.re hzsimp only [Complex.mul_re, Complex.mul_im, Complex.conj_re, Complex.conj_im,chordNumerator] at hh ⊢linarithhave hbase : Complex.normSq a + Complex.normSq b - 2 * q.re = 1 + ε ^ 4 * M ^ 2 := bysimpa [Complex.normSq_sub, q, mul_comm, add_comm] using hdisthave hns : Complex.normSq (a - b * w) = 1 := byrw [Complex.normSq_sub, Complex.normSq_mul, Complex.normSq_eq_norm_sq w, hw, one_pow, mul_one,hreal]linarithrw [Complex.normSq_eq_norm_sq] at hnsnlinarith [norm_nonneg (a - b * w)]endend Proofend OriginalCorrectionAlgebra/- ## SeedGerms -/section OriginalSeedGerms/- Continuous formulas for the small correction rotations at a seed. -/namespace Proofopen Filteropen scoped Topologynoncomputable sectiondef seedTangent (ε x t y u : ℝ) : ℝ :=(x - y) / 2 + ε ^ 2 * (x * pointD y u + y * lineC x t)def seedProduct (ε x t y u : ℝ) : ℂ :=starRingEnd ℂ (lineSeed ε x t) * pointSeed ε y udef seedCoefficient (ε x t y u : ℝ) : ℂ :=correctionCoefficient ε (seedTangent ε x t y u) (pointD y u - lineC x t)(seedProduct ε x t y u)def seedCorrection (ε x t y u : ℝ) : ℂ :=correction ε (seedTangent ε x t y u) (pointD y u - lineC x t)(seedProduct ε x t y u)theorem seedProduct_im (ε x t y u : ℝ) :(seedProduct ε x t y u).im = ε * seedTangent ε x t y u := bysimp [seedProduct, seedTangent, lineSeed, pointSeed, Complex.mul_im]ringtheorem seedProduct_zero (x t y u : ℝ) : seedProduct 0 x t y u = (-1 / 4 : ℂ) := byapply Complex.ext <;> norm_num [seedProduct, lineSeed, pointSeed, Complex.mul_re, Complex.mul_im]theorem continuous_lineSeed (x t : ℝ) : Continuous (fun ε => lineSeed ε x t) := byunfold lineSeedsimp only [Complex.mk_eq_add_mul_I]fun_proptheorem continuous_pointSeed (x t : ℝ) : Continuous (fun ε => pointSeed ε x t) := byunfold pointSeedsimp only [Complex.mk_eq_add_mul_I]fun_proptheorem continuous_seedProduct (x t y u : ℝ) : Continuous (fun ε => seedProduct ε x t y u) := byexact ((continuous_lineSeed x t).star).mul (continuous_pointSeed y u)theorem continuous_seedTangent (x t y u : ℝ) : Continuous (fun ε => seedTangent ε x t y u) := byunfold seedTangentfun_proptheorem seed_radicand_zero (x t y u : ℝ) :correctionRadicand 0 (seedTangent 0 x t y u) (pointD y u - lineC x t)(seedProduct 0 x t y u).re = ((x - y) / 2) ^ 2 := bysimp [correctionRadicand, seedTangent]theorem seed_denominator_pos (x t y u : ℝ) (hxy : x < y) :0 < Real.sqrt (correctionRadicand 0 (seedTangent 0 x t y u)(pointD y u - lineC x t) (seedProduct 0 x t y u).re) - seedTangent 0 x t y u := byrw [seed_radicand_zero]simp only [seedTangent, zero_pow (by decide : 2 ≠ 0), zero_mul, add_zero]rw [Real.sqrt_sq_eq_abs, abs_of_neg (by linarith : (x - y) / 2 < 0)]linariththeorem continuousAt_seedCoefficient (x t y u : ℝ) (hxy : x < y) :ContinuousAt (fun ε => seedCoefficient ε x t y u) 0 := byhave hq : seedProduct 0 x t y u ≠ 0 := by rw [seedProduct_zero]; norm_numhave hden := ne_of_gt (seed_denominator_pos x t y u hxy)have hcq := (continuous_seedProduct x t y u).continuousAt (x := 0)have hct := (continuous_seedTangent x t y u).continuousAt (x := 0)unfold seedCoefficient correctionCoefficientapply ContinuousAt.div _ hcq hqsimp only [Complex.mk_eq_add_mul_I]have hreal : ContinuousAt (fun ε =>(pointD y u - lineC x t) ^ 2 *((seedProduct ε x t y u).re + ε ^ 4 * (pointD y u - lineC x t) ^ 2 / 4) /(Real.sqrt (correctionRadicand ε (seedTangent ε x t y u)(pointD y u - lineC x t) (seedProduct ε x t y u).re) - seedTangent ε x t y u)) 0 := byapply ContinuousAt.div· fun_prop· unfold correctionRadicandfun_prop· exact hdenfun_proptheorem seedCorrection_properties (x t y u : ℝ) (hxy : x < y)(hinc : u - t = (y - x) ^ 2) :∀ᶠ ε in 𝓝 (0 : ℝ),‖seedCorrection ε x t y u‖ = 1 ∧‖lineSeed ε x t - pointSeed ε y u * seedCorrection ε x t y u‖ = 1 ∧seedCorrection ε x t y u - 1 = (ε : ℂ) ^ 3 * seedCoefficient ε x t y u := byhave hq : ∀ᶠ ε in 𝓝 (0 : ℝ), seedProduct ε x t y u ≠ 0 :=(continuous_seedProduct x t y u).continuousAt.eventually_ne (by rw [seedProduct_zero]; norm_num)have hFcont : Continuous (fun ε => correctionRadicand ε (seedTangent ε x t y u)(pointD y u - lineC x t) (seedProduct ε x t y u).re) := byunfold correctionRadicandhave ht := continuous_seedTangent x t y uhave hq := continuous_seedProduct x t y ufun_prophave hF : ∀ᶠ ε in 𝓝 (0 : ℝ), 0 < correctionRadicand ε (seedTangent ε x t y u)(pointD y u - lineC x t) (seedProduct ε x t y u).re := byapply continuousAt_const.eventually_lt hFcont.continuousAtrw [seed_radicand_zero]exact sq_pos_of_ne_zero (by linarith)have hdc : Continuous (fun ε => Real.sqrt (correctionRadicand ε (seedTangent ε x t y u)(pointD y u - lineC x t) (seedProduct ε x t y u).re) - seedTangent ε x t y u) :=hFcont.sqrt.sub (continuous_seedTangent x t y u)have hd := hdc.continuousAt.eventually_ne (ne_of_gt (seed_denominator_pos x t y u hxy))filter_upwards [hq, hF, hd] with ε hq hF hdexact ⟨correction_norm _ _ _ _ hq (seedProduct_im ε x t y u) hF.le,correction_unit_distance _ _ _ _ _ hq (seedProduct_im ε x t y u) hF.le(incidence_distance_identity ε x t y u hinc),correction_cubic_identity _ _ _ _ hq (seedProduct_im ε x t y u) hF.le hd⟩theorem seedCorrection_im_negative (x t y u : ℝ) (hxy : x < y) :∀ᶠ ε in 𝓝[>] (0 : ℝ),(seedProduct ε x t y u * seedCorrection ε x t y u).im < 0 := byhave hq : ∀ᶠ ε in 𝓝 (0 : ℝ), seedProduct ε x t y u ≠ 0 :=(continuous_seedProduct x t y u).continuousAt.eventually_ne (by rw [seedProduct_zero]; norm_num)have hFcont : Continuous (fun ε => correctionRadicand ε (seedTangent ε x t y u)(pointD y u - lineC x t) (seedProduct ε x t y u).re) := byunfold correctionRadicandhave ht := continuous_seedTangent x t y uhave hq := continuous_seedProduct x t y ufun_prophave hF : ∀ᶠ ε in 𝓝 (0 : ℝ), 0 < correctionRadicand ε (seedTangent ε x t y u)(pointD y u - lineC x t) (seedProduct ε x t y u).re := byapply continuousAt_const.eventually_lt hFcont.continuousAtrw [seed_radicand_zero]exact sq_pos_of_ne_zero (by linarith)filter_upwards [hq.filter_mono nhdsWithin_le_nhds, hF.filter_mono nhdsWithin_le_nhds,self_mem_nhdsWithin] with ε hq hF (hε : 0 < ε)change (seedProduct ε x t y u * (chordNumerator ε (seedTangent ε x t y u)(pointD y u - lineC x t) (seedProduct ε x t y u) / seedProduct ε x t y u)).im < 0rw [mul_div_cancel₀ _ hq]change -ε * Real.sqrt (correctionRadicand ε (seedTangent ε x t y u)(pointD y u - lineC x t) (seedProduct ε x t y u).re) < 0exact mul_neg_of_neg_of_pos (neg_neg_of_pos hε) (Real.sqrt_pos.mpr hF)endend Proofend OriginalSeedGerms/- ## SeedLimits -/section OriginalSeedLimits/- Choosing one sufficiently small positive parameter for finitely many seed inequalities. -/namespace Proofopen Filteropen scoped Topologynoncomputable sectiontheorem eventually_scaled_ne (a b : ℝ → ℂ) (F : ℝ → ℝ)(hF : ContinuousAt F 0) (hF0 : F 0 ≠ 0)(hid : ∀ ε, Complex.normSq (a ε) - Complex.normSq (b ε) = ε ^ 2 * F ε) :∀ᶠ ε in 𝓝[>] (0 : ℝ), ‖a ε‖ ≠ ‖b ε‖ := byhave he : ∀ᶠ ε in 𝓝[>] (0 : ℝ), F ε ≠ 0 :=(hF.eventually_ne hF0).filter_mono nhdsWithin_le_nhdsfilter_upwards [he, self_mem_nhdsWithin] with ε hFε (hε : 0 < ε)intro hnhave hs : Complex.normSq (a ε) = Complex.normSq (b ε) := bysimp only [Complex.normSq_eq_norm_sq, hn]have hz := hid εrw [hs, sub_self] at hzexact mul_ne_zero (pow_ne_zero 2 (ne_of_gt hε)) hFε hz.symmtheorem eventually_scaled_support (a b : ℝ → ℂ) (A F : ℝ → ℝ)(hF : ContinuousAt F 0) (hF0 : F 0 < 0)(hid : ∀ ε, support (a ε) (b ε) + ε ^ 3 * A ε = ε ^ 2 * F ε) :∀ᶠ ε in 𝓝[>] (0 : ℝ), support (a ε) (b ε) < -ε ^ 3 * A ε := byhave he : ∀ᶠ ε in 𝓝[>] (0 : ℝ), F ε < 0 :=(hF.eventually_lt continuousAt_const hF0).filter_mono nhdsWithin_le_nhdsfilter_upwards [he, self_mem_nhdsWithin] with ε hFε (hε : 0 < ε)have hh : ε ^ 2 * F ε < 0 := mul_neg_of_pos_of_neg (pow_pos hε 2) hFεlinarith [hid ε]theorem eventually_line_support (x t y u : ℝ) (A : ℝ → ℝ)(hA : ContinuousAt A 0) (hm : -(y - x) ^ 2 / 2 - (u - t) / 4 < 0) :∀ᶠ ε in 𝓝[>] (0 : ℝ), support (lineSeed ε x t) (lineSeed ε y u) < -ε ^ 3 * A ε := bylet F := fun ε => -(y - x) ^ 2 / 2 - (u - t) / 4 +ε ^ 2 * lineC x t * (lineC y u - lineC x t) + ε * A εapply eventually_scaled_support _ _ A F· unfold F; fun_prop· simpa [F] using hm· intro εrw [line_support_identity]dsimp [F]ringtheorem eventually_point_support (x t y u : ℝ) (A : ℝ → ℝ)(hA : ContinuousAt A 0) (hm : -(y - x) ^ 2 / 2 + (u - t) / 4 < 0) :∀ᶠ ε in 𝓝[>] (0 : ℝ), support (pointSeed ε x t) (pointSeed ε y u) < -ε ^ 3 * A ε := bylet F := fun ε => -(y - x) ^ 2 / 2 + (u - t) / 4 +ε ^ 2 * pointD x t * (pointD y u - pointD x t) + ε * A εapply eventually_scaled_support _ _ A F· unfold F; fun_prop· simpa [F] using hm· intro εrw [point_support_identity]dsimp [F]ringtheorem eventually_cross_support (x t y u : ℝ) (A : ℝ → ℝ) (hA : ContinuousAt A 0) :∀ᶠ ε in 𝓝[>] (0 : ℝ),support (lineSeed ε x t) (pointSeed ε y u) < -ε ^ 3 * A ε ∧support (pointSeed ε y u) (lineSeed ε x t) < -ε ^ 3 * A ε := byhave hc₁ : ContinuousAt (fun ε => support (lineSeed ε x t) (pointSeed ε y u) + ε ^ 3 * A ε) 0 := byunfold support lineSeed pointSeed; fun_prophave hc₂ : ContinuousAt (fun ε => support (pointSeed ε y u) (lineSeed ε x t) + ε ^ 3 * A ε) 0 := byunfold support lineSeed pointSeed; fun_prophave h₁ : ∀ᶠ ε in 𝓝 (0 : ℝ), support (lineSeed ε x t) (pointSeed ε y u) + ε ^ 3 * A ε < 0 :=hc₁.eventually_lt continuousAt_const (by norm_num [support, lineSeed, pointSeed])have h₂ : ∀ᶠ ε in 𝓝 (0 : ℝ), support (pointSeed ε y u) (lineSeed ε x t) + ε ^ 3 * A ε < 0 :=hc₂.eventually_lt continuousAt_const (by norm_num [support, lineSeed, pointSeed])filter_upwards [h₁.filter_mono nhdsWithin_le_nhds, h₂.filter_mono nhdsWithin_le_nhds] with ε h₁ h₂constructor <;> linariththeorem eventually_line_norm_ne (x t y u : ℝ) (htu : t ≠ u) :∀ᶠ ε in 𝓝[>] (0 : ℝ), ‖lineSeed ε x t‖ ≠ ‖lineSeed ε y u‖ := byapply eventually_scaled_ne _ _ (fun ε => -(t - u) / 2 + ε ^ 2 * ((lineC x t) ^ 2 - (lineC y u) ^ 2))· fun_prop· simp only [zero_pow (by decide : 2 ≠ 0), zero_mul, add_zero]exact div_ne_zero (neg_ne_zero.mpr (sub_ne_zero.mpr htu)) (by norm_num)· intro εrw [line_normSq, line_normSq]ringtheorem eventually_point_norm_ne (x t y u : ℝ) (htu : t ≠ u) :∀ᶠ ε in 𝓝[>] (0 : ℝ), ‖pointSeed ε x t‖ ≠ ‖pointSeed ε y u‖ := byapply eventually_scaled_ne _ _ (fun ε => (t - u) / 2 + ε ^ 2 * ((pointD x t) ^ 2 - (pointD y u) ^ 2))· fun_prop· simp only [zero_pow (by decide : 2 ≠ 0), zero_mul, add_zero]exact div_ne_zero (sub_ne_zero.mpr htu) (by norm_num)· intro εrw [point_normSq, point_normSq]ringtheorem eventually_cross_norm_ne (x t y u : ℝ) (ht : 0 < t) (hu : 0 < u) :∀ᶠ ε in 𝓝[>] (0 : ℝ), ‖lineSeed ε x t‖ ≠ ‖pointSeed ε y u‖ := byapply eventually_scaled_ne _ _ (fun ε => -(t + u) / 2 + ε ^ 2 * ((lineC x t) ^ 2 - (pointD y u) ^ 2))· fun_prop· simp only [zero_pow (by decide : 2 ≠ 0), zero_mul, add_zero]linarith· intro εrw [line_normSq, point_normSq]ringendend Proofend OriginalSeedLimits/- ## Incidence -/section OriginalIncidence/- The coordinate incidence graph used in the construction. -/namespace Proofabbrev PointLabel (d : ℕ) := Fin d → Fin dabbrev LineLabel (d : ℕ) := (i : Fin d) × ({j : Fin d // j ≠ i} → Fin d)abbrev EdgeLabel (d : ℕ) := PointLabel d × Fin ddef edgePoint {d : ℕ} (e : EdgeLabel d) : PointLabel d := e.1def edgeLine {d : ℕ} (e : EdgeLabel d) : LineLabel d := ⟨e.2, fun j => e.1 j⟩theorem edge_endpoints_injective (d : ℕ) :Function.Injective (fun e : EdgeLabel d => (edgeLine e, edgePoint e)) := byintro e f hhave hpoint : e.1 = f.1 := congrArg Prod.snd hhave hline : e.2 = f.2 := congrArg (fun p => p.1.1) hexact Prod.ext hpoint hlinetheorem pointLabel_card (d : ℕ) : Fintype.card (PointLabel d) = d ^ d := bysimp [PointLabel]theorem puncturedFin_card {d : ℕ} (i : Fin d) :Fintype.card {j : Fin d // j ≠ i} = d - 1 := bysimptheorem lineLabel_card (d : ℕ) : Fintype.card (LineLabel d) = d * d ^ (d - 1) := bysimp [LineLabel, Fintype.card_sigma]theorem edgeLabel_card (d : ℕ) : Fintype.card (EdgeLabel d) = d ^ (d + 1) := bysimp [EdgeLabel, pow_succ]theorem vertexLabel_card {d : ℕ} (hd : 1 ≤ d) :Fintype.card (LineLabel d ⊕ PointLabel d) = 2 * d ^ d := byrw [Fintype.card_sum, lineLabel_card, pointLabel_card]have hpow : d * d ^ (d - 1) = d ^ d := byrw [← pow_succ', Nat.sub_add_cancel hd]omegaend Proofend OriginalIncidence/- ## Digits -/section OriginalDigits/- Separation of distinct finite sums of powers of five. -/namespace Proofnoncomputable sectiondef digitSum (q : ℝ) (s : Finset ℕ) : ℝ := ∑ i ∈ s, q ^ itheorem geometric_five (n : ℕ) :4 * (∑ i ∈ Finset.range n, (5 : ℝ) ^ i) = (5 : ℝ) ^ n - 1 := byinduction n with| zero => norm_num| succ n ih => rw [Finset.sum_range_succ, pow_succ]; linariththeorem geometric_twentyfive (n : ℕ) :24 * (∑ i ∈ Finset.range n, (25 : ℝ) ^ i) = (25 : ℝ) ^ n - 1 := byinduction n with| zero => norm_num| succ n ih => rw [Finset.sum_range_succ, pow_succ]; linariththeorem dominant_digit_bounds {q : ℝ} (hq : 0 ≤ q) {A B : Finset ℕ} {h : ℕ}(hdis : Disjoint A B) (hmem : h ∈ A) (hmax : ∀ j ∈ A ∪ B, j ≤ h) :q ^ h - (∑ i ∈ Finset.range h, q ^ i) ≤ digitSum q A - digitSum q B ∧digitSum q A - digitSum q B ≤ q ^ h + (∑ i ∈ Finset.range h, q ^ i) := byhave hsubB : B ⊆ Finset.range h := byintro j hjhave hle := hmax j (Finset.mem_union_right A hj)have hne : j ≠ h := byintro heexact (Finset.disjoint_left.mp hdis hmem) (he ▸ hj)exact Finset.mem_range.mpr (lt_of_le_of_ne hle hne)have hsubA : A ⊆ Finset.range (h + 1) := byintro j hjexact Finset.mem_range.mpr (Nat.lt_succ_of_le (hmax j (Finset.mem_union_left B hj)))have hAlo : q ^ h ≤ digitSum q A :=Finset.single_le_sum (fun j _ => pow_nonneg hq j) hmemhave hBlo : 0 ≤ digitSum q B := Finset.sum_nonneg (fun j _ => pow_nonneg hq j)have hAhi : digitSum q A ≤ ∑ i ∈ Finset.range (h + 1), q ^ i :=Finset.sum_le_sum_of_subset_of_nonneg hsubA (fun j _ _ => pow_nonneg hq j)have hBhi : digitSum q B ≤ ∑ i ∈ Finset.range h, q ^ i :=Finset.sum_le_sum_of_subset_of_nonneg hsubB (fun j _ _ => pow_nonneg hq j)rw [Finset.sum_range_succ] at hAhiconstructor <;> linariththeorem dominant_five_separation {A B : Finset ℕ} {h : ℕ}(hdis : Disjoint A B) (hmem : h ∈ A) (hmax : ∀ j ∈ A ∪ B, j ≤ h) :0 < digitSum 5 A - digitSum 5 B ∧0 < digitSum 25 A - digitSum 25 B ∧digitSum 25 A - digitSum 25 B <(50 / 27 : ℝ) * (digitSum 5 A - digitSum 5 B) ^ 2 := byobtain ⟨h5lo, h5hi⟩ := dominant_digit_bounds (q := 5) (by norm_num) hdis hmem hmaxobtain ⟨h25lo, h25hi⟩ := dominant_digit_bounds (q := 25) (by norm_num) hdis hmem hmaxhave g5 := geometric_five hhave g25 := geometric_twentyfive hhave hp5 : 0 < (5 : ℝ) ^ h := by positivityhave hp25 : 0 < (25 : ℝ) ^ h := by positivityhave hx : 3 / 4 * (5 : ℝ) ^ h < digitSum 5 A - digitSum 5 B := by linarithhave ht : digitSum 25 A - digitSum 25 B < 25 / 24 * (25 : ℝ) ^ h := by linarithhave hp : (25 : ℝ) ^ h = ((5 : ℝ) ^ h) ^ 2 := byrw [← pow_mul, Nat.mul_comm, pow_mul]norm_numhave hsq := mul_self_lt_mul_self (by positivity : (0 : ℝ) ≤ 3 / 4 * 5 ^ h) hxrefine ⟨by linarith, by linarith, ?_⟩rw [hp] at htnlinariththeorem digit_separation {s t : Finset ℕ} (hne : s ≠ t) :digitSum 5 s ≠ digitSum 5 t ∧ digitSum 25 s ≠ digitSum 25 t ∧|digitSum 25 s - digitSum 25 t| <(50 / 27 : ℝ) * (digitSum 5 s - digitSum 5 t) ^ 2 := bylet A := s \ tlet B := t \ shave hdis : Disjoint A B := bysimp only [A, B, Finset.disjoint_left, Finset.mem_sdiff]aesophave hneAB : (A ∪ B).Nonempty := byby_contra hchave he : A ∪ B = ∅ := Finset.not_nonempty_iff_eq_empty.mp hcapply hneext ihave hi : i ∉ A ∪ B := by rw [he]; simpsimp only [A, B, Finset.mem_union, Finset.mem_sdiff] at hitautolet h := (A ∪ B).max' hneABhave hh : h ∈ A ∪ B := Finset.max'_mem _ _have hmax : ∀ j ∈ A ∪ B, j ≤ h := fun j hj => Finset.le_max' _ j hjhave he5 : digitSum 5 s - digitSum 5 t = digitSum 5 A - digitSum 5 B := byexact (Finset.sum_sdiff_sub_sum_sdiff (s₁ := t) (s₂ := s) (f := fun i => (5 : ℝ) ^ i)).symmhave he25 : digitSum 25 s - digitSum 25 t = digitSum 25 A - digitSum 25 B := byexact (Finset.sum_sdiff_sub_sum_sdiff (s₁ := t) (s₂ := s) (f := fun i => (25 : ℝ) ^ i)).symmrcases Finset.mem_union.mp hh with hh | hh· obtain ⟨hx, ht, hbound⟩ := dominant_five_separation hdis hh hmaxrefine ⟨?_, ?_, ?_⟩· intro he; rw [he, sub_self] at he5; linarith· intro he; rw [he, sub_self] at he25; linarith· rw [he5, he25, abs_of_pos ht]; exact hbound· have hmax' : ∀ j ∈ B ∪ A, j ≤ h := by simpa [Finset.union_comm] using hmaxobtain ⟨hx, ht, hbound⟩ := dominant_five_separation hdis.symm hh hmax'refine ⟨?_, ?_, ?_⟩· intro he; rw [he, sub_self] at he5; linarith· intro he; rw [he, sub_self] at he25; linarith· rw [he5, he25, abs_of_neg (by linarith : digitSum 25 A - digitSum 25 B < 0)]nlinarithendend Proofend OriginalDigits/- ## LabelDigits -/section OriginalLabelDigits/- An injective assignment of lacunary digits to coordinate incidence labels. -/namespace Proofnoncomputable sectiondef pointCells {d : ℕ} (p : PointLabel d) : Finset (Fin d × Fin d) :=Finset.univ.image (fun i => (i, p i))def lineCells {d : ℕ} (l : LineLabel d) : Finset (Fin d × Fin d) :=Finset.univ.image (fun i : {j : Fin d // j ≠ l.1} => (i.val, l.2 i))theorem mem_pointCells {d : ℕ} (p : PointLabel d) (i j : Fin d) :(i, j) ∈ pointCells p ↔ p i = j := bysimp [pointCells]theorem mem_lineCells {d : ℕ} (l : LineLabel d) (i j : Fin d) :(i, j) ∈ lineCells l ↔ ∃ h : i ≠ l.1, l.2 ⟨i, h⟩ = j := bysimp [lineCells]theorem pointCells_injective (d : ℕ) : Function.Injective (@pointCells d) := byintro p q hefunext ihave hi : (i, p i) ∈ pointCells q := by rw [← he, mem_pointCells]exact (mem_pointCells q i (p i)).mp hi |>.symmtheorem lineCells_injective (d : ℕ) : Function.Injective (@lineCells d) := byrintro ⟨i, f⟩ ⟨j, g⟩ hehave hij : i = j := byby_contra hnehave hj : (i, g ⟨i, hne⟩) ∈ lineCells ⟨j, g⟩ := byrw [mem_lineCells]exact ⟨hne, rfl⟩rw [← he, mem_lineCells] at hjobtain ⟨hbad, _⟩ := hjexact hbad rflsubst jhave hfg : f = g := byfunext khave hk : (k.val, f k) ∈ lineCells ⟨i, g⟩ := byrw [← he, mem_lineCells]exact ⟨k.property, rfl⟩obtain ⟨_, hh⟩ := (mem_lineCells _ _ _).mp hkexact hh.symmsubst grfltheorem incidence_cells {d : ℕ} (e : EdgeLabel d) :pointCells (edgePoint e) = insert (e.2, e.1 e.2) (lineCells (edgeLine e)) := byext ⟨i, j⟩simp only [Finset.mem_insert, mem_pointCells, mem_lineCells, edgePoint, edgeLine,Prod.mk.injEq]by_cases hi : i = e.2· subst isimp [eq_comm]· simp [hi]theorem completing_cell_absent {d : ℕ} (e : EdgeLabel d) :(e.2, e.1 e.2) ∉ lineCells (edgeLine e) := bysimp [mem_lineCells, edgeLine]def digitIndex (d : ℕ) : (Fin d × Fin d) ↪ ℕ :=(Fintype.equivFin (Fin d × Fin d)).toEmbedding.trans ⟨Fin.val, Fin.val_injective⟩def pointDigits {d : ℕ} (p : PointLabel d) : Finset ℕ := (pointCells p).map (digitIndex d)def lineDigits {d : ℕ} (l : LineLabel d) : Finset ℕ := (lineCells l).map (digitIndex d)theorem pointDigits_injective (d : ℕ) : Function.Injective (@pointDigits d) := byintro p q heexact pointCells_injective d (Finset.map_injective (digitIndex d) he)theorem lineDigits_injective (d : ℕ) : Function.Injective (@lineDigits d) := byintro p q heexact lineCells_injective d (Finset.map_injective (digitIndex d) he)def pointX {d : ℕ} (p : PointLabel d) : ℝ := digitSum 5 (pointDigits p)def lineX {d : ℕ} (l : LineLabel d) : ℝ := digitSum 5 (lineDigits l)def pointT {d : ℕ} (p : PointLabel d) : ℝ := 1 + digitSum 25 (pointDigits p)def lineT {d : ℕ} (l : LineLabel d) : ℝ := 1 + digitSum 25 (lineDigits l)theorem incidence_digit_identity {d : ℕ} (e : EdgeLabel d) :let z : ℝ := 5 ^ (digitIndex d (e.2, e.1 e.2))0 < z ∧ pointX (edgePoint e) - lineX (edgeLine e) = z ∧pointT (edgePoint e) - lineT (edgeLine e) = z ^ 2 := byhave hnew : digitIndex d (e.2, e.1 e.2) ∉ lineDigits (edgeLine e) := bysimp [lineDigits, completing_cell_absent]have hcells : pointDigits (edgePoint e) =insert (digitIndex d (e.2, e.1 e.2)) (lineDigits (edgeLine e)) := bysimp only [pointDigits, lineDigits, incidence_cells, Finset.map_insert]dsimp onlyrefine ⟨by positivity, ?_, ?_⟩· simp [pointX, lineX, digitSum, hcells, Finset.sum_insert hnew]· simp only [pointT, lineT, hcells, digitSum, Finset.sum_insert hnew]have hp : (25 : ℝ) ^ (digitIndex d (e.2, e.1 e.2)) =((5 : ℝ) ^ (digitIndex d (e.2, e.1 e.2))) ^ 2 := byrw [← pow_mul, Nat.mul_comm, pow_mul]norm_numlinarithendend Proofend OriginalLabelDigits/- ## SeedPattern -/section OriginalSeedPattern/- Abstract hypotheses on a finite incidence pattern and its lacunary realization. -/namespace Proofopen Filteropen scoped Topologynoncomputable sectionstructure SeedPattern (L P E : Type*) whereline : E → Lpoint : E → Pendpoints_injective : Function.Injective (fun e => (line e, point e))LX : L → ℝLT : L → ℝPX : P → ℝPT : P → ℝLT_pos : ∀ l, 0 < LT lPT_pos : ∀ p, 0 < PT pLT_injective : Function.Injective LTPT_injective : Function.Injective PTline_margin : ∀ l k, l ≠ k → -(LX k - LX l) ^ 2 / 2 - (LT k - LT l) / 4 < 0point_margin : ∀ p q, p ≠ q → -(PX q - PX p) ^ 2 / 2 + (PT q - PT p) / 4 < 0edge_positive : ∀ e, LX (line e) < PX (point e)edge_identity : ∀ e, PT (point e) - LT (line e) = (PX (point e) - LX (line e)) ^ 2def coordinatePattern (d : ℕ) : SeedPattern (LineLabel d) (PointLabel d) (EdgeLabel d) whereline := edgeLinepoint := edgePointendpoints_injective := edge_endpoints_injective dLX := lineXLT := lineTPX := pointXPT := pointTLT_pos l := byhave hh : 0 ≤ digitSum 25 (lineDigits l) := Finset.sum_nonneg (fun _ _ => by positivity)dsimp [lineT]; linarithPT_pos p := byhave hh : 0 ≤ digitSum 25 (pointDigits p) := Finset.sum_nonneg (fun _ _ => by positivity)dsimp [pointT]; linarithLT_injective := byintro l k heby_contra hnehave hh := (digit_separation ((lineDigits_injective d).ne hne)).2.1apply hhdsimp [lineT] at helinarithPT_injective := byintro p q heby_contra hnehave hh := (digit_separation ((pointDigits_injective d).ne hne)).2.1apply hhdsimp [pointT] at helinarithline_margin := byintro l k hneobtain ⟨hX, _, hsep⟩ := digit_separation ((lineDigits_injective d).ne hne.symm)have hm := (signed_digit_margin hsep).1have hsq : 0 < (digitSum 5 (lineDigits k) - digitSum 5 (lineDigits l)) ^ 2 :=sq_pos_of_ne_zero (sub_ne_zero.mpr hX)dsimp [lineX, lineT]have he : 1 + digitSum 25 (lineDigits k) - (1 + digitSum 25 (lineDigits l)) =digitSum 25 (lineDigits k) - digitSum 25 (lineDigits l) := by ringrw [he]linarithpoint_margin := byintro p q hneobtain ⟨hX, _, hsep⟩ := digit_separation ((pointDigits_injective d).ne hne.symm)have hm := (signed_digit_margin hsep).2have hsq : 0 < (digitSum 5 (pointDigits q) - digitSum 5 (pointDigits p)) ^ 2 :=sq_pos_of_ne_zero (sub_ne_zero.mpr hX)dsimp [pointX, pointT]have he : 1 + digitSum 25 (pointDigits q) - (1 + digitSum 25 (pointDigits p)) =digitSum 25 (pointDigits q) - digitSum 25 (pointDigits p) := by ringrw [he]linarithedge_positive e := byobtain ⟨hz, hx, ht⟩ := incidence_digit_identity elinarithedge_identity e := byobtain ⟨hz, hx, ht⟩ := incidence_digit_identity erw [hx, ht]def SeedPattern.base {L P E : Type*} (S : SeedPattern L P E) (ε : ℝ) : L ⊕ P → ℂ :=Sum.elim (fun l => lineSeed ε (S.LX l) (S.LT l)) (fun p => pointSeed ε (S.PX p) (S.PT p))def SeedPattern.rot {L P E : Type*} (S : SeedPattern L P E) (ε : ℝ) (e : E) : ℂ :=seedCorrection ε (S.LX (S.line e)) (S.LT (S.line e)) (S.PX (S.point e)) (S.PT (S.point e))def SeedPattern.coeff {L P E : Type*} (S : SeedPattern L P E) (ε : ℝ) (e : E) : ℂ :=seedCoefficient ε (S.LX (S.line e)) (S.LT (S.line e)) (S.PX (S.point e)) (S.PT (S.point e))theorem SeedPattern.coeff_continuous {L P E : Type*} (S : SeedPattern L P E) (e : E) :ContinuousAt (fun ε => S.coeff ε e) 0 :=continuousAt_seedCoefficient _ _ _ _ (S.edge_positive e)endend Proofend OriginalSeedPattern/- ## PreparedSeed -/section OriginalPreparedSeed/- Existence of a finite seed with exact unit corrections and a strict support margin. -/namespace Proofopen Filteropen scoped Topologynoncomputable sectionstructure PreparedSeed {L P E : Type*} [Fintype E] (l : E → L) (p : E → P) wherebase : L ⊕ P → ℂrotation : E → ℂbase_ne_zero : ∀ i, base i ≠ 0base_norm_lt : ∀ i, ‖base i‖ < 1radii_injective : Function.Injective (fun i => ‖base i‖)rotation_norm : ∀ e, ‖rotation e‖ = 1unit_edge : ∀ e, ‖base (Sum.inl (l e)) - base (Sum.inr (p e)) * rotation e‖ = 1support_margin : ∀ i j, i ≠ j →support (base i) (base j) < -2 * ∑ e, ‖rotation e - 1‖chord_im_negative : ∀ e,(starRingEnd ℂ (base (Sum.inl (l e))) * base (Sum.inr (p e)) * rotation e).im < 0theorem SeedPattern.exists_prepared {L P E : Type*} [Fintype L] [Fintype P] [Fintype E](S : SeedPattern L P E) : Nonempty (PreparedSeed S.line S.point) := bylet A := fun ε : ℝ => 2 * ∑ e, ‖S.coeff ε e‖have hcoeff : ∀ e, ContinuousAt (fun ε => S.coeff ε e) 0 := S.coeff_continuoushave hA : ContinuousAt A 0 := by unfold A; fun_prophave hbase : ∀ i, Continuous (fun ε => S.base ε i) := byintro icases i with| inl l => exact continuous_lineSeed _ _| inr p => exact continuous_pointSeed _ _have hbase0 : ∀ i, ‖S.base 0 i‖ = 1 / 2 := byintro icases i <;> norm_num [SeedPattern.base, lineSeed, pointSeed, Complex.norm_def, Complex.normSq_apply]have hbounds : ∀ i, ∀ᶠ ε in 𝓝[>] (0 : ℝ), S.base ε i ≠ 0 ∧ ‖S.base ε i‖ < 1 := byintro ihave hlo : ∀ᶠ ε in 𝓝 (0 : ℝ), 0 < ‖S.base ε i‖ :=continuousAt_const.eventually_lt (hbase i).norm.continuousAt (by rw [hbase0]; norm_num)have hhi : ∀ᶠ ε in 𝓝 (0 : ℝ), ‖S.base ε i‖ < 1 :=(hbase i).norm.continuousAt.eventually_lt continuousAt_const (by rw [hbase0]; norm_num)filter_upwards [hlo.filter_mono nhdsWithin_le_nhds, hhi.filter_mono nhdsWithin_le_nhds] with ε hlo hhiexact ⟨norm_pos_iff.mp hlo, hhi⟩have hnorms : ∀ i j, ∀ᶠ ε in 𝓝[>] (0 : ℝ), i ≠ j → ‖S.base ε i‖ ≠ ‖S.base ε j‖ := byintro i jby_cases hij : i = j· exact Eventually.of_forall (fun _ h => (h hij).elim)cases i with| inl l =>cases j with| inl k =>have hk : l ≠ k := fun h => hij (congrArg Sum.inl h)exact (eventually_line_norm_ne _ _ _ _ (S.LT_injective.ne hk)).mono (fun _ h _ => h)| inr p =>exact (eventually_cross_norm_ne _ _ _ _ (S.LT_pos l) (S.PT_pos p)).mono (fun _ h _ => h)| inr p =>cases j with| inl l =>exact (eventually_cross_norm_ne _ _ _ _ (S.LT_pos l) (S.PT_pos p)).mono (fun _ h _ => h.symm)| inr q =>have hq : p ≠ q := fun h => hij (congrArg Sum.inr h)exact (eventually_point_norm_ne _ _ _ _ (S.PT_injective.ne hq)).mono (fun _ h _ => h)have hsupports : ∀ i j, ∀ᶠ ε in 𝓝[>] (0 : ℝ),i ≠ j → support (S.base ε i) (S.base ε j) < -ε ^ 3 * A ε := byintro i jby_cases hij : i = j· exact Eventually.of_forall (fun _ h => (h hij).elim)cases i with| inl l =>cases j with| inl k =>have hk : l ≠ k := fun h => hij (congrArg Sum.inl h)exact (eventually_line_support _ _ _ _ A hA (S.line_margin l k hk)).mono (fun _ h _ => h)| inr p =>exact (eventually_cross_support _ _ _ _ A hA).mono (fun _ h _ => h.1)| inr p =>cases j with| inl l =>exact (eventually_cross_support _ _ _ _ A hA).mono (fun _ h _ => h.2)| inr q =>have hq : p ≠ q := fun h => hij (congrArg Sum.inr h)exact (eventually_point_support _ _ _ _ A hA (S.point_margin p q hq)).mono (fun _ h _ => h)have hedges : ∀ e, ∀ᶠ ε in 𝓝[>] (0 : ℝ),‖S.rot ε e‖ = 1 ∧‖S.base ε (Sum.inl (S.line e)) - S.base ε (Sum.inr (S.point e)) * S.rot ε e‖ = 1 ∧S.rot ε e - 1 = (ε : ℂ) ^ 3 * S.coeff ε e := fun e =>(seedCorrection_properties _ _ _ _ (S.edge_positive e) (S.edge_identity e)).filter_mononhdsWithin_le_nhdshave him : ∀ e, ∀ᶠ ε in 𝓝[>] (0 : ℝ),(starRingEnd ℂ (S.base ε (Sum.inl (S.line e))) *S.base ε (Sum.inr (S.point e)) * S.rot ε e).im < 0 := fun e =>seedCorrection_im_negative _ _ _ _ (S.edge_positive e)have hbAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i, S.base ε i ≠ 0 ∧ ‖S.base ε i‖ < 1 := bysimpa only [eventually_all] using hboundshave hnAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i j, i ≠ j → ‖S.base ε i‖ ≠ ‖S.base ε j‖ := bysimpa only [eventually_all] using hnormshave hsAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i j, i ≠ j →support (S.base ε i) (S.base ε j) < -ε ^ 3 * A ε := bysimpa only [eventually_all] using hsupportshave heAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ e,‖S.rot ε e‖ = 1 ∧‖S.base ε (Sum.inl (S.line e)) - S.base ε (Sum.inr (S.point e)) * S.rot ε e‖ = 1 ∧S.rot ε e - 1 = (ε : ℂ) ^ 3 * S.coeff ε e := bysimpa only [eventually_all] using hedgeshave hiAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ e,(starRingEnd ℂ (S.base ε (Sum.inl (S.line e))) *S.base ε (Sum.inr (S.point e)) * S.rot ε e).im < 0 := bysimpa only [eventually_all] using himhave hall := hbAll.and (hnAll.and (hsAll.and (heAll.and (hiAll.and self_mem_nhdsWithin))))obtain ⟨ε, hb, hn, hs, he, hi, hε⟩ := hall.existshave hε : 0 < ε := hεhave hsum : 2 * ∑ e, ‖S.rot ε e - 1‖ = ε ^ 3 * A ε := bysimp_rw [fun e => (he e).2.2, norm_mul, norm_pow, Complex.norm_real, Real.norm_eq_abs,abs_of_pos hε]rw [← Finset.mul_sum]dsimp [A]ringrefine ⟨{base := S.base εrotation := S.rot εbase_ne_zero := fun i => (hb i).1base_norm_lt := fun i => (hb i).2radii_injective := fun i j hh => by_contra fun hij => hn i j hij hhrotation_norm := fun e => (he e).1unit_edge := fun e => (he e).2.1support_margin := ?_chord_im_negative := hi }⟩intro i j hijhave hh := hs i j hijlinarith [hsum]endend Proofend OriginalPreparedSeed/- ## PhaseGeometry -/section OriginalPhaseGeometry/- Unit chords and radial changes with the directions held fixed. -/namespace Proofnoncomputable sectiondef unitChord (r s : ℝ) : ℂ := Complex.exp (((-chordAngle r s : ℝ) : ℂ) * Complex.I)theorem unitChord_norm (r s : ℝ) : ‖unitChord r s‖ = 1 := Complex.norm_exp_ofReal_mul_I _theorem unitChord_re {r s : ℝ} (hf : ChordFeasible r s) : (unitChord r s).re = chordCos r s := bysimp [unitChord, Complex.exp_re, chordAngle, Real.cos_arccos hf.2.2.1.le hf.2.2.2.le]theorem unitChord_im (r s : ℝ) : (unitChord r s).im = -Real.sqrt (1 - chordCos r s ^ 2) := bysimp [unitChord, Complex.exp_im, chordAngle, Real.sin_arccos]theorem unitChord_im_neg {r s : ℝ} (hf : ChordFeasible r s) : (unitChord r s).im < 0 := byrw [unitChord_im]exact neg_neg_of_pos (Real.sqrt_pos.mpr (chord_discriminant_pos hf.2.2.1 hf.2.2.2))theorem unitChord_distance {r s : ℝ} (hf : ChordFeasible r s) :‖(r : ℂ) - (s : ℂ) * unitChord r s‖ = 1 := byhave hs : Complex.normSq ((r : ℂ) - (s : ℂ) * unitChord r s) = 1 := byrw [Complex.normSq_sub, Complex.normSq_mul, Complex.normSq_eq_norm_sq (unitChord r s),unitChord_norm, one_pow, mul_one]simp only [Complex.normSq_ofReal, Complex.mul_re, Complex.ofReal_re,Complex.ofReal_im, zero_mul, sub_zero, Complex.conj_re, unitChord_re hf]unfold chordCosfield_simp [hf.1, hf.2.1]ringrw [Complex.normSq_eq_norm_sq] at hsnlinarith [norm_nonneg ((r : ℂ) - (s : ℂ) * unitChord r s)]theorem normSq_sub_mul (a b w : ℂ) :Complex.normSq (a - b * w) = Complex.normSq a + Complex.normSq b * Complex.normSq w -2 * (starRingEnd ℂ a * b * w).re := bysimp only [Complex.normSq_apply, Complex.sub_re, Complex.sub_im, Complex.mul_re,Complex.mul_im, Complex.conj_re, Complex.conj_im]ringtheorem lower_half_unique {z w : ℂ} (hn : ‖z‖ = ‖w‖) (hr : z.re = w.re)(hz : z.im < 0) (hw : w.im < 0) : z = w := byhave hsq : Complex.normSq z = Complex.normSq w := bysimp only [Complex.normSq_eq_norm_sq, hn]apply Complex.ext hrsimp only [Complex.normSq_apply] at hsqrw [hr] at hsqnlinariththeorem corrected_chord {a b w : ℂ} (ha : a ≠ 0) (hb : b ≠ 0) (hw : ‖w‖ = 1)(he : ‖a - b * w‖ = 1) (him : (starRingEnd ℂ a * b * w).im < 0) :ChordFeasible ‖a‖ ‖b‖ ∧starRingEnd ℂ a * b * w = ((‖a‖ * ‖b‖ : ℝ) : ℂ) * unitChord ‖a‖ ‖b‖ := bylet q := starRingEnd ℂ a * b * whave hr : 0 < ‖a‖ := norm_pos_iff.mpr hahave hs : 0 < ‖b‖ := norm_pos_iff.mpr hbhave hprod : 0 < ‖a‖ * ‖b‖ := mul_pos hr hshave hqnorm : ‖q‖ = ‖a‖ * ‖b‖ := by simp [q, hw]have hqnormSq : q.re ^ 2 + q.im ^ 2 = (‖a‖ * ‖b‖) ^ 2 := byhave h := Complex.normSq_eq_norm_sq qrw [hqnorm] at hsimpa [Complex.normSq_apply, pow_two] using hhave hqre : q.re = (‖a‖ ^ 2 + ‖b‖ ^ 2 - 1) / 2 := byhave h := normSq_sub_mul a b wsimp only [Complex.normSq_eq_norm_sq, he, hw, one_pow, mul_one] at hchange _ = _ - 2 * q.re at hlinarithhave hratio : q.re / (‖a‖ * ‖b‖) = chordCos ‖a‖ ‖b‖ := byrw [hqre]unfold chordCosringhave hqim : q.im < 0 := himhave hsqim : 0 < q.im ^ 2 := sq_pos_of_ne_zero (ne_of_lt hqim)have hlo : -(‖a‖ * ‖b‖) < q.re := by nlinarithhave hhi : q.re < ‖a‖ * ‖b‖ := by nlinarithhave hf : ChordFeasible ‖a‖ ‖b‖ := byrefine ⟨ne_of_gt hr, ne_of_gt hs, ?_, ?_⟩· rw [← hratio]exact (lt_div_iff₀ hprod).mpr (by linarith)· rw [← hratio]exact (div_lt_iff₀ hprod).mpr (by linarith)refine ⟨hf, ?_⟩apply lower_half_unique· calc‖q‖ = ‖a‖ * ‖b‖ := hqnorm_ = ‖((‖a‖ * ‖b‖ : ℝ) : ℂ) * unitChord ‖a‖ ‖b‖‖ := byrw [norm_mul, unitChord_norm, Complex.norm_of_nonneg hprod.le, mul_one]· calcq.re = (‖a‖ * ‖b‖) * chordCos ‖a‖ ‖b‖ := by rw [← hratio]; field_simp_ = (((‖a‖ * ‖b‖ : ℝ) : ℂ) * unitChord ‖a‖ ‖b‖).re := by simp [unitChord_re hf]· exact him· simpa only [Complex.mul_im, Complex.ofReal_re, Complex.ofReal_im, zero_mul, zero_add, add_zero] usingmul_neg_of_pos_of_neg hprod (unitChord_im_neg hf)def radialBase {I : Type*} (b : I → ℂ) (r : I → ℝ) (i : I) : ℂ :=(r i : ℂ) * (b i / (‖b i‖ : ℂ))theorem radialBase_at_norm {I : Type*} (b : I → ℂ) (hb : ∀ i, b i ≠ 0) :radialBase b (fun i => ‖b i‖) = b := byfunext iexact mul_div_cancel₀ _ (Complex.ofReal_ne_zero.mpr (norm_ne_zero_iff.mpr (hb i)))theorem normalized_norm {b : ℂ} (hb : b ≠ 0) : ‖b / (‖b‖ : ℂ)‖ = 1 := byrw [norm_div, Complex.norm_of_nonneg (norm_nonneg _)]exact div_self (norm_ne_zero_iff.mpr hb)theorem radialBase_norm {I : Type*} (b : I → ℂ) (hb : ∀ i, b i ≠ 0)(r : I → ℝ) (hr : ∀ i, 0 ≤ r i) (i : I) : ‖radialBase b r i‖ = r i := byrw [radialBase, norm_mul, normalized_norm (hb i), mul_one, Complex.norm_of_nonneg (hr i)]def directionRatio (a b : ℂ) : ℂ := (a / (‖a‖ : ℂ)) / (b / (‖b‖ : ℂ))theorem directionRatio_norm {a b : ℂ} (ha : a ≠ 0) (hb : b ≠ 0) : ‖directionRatio a b‖ = 1 := byrw [directionRatio, norm_div, normalized_norm ha, normalized_norm hb, div_self (by norm_num : (1 : ℝ) ≠ 0)]theorem directionRatio_cancel {a b : ℂ} (ha : a ≠ 0) (hb : b ≠ 0) :starRingEnd ℂ a * b * directionRatio a b = ((‖a‖ * ‖b‖ : ℝ) : ℂ) := byhave hra : (‖a‖ : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr (norm_ne_zero_iff.mpr ha)have hrb : (‖b‖ : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr (norm_ne_zero_iff.mpr hb)have hnorm : starRingEnd ℂ a * a = (‖a‖ : ℂ) ^ 2 := byrw [← Complex.normSq_eq_conj_mul_self, Complex.normSq_eq_norm_sq, Complex.ofReal_pow]unfold directionRatiocalcstarRingEnd ℂ a * b * ((a / (‖a‖ : ℂ)) / (b / (‖b‖ : ℂ))) =(starRingEnd ℂ a * a) * (‖b‖ : ℂ) / (‖a‖ : ℂ) := by field_simp [hra, hrb, hb]_ = ((‖a‖ * ‖b‖ : ℝ) : ℂ) := by rw [hnorm, Complex.ofReal_mul]; field_simp [hra]theorem phaseRotations_factor {L P E : Type*} (l : E → L) (p : E → P) (θ : E → ℝ)(σ : E → ℂ) (hσ : ∀ e, Complex.exp ((θ e : ℂ) * Complex.I) = σ e)(z : (L → ℝ) × (P → ℝ)) (e : E) :phaseRotations l p θ z e = σ e * unitChord (z.1 (l e)) (z.2 (p e)) := bysimp only [phaseRotations, unitChord, Complex.ofReal_sub, Complex.ofReal_neg, sub_mul, neg_mul,Complex.exp_sub, Complex.exp_neg, hσ, div_eq_mul_inv]theorem radial_unit_distance {a b : ℂ} (ha : a ≠ 0) (hb : b ≠ 0){r s : ℝ} (hf : ChordFeasible r s) :‖(r : ℂ) * (a / (‖a‖ : ℂ)) - (s : ℂ) * (b / (‖b‖ : ℂ)) *(directionRatio a b * unitChord r s)‖ = 1 := byhave hbn : b / (‖b‖ : ℂ) ≠ 0 :=div_ne_zero hb (Complex.ofReal_ne_zero.mpr (norm_ne_zero_iff.mpr hb))have hra : (‖a‖ : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr (norm_ne_zero_iff.mpr ha)have hrb : (‖b‖ : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr (norm_ne_zero_iff.mpr hb)have he : (r : ℂ) * (a / (‖a‖ : ℂ)) - (s : ℂ) * (b / (‖b‖ : ℂ)) *(directionRatio a b * unitChord r s) =(a / (‖a‖ : ℂ)) * ((r : ℂ) - (s : ℂ) * unitChord r s) := byunfold directionRatiofield_simp [hbn, hra, hrb, hb]rw [he, norm_mul, normalized_norm ha, unitChord_distance hf, one_mul]def PreparedSeed.angles {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}(Q : PreparedSeed l p) (e : E) : ℝ :=Complex.arg (directionRatio (Q.base (Sum.inl (l e))) (Q.base (Sum.inr (p e))))def PreparedSeed.radii {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}(Q : PreparedSeed l p) : (L → ℝ) × (P → ℝ) :=(fun i => ‖Q.base (Sum.inl i)‖, fun j => ‖Q.base (Sum.inr j)‖)theorem PreparedSeed.angles_exp {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}(Q : PreparedSeed l p) (e : E) :Complex.exp ((Q.angles e : ℂ) * Complex.I) =directionRatio (Q.base (Sum.inl (l e))) (Q.base (Sum.inr (p e))) := byhave hnorm := directionRatio_norm (Q.base_ne_zero (Sum.inl (l e))) (Q.base_ne_zero (Sum.inr (p e)))have hh := Complex.norm_mul_exp_arg_mul_I (directionRatio (Q.base (Sum.inl (l e))) (Q.base (Sum.inr (p e))))simpa only [PreparedSeed.angles, hnorm, Complex.ofReal_one, one_mul] using hhtheorem PreparedSeed.feasible {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}(Q : PreparedSeed l p) (e : E) : ChordFeasible (Q.radii.1 (l e)) (Q.radii.2 (p e)) :=(corrected_chord (Q.base_ne_zero _) (Q.base_ne_zero _) (Q.rotation_norm e)(Q.unit_edge e) (Q.chord_im_negative e)).1theorem PreparedSeed.phase_at_radii {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}(Q : PreparedSeed l p) : phaseRotations l p Q.angles Q.radii = Q.rotation := byfunext ehave ha := Q.base_ne_zero (Sum.inl (l e))have hb := Q.base_ne_zero (Sum.inr (p e))have he := (corrected_chord ha hb (Q.rotation_norm e) (Q.unit_edge e) (Q.chord_im_negative e)).2apply mul_left_cancel₀ (mul_ne_zero ((map_ne_zero (starRingEnd ℂ)).mpr ha) hb)rw [phaseRotations_factor l p Q.angles _ Q.angles_exp, ← mul_assoc, directionRatio_cancel ha hb]exact he.symmendend Proofend OriginalPhaseGeometry/- ## Perturbation -/section OriginalPerturbation/- A simultaneous radius perturbation preserving support and separating every subset product. -/namespace Proofopen Set Filteropen scoped Topologynoncomputable sectiondef joinedRadii {L P : Type*} (z : (L → ℝ) × (P → ℝ)) : L ⊕ P → ℝ := Sum.elim z.1 z.2def PreparedSeed.varBase {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}(Q : PreparedSeed l p) (z : (L → ℝ) × (P → ℝ)) : L ⊕ P → ℂ := radialBase Q.base (joinedRadii z)theorem PreparedSeed.varBase_at_radii {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}(Q : PreparedSeed l p) : Q.varBase Q.radii = Q.base := byhave hh : joinedRadii Q.radii = fun i => ‖Q.base i‖ := by funext i; cases i <;> rflunfold PreparedSeed.varBaserw [hh]exact radialBase_at_norm Q.base Q.base_ne_zerotheorem PreparedSeed.varBase_continuous {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}(Q : PreparedSeed l p) (i : L ⊕ P) : Continuous (fun z => Q.varBase z i) := bycases i <;> simp only [PreparedSeed.varBase, radialBase, joinedRadii, Sum.elim_inl, Sum.elim_inr] <;> fun_proptheorem joinedRadii_continuous {L P : Type*} (i : L ⊕ P) :Continuous (fun z : (L → ℝ) × (P → ℝ) => joinedRadii z i) := bycases i <;> simp only [joinedRadii, Sum.elim_inl, Sum.elim_inr] <;> fun_proptheorem PreparedSeed.varBase_unit_edge {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}(Q : PreparedSeed l p) (z : (L → ℝ) × (P → ℝ)) (e : E)(hf : ChordFeasible (z.1 (l e)) (z.2 (p e))) :‖Q.varBase z (Sum.inl (l e)) - Q.varBase z (Sum.inr (p e)) * phaseRotations l p Q.angles z e‖ = 1 := byrw [phaseRotations_factor l p Q.angles _ Q.angles_exp]exact radial_unit_distance (Q.base_ne_zero _) (Q.base_ne_zero _) hfstructure SeparatedSeed {L P E : Type*} [Fintype E] (l : E → L) (p : E → P) wherebase : L ⊕ P → ℂrotation : E → ℂbase_ne_zero : ∀ i, base i ≠ 0base_norm_lt : ∀ i, ‖base i‖ < 1radii_injective : Function.Injective (fun i => ‖base i‖)rotation_norm : ∀ e, ‖rotation e‖ = 1unit_edge : ∀ e, ‖base (Sum.inl (l e)) - base (Sum.inr (p e)) * rotation e‖ = 1support_margin : ∀ i j, i ≠ j → support (base i) (base j) < -2 * ∑ e, ‖rotation e - 1‖products_injective : Function.Injective (subsetProduct rotation)def GoodRadii {L P E : Type*} [Fintype E] {l : E → L} {p : E → P}(Q : PreparedSeed l p) (z : (L → ℝ) × (P → ℝ)) : Prop :=(∀ i, 0 < joinedRadii z i) ∧ (∀ i, ‖Q.varBase z i‖ < 1) ∧Function.Injective (joinedRadii z) ∧(∀ e, ChordFeasible (z.1 (l e)) (z.2 (p e))) ∧∀ i j, i ≠ j → support (Q.varBase z i) (Q.varBase z j) <-2 * ∑ e, ‖phaseRotations l p Q.angles z e - 1‖theorem PreparedSeed.goodRadii_nhds {L P E : Type*} [Fintype L] [Fintype P] [Fintype E]{l : E → L} {p : E → P} (Q : PreparedSeed l p) :∀ᶠ z in 𝓝 Q.radii, GoodRadii Q z := byhave hjoined : ∀ i, joinedRadii Q.radii i = ‖Q.base i‖ := by intro i; cases i <;> rflhave hr : ∀ i, Q.radii.1 i ≠ 0 := fun i => norm_ne_zero_iff.mpr (Q.base_ne_zero _)have hs : ∀ j, Q.radii.2 j ≠ 0 := fun j => norm_ne_zero_iff.mpr (Q.base_ne_zero _)have hrot : ∀ e, ContinuousAt (fun z => phaseRotations l p Q.angles z e) Q.radii :=phaseRotations_continuousAt l p Q.angles Q.radii hr hshave hbase : ∀ i, ContinuousAt (fun z => Q.varBase z i) Q.radii :=fun i => (Q.varBase_continuous i).continuousAthave hpos : ∀ i, ∀ᶠ z in 𝓝 Q.radii, 0 < joinedRadii z i := byintro iapply continuousAt_const.eventually_lt (joinedRadii_continuous i).continuousAtrw [hjoined]exact norm_pos_iff.mpr (Q.base_ne_zero i)have hnorm : ∀ i, ∀ᶠ z in 𝓝 Q.radii, ‖Q.varBase z i‖ < 1 := byintro iapply (hbase i).norm.eventually_lt continuousAt_constrw [Q.varBase_at_radii]exact Q.base_norm_lt ihave hinj : ∀ i j, ∀ᶠ z in 𝓝 Q.radii, i ≠ j → joinedRadii z i ≠ joinedRadii z j := byintro i jby_cases hij : i = j· exact Eventually.of_forall (fun _ h => (h hij).elim)have hdiff : ContinuousAt (fun z => joinedRadii z i - joinedRadii z j) Q.radii :=(joinedRadii_continuous i).continuousAt.sub (joinedRadii_continuous j).continuousAthave hdiff0 : joinedRadii Q.radii i - joinedRadii Q.radii j ≠ 0 := byrw [hjoined, hjoined]exact sub_ne_zero.mpr (Q.radii_injective.ne hij)exact (hdiff.eventually_ne hdiff0).mono (fun _ hh _ => sub_ne_zero.mp hh)have hfeas : ∀ e, ∀ᶠ z in 𝓝 Q.radii, ChordFeasible (z.1 (l e)) (z.2 (p e)) := byintro ehave hcos : ContinuousAt (fun z : (L → ℝ) × (P → ℝ) => chordCos (z.1 (l e)) (z.2 (p e))) Q.radii := byunfold chordCosfun_prop (disch := aesop)have hl : ∀ᶠ z in 𝓝 Q.radii, -1 < chordCos (z.1 (l e)) (z.2 (p e)) :=continuousAt_const.eventually_lt hcos (Q.feasible e).2.2.1have hu : ∀ᶠ z in 𝓝 Q.radii, chordCos (z.1 (l e)) (z.2 (p e)) < 1 :=hcos.eventually_lt continuousAt_const (Q.feasible e).2.2.2filter_upwards [hpos (Sum.inl (l e)), hpos (Sum.inr (p e)), hl, hu] with z hr hs hl huexact ⟨ne_of_gt hr, ne_of_gt hs, hl, hu⟩have hmargin : ∀ i j, ∀ᶠ z in 𝓝 Q.radii, i ≠ j →support (Q.varBase z i) (Q.varBase z j) < -2 * ∑ e, ‖phaseRotations l p Q.angles z e - 1‖ := byintro i jby_cases hij : i = j· exact Eventually.of_forall (fun _ h => (h hij).elim)have hc : ContinuousAt (fun z => support (Q.varBase z i) (Q.varBase z j) +2 * ∑ e, ‖phaseRotations l p Q.angles z e - 1‖) Q.radii := byhave hri := Complex.continuous_re.continuousAt.comp (hbase i)have hrj := Complex.continuous_re.continuousAt.comp (hbase j)have hii := Complex.continuous_im.continuousAt.comp (hbase i)have hij := Complex.continuous_im.continuousAt.comp (hbase j)unfold supportexact ((hri.mul (hrj.sub hri)).add (hii.mul (hij.sub hii))).add(continuousAt_const.mul(tendsto_finsetSum Finset.univ (fun e _ =>((hrot e).sub continuousAt_const).norm)))have hvalue : support (Q.varBase Q.radii i) (Q.varBase Q.radii j) +2 * ∑ e, ‖phaseRotations l p Q.angles Q.radii e - 1‖ < 0 := byrw [Q.varBase_at_radii, Q.phase_at_radii]linarith [Q.support_margin i j hij]exact (hc.eventually_lt continuousAt_const hvalue).mono (fun _ hh _ => by linarith)have hposAll : ∀ᶠ z in 𝓝 Q.radii, ∀ i, 0 < joinedRadii z i := by simpa only [eventually_all] using hposhave hnAll : ∀ᶠ z in 𝓝 Q.radii, ∀ i, ‖Q.varBase z i‖ < 1 := by simpa only [eventually_all] using hnormhave hiAll : ∀ᶠ z in 𝓝 Q.radii, ∀ i j, i ≠ j → joinedRadii z i ≠ joinedRadii z j := bysimpa only [eventually_all] using hinjhave hfAll : ∀ᶠ z in 𝓝 Q.radii, ∀ e, ChordFeasible (z.1 (l e)) (z.2 (p e)) := bysimpa only [eventually_all] using hfeashave hmAll : ∀ᶠ z in 𝓝 Q.radii, ∀ i j, i ≠ j →support (Q.varBase z i) (Q.varBase z j) < -2 * ∑ e, ‖phaseRotations l p Q.angles z e - 1‖ := bysimpa only [eventually_all] using hmarginfilter_upwards [hposAll, hnAll, hiAll, hfAll, hmAll] with z hp hn hi hf hmexact ⟨hp, hn, fun i j h => by_contra (fun hij => hi i j hij h), hf, hm⟩theorem PreparedSeed.exists_separated {L P E : Type*} [Fintype L] [Fintype P] [Fintype E]{l : E → L} {p : E → P} (Q : PreparedSeed l p)(hij : Function.Injective (fun e => (l e, p e))) : Nonempty (SeparatedSeed l p) := byclassicalobtain ⟨U, hUgood, hU, hz₀⟩ := mem_nhds_iff.mp Q.goodRadii_nhdshave hne : U.Nonempty := ⟨Q.radii, hz₀⟩have hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0) := byintro z hzexact ⟨fun i => ne_of_gt ((hUgood hz).1 (Sum.inl i)), fun j => ne_of_gt ((hUgood hz).1 (Sum.inr j))⟩obtain ⟨z, hz, hprod⟩ := exists_injective_subsetProducts l p hij Q.angles U hU hne hnz(fun e z hz => (hUgood hz).2.2.2.1 e)obtain ⟨hpos, hnorm, hinj, hfeas, hmargin⟩ := hUgood hzhave hrnorm : ∀ i, ‖Q.varBase z i‖ = joinedRadii z i :=radialBase_norm Q.base Q.base_ne_zero (joinedRadii z) (fun i => (hpos i).le)refine ⟨{base := Q.varBase zrotation := phaseRotations l p Q.angles zbase_ne_zero := fun i => norm_pos_iff.mp (by rw [hrnorm]; exact hpos i)base_norm_lt := hnormradii_injective := ?_rotation_norm := phaseRotations_norm l p Q.angles zunit_edge := fun e => Q.varBase_unit_edge z e (hfeas e)support_margin := hmarginproducts_injective := hprod }⟩intro i j hhdsimp only at hhrw [hrnorm, hrnorm] at hhexact hinj hhendend Proofend OriginalPerturbation/- ## Counting -/section OriginalCounting/- Exact vertex counts and a lower bound for unordered unit pairs. -/namespace Proofnoncomputable sectiondef pairDistance {X : Type*} [MetricSpace X] (p : Sym2 X) : ℝ :=Sym2.lift ⟨dist, fun a b => dist_comm a b⟩ pdef unitPairs {X : Type*} [MetricSpace X] (P : Finset X) : Finset (Sym2 X) := byclassicalexact P.sym2.filter (fun p => pairDistance p = 1)def rotatedSet {I E : Type*} [Fintype I] [Fintype E] (b : I → ℂ) (w : E → ℂ) : Finset ℂ := byclassicalexact Finset.univ.image (rotatedCopy b w)theorem mem_rotatedSet {I E : Type*} [Fintype I] [Fintype E](b : I → ℂ) (w : E → ℂ) (x : I × Finset E) :rotatedCopy b w x ∈ rotatedSet b w := byclassicalexact Finset.mem_image.mpr ⟨x, Finset.mem_univ _, rfl⟩theorem rotatedSet_card {I E : Type*} [Fintype I] [Fintype E](b : I → ℂ) (w : E → ℂ) (hinj : Function.Injective (rotatedCopy b w)) :(rotatedSet b w).card = Fintype.card I * 2 ^ Fintype.card E := byclassicalrw [rotatedSet, Finset.card_image_of_injective _ hinj]simptheorem rotatedSet_convexIndependent {I E : Type*} [Fintype I] [Fintype E](b : I → ℂ) (w : E → ℂ) (hc : ConvexIndependent ℝ (rotatedCopy b w)) :ConvexIndependent ℝ (fun z : ↥(rotatedSet b w : Set ℂ) => (z : ℂ)) := byhave he : (rotatedSet b w : Set ℂ) = Set.range (rotatedCopy b w) := byclassicalsimp [rotatedSet]rw [he]exact hc.rangeabbrev LiftedEdge (E : Type*) := (e : E) × {S : Finset E // e ∉ S}theorem subsets_avoiding_card {E : Type*} [Fintype E] [DecidableEq E] (e : E) :Fintype.card {S : Finset E // e ∉ S} = 2 ^ (Fintype.card E - 1) := byrw [Fintype.card_of_subtype ((Finset.univ.erase e).powerset)(fun S => by simp [Finset.mem_powerset, Finset.subset_erase])]simptheorem liftedEdge_card {E : Type*} [Fintype E] [DecidableEq E] :Fintype.card (LiftedEdge E) = Fintype.card E * 2 ^ (Fintype.card E - 1) := bysimp only [LiftedEdge, Fintype.card_sigma, subsets_avoiding_card,Finset.sum_const, Finset.card_univ, smul_eq_mul]def liftedPair {L P E : Type*} [DecidableEq E](l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ) (x : LiftedEdge E) : Sym2 ℂ :=s(rotatedCopy b w (Sum.inl (l x.1), x.2.val),rotatedCopy b w (Sum.inr (p x.1), insert x.1 x.2.val))theorem liftedPair_injective {L P E : Type*} [DecidableEq E](l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)(he : Function.Injective (fun e => (l e, p e)))(hinj : Function.Injective (rotatedCopy b w)) :Function.Injective (liftedPair l p b w) := byrintro ⟨e, S⟩ ⟨f, T⟩ hhsimp only [liftedPair, Sym2.eq, Sym2.rel_iff', Prod.mk.injEq, Prod.swap_prod_mk] at hhrcases hh with ⟨hl, hp⟩ | ⟨hl, hp⟩· have hl := hinj hlhave hp := hinj hphave hlf : l e = l f := Sum.inl.inj (congrArg Prod.fst hl)have hpf : p e = p f := Sum.inr.inj (congrArg Prod.fst hp)have hef := he (Prod.ext hlf hpf)subst fhave hST : S = T := Subtype.ext (congrArg Prod.snd hl)subst Trfl· have hbad := congrArg Prod.fst (hinj hl)cases hbadtheorem liftedPair_mem_unitPairs {L P E : Type*}[Fintype L] [Fintype P] [Fintype E] [DecidableEq E](l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)(hw : ∀ e, ‖w e‖ = 1)(hedge : ∀ e, ‖b (Sum.inl (l e)) - b (Sum.inr (p e)) * w e‖ = 1)(x : LiftedEdge E) : liftedPair l p b w x ∈ unitPairs (rotatedSet b w) := byclassicalapply Finset.mem_filter.mprconstructor· apply Finset.mk_mem_sym2_iff.mprexact ⟨mem_rotatedSet b w _, mem_rotatedSet b w _⟩· exact rotatedCopy_unit_edge b w hw _ _ x.1 (hedge x.1) x.2.val x.2.propertytheorem amplification_unitPairs_bound {L P E : Type*}[Fintype L] [Fintype P] [Fintype E] [DecidableEq E](l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)(he : Function.Injective (fun e => (l e, p e)))(hinj : Function.Injective (rotatedCopy b w)) (hw : ∀ e, ‖w e‖ = 1)(hedge : ∀ e, ‖b (Sum.inl (l e)) - b (Sum.inr (p e)) * w e‖ = 1) :Fintype.card E * 2 ^ (Fintype.card E - 1) ≤ (unitPairs (rotatedSet b w)).card := bylet f : LiftedEdge E → unitPairs (rotatedSet b w) := fun x =>⟨liftedPair l p b w x, liftedPair_mem_unitPairs l p b w hw hedge x⟩have hf : Function.Injective f := fun x y h =>liftedPair_injective l p b w he hinj (congrArg Subtype.val h)have hc := Fintype.card_le_of_injective f hfsimpa only [liftedEdge_card, Fintype.card_coe] using hcendend Proofend OriginalCounting/- ## Counterexample -/section OriginalCounterexample/- Convex configurations with an unbounded ratio of unit distances to vertices. -/namespace Proofnoncomputable sectiondef constructionSize (d : ℕ) : ℕ := 2 * d ^ d * 2 ^ (d ^ (d + 1))theorem convex_unit_counterexample (d : ℕ) (hd : 2 ≤ d) :∃ P : Finset ℂ,ConvexIndependent ℝ (fun z : ↥(P : Set ℂ) => (z : ℂ)) ∧P.card = constructionSize d ∧ d * P.card ≤ 4 * (unitPairs P).card := byclassicalobtain ⟨Q⟩ := (coordinatePattern d).exists_preparedobtain ⟨R⟩ := Q.exists_separated (coordinatePattern d).endpoints_injectivelet P := rotatedSet R.base R.rotationhave hinj := rotatedCopy_injective R.base R.rotation R.base_ne_zero R.radii_injectiveR.rotation_norm R.products_injectivehave hconv := rotatedCopy_convexIndependent R.base R.rotation R.base_ne_zero R.radii_injective(fun i => (R.base_norm_lt i).le) R.rotation_norm R.products_injective R.support_marginhave hcard := rotatedSet_card R.base R.rotation hinjhave hcount := amplification_unitPairs_bound (coordinatePattern d).line (coordinatePattern d).pointR.base R.rotation (coordinatePattern d).endpoints_injective hinj R.rotation_norm R.unit_edgerefine ⟨P, rotatedSet_convexIndependent R.base R.rotation hconv, ?_, ?_⟩· simpa [P, vertexLabel_card (by omega : 1 ≤ d), edgeLabel_card, constructionSize,pow_succ] using hcard· have hm : 1 ≤ Fintype.card (EdgeLabel d) := byrw [edgeLabel_card]exact Nat.one_le_iff_ne_zero.mpr (pow_ne_zero _ (by omega))have hpow : 2 ^ Fintype.card (EdgeLabel d) = 2 * 2 ^ (Fintype.card (EdgeLabel d) - 1) := byrw [← pow_succ', Nat.sub_add_cancel hm]have hid : d * P.card = 4 * (Fintype.card (EdgeLabel d) * 2 ^ (Fintype.card (EdgeLabel d) - 1)) := bydsimp [P]rw [hcard, vertexLabel_card (by omega : 1 ≤ d), hpow, edgeLabel_card, pow_succ]ringrw [hid]exact Nat.mul_le_mul_left 4 hcounttheorem constructionSize_pos {d : ℕ} (hd : 1 ≤ d) : 0 < constructionSize d := byunfold constructionSizepositivitytheorem convex_unit_ratios_unbounded (C : ℝ) :∃ P : Finset ℂ, ConvexIndependent ℝ (fun z : ↥(P : Set ℂ) => (z : ℂ)) ∧C * (P.card : ℝ) < ((unitPairs P).card : ℝ) := byobtain ⟨n, hn⟩ := exists_nat_gt (4 * C)obtain ⟨P, hconv, hcard, hcount⟩ := convex_unit_counterexample (n + 2) (by omega)have hP : (0 : ℝ) < P.card := by exact_mod_cast (hcard ▸ constructionSize_pos (by omega : 1 ≤ n + 2))have hcountR : ((n + 2 : ℕ) : ℝ) * P.card ≤ 4 * (unitPairs P).card := by exact_mod_cast hcounthave hdR : 4 * C < ((n + 2 : ℕ) : ℝ) := by push_cast; linarithrefine ⟨P, hconv, ?_⟩nlinarith [mul_pos (sub_pos.mpr hdR) hP]endend Proofend OriginalCounterexample/- ## PlaneBridge -/section OriginalPlaneBridge/- Transfer from the complex plane to the literal Euclidean-plane definitions. -/namespace Proofnoncomputable sectionopen scoped EuclideanGeometrydef complexToPlane : ℂ ≃ₗᵢ[ℝ] ℝ² := Complex.orthonormalBasisOneI.reprtheorem pairDistance_eq_out {X : Type*} [MetricSpace X] (p : Sym2 X) :pairDistance p = dist p.out.1 p.out.2 := byhave hp : s(p.out.1, p.out.2) = p := by rw [Sym2.mk, p.out_eq]conv_lhs => rw [← hp]rfltheorem unitDistNum_eq_card_unitPairs {X : Type*} [MetricSpace X] (P : Finset X) :unitDistNum P = (unitPairs P).card := byclassicalsimp only [unitDistNum, unitPairs, pairDistance_eq_out]theorem pairDistance_map_isometry {X Y : Type*} [MetricSpace X] [MetricSpace Y](f : X → Y) (hf : Isometry f) (p : Sym2 X) :pairDistance (Sym2.map f p) = pairDistance p := byrefine Sym2.inductionOn p ?_intro a bexact hf.dist_eq a btheorem unitPairs_image_isometry {X Y : Type*} [MetricSpace X] [MetricSpace Y] [DecidableEq Y](f : X → Y) (hf : Isometry f) (P : Finset X) :unitPairs (P.image f) = (unitPairs P).image (Sym2.map f) := byclassicalrw [unitPairs, Finset.sym2_image, Finset.filter_image]congr 1ext psimp only [Finset.mem_filter, pairDistance_map_isometry f hf, unitPairs]theorem unitPairs_card_image_isometry {X Y : Type*} [MetricSpace X] [MetricSpace Y] [DecidableEq Y](f : X → Y) (hf : Isometry f) (P : Finset X) :(unitPairs (P.image f)).card = (unitPairs P).card := byclassicalrw [unitPairs_image_isometry f hf, Finset.card_image_of_injective _(Sym2.map.injective hf.injective)]theorem convexIndependent_linearMap {I V W : Type*}[AddCommGroup V] [Module ℝ V] [AddCommGroup W] [Module ℝ W](f : V →ₗ[ℝ] W) (hf : Function.Injective f) (p : I → V)(hp : ConvexIndependent ℝ p) : ConvexIndependent ℝ (f ∘ p) := byintro S i hiapply hp S ihave himg : (f ∘ p) '' S = f '' (p '' S) := (Set.image_image f p S).symmrw [himg, ← f.image_convexHull] at hiobtain ⟨x, hx, hxi⟩ := hihave heq : x = p i := hf hxisimpa only [heq] using hxtheorem convexIndep_image_complexToPlane (P : Finset ℂ)(hp : ConvexIndependent ℝ (fun z : ↥(P : Set ℂ) => (z : ℂ))) :EuclideanGeometry.ConvexIndep (P.image complexToPlane) := byclassicalapply convexIndependent_set_iff_notMem_convexHull_sdiff.mphave hc := convexIndependent_linearMap complexToPlane.toLinearEquiv.toLinearMapcomplexToPlane.injective (fun z : ↥(P : Set ℂ) => (z : ℂ)) hphave hrange : (P.image complexToPlane : Set ℝ²) =Set.range (fun z : ↥(P : Set ℂ) => complexToPlane (z : ℂ)) := byext ysimprw [hrange]exact hc.rangetheorem convexUnitDistanceCounts_bddAbove (n : ℕ) :BddAbove (convexUnitDistanceCounts n) := byclassicalrefine ⟨(n + 1).choose 2, ?_⟩rintro _ ⟨P, hP, _, rfl⟩rw [unitDistNum_eq_card_unitPairs]calc(unitPairs P).card ≤ P.sym2.card := Finset.card_filter_le _ __ = (n + 1).choose 2 := by rw [Finset.card_sym2, hP]theorem unitDistNum_le_max (P : Finset ℝ²) (hP : EuclideanGeometry.ConvexIndep P) :unitDistNum P ≤ maxConvexUnitDistances P.card := byapply le_csSup (convexUnitDistanceCounts_bddAbove P.card)exact ⟨P, rfl, hP, rfl⟩endend Proofend OriginalPlaneBridge/- ## Problem -/section OriginalProblem/-The negation of Erdős problem 96, with the Euclidean-plane, convexity,unordered-pair-count, and supremum definitions of Formal Conjectures.-/namespace Proofnoncomputable sectionopen Filter EuclideanGeometryopen scoped EuclideanGeometrytheorem constructionSize_ge_dimension {d : ℕ} (hd : 1 ≤ d) :d ≤ constructionSize d := byhave hpow : 1 ≤ 2 ^ (d ^ (d + 1)) := Nat.one_le_iff_ne_zero.mpr (by positivity)calcd ≤ d ^ d := le_self_pow hd (by omega)_ ≤ 2 * d ^ d := by omega_ ≤ constructionSize d := bysimpa only [constructionSize, mul_one] using Nat.mul_le_mul_left (2 * d ^ d) hpow/-- The explicit family in the literal Euclidean plane. -/theorem plane_counterexample (d : ℕ) (hd : 2 ≤ d) :∃ points : Finset ℝ²,ConvexIndep points ∧ points.card = constructionSize d ∧d * points.card ≤ 4 * unitDistNum points := byclassicalobtain ⟨P, hconv, hcard, hcount⟩ := convex_unit_counterexample d hdlet points := P.image complexToPlanehave hcard' : points.card = P.card :=Finset.card_image_of_injective _ complexToPlane.injectivehave hunit : unitDistNum points = (unitPairs P).card := byrw [unitDistNum_eq_card_unitPairs]exact unitPairs_card_image_isometry complexToPlane complexToPlane.isometry Prefine ⟨points, convexIndep_image_complexToPlane P hconv, hcard'.trans hcard, ?_⟩rw [hcard', hunit]exact hcount/-- Counterexamples occur past every cardinality threshold and every proposed linear bound. -/theorem large_convex_counterexample (C : ℝ) (N₀ : ℕ) :∃ points : Finset ℝ²,N₀ ≤ points.card ∧ ConvexIndep points ∧C * (points.card : ℝ) < (unitDistNum points : ℝ) := byobtain ⟨n, hn⟩ := exists_nat_gt (4 * C)let d := n + N₀ + 2have hd : 2 ≤ d := by dsimp [d]; omegaobtain ⟨P, hconv, hcard, hcount⟩ := plane_counterexample d hdhave hsize : N₀ ≤ P.card := byrw [hcard]exact le_trans (by dsimp [d]; omega) (constructionSize_ge_dimension (by omega))have hP : (0 : ℝ) < P.card := byhave hh : 0 < P.card := by rw [hcard]; exact constructionSize_pos (by omega)exact_mod_cast hhhave hcountR : (d : ℝ) * P.card ≤ 4 * unitDistNum P := by exact_mod_cast hcounthave hdR : 4 * C < (d : ℝ) := by dsimp [d]; push_cast; linarithrefine ⟨P, hsize, hconv, ?_⟩nlinarith [mul_pos (sub_pos.mpr hdR) hP]/-- The maximum number of unit distances in a convex n-gon is not O(n). -/theorem erdos_96_false :¬ ((fun n => (maxConvexUnitDistances n : ℝ)) =O[atTop] fun n => (n : ℝ)) := byintro hobtain ⟨C, hC⟩ := h.boundobtain ⟨N₀, hN₀⟩ := eventually_atTop.mp hCobtain ⟨P, hlarge, hconv, hcount⟩ := large_convex_counterexample C N₀have hupper := hN₀ P.card hlargehave hmax : (unitDistNum P : ℝ) ≤ (maxConvexUnitDistances P.card : ℝ) := byexact_mod_cast unitDistNum_le_max P hconvsimp only [Real.norm_natCast] at hupperlinarithendend Proofend OriginalProblem/-- The negation of the exact proposition in the supplied task. -/theorem target : ¬ (True ↔((fun n => (Erdos96.maxConvexUnitDistances n : ℝ)) =O[Filter.atTop]fun n => (n : ℝ))) := byintro hexact Proof.erdos_96_false (h.mp True.intro)end Combined_Erdos96/-! ## Source: UnitDegree.lean -/section Combined_UnitDegree/-! Unit-distance degrees and density-preserving vertex deletion (Lemma 4.1). -/namespace Proofnoncomputable sectionvariable {X : Type*} [MetricSpace X]def unitNeighbors (P : Finset X) (x : X) : Finset X := byclassicalexact P.filter (fun y => dist x y = 1)def unitDegree (P : Finset X) (x : X) : ℕ := (unitNeighbors P x).carddef HasUnitMinDegree (P : Finset X) (k : ℕ) : Prop :=∀ x ∈ P, k ≤ unitDegree P x@[simp] theorem mem_unitNeighbors {P : Finset X} {x y : X} :y ∈ unitNeighbors P x ↔ y ∈ P ∧ dist x y = 1 := byclassicalsimp [unitNeighbors]@[simp] theorem self_not_mem_unitNeighbors (P : Finset X) (x : X) :x ∉ unitNeighbors P x := by simp@[simp] theorem mk_mem_unitPairs {P : Finset X} {x y : X} :s(x, y) ∈ unitPairs P ↔ x ∈ P ∧ y ∈ P ∧ dist x y = 1 := byclassicalrw [unitPairs, Finset.mem_filter, Finset.mk_mem_sym2_iff]change ((x ∈ P ∧ y ∈ P) ∧ dist x y = 1) ↔ _exact and_assoc@[simp] theorem unitPairs_empty : unitPairs (∅ : Finset X) = ∅ := byclassicalsimp [unitPairs]theorem unitDegree_mono {P Q : Finset X} (h : P ⊆ Q) (x : X) :unitDegree P x ≤ unitDegree Q x := byclassicalexact Finset.card_le_card (Finset.filter_subset_filter _ h)theorem unitDegree_lt_card {P : Finset X} {x : X} (hx : x ∈ P) :unitDegree P x < P.card := byclassicalapply Finset.card_lt_cardexact Finset.ssubset_iff_subset_ne.mpr⟨Finset.filter_subset _ _, fun he => self_not_mem_unitNeighbors P x (he.symm ▸ hx)⟩theorem unitPairs_mono {P Q : Finset X} (h : P ⊆ Q) : unitPairs P ⊆ unitPairs Q := byclassicalintro einduction e using Sym2.inductionOn with| hf x y => simp only [mk_mem_unitPairs]; exact fun hh => ⟨h hh.1, h hh.2.1, hh.2.2⟩theorem unitDegree_erase_le [DecidableEq X] (P : Finset X) (x v : X) :unitDegree P x ≤ unitDegree (P.erase v) x + 1 := byclassicalunfold unitDegree unitNeighborsrw [Finset.filter_erase]by_cases h : v ∈ P.filter (fun y => dist x y = 1)· exact (Finset.card_erase_add_one h).ge· rw [Finset.erase_eq_of_notMem h]omegatheorem unitPairs_erase_add_degree [DecidableEq X] {P : Finset X} {x : X} (hx : x ∈ P) :(unitPairs (P.erase x)).card + unitDegree P x = (unitPairs P).card := byclassicallet f : X → Sym2 X := fun y => s(x, y)have hf : Function.Injective f := byintro y z hsimp only [f, Sym2.eq, Sym2.rel_iff', Prod.mk.injEq, Prod.swap_prod_mk] at hrcases h with h | h· exact h.2· exact h.2.trans h.1have hunion : unitPairs (P.erase x) ∪ (unitNeighbors P x).image f = unitPairs P := byext einduction e using Sym2.inductionOn with| hf a b =>simp only [Finset.mem_union, mk_mem_unitPairs, Finset.mem_erase, Finset.mem_image,mem_unitNeighbors, f, Sym2.eq, Sym2.rel_iff', Prod.mk.injEq, Prod.swap_prod_mk]constructor· rintro (⟨⟨_, ha⟩, ⟨_, hb⟩, hab⟩ | ⟨y, ⟨hy, hxy⟩, he⟩)· exact ⟨ha, hb, hab⟩· rcases he with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩· exact ⟨hx, hy, hxy⟩· exact ⟨hy, hx, by simpa only [dist_comm] using hxy⟩· rintro ⟨ha, hb, hab⟩by_cases hax : a = x· subst aexact Or.inr ⟨b, ⟨hb, hab⟩, Or.inl ⟨rfl, rfl⟩⟩by_cases hbx : b = x· subst bexact Or.inr ⟨a, ⟨ha, by simpa only [dist_comm] using hab⟩, Or.inr ⟨rfl, rfl⟩⟩exact Or.inl ⟨⟨hax, ha⟩, ⟨hbx, hb⟩, hab⟩have hdis : Disjoint (unitPairs (P.erase x)) ((unitNeighbors P x).image f) := byapply Finset.disjoint_left.mprintro e he hfmemobtain ⟨y, _, rfl⟩ := Finset.mem_image.mp hfmemhave hh := (mk_mem_unitPairs.mp he).1exact (Finset.mem_erase.mp hh).1 rflrw [← hunion, Finset.card_union_of_disjoint hdis, Finset.card_image_of_injective _ hf]rfl/-- Repeated deletion retains both a minimum-degree bound and the original density. -/theorem dense_subset_min_degree (α : ℝ) (k : ℕ) (hα : (k : ℝ) < α)(P : Finset X) (hP : P.Nonempty) (hcount : α * P.card ≤ (unitPairs P).card) :∃ Q : Finset X, Q ⊆ P ∧ Q.Nonempty ∧ HasUnitMinDegree Q (k + 1) ∧α * Q.card ≤ (unitPairs Q).card := byclassicalrevert hP hcountrefine Finset.strongInductionOn P ?_intro P ih hP hcountby_cases hd : HasUnitMinDegree P (k + 1)· exact ⟨P, Finset.Subset.refl P, hP, hd, hcount⟩simp only [HasUnitMinDegree, not_forall, not_le] at hdobtain ⟨x, hx, hdeg⟩ := hdhave hdeg' : (unitDegree P x : ℝ) ≤ k := by exact_mod_cast (by omega : unitDegree P x ≤ k)have hcard : ((P.erase x).card : ℝ) + 1 = P.card := byexact_mod_cast Finset.card_erase_add_one hxhave hedge : ((unitPairs (P.erase x)).card : ℝ) + unitDegree P x = (unitPairs P).card := byexact_mod_cast unitPairs_erase_add_degree hxhave hnew : α * (P.erase x).card < (unitPairs (P.erase x)).card := bynlinarithhave hne : (P.erase x).Nonempty := byby_contra hnrw [Finset.not_nonempty_iff_eq_empty.mp hn] at hnewsimpa using hnewobtain ⟨Q, hQP, hQ, hdQ, hcQ⟩ := ih (P.erase x) (Finset.erase_ssubset hx) hne hnew.leexact ⟨Q, hQP.trans (Finset.erase_subset _ _), hQ, hdQ, hcQ⟩open EuclideanGeometryopen scoped EuclideanGeometrytheorem convexIndep_subset {P Q : Finset ℝ²} (hP : ConvexIndep P) (hQP : Q ⊆ P) :ConvexIndep Q := byintro x hx hhapply hP x (hQP hx)have hsub : ((Q : Set ℝ²) \ {x}) ⊆ ((P : Set ℝ²) \ {x}) :=fun y hy => ⟨hQP hy.1, hy.2⟩exact convexHull_mono hsub hh/-- All vertices can have arbitrarily many neighbours at the same distance, namely one. -/theorem exists_convex_min_degree (k : ℕ) :∃ P : Finset ℝ², P.Nonempty ∧ ConvexIndep P ∧ HasUnitMinDegree P k := byobtain ⟨P, _, hconv, hc⟩ := large_convex_counterexample ((k : ℝ) + 1) 0rw [unitDistNum_eq_card_unitPairs] at hchave hP : P.Nonempty := byby_contra hnrw [Finset.not_nonempty_iff_eq_empty.mp hn] at hcsimpa using hcobtain ⟨Q, hQP, hQ, hd, _⟩ := dense_subset_min_degree ((k : ℝ) + 1) k(by linarith) P hP hc.leexact ⟨Q, hQ, convexIndep_subset hconv hQP, fun x hx => (Nat.le_succ k).trans (hd x hx)⟩theorem exists_convex_equidistant (k : ℕ) :∃ P : Finset ℝ², P.Nonempty ∧ ConvexIndep P ∧ Erdos97.HasNEquidistantProperty k P := byobtain ⟨P, hP, hconv, hd⟩ := exists_convex_min_degree kexact ⟨P, hP, hconv, fun x hx => ⟨1, by norm_num, hd x hx⟩⟩theorem erdos_97_false :¬ (∀ P : Finset ℝ², P.Nonempty → ConvexIndep P → ¬ Erdos97.HasNEquidistantProperty 4 P) := byobtain ⟨P, hP, hconv, he⟩ := exists_convex_equidistant 4exact fun h => h P hP hconv hetheorem erdos_97_general_false :¬ (∃ k : ℕ, ∀ P : Finset ℝ², P.Nonempty → ConvexIndep P →¬ Erdos97.HasNEquidistantProperty k P) := byrintro ⟨k, hk⟩obtain ⟨P, hP, hconv, he⟩ := exists_convex_equidistant kexact hk P hP hconv heendend Proofend Combined_UnitDegree/-! ## Source: GeneralProducts.lean -/section Combined_GeneralProducts/-! Products with bounded exponents: Lemma 2.1 and the general form of Lemma 3.4. -/namespace Proofnoncomputable sectiondef boundedProduct {E : Type*} [Fintype E] {q : ℕ}(w : E → ℂ) (a : E → Fin q) : ℂ := ∏ e, w e ^ (a e).valdef rotationBudget {E : Type*} [Fintype E] (q : ℕ) (w : E → ℂ) : ℝ :=(q - 1 : ℕ) * ∑ e, ‖w e - 1‖theorem boundedProduct_norm {E : Type*} [Fintype E] {q : ℕ}(w : E → ℂ) (hw : ∀ e, ‖w e‖ = 1) (a : E → Fin q) :‖boundedProduct w a‖ = 1 := bysimp [boundedProduct, norm_prod, norm_pow, hw]theorem norm_pow_sub_one_le (w : ℂ) (hw : ‖w‖ = 1) (n : ℕ) :‖w ^ n - 1‖ ≤ n * ‖w - 1‖ := byinduction n with| zero => simp| succ n ih =>calc‖w ^ (n + 1) - 1‖ = ‖(w ^ n - 1) * w + (w - 1)‖ := bycongr 1rw [pow_succ]ring_ ≤ ‖(w ^ n - 1) * w‖ + ‖w - 1‖ := norm_add_le _ __ = ‖w ^ n - 1‖ + ‖w - 1‖ := by rw [norm_mul, hw, mul_one]_ ≤ (n + 1 : ℕ) * ‖w - 1‖ := by push_cast; nlinariththeorem boundedProduct_close {E : Type*} [Fintype E] {q : ℕ}(w : E → ℂ) (hw : ∀ e, ‖w e‖ = 1) (a : E → Fin q) :‖boundedProduct w a - 1‖ ≤ rotationBudget q w := byclassicalcalc‖boundedProduct w a - 1‖ ≤ ∑ e, ‖w e ^ (a e).val - 1‖ :=norm_prod_sub_one_le Finset.univ _ (by simp [norm_pow, hw])_ ≤ ∑ e, ((a e).val : ℝ) * ‖w e - 1‖ :=Finset.sum_le_sum (fun e _ => norm_pow_sub_one_le _ (hw e) _)_ ≤ ∑ e, ((q - 1 : ℕ) : ℝ) * ‖w e - 1‖ := byapply Finset.sum_le_sumintro e _apply mul_le_mul_of_nonneg_right _ (norm_nonneg _)exact_mod_cast Nat.le_sub_one_of_lt (a e).isLt_ = rotationBudget q w := by rw [rotationBudget, Finset.mul_sum]def boundedCopy {I E : Type*} [Fintype E] {q : ℕ}(b : I → ℂ) (w : E → ℂ) (x : I × (E → Fin q)) : ℂ :=b x.1 * boundedProduct w x.2theorem boundedCopy_injective {I E : Type*} [Fintype E] {q : ℕ}(b : I → ℂ) (w : E → ℂ) (hb : ∀ i, b i ≠ 0)(hn : Function.Injective (fun i => ‖b i‖)) (hw : ∀ e, ‖w e‖ = 1)(hprod : Function.Injective (boundedProduct (q := q) w)) :Function.Injective (boundedCopy (q := q) b w) := byrintro ⟨i, a⟩ ⟨j, c⟩ hehave hnorm := congrArg norm hesimp only [boundedCopy, norm_mul, boundedProduct_norm w hw, mul_one] at hnormhave hij := hn hnormsubst jexact Prod.ext rfl (hprod (mul_left_cancel₀ (hb i) he))theorem boundedCopy_support {I E : Type*} [Fintype E] {q : ℕ}(b : I → ℂ) (w : E → ℂ) (hb : ∀ i, b i ≠ 0)(hn : Function.Injective (fun i => ‖b i‖)) (hb1 : ∀ i, ‖b i‖ ≤ 1)(hw : ∀ e, ‖w e‖ = 1) (hprod : Function.Injective (boundedProduct (q := q) w))(hs : ∀ i j, i ≠ j → support (b i) (b j) < -2 * rotationBudget q w)(x y : I × (E → Fin q)) (hne : x ≠ y) :support (boundedCopy b w x) (boundedCopy b w y) < 0 := byrcases x with ⟨i, a⟩rcases y with ⟨j, c⟩by_cases hij : i = j· subst japply support_negative_of_equal_norm· exact (boundedCopy_injective b w hb hn hw hprod).ne hne· simp only [boundedCopy, norm_mul, boundedProduct_norm w hw]· have hh := rotated_support_bound (hb1 i) (hb1 j)(boundedProduct_norm w hw a) (boundedProduct_norm w hw c)(boundedProduct_close w hw a) (boundedProduct_close w hw c)dsimp [boundedCopy]linarith [hs i j hij]theorem boundedCopy_displacement {I E : Type*} [Fintype E] {q : ℕ}(b : I → ℂ) (w : E → ℂ) (hb : ∀ i, ‖b i‖ ≤ 1)(hw : ∀ e, ‖w e‖ = 1) (x : I × (E → Fin q)) :‖boundedCopy b w x - b x.1‖ ≤ rotationBudget q w := byrw [boundedCopy, ← mul_sub_one, norm_mul]exact (mul_le_mul (hb _) (boundedProduct_close w hw _) (norm_nonneg _)(by norm_num)).trans_eq (one_mul _)def boundedSet {I E : Type*} [Fintype I] [Fintype E] {q : ℕ}(b : I → ℂ) (w : E → ℂ) : Finset ℂ := byclassicalexact Finset.univ.image (boundedCopy (q := q) b w)theorem boundedSet_card {I E : Type*} [Fintype I] [Fintype E] {q : ℕ}(b : I → ℂ) (w : E → ℂ) (hi : Function.Injective (boundedCopy (q := q) b w)) :(boundedSet (q := q) b w).card = Fintype.card I * q ^ Fintype.card E := byclassicalrw [boundedSet, Finset.card_image_of_injective _ hi]simpdef exponentDifference {E : Type*} {q : ℕ} (a b : E → Fin q) (e : E) : ℝ :=((a e).val : ℝ) - (b e).valtheorem exponentDifference_nonzero {E : Type*} {q : ℕ} {a b : E → Fin q}(hne : a ≠ b) : ∃ e, exponentDifference a b e ≠ 0 := byby_contra hpush Not at happly hnefunext eapply Fin.exthave hh := sub_eq_zero.mp (h e)exact_mod_cast hhdef boundedPhase {L P E : Type*} [Fintype E] {q : ℕ}(l : E → L) (p : E → P) (θ : E → ℝ) (a : E → Fin q)(z : (L → ℝ) × (P → ℝ)) : ℝ :=∑ e, ((a e).val : ℝ) * (θ e - chordAngle (z.1 (l e)) (z.2 (p e)))theorem boundedProduct_phase {L P E : Type*} [Fintype E] {q : ℕ}(l : E → L) (p : E → P) (θ : E → ℝ) (z : (L → ℝ) × (P → ℝ))(a : E → Fin q) :boundedProduct (phaseRotations l p θ z) a =Complex.exp ((boundedPhase l p θ a z : ℂ) * Complex.I) := byunfold boundedProduct phaseRotations boundedPhasesimp_rw [← Complex.exp_nat_mul]rw [← Complex.exp_sum]congr 1simp only [Complex.ofReal_sum, Complex.ofReal_mul, Complex.ofReal_natCast, Finset.sum_mul,mul_assoc]theorem boundedPhase_difference {L P E : Type*} [Fintype E] {q : ℕ}(l : E → L) (p : E → P) (θ : E → ℝ) (a b : E → Fin q)(z : (L → ℝ) × (P → ℝ)) :boundedPhase l p θ a z - boundedPhase l p θ b z =(∑ e, exponentDifference a b e * θ e) - edgeAngleSum l p (exponentDifference a b) z := bysimp only [boundedPhase, edgeAngleSum, ← Finset.sum_sub_distrib]apply Finset.sum_congr rflintro e _unfold exponentDifferenceringopen Set Filteropen scoped Topologytheorem bounded_products_separate {L P E : Type*} [Fintype E] {q : ℕ}[DecidableEq L] [DecidableEq P] [DecidableEq E](l : E → L) (p : E → P) (hij : Function.Injective (fun e => (l e, p e)))(θ : E → ℝ) (U : Set ((L → ℝ) × (P → ℝ))) (hU : IsOpen U) (hne : U.Nonempty)(hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0))(hf : ∀ e, ∀ z ∈ U, ChordFeasible (z.1 (l e)) (z.2 (p e)))(a b : E → Fin q) (hab : a ≠ b) :∃ z ∈ U, boundedProduct (phaseRotations l p θ z) a ≠boundedProduct (phaseRotations l p θ z) b := byby_contra hnonepush Not at hnoneobtain ⟨e, he⟩ := exponentDifference_nonzero habobtain ⟨z₀, hz₀⟩ := hnelet φ := fun z => boundedPhase l p θ a z - boundedPhase l p θ b zhave hφ : ∀ z, φ z = (∑ e, exponentDifference a b e * θ e) -edgeAngleSum l p (exponentDifference a b) z := boundedPhase_difference l p θ a bhave hc : ContinuousOn φ U := byintro z hzhave hh : ContinuousAt (fun z => (∑ e, exponentDifference a b e * θ e) -edgeAngleSum l p (exponentDifference a b) z) z := continuousAt_const.sub(edge_angles_continuousAt l p (exponentDifference a b) z (hnz z hz).1 (hnz z hz).2)simpa only [show φ = fun z => (∑ e, exponentDifference a b e * θ e) -edgeAngleSum l p (exponentDifference a b) z from funext hφ] using hh.continuousWithinAthave hexp : ∀ z ∈ U, Complex.exp ((φ z : ℂ) * Complex.I) = 1 := byintro z hzdsimp [φ]rw [Complex.ofReal_sub, sub_mul, Complex.exp_sub, ← boundedProduct_phase,← boundedProduct_phase, hnone z hz]apply div_selfrw [boundedProduct_phase]exact Complex.exp_ne_zero _let V := U ∩ (fun z => |φ z - φ z₀|) ⁻¹' Iio Real.pihave hVo : IsOpen V :=(hc.sub continuousOn_const).abs.isOpen_inter_preimage hU isOpen_Iiohave hVne : V.Nonempty := ⟨z₀, hz₀, by simpa using Real.pi_pos⟩have hVU : V ⊆ U := inter_subset_lefthave hconst : ∀ z ∈ V, edgeAngleSum l p (exponentDifference a b) z =(∑ e, exponentDifference a b e * θ e) - φ z₀ := byintro z hzhave hh : φ z = φ z₀ := exp_phase_small_injective hz.2((hexp z (hVU hz)).trans (hexp z₀ hz₀).symm)rw [hφ] at hhlinarithobtain ⟨z, hz, hh⟩ := edge_angle_sum_not_constant l p hij (exponentDifference a b) e heV hVo hVne (fun z hz => hf e z (hVU hz))((∑ e, exponentDifference a b e * θ e) - φ z₀)exact hh (hconst z hz)theorem exists_injective_boundedProducts {L P E : Type*} [Fintype E] (q : ℕ)[DecidableEq L] [DecidableEq P] [DecidableEq E](l : E → L) (p : E → P) (hij : Function.Injective (fun e => (l e, p e)))(θ : E → ℝ) (U : Set ((L → ℝ) × (P → ℝ))) (hU : IsOpen U) (hne : U.Nonempty)(hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0))(hf : ∀ e, ∀ z ∈ U, ChordFeasible (z.1 (l e)) (z.2 (p e))) :∃ z ∈ U, Function.Injective (boundedProduct (q := q) (phaseRotations l p θ z)) := byclassicallet K := {ab : (E → Fin q) × (E → Fin q) // ab.1 ≠ ab.2}let f := fun (k : K) (z : (L → ℝ) × (P → ℝ)) =>boundedProduct (phaseRotations l p θ z) k.val.1 -boundedProduct (phaseRotations l p θ z) k.val.2have hc : ∀ k, ContinuousOn (f k) U := byintro k z hzhave hrot := phaseRotations_continuousAt l p θ z (hnz z hz).1 (hnz z hz).2apply ContinuousAt.continuousWithinAtunfold f boundedProductfun_prophave hnc : ∀ k, ∀ V : Set ((L → ℝ) × (P → ℝ)),V ⊆ U → IsOpen V → V.Nonempty → ∃ z ∈ V, f k z ≠ 0 := byintro k V hVU hVo hVneobtain ⟨z, hz, hh⟩ := bounded_products_separate l p hij θ V hVo hVne(fun z hz => hnz z (hVU hz)) (fun e z hz => hf e z (hVU hz))k.val.1 k.val.2 k.propertyexact ⟨z, hz, sub_ne_zero.mpr hh⟩obtain ⟨z, hz, hh⟩ := finite_avoidance f U hU hne hc hnc Finset.univrefine ⟨z, hz, ?_⟩intro a b heqby_contra habexact hh (⟨(a, b), hab⟩ : K) (Finset.mem_univ _) (sub_eq_zero.mpr heq)endend Proofend Combined_GeneralProducts/-! ## Source: BoundedCounting.lean -/section Combined_BoundedCounting/-! The exact number of distinct lifted unit edges for bounded exponents. -/namespace Proofnoncomputable sectiondef incrementExponent {E : Type*} [DecidableEq E] {q : ℕ}(a : E → Fin q) (e : E) (h : (a e).val + 1 < q) : E → Fin q :=Function.update a e ⟨(a e).val + 1, h⟩theorem boundedProduct_increment {E : Type*} [Fintype E] [DecidableEq E] {q : ℕ}(w : E → ℂ) (a : E → Fin q) (e : E) (h : (a e).val + 1 < q) :boundedProduct w (incrementExponent a e h) = boundedProduct w a * w e := byhave he : ∀ f, w f ^ (incrementExponent a e h f).val =w f ^ (a f).val * (if f = e then w e else 1) := byintro fby_cases hf : f = e· subst fsimp [incrementExponent, pow_succ]· simp [incrementExponent, Function.update_of_ne hf, hf]simp only [boundedProduct, he, Finset.prod_mul_distrib]simpabbrev BoundedLiftedEdge (E : Type*) (q : ℕ) :=(e : E) × (Fin (q - 1) × ({f : E // f ≠ e} → Fin q))def edgeExponent {E : Type*} [DecidableEq E] {q : ℕ}(e : E) (a : Fin (q - 1) × ({f : E // f ≠ e} → Fin q)) (f : E) : Fin q :=if h : f = e then ⟨a.1.val, by have := a.1.isLt; omega⟩ else a.2 ⟨f, h⟩@[simp] theorem edgeExponent_self {E : Type*} [DecidableEq E] {q : ℕ}(e : E) (a : Fin (q - 1) × ({f : E // f ≠ e} → Fin q)) :(edgeExponent e a e).val = a.1.val := by simp [edgeExponent]theorem edgeExponent_injective {E : Type*} [DecidableEq E] {q : ℕ} (e : E) :Function.Injective (edgeExponent (q := q) e) := byintro a b happly Prod.ext· apply Fin.extsimpa using congrArg (fun f => (f e).val) h· funext fhave hh := congrFun h f.valsimpa [edgeExponent, f.property] using hhtheorem edgeExponent_succ_lt {E : Type*} [DecidableEq E] {q : ℕ}(e : E) (a : Fin (q - 1) × ({f : E // f ≠ e} → Fin q)) :(edgeExponent e a e).val + 1 < q := byrw [edgeExponent_self]have := a.1.isLtomegatheorem boundedLiftedEdge_card {E : Type*} [Fintype E] [DecidableEq E] (q : ℕ) :Fintype.card (BoundedLiftedEdge E q) =Fintype.card E * (q - 1) * q ^ (Fintype.card E - 1) := bysimp [BoundedLiftedEdge, Fintype.card_sigma, mul_assoc]def boundedLiftedPair {L P E : Type*} [Fintype E] [DecidableEq E] {q : ℕ}(l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)(x : BoundedLiftedEdge E q) : Sym2 ℂ :=s(boundedCopy b w (Sum.inl (l x.1), edgeExponent x.1 x.2),boundedCopy b w (Sum.inr (p x.1),incrementExponent (edgeExponent x.1 x.2) x.1 (edgeExponent_succ_lt x.1 x.2)))theorem boundedLiftedPair_injective {L P E : Type*} [Fintype E] [DecidableEq E] {q : ℕ}(l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)(he : Function.Injective (fun e => (l e, p e)))(hinj : Function.Injective (boundedCopy (q := q) b w)) :Function.Injective (boundedLiftedPair (q := q) l p b w) := byrintro ⟨e, a⟩ ⟨f, c⟩ hhsimp only [boundedLiftedPair, Sym2.eq, Sym2.rel_iff', Prod.mk.injEq, Prod.swap_prod_mk] at hhrcases hh with ⟨hl, hp⟩ | ⟨hl, _⟩· have hl := hinj hlhave hp := hinj hphave hef := he (Prod.ext (Sum.inl.inj (congrArg Prod.fst hl))(Sum.inr.inj (congrArg Prod.fst hp)))subst fhave hac := edgeExponent_injective e (congrArg Prod.snd hl)subst crfl· have hbad := congrArg Prod.fst (hinj hl)cases hbadtheorem mem_boundedSet {I E : Type*} [Fintype I] [Fintype E] {q : ℕ}(b : I → ℂ) (w : E → ℂ) (x : I × (E → Fin q)) :boundedCopy b w x ∈ boundedSet (q := q) b w := byclassicalexact Finset.mem_image.mpr ⟨x, Finset.mem_univ _, rfl⟩theorem boundedCopy_unit_edge {I E : Type*} [Fintype E] [DecidableEq E] {q : ℕ}(b : I → ℂ) (w : E → ℂ) (hw : ∀ e, ‖w e‖ = 1)(i j : I) (e : E) (he : ‖b i - b j * w e‖ = 1)(a : E → Fin q) (h : (a e).val + 1 < q) :dist (boundedCopy b w (i, a)) (boundedCopy b w (j, incrementExponent a e h)) = 1 := bysimp only [boundedCopy, boundedProduct_increment, dist_eq_norm]rw [show b i * boundedProduct w a - b j * (boundedProduct w a * w e) =(b i - b j * w e) * boundedProduct w a by ring]rw [norm_mul, he, boundedProduct_norm w hw, one_mul]theorem boundedLiftedPair_mem_unitPairs {L P E : Type*}[Fintype L] [Fintype P] [Fintype E] [DecidableEq E] {q : ℕ}(l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)(hw : ∀ e, ‖w e‖ = 1)(hedge : ∀ e, ‖b (Sum.inl (l e)) - b (Sum.inr (p e)) * w e‖ = 1)(x : BoundedLiftedEdge E q) :boundedLiftedPair l p b w x ∈ unitPairs (boundedSet (q := q) b w) := byclassicalapply mk_mem_unitPairs.mprexact ⟨mem_boundedSet b w _, mem_boundedSet b w _,boundedCopy_unit_edge b w hw _ _ x.1 (hedge x.1) _ _⟩theorem bounded_amplification_unitPairs_bound {L P E : Type*}[Fintype L] [Fintype P] [Fintype E] [DecidableEq E] {q : ℕ}(l : E → L) (p : E → P) (b : L ⊕ P → ℂ) (w : E → ℂ)(he : Function.Injective (fun e => (l e, p e)))(hinj : Function.Injective (boundedCopy (q := q) b w)) (hw : ∀ e, ‖w e‖ = 1)(hedge : ∀ e, ‖b (Sum.inl (l e)) - b (Sum.inr (p e)) * w e‖ = 1) :Fintype.card E * (q - 1) * q ^ (Fintype.card E - 1) ≤(unitPairs (boundedSet (q := q) b w)).card := bylet f : BoundedLiftedEdge E q → unitPairs (boundedSet (q := q) b w) :=fun x => ⟨boundedLiftedPair l p b w x, boundedLiftedPair_mem_unitPairs l p b w hw hedge x⟩have hf : Function.Injective f := fun x y h =>boundedLiftedPair_injective l p b w he hinj (congrArg Subtype.val h)simpa only [boundedLiftedEdge_card, Fintype.card_coe] using Fintype.card_le_of_injective f hfendend Proofend Combined_BoundedCounting/-! ## Source: MiddleLevels.lean -/section Combined_MiddleLevels/-! The middle-levels incidence graph and its powers-of-five seed pattern. -/namespace Proofnoncomputable sectionabbrev MiddleLower (d : ℕ) := {A : Finset (Fin (2 * d - 1)) // A.card = d - 1}abbrev MiddleUpper (d : ℕ) := {B : Finset (Fin (2 * d - 1)) // B.card = d}abbrev MiddleEdge (d : ℕ) := (B : MiddleUpper d) × {j : Fin (2 * d - 1) // j ∈ B.val}def middlePoint {d : ℕ} (e : MiddleEdge d) : MiddleUpper d := e.1def middleLine {d : ℕ} (e : MiddleEdge d) : MiddleLower d :=⟨e.1.val.erase e.2.val, by rw [Finset.card_erase_of_mem e.2.property, e.1.property]⟩theorem middle_endpoints_injective (d : ℕ) :Function.Injective (fun e : MiddleEdge d => (middleLine e, middlePoint e)) := byrintro ⟨B, j⟩ ⟨C, k⟩ hhave hBC : B = C := congrArg Prod.snd hsubst Chave hjk : j = k := byapply Subtype.extexact (Finset.erase_inj B.val j.property).mp (congrArg (fun z => z.1.val) h)subst krfltheorem finite_layer_card (n r : ℕ) :Fintype.card {A : Finset (Fin n) // A.card = r} = n.choose r := byclassicalrw [Fintype.card_of_subtype (Finset.univ.powersetCard r)(fun A => by simp [Finset.mem_powersetCard])]simp [Finset.card_powersetCard]theorem middleLower_card (d : ℕ) :Fintype.card (MiddleLower d) = (2 * d - 1).choose (d - 1) := finite_layer_card _ _theorem middleUpper_card (d : ℕ) :Fintype.card (MiddleUpper d) = (2 * d - 1).choose d := finite_layer_card _ _theorem middle_layers_equal {d : ℕ} (hd : 1 ≤ d) :(2 * d - 1).choose (d - 1) = (2 * d - 1).choose d :=Nat.choose_symm_of_eq_add (by omega)def middleVertexCount (d : ℕ) : ℕ := (2 * d).choose ddef middleEdgeCount (d : ℕ) : ℕ := d * (2 * d - 1).choose ddef finiteSize (d q : ℕ) : ℕ := middleVertexCount d * q ^ middleEdgeCount dtheorem middleVertex_card {d : ℕ} (hd : 1 ≤ d) :Fintype.card (MiddleLower d ⊕ MiddleUpper d) = middleVertexCount d := byrw [Fintype.card_sum, middleLower_card, middleUpper_card]unfold middleVertexCounthave h := Nat.choose_succ_succ' (2 * d - 1) (d - 1)simpa only [Nat.sub_add_cancel hd, Nat.sub_add_cancel (by omega : 1 ≤ 2 * d)] using h.symmtheorem middleEdge_card (d : ℕ) : Fintype.card (MiddleEdge d) = middleEdgeCount d := byclassicalrw [Fintype.card_sigma]simp only [Fintype.card_coe]simp_rw [show ∀ B : MiddleUpper d, B.val.card = d from fun B => B.property]simp [middleUpper_card, middleEdgeCount, mul_comm]theorem middleVertexCount_eq_twice {d : ℕ} (hd : 1 ≤ d) :middleVertexCount d = 2 * (2 * d - 1).choose d := byrw [← middleVertex_card hd, Fintype.card_sum, middleLower_card, middleUpper_card,middle_layers_equal hd]omegatheorem middleEdgeCount_twice {d : ℕ} (hd : 1 ≤ d) :2 * middleEdgeCount d = d * middleVertexCount d := byrw [middleVertexCount_eq_twice hd, middleEdgeCount]ringtheorem middleEdgeCount_formula {d : ℕ} (hd : 1 ≤ d) :middleEdgeCount d = d * (2 * d).choose d / 2 := byhave h := middleEdgeCount_twice hdchange 2 * middleEdgeCount d = d * (2 * d).choose d at homegatheorem middleVertexCount_pos (d : ℕ) : 0 < middleVertexCount d := byexact Nat.choose_pos (by omega)theorem middleEdgeCount_pos {d : ℕ} (hd : 1 ≤ d) : 0 < middleEdgeCount d := byexact Nat.mul_pos (by omega) (Nat.choose_pos (by omega))theorem finiteSize_pos {d q : ℕ} (hq : 1 ≤ q) : 0 < finiteSize d q :=Nat.mul_pos (middleVertexCount_pos d) (pow_pos (by omega) _)def finiteDigits {n : ℕ} (A : Finset (Fin n)) : Finset ℕ :=A.map ⟨Fin.val, Fin.val_injective⟩theorem finiteDigits_injective (n : ℕ) : Function.Injective (@finiteDigits n) :=Finset.map_injective _def middleX {n : ℕ} (A : Finset (Fin n)) : ℝ := digitSum 5 (finiteDigits A)def middleT {n : ℕ} (A : Finset (Fin n)) : ℝ := 1 + digitSum 25 (finiteDigits A)theorem middleT_pos {n : ℕ} (A : Finset (Fin n)) : 0 < middleT A := byhave h : 0 ≤ digitSum 25 (finiteDigits A) := Finset.sum_nonneg (fun _ _ => by positivity)dsimp [middleT]linariththeorem middleT_injective (n : ℕ) : Function.Injective (@middleT n) := byintro A B hby_contra hnehave hh := (digit_separation ((finiteDigits_injective n).ne hne)).2.1apply hhdsimp [middleT] at hlinariththeorem middle_digit_margin {n : ℕ} {A B : Finset (Fin n)} (hne : A ≠ B) :-(middleX B - middleX A) ^ 2 / 2 - (middleT B - middleT A) / 4 < 0 ∧-(middleX B - middleX A) ^ 2 / 2 + (middleT B - middleT A) / 4 < 0 := byobtain ⟨hX, _, hsep⟩ := digit_separation ((finiteDigits_injective n).ne hne.symm)have hm := signed_digit_margin hsephave hsq : 0 < (digitSum 5 (finiteDigits B) - digitSum 5 (finiteDigits A)) ^ 2 :=sq_pos_of_ne_zero (sub_ne_zero.mpr hX)dsimp [middleX, middleT]constructor <;> nlinarith [hm.1, hm.2]theorem middle_incidence_digits {d : ℕ} (e : MiddleEdge d) :middleX e.1.val - middleX (middleLine e).val = (5 : ℝ) ^ e.2.val.val ∧middleT e.1.val - middleT (middleLine e).val = ((5 : ℝ) ^ e.2.val.val) ^ 2 := byhave he : finiteDigits e.1.val = insert e.2.val.val (finiteDigits (middleLine e).val) := bycalcfiniteDigits e.1.val = finiteDigits (insert e.2.val (middleLine e).val) :=congrArg finiteDigits (Finset.insert_erase e.2.property).symm_ = _ := Finset.map_insert _ _ _have hne : e.2.val.val ∉ finiteDigits (middleLine e).val := bysimp [finiteDigits, middleLine]constructor· simp [middleX, he, digitSum, Finset.sum_insert hne]· simp only [middleT, he, digitSum, Finset.sum_insert hne]have hp : (25 : ℝ) ^ e.2.val.val = ((5 : ℝ) ^ e.2.val.val) ^ 2 := byrw [← pow_mul, Nat.mul_comm e.2.val.val 2, pow_mul]norm_numlinarithdef middlePattern (d : ℕ) : SeedPattern (MiddleLower d) (MiddleUpper d) (MiddleEdge d) whereline := middleLinepoint := middlePointendpoints_injective := middle_endpoints_injective dLX A := middleX A.valLT A := middleT A.valPX B := middleX B.valPT B := middleT B.valLT_pos A := middleT_pos A.valPT_pos B := middleT_pos B.valLT_injective := fun A B h => Subtype.ext (middleT_injective _ h)PT_injective := fun A B h => Subtype.ext (middleT_injective _ h)line_margin A B h := (middle_digit_margin (fun he => h (Subtype.ext he))).1point_margin A B h := (middle_digit_margin (fun he => h (Subtype.ext he))).2edge_positive e := byhave hh := (middle_incidence_digits e).1have hp : 0 < (5 : ℝ) ^ e.2.val.val := by positivitychange middleX (middleLine e).val < middleX e.1.vallinarithedge_identity e := bychange middleT e.1.val - middleT (middleLine e).val =(middleX e.1.val - middleX (middleLine e).val) ^ 2rw [(middle_incidence_digits e).1, (middle_incidence_digits e).2]endend Proofend Combined_MiddleLevels/-! ## Source: LocalizedSeeds.lean -/section Combined_LocalizedSeeds/-! Seed preparation with an arbitrary exponent bound and prescribed localization. -/namespace Proofnoncomputable sectionopen Set Filteropen scoped Topologydef seedCenter {L P : Type*} : L ⊕ P → ℂ :=Sum.elim (fun _ => ⟨0, -1 / 2⟩) (fun _ => ⟨0, 1 / 2⟩)theorem SeedPattern.base_zero {L P E : Type*} (S : SeedPattern L P E) (i : L ⊕ P) :S.base 0 i = seedCenter i := bycases i <;> simp [SeedPattern.base, lineSeed, pointSeed, seedCenter]structure LocalPreparedSeed {L P E : Type*} [Fintype E](l : E → L) (p : E → P) (q : ℕ) (η : ℝ) whereseed : PreparedSeed l psupport_margin : ∀ i j, i ≠ j →support (seed.base i) (seed.base j) < -2 * rotationBudget q seed.rotationlocalized : ∀ i, ‖seed.base i - seedCenter i‖ + rotationBudget q seed.rotation < ηtheorem SeedPattern.exists_local_prepared {L P E : Type*}[Fintype L] [Fintype P] [Fintype E] (S : SeedPattern L P E)(q : ℕ) (hq : 2 ≤ q) (η : ℝ) (hη : 0 < η) :Nonempty (LocalPreparedSeed S.line S.point q η) := bylet A := fun ε : ℝ => 2 * ((q - 1 : ℕ) : ℝ) * ∑ e, ‖S.coeff ε e‖have hcoeff : ∀ e, ContinuousAt (fun ε => S.coeff ε e) 0 := S.coeff_continuoushave hA : ContinuousAt A 0 := by unfold A; fun_prophave hbase : ∀ i, Continuous (fun ε => S.base ε i) := byintro icases i with| inl l => exact continuous_lineSeed _ _| inr p => exact continuous_pointSeed _ _have hbase0 : ∀ i, ‖S.base 0 i‖ = 1 / 2 := byintro icases i <;> norm_num [SeedPattern.base, lineSeed, pointSeed, Complex.norm_def, Complex.normSq_apply]have hbounds : ∀ i, ∀ᶠ ε in 𝓝[>] (0 : ℝ), S.base ε i ≠ 0 ∧ ‖S.base ε i‖ < 1 := byintro ihave hlo : ∀ᶠ ε in 𝓝 (0 : ℝ), 0 < ‖S.base ε i‖ :=continuousAt_const.eventually_lt (hbase i).norm.continuousAt (by rw [hbase0]; norm_num)have hhi : ∀ᶠ ε in 𝓝 (0 : ℝ), ‖S.base ε i‖ < 1 :=(hbase i).norm.continuousAt.eventually_lt continuousAt_const (by rw [hbase0]; norm_num)filter_upwards [hlo.filter_mono nhdsWithin_le_nhds, hhi.filter_mono nhdsWithin_le_nhds] with ε hlo hhiexact ⟨norm_pos_iff.mp hlo, hhi⟩have hnorms : ∀ i j, ∀ᶠ ε in 𝓝[>] (0 : ℝ), i ≠ j → ‖S.base ε i‖ ≠ ‖S.base ε j‖ := byintro i jby_cases hij : i = j· exact Eventually.of_forall (fun _ h => (h hij).elim)cases i with| inl l =>cases j with| inl k =>have hk : l ≠ k := fun h => hij (congrArg Sum.inl h)exact (eventually_line_norm_ne _ _ _ _ (S.LT_injective.ne hk)).mono (fun _ h _ => h)| inr p =>exact (eventually_cross_norm_ne _ _ _ _ (S.LT_pos l) (S.PT_pos p)).mono (fun _ h _ => h)| inr p =>cases j with| inl l =>exact (eventually_cross_norm_ne _ _ _ _ (S.LT_pos l) (S.PT_pos p)).mono (fun _ h _ => h.symm)| inr r =>have hr : p ≠ r := fun h => hij (congrArg Sum.inr h)exact (eventually_point_norm_ne _ _ _ _ (S.PT_injective.ne hr)).mono (fun _ h _ => h)have hsupports : ∀ i j, ∀ᶠ ε in 𝓝[>] (0 : ℝ),i ≠ j → support (S.base ε i) (S.base ε j) < -ε ^ 3 * A ε := byintro i jby_cases hij : i = j· exact Eventually.of_forall (fun _ h => (h hij).elim)cases i with| inl l =>cases j with| inl k =>have hk : l ≠ k := fun h => hij (congrArg Sum.inl h)exact (eventually_line_support _ _ _ _ A hA (S.line_margin l k hk)).mono (fun _ h _ => h)| inr p =>exact (eventually_cross_support _ _ _ _ A hA).mono (fun _ h _ => h.1)| inr p =>cases j with| inl l =>exact (eventually_cross_support _ _ _ _ A hA).mono (fun _ h _ => h.2)| inr r =>have hr : p ≠ r := fun h => hij (congrArg Sum.inr h)exact (eventually_point_support _ _ _ _ A hA (S.point_margin p r hr)).mono (fun _ h _ => h)have hedges : ∀ e, ∀ᶠ ε in 𝓝[>] (0 : ℝ),‖S.rot ε e‖ = 1 ∧‖S.base ε (Sum.inl (S.line e)) - S.base ε (Sum.inr (S.point e)) * S.rot ε e‖ = 1 ∧S.rot ε e - 1 = (ε : ℂ) ^ 3 * S.coeff ε e := fun e =>(seedCorrection_properties _ _ _ _ (S.edge_positive e) (S.edge_identity e)).filter_mononhdsWithin_le_nhdshave him : ∀ e, ∀ᶠ ε in 𝓝[>] (0 : ℝ),(starRingEnd ℂ (S.base ε (Sum.inl (S.line e))) *S.base ε (Sum.inr (S.point e)) * S.rot ε e).im < 0 := fun e =>seedCorrection_im_negative _ _ _ _ (S.edge_positive e)have hlocal : ∀ i, ∀ᶠ ε in 𝓝[>] (0 : ℝ),‖S.base ε i - seedCenter i‖ + ε ^ 3 * A ε / 2 < η := byintro ihave hc : ContinuousAt (fun ε => ‖S.base ε i - seedCenter i‖ + ε ^ 3 * A ε / 2) 0 := byfun_propexact (hc.eventually_lt continuousAt_const (by simpa [S.base_zero] using hη)).filter_mononhdsWithin_le_nhdshave hbAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i, S.base ε i ≠ 0 ∧ ‖S.base ε i‖ < 1 := bysimpa only [eventually_all] using hboundshave hnAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i j, i ≠ j → ‖S.base ε i‖ ≠ ‖S.base ε j‖ := bysimpa only [eventually_all] using hnormshave hsAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i j, i ≠ j →support (S.base ε i) (S.base ε j) < -ε ^ 3 * A ε := bysimpa only [eventually_all] using hsupportshave heAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ e,‖S.rot ε e‖ = 1 ∧‖S.base ε (Sum.inl (S.line e)) - S.base ε (Sum.inr (S.point e)) * S.rot ε e‖ = 1 ∧S.rot ε e - 1 = (ε : ℂ) ^ 3 * S.coeff ε e := bysimpa only [eventually_all] using hedgeshave hiAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ e,(starRingEnd ℂ (S.base ε (Sum.inl (S.line e))) *S.base ε (Sum.inr (S.point e)) * S.rot ε e).im < 0 := bysimpa only [eventually_all] using himhave hlAll : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ∀ i,‖S.base ε i - seedCenter i‖ + ε ^ 3 * A ε / 2 < η := bysimpa only [eventually_all] using hlocalobtain ⟨ε, hb, hn, hs, he, hi, hl, hε⟩ :=(hbAll.and (hnAll.and (hsAll.and (heAll.and (hiAll.and (hlAll.and self_mem_nhdsWithin)))))).existshave hε : 0 < ε := hεhave hsum : 2 * rotationBudget q (S.rot ε) = ε ^ 3 * A ε := byunfold rotationBudgetsimp_rw [fun e => (he e).2.2, norm_mul, norm_pow, Complex.norm_real, Real.norm_eq_abs,abs_of_pos hε]rw [← Finset.mul_sum]dsimp [A]ringhave hsup : ∀ i j, i ≠ j →support (S.base ε i) (S.base ε j) < -2 * rotationBudget q (S.rot ε) := byintro i j hijlinarith [hs i j hij]let Q : PreparedSeed S.line S.point := {base := S.base εrotation := S.rot εbase_ne_zero := fun i => (hb i).1base_norm_lt := fun i => (hb i).2radii_injective := fun i j hh => by_contra fun hij => hn i j hij hhrotation_norm := fun e => (he e).1unit_edge := fun e => (he e).2.1support_margin := byintro i j hijhave hh := hsup i j hijhave hK : (1 : ℝ) ≤ ((q - 1 : ℕ) : ℝ) := by exact_mod_cast (by omega : 1 ≤ q - 1)have hnn : 0 ≤ ∑ e, ‖S.rot ε e - 1‖ := Finset.sum_nonneg (fun _ _ => norm_nonneg _)unfold rotationBudget at hhnlinarithchord_im_negative := hi }refine ⟨⟨Q, hsup, ?_⟩⟩intro ichange ‖S.base ε i - seedCenter i‖ + rotationBudget q (S.rot ε) < ηlinarith [hl i]structure LocalSeparatedSeed {L P E : Type*} [Fintype E](l : E → L) (p : E → P) (q : ℕ) (η : ℝ) wherebase : L ⊕ P → ℂrotation : E → ℂbase_ne_zero : ∀ i, base i ≠ 0base_norm_lt : ∀ i, ‖base i‖ < 1radii_injective : Function.Injective (fun i => ‖base i‖)rotation_norm : ∀ e, ‖rotation e‖ = 1unit_edge : ∀ e, ‖base (Sum.inl (l e)) - base (Sum.inr (p e)) * rotation e‖ = 1support_margin : ∀ i j, i ≠ j → support (base i) (base j) < -2 * rotationBudget q rotationproducts_injective : Function.Injective (boundedProduct (q := q) rotation)localized : ∀ i, ‖base i - seedCenter i‖ + rotationBudget q rotation < ηtheorem LocalPreparedSeed.exists_separated {L P E : Type*}[Fintype L] [Fintype P] [Fintype E] {l : E → L} {p : E → P} {q : ℕ} {η : ℝ}(R : LocalPreparedSeed l p q η) (hij : Function.Injective (fun e => (l e, p e))) :Nonempty (LocalSeparatedSeed l p q η) := byclassicallet Q := R.seedhave hr : ∀ i, Q.radii.1 i ≠ 0 := fun i => norm_ne_zero_iff.mpr (Q.base_ne_zero _)have hs : ∀ j, Q.radii.2 j ≠ 0 := fun j => norm_ne_zero_iff.mpr (Q.base_ne_zero _)have hrot : ∀ e, ContinuousAt (fun z => phaseRotations l p Q.angles z e) Q.radii :=phaseRotations_continuousAt l p Q.angles Q.radii hr hshave hbase : ∀ i, ContinuousAt (fun z => Q.varBase z i) Q.radii :=fun i => (Q.varBase_continuous i).continuousAthave hH : ContinuousAt (fun z => rotationBudget q (phaseRotations l p Q.angles z)) Q.radii := byunfold rotationBudgetfun_prophave hmargin : ∀ i j, ∀ᶠ z in 𝓝 Q.radii, i ≠ j →support (Q.varBase z i) (Q.varBase z j) < -2 * rotationBudget q (phaseRotations l p Q.angles z) := byintro i jby_cases hij : i = j· exact Eventually.of_forall (fun _ h => (h hij).elim)have hc : ContinuousAt (fun z => support (Q.varBase z i) (Q.varBase z j) +2 * rotationBudget q (phaseRotations l p Q.angles z)) Q.radii := byhave hri := Complex.continuous_re.continuousAt.comp (hbase i)have hrj := Complex.continuous_re.continuousAt.comp (hbase j)have hii := Complex.continuous_im.continuousAt.comp (hbase i)have hij := Complex.continuous_im.continuousAt.comp (hbase j)unfold supportexact ((hri.mul (hrj.sub hri)).add (hii.mul (hij.sub hii))).add(continuousAt_const.mul hH)have hvalue : support (Q.varBase Q.radii i) (Q.varBase Q.radii j) +2 * rotationBudget q (phaseRotations l p Q.angles Q.radii) < 0 := byrw [Q.varBase_at_radii, Q.phase_at_radii]linarith [R.support_margin i j hij]exact (hc.eventually_lt continuousAt_const hvalue).mono (fun _ hh _ => by linarith)have hlocal : ∀ i, ∀ᶠ z in 𝓝 Q.radii,‖Q.varBase z i - seedCenter i‖ + rotationBudget q (phaseRotations l p Q.angles z) < η := byintro ihave hc : ContinuousAt (fun z => ‖Q.varBase z i - seedCenter i‖ +rotationBudget q (phaseRotations l p Q.angles z)) Q.radii := by fun_propapply hc.eventually_lt continuousAt_constrw [Q.varBase_at_radii, Q.phase_at_radii]exact R.localized ihave hmAll : ∀ᶠ z in 𝓝 Q.radii, ∀ i j, i ≠ j →support (Q.varBase z i) (Q.varBase z j) < -2 * rotationBudget q (phaseRotations l p Q.angles z) := bysimpa only [eventually_all] using hmarginhave hlAll : ∀ᶠ z in 𝓝 Q.radii, ∀ i,‖Q.varBase z i - seedCenter i‖ + rotationBudget q (phaseRotations l p Q.angles z) < η := bysimpa only [eventually_all] using hlocalobtain ⟨U, hUgood, hU, hz₀⟩ := mem_nhds_iff.mp (Q.goodRadii_nhds.and (hmAll.and hlAll))have hne : U.Nonempty := ⟨Q.radii, hz₀⟩have hnz : ∀ z ∈ U, (∀ i, z.1 i ≠ 0) ∧ (∀ j, z.2 j ≠ 0) := byintro z hzexact ⟨fun i => ne_of_gt ((hUgood hz).1.1 (Sum.inl i)),fun j => ne_of_gt ((hUgood hz).1.1 (Sum.inr j))⟩obtain ⟨z, hz, hprod⟩ := exists_injective_boundedProducts q l p hij Q.angles U hU hne hnz(fun e z hz => (hUgood hz).1.2.2.2.1 e)obtain ⟨⟨hpos, hnorm, hinj, hfeas, _⟩, hmargin, hloc⟩ := hUgood hzhave hrnorm : ∀ i, ‖Q.varBase z i‖ = joinedRadii z i :=radialBase_norm Q.base Q.base_ne_zero (joinedRadii z) (fun i => (hpos i).le)refine ⟨{base := Q.varBase zrotation := phaseRotations l p Q.angles zbase_ne_zero := fun i => norm_pos_iff.mp (by rw [hrnorm]; exact hpos i)base_norm_lt := hnormradii_injective := ?_rotation_norm := phaseRotations_norm l p Q.angles zunit_edge := fun e => Q.varBase_unit_edge z e (hfeas e)support_margin := hmarginproducts_injective := hprodlocalized := hloc }⟩intro i j hhdsimp only at hhrw [hrnorm, hrnorm] at hhexact hinj hhendend Proofend Combined_LocalizedSeeds/-! ## Source: FiniteConstruction.lean -/section Combined_FiniteConstruction/-! The full finite construction of Theorem 1.3. -/namespace Proofnoncomputable sectiondef lowerCenter : ℂ := ⟨0, -1 / 2⟩def upperCenter : ℂ := ⟨0, 1 / 2⟩def twoDisks (η : ℝ) : Set ℂ := Metric.ball lowerCenter η ∪ Metric.ball upperCenter ηdef RadialSupport (P : Finset ℂ) : Prop :=∀ x ∈ P, ∀ y ∈ P, x ≠ y → support x y < 0theorem RadialSupport.mono {P Q : Finset ℂ} (hP : RadialSupport P) (hQP : Q ⊆ P) :RadialSupport Q := fun x hx y hy hne => hP x (hQP hx) y (hQP hy) hnetheorem RadialSupport.convexIndependent {P : Finset ℂ} (hP : RadialSupport P) :ConvexIndependent ℝ (fun z : ↥(P : Set ℂ) => (z : ℂ)) := byapply convexIndependent_of_supportintro x y hneexact hP x.val x.property y.val y.property (fun h => hne (Subtype.ext h))theorem twoDisks_open (η : ℝ) : IsOpen (twoDisks η) :=Metric.isOpen_ball.union Metric.isOpen_balltheorem SeedPattern.finite_construction {L R E : Type*}[Fintype L] [Fintype R] [Fintype E] (S : SeedPattern L R E)(q : ℕ) (hq : 2 ≤ q) (η : ℝ) (hη : 0 < η) :∃ P : Finset ℂ,P.card = Fintype.card (L ⊕ R) * q ^ Fintype.card E ∧Fintype.card E * (q - 1) * q ^ (Fintype.card E - 1) ≤ (unitPairs P).card ∧RadialSupport P ∧ 0 ∉ P ∧ (P : Set ℂ) ⊆ twoDisks η := byclassicalobtain ⟨Q⟩ := S.exists_local_prepared q hq η hηobtain ⟨B⟩ := Q.exists_separated S.endpoints_injectivelet P := boundedSet (q := q) B.base B.rotationhave hinj := boundedCopy_injective B.base B.rotation B.base_ne_zero B.radii_injectiveB.rotation_norm B.products_injectiverefine ⟨P, boundedSet_card B.base B.rotation hinj,bounded_amplification_unitPairs_bound S.line S.point B.base B.rotationS.endpoints_injective hinj B.rotation_norm B.unit_edge, ?_, ?_, ?_⟩· intro x hx y hy hneobtain ⟨a, _, rfl⟩ := Finset.mem_image.mp hxobtain ⟨b, _, rfl⟩ := Finset.mem_image.mp hyexact boundedCopy_support B.base B.rotation B.base_ne_zero B.radii_injective(fun i => (B.base_norm_lt i).le) B.rotation_norm B.products_injective B.support_margina b (fun h => hne (congrArg (boundedCopy B.base B.rotation) h))· intro hzobtain ⟨a, _, ha⟩ := Finset.mem_image.mp hzhave hn : boundedProduct B.rotation a.2 ≠ 0 := norm_ne_zero_iff.mp(by rw [boundedProduct_norm B.rotation B.rotation_norm]; norm_num)exact mul_ne_zero (B.base_ne_zero a.1) hn ha· intro x hxobtain ⟨a, _, rfl⟩ := Finset.mem_image.mp hxhave hclose : ‖boundedCopy B.base B.rotation a - seedCenter a.1‖ < η := byhave hd := boundedCopy_displacement B.base B.rotation (fun i => (B.base_norm_lt i).le)B.rotation_norm ahave ht := norm_sub_le_norm_sub_add_norm_sub (boundedCopy B.base B.rotation a)(B.base a.1) (seedCenter a.1)linarith [B.localized a.1]cases h : a.1 with| inl l =>apply Or.inlsimpa only [Metric.mem_ball, dist_eq_norm, h, seedCenter, Sum.elim_inl, lowerCenter] using hclose| inr r =>apply Or.inrsimpa only [Metric.mem_ball, dist_eq_norm, h, seedCenter, Sum.elim_inr, upperCenter] using hclose/-- The finite theorem with an integer form of its edge-density bound. -/theorem finite_construction (d q : ℕ) (hd : 2 ≤ d) (hq : 2 ≤ q)(η : ℝ) (hη : 0 < η) :∃ P : Finset ℂ,P.card = finiteSize d q ∧ d * (q - 1) * P.card ≤ 2 * q * (unitPairs P).card ∧RadialSupport P ∧ 0 ∉ P ∧ (P : Set ℂ) ⊆ twoDisks η := byobtain ⟨P, hc, he, hs, hn, hl⟩ := (middlePattern d).finite_construction q hq η hηsimp only [middleVertex_card (by omega : 1 ≤ d), middleEdge_card] at hc herefine ⟨P, hc, ?_, hs, hn, hl⟩have hm : 1 ≤ middleEdgeCount d := middleEdgeCount_pos (by omega)have hpow : q ^ middleEdgeCount d = q * q ^ (middleEdgeCount d - 1) := byrw [← pow_succ', Nat.sub_add_cancel hm]calcd * (q - 1) * P.card =2 * q * (middleEdgeCount d * (q - 1) * q ^ (middleEdgeCount d - 1)) := bycalc_ = (d * middleVertexCount d) * (q - 1) * q * q ^ (middleEdgeCount d - 1) := byrw [hc, hpow]ring_ = _ := by rw [← middleEdgeCount_twice (by omega : 1 ≤ d)]; ring_ ≤ 2 * q * (unitPairs P).card := Nat.mul_le_mul_left _ he/-- Theorem 1.3 in the manuscript's real-valued notation. -/theorem finite_construction_real (d q : ℕ) (hd : 2 ≤ d) (hq : 2 ≤ q)(η : ℝ) (hη : 0 < η) :∃ P : Finset ℂ,P.card = finiteSize d q ∧(d : ℝ) / 2 * (1 - 1 / (q : ℝ)) * P.card ≤ (unitPairs P).card ∧RadialSupport P ∧ 0 ∉ P ∧ (P : Set ℂ) ⊆ twoDisks η := byobtain ⟨P, hc, he, hs, hn, hl⟩ := finite_construction d q hd hq η hηrefine ⟨P, hc, ?_, hs, hn, hl⟩have heR : (d : ℝ) * ((q - 1 : ℕ) : ℝ) * P.card ≤ 2 * q * (unitPairs P).card := byexact_mod_cast herw [Nat.cast_sub (by omega : 1 ≤ q), Nat.cast_one] at heRhave hqR : (0 : ℝ) < q := by exact_mod_cast (by omega : 0 < q)apply (mul_le_mul_iff_right₀ (show (0 : ℝ) < 2 * q by positivity)).mphave hid : (2 * (q : ℝ)) * ((d : ℝ) / 2 * (1 - 1 / (q : ℝ)) * P.card) =(d : ℝ) * ((q : ℝ) - 1) * P.card := byfield_simp [ne_of_gt hqR] <;> ringrw [hid]exact heRendend Proofend Combined_FiniteConstruction/-! ## Source: UnitGraph.lean -/section Combined_UnitGraph/-! Graph and finite-set counting tools for the prescribed-cardinality construction. -/namespace Proofnoncomputable sectionopen Classicalvariable {X Y : Type*} [MetricSpace X] [MetricSpace Y]def unitDistanceGraph (P : Finset X) : SimpleGraph P whereAdj x y := dist (x : X) (y : X) = 1symm := ⟨fun x y h => by simpa only [dist_comm] using h⟩loopless := ⟨fun x => by simp⟩theorem unitDistanceGraph_degree (P : Finset X) (x : P) :(unitDistanceGraph P).degree x = unitDegree P x.val := byhave he : ((unitDistanceGraph P).neighborFinset x).image Subtype.val = unitNeighbors P x.val := byext ysimp only [Finset.mem_image, mem_unitNeighbors]constructor· rintro ⟨z, hz, rfl⟩exact ⟨z.property, ((unitDistanceGraph P).mem_neighborFinset x z).mp hz⟩· rintro ⟨hy, hxy⟩exact ⟨⟨y, hy⟩, ((unitDistanceGraph P).mem_neighborFinset x ⟨y, hy⟩).mpr hxy, rfl⟩have hc := Finset.card_image_of_injective ((unitDistanceGraph P).neighborFinset x)(show Function.Injective (Subtype.val : P → X) from Subtype.val_injective)rw [he] at hcexact hc.symmtheorem unitDistanceGraph_edges (P : Finset X) :((unitDistanceGraph P).edgeFinset).image (Sym2.map (Subtype.val : P → X)) = unitPairs P := byext einduction e using Sym2.inductionOn with| hf x y =>rw [mk_mem_unitPairs]constructor· rintro heobtain ⟨f, hf, hfe⟩ := Finset.mem_image.mp heinduction f using Sym2.inductionOn with| hf a b =>have hab : dist (a : X) (b : X) = 1 := byexact (SimpleGraph.mem_edgeSet (unitDistanceGraph P)).mp (SimpleGraph.mem_edgeFinset.mp hf)have hm : s(a.val, b.val) ∈ unitPairs P :=mk_mem_unitPairs.mpr ⟨a.property, b.property, hab⟩rw [show s(a.val, b.val) = s(x, y) from hfe] at hmexact mk_mem_unitPairs.mp hm· rintro ⟨hx, hy, hxy⟩apply Finset.mem_image.mprrefine ⟨s((⟨x, hx⟩ : P), (⟨y, hy⟩ : P)), ?_, rfl⟩exact SimpleGraph.mem_edgeFinset.mpr ((SimpleGraph.mem_edgeSet (unitDistanceGraph P)).mpr hxy)theorem unitDistanceGraph_card_edges (P : Finset X) :(unitDistanceGraph P).edgeFinset.card = (unitPairs P).card := byrw [← unitDistanceGraph_edges, Finset.card_image_of_injective _(Sym2.map.injective (show Function.Injective (Subtype.val : P → X) from Subtype.val_injective))]theorem sum_unitDegree (P : Finset X) :∑ x ∈ P, unitDegree P x = 2 * (unitPairs P).card := byhave h := (unitDistanceGraph P).sum_degrees_eq_twice_card_edgessimp_rw [unitDistanceGraph_degree] at hrw [unitDistanceGraph_card_edges] at hsimpa only [Finset.univ_eq_attach, Finset.sum_attach] using htheorem exists_degree_le_average (P : Finset X) (hP : P.Nonempty) :∃ x ∈ P, (unitDegree P x : ℝ) * P.card ≤ 2 * (unitPairs P).card := byby_contra hpush Not at hhave hsum : ∑ x ∈ P, (2 * ((unitPairs P).card : ℝ)) <∑ x ∈ P, (unitDegree P x : ℝ) * P.card :=Finset.sum_lt_sum_of_nonempty hP (fun x hx => h x hx)rw [Finset.sum_const, nsmul_eq_mul, ← Finset.sum_mul, ← Nat.cast_sum, sum_unitDegree] at hsumpush_cast at hsumnlinariththeorem unitNeighbors_image_isometry (f : X → Y) (hf : Isometry f) (P : Finset X) (x : X) :unitNeighbors (P.image f) (f x) = (unitNeighbors P x).image f := byunfold unitNeighborsrw [Finset.filter_image]simp only [hf.dist_eq]theorem unitDegree_image_isometry (f : X → Y) (hf : Isometry f) (P : Finset X) (x : X) :unitDegree (P.image f) (f x) = unitDegree P x := byrw [unitDegree, unitNeighbors_image_isometry f hf, Finset.card_image_of_injective _ hf.injective]rfltheorem unitPairs_disjoint {P Q : Finset X} (h : Disjoint P Q) :Disjoint (unitPairs P) (unitPairs Q) := byapply Finset.disjoint_left.mprintro e hp hqinduction e using Sym2.inductionOn with| hf x y => exact Finset.disjoint_left.mp h (mk_mem_unitPairs.mp hp).1 (mk_mem_unitPairs.mp hq).1theorem unitPairs_union_bound {P Q : Finset X} (h : Disjoint P Q) :(unitPairs P).card + (unitPairs Q).card ≤ (unitPairs (P ∪ Q)).card := byrw [← Finset.card_union_of_disjoint (unitPairs_disjoint h)]apply Finset.card_le_cardexact Finset.union_subset (unitPairs_mono Finset.subset_union_left)(unitPairs_mono Finset.subset_union_right)endend Proofend Combined_UnitGraph/-! ## Source: RotatedCopies.lean -/section Combined_RotatedCopies/-! Arbitrarily small disjoint rotations preserving strict support (Lemma 4.2). -/namespace Proofnoncomputable sectionopen Set Filter Classicalopen scoped Topologydef rotate (θ : ℝ) (z : ℂ) : ℂ := z * Complex.exp ((θ : ℂ) * Complex.I)theorem rotate_zero (z : ℂ) : rotate 0 z = z := by simp [rotate]theorem rotate_norm (θ : ℝ) (z : ℂ) : ‖rotate θ z‖ = ‖z‖ := byrw [rotate, norm_mul, Complex.norm_exp_ofReal_mul_I, mul_one]theorem rotate_isometry (θ : ℝ) : Isometry (rotate θ) := byapply Isometry.of_dist_eqintro x ysimp only [rotate, dist_eq_norm, ← sub_mul, norm_mul, Complex.norm_exp_ofReal_mul_I, mul_one]theorem rotate_ne_zero (θ : ℝ) {z : ℂ} (hz : z ≠ 0) : rotate θ z ≠ 0 :=mul_ne_zero hz (Complex.exp_ne_zero _)def rotatedUnion {I : Type*} [Fintype I] (A : I → Finset ℂ) (θ : I → ℝ) : Finset ℂ :=Finset.univ.biUnion (fun i => (A i).image (rotate (θ i)))theorem small_rotations {I : Type*} [Fintype I] (Q : Finset ℂ)(hzero : 0 ∉ Q) (hQ : RadialSupport Q) (O : Set ℂ) (hO : IsOpen O)(hQO : (Q : Set ℂ) ⊆ O) (τ : ℝ) (hτ : 0 < τ) :∃ θ : I → ℝ,(∀ i, |θ i| < τ) ∧Function.Injective (fun a : I × Q => rotate (θ a.1) a.2.val) ∧(∀ a b : I × Q, a ≠ b → support (rotate (θ a.1) a.2.val) (rotate (θ b.1) b.2.val) < 0) ∧(∀ a : I × Q, rotate (θ a.1) a.2.val ∈ O) := bylet rank : I → ℝ := fun i => ((Fintype.equivFin I i).val : ℝ)have hrank : Function.Injective rank := byintro i j happly (Fintype.equivFin I).injectiveapply Fin.extdsimp [rank] at hexact_mod_cast hlet F := fun (ε : ℝ) (a : I × Q) => rotate (ε * rank a.1) a.2.valhave hF : ∀ a, Continuous (fun ε => F ε a) := byintro aunfold F rotatefun_prophave hF0 : ∀ a, F 0 a = a.2.val := fun a => by simp [F, rotate]have hsupport : ∀ a b : I × Q, ∀ᶠ ε in 𝓝 (0 : ℝ), a.2.val ≠ b.2.val →support (F ε a) (F ε b) < 0 := byintro a bby_cases hab : a.2.val = b.2.val· exact Eventually.of_forall (fun _ h => (h hab).elim)have hc : ContinuousAt (fun ε => support (F ε a) (F ε b)) 0 := byhave ha := (hF a).continuousAt (x := 0)have hb := (hF b).continuousAt (x := 0)unfold supportfun_prophave h0 : support (F 0 a) (F 0 b) < 0 := byrw [hF0, hF0]exact hQ _ a.2.property _ b.2.property habexact (hc.eventually_lt continuousAt_const h0).mono (fun _ h _ => h)have hloc : ∀ a : I × Q, ∀ᶠ ε in 𝓝 (0 : ℝ), F ε a ∈ O := byintro aapply (hF a).continuousAt.eventuallyapply hO.mem_nhdschange F 0 a ∈ Orw [hF0]exact hQO a.2.propertyhave hphase : ∀ i j : I, ∀ᶠ ε in 𝓝 (0 : ℝ), |ε * rank i - ε * rank j| < Real.pi := byintro i jhave hc : ContinuousAt (fun ε : ℝ => |ε * rank i - ε * rank j|) 0 := by fun_propexact hc.eventually_lt continuousAt_const (by simpa using Real.pi_pos)have hsmall : ∀ i : I, ∀ᶠ ε in 𝓝 (0 : ℝ), |ε * rank i| < τ := byintro ihave hc : ContinuousAt (fun ε : ℝ => |ε * rank i|) 0 := by fun_propexact hc.eventually_lt continuousAt_const (by simpa using hτ)have hsAll : ∀ᶠ ε in 𝓝 (0 : ℝ), ∀ a b : I × Q, a.2.val ≠ b.2.val →support (F ε a) (F ε b) < 0 := by simpa only [eventually_all] using hsupporthave hlAll : ∀ᶠ ε in 𝓝 (0 : ℝ), ∀ a : I × Q, F ε a ∈ O := bysimpa only [eventually_all] using hlochave hpAll : ∀ᶠ ε in 𝓝 (0 : ℝ), ∀ i j : I, |ε * rank i - ε * rank j| < Real.pi := bysimpa only [eventually_all] using hphasehave htAll : ∀ᶠ ε in 𝓝 (0 : ℝ), ∀ i : I, |ε * rank i| < τ := bysimpa only [eventually_all] using hsmallobtain ⟨ε, ⟨hs, hl, hp, ht⟩, hε⟩ :=(((hsAll.and (hlAll.and (hpAll.and htAll))).filter_mono nhdsWithin_le_nhds).and(self_mem_nhdsWithin : ∀ᶠ ε in 𝓝[>] (0 : ℝ), ε ∈ Ioi 0)).existshave hε : 0 < ε := hεhave hinj : Function.Injective (F ε) := byrintro ⟨i, x⟩ ⟨j, y⟩ heby_cases hxy : x = y· subst yhave hx : (x : ℂ) ≠ 0 := fun h => hzero (h ▸ x.property)have hexp := mul_left_cancel₀ hx hehave hangle := exp_phase_small_injective (hp i j) hexpexact Prod.ext (hrank (mul_left_cancel₀ (ne_of_gt hε) hangle)) rfl· have hn := hs (i, x) (j, y) (fun h => hxy (Subtype.ext h))rw [he] at hnsimpa [support] using hnrefine ⟨fun i => ε * rank i, ht, hinj, ?_, hl⟩intro a b habby_cases hxy : a.2.val = b.2.val· apply support_negative_of_equal_norm (hinj.ne hab)change ‖rotate (ε * rank a.1) a.2.val‖ = ‖rotate (ε * rank b.1) b.2.val‖rw [rotate_norm, rotate_norm, hxy]· exact hs a b hxytheorem small_rotated_copies {I : Type*} [Fintype I] (Q : Finset ℂ)(hzero : 0 ∉ Q) (hQ : RadialSupport Q) (O : Set ℂ) (hO : IsOpen O)(hQO : (Q : Set ℂ) ⊆ O) (A : I → Finset ℂ) (hA : ∀ i, A i ⊆ Q)(τ : ℝ) (hτ : 0 < τ) :∃ θ : I → ℝ,(∀ i, |θ i| < τ) ∧Pairwise (fun i j => Disjoint ((A i).image (rotate (θ i))) ((A j).image (rotate (θ j)))) ∧RadialSupport (rotatedUnion A θ) ∧(rotatedUnion A θ : Set ℂ) ⊆ O ∧ 0 ∉ rotatedUnion A θ := byobtain ⟨θ, ht, hinj, hs, hl⟩ := small_rotations (I := I) Q hzero hQ O hO hQO τ hτrefine ⟨θ, ht, ?_, ?_, ?_, ?_⟩· intro i j hijapply Finset.disjoint_left.mprintro z hi hjobtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hiobtain ⟨y, hy, he⟩ := Finset.mem_image.mp hjhave hh := hinj (a₁ := (j, ⟨y, hA j hy⟩)) (a₂ := (i, ⟨x, hA i hx⟩)) heexact hij (congrArg Prod.fst hh).symm· intro x hx y hy hxyobtain ⟨i, _, hx⟩ := Finset.mem_biUnion.mp hxobtain ⟨j, _, hy⟩ := Finset.mem_biUnion.mp hyobtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hxobtain ⟨b, hb, rfl⟩ := Finset.mem_image.mp hyapply hs (i, ⟨a, hA i ha⟩) (j, ⟨b, hA j hb⟩)exact fun h => hxy (congrArg (fun a : I × Q => rotate (θ a.1) a.2.val) h)· intro x hxobtain ⟨i, _, hx⟩ := Finset.mem_biUnion.mp hxobtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hxexact hl (i, ⟨a, hA i ha⟩)· intro hzobtain ⟨i, _, hz⟩ := Finset.mem_biUnion.mp hzobtain ⟨a, ha, he⟩ := Finset.mem_image.mp hzexact rotate_ne_zero (θ i) (fun h => hzero (h ▸ hA i ha)) heendend Proofend Combined_RotatedCopies/-! ## Source: Gluing.lean -/section Combined_Gluing/-! Counting and minimum-degree bounds for unions of disjoint rotated copies. -/namespace Proofnoncomputable sectionopen Classicaltheorem rotatedUnion_card {I : Type*} [Fintype I] (A : I → Finset ℂ) (θ : I → ℝ)(hd : Pairwise (fun i j => Disjoint ((A i).image (rotate (θ i))) ((A j).image (rotate (θ j))))) :(rotatedUnion A θ).card = ∑ i, (A i).card := byrw [rotatedUnion, Finset.card_biUnion (fun i _ j _ hij => hd hij)]apply Finset.sum_congr rflintro i _exact Finset.card_image_of_injective _ (rotate_isometry (θ i)).injectivetheorem rotatedUnion_edges {I : Type*} [Fintype I] (A : I → Finset ℂ) (θ : I → ℝ)(hd : Pairwise (fun i j => Disjoint ((A i).image (rotate (θ i))) ((A j).image (rotate (θ j))))) :∑ i, (unitPairs (A i)).card ≤ (unitPairs (rotatedUnion A θ)).card := bylet U := fun i => unitPairs ((A i).image (rotate (θ i)))have hdu : ((Finset.univ : Finset I) : Set I).PairwiseDisjoint U :=fun i _ j _ hij => unitPairs_disjoint (hd hij)have hsub : Finset.univ.biUnion U ⊆ unitPairs (rotatedUnion A θ) := byintro e heobtain ⟨i, hi, he⟩ := Finset.mem_biUnion.mp heexact unitPairs_mono (Finset.subset_biUnion_of_mem(fun i => (A i).image (rotate (θ i))) hi) hehave hc := Finset.card_le_card hsubrw [Finset.card_biUnion hdu] at hcsimpa only [U, unitPairs_card_image_isometry _ (rotate_isometry _)] using hctheorem rotatedUnion_degree {I : Type*} [Fintype I] (A : I → Finset ℂ) (θ : I → ℝ)(k : ℕ) (hk : ∀ i, HasUnitMinDegree (A i) k) : HasUnitMinDegree (rotatedUnion A θ) k := byintro x hxobtain ⟨i, hi, hx⟩ := Finset.mem_biUnion.mp hxobtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hxhave hm := unitDegree_mono (Finset.subset_biUnion_of_mem(fun i => (A i).image (rotate (θ i))) hi) (rotate (θ i) a)rw [unitDegree_image_isometry _ (rotate_isometry _)] at hmexact (hk i a ha).trans hmtheorem glue_dense_copies {I : Type*} [Fintype I] (Q : Finset ℂ)(hzero : 0 ∉ Q) (hQ : RadialSupport Q) (η : ℝ)(hloc : (Q : Set ℂ) ⊆ twoDisks η) (A : I → Finset ℂ) (hA : ∀ i, A i ⊆ Q)(k : ℕ) (hk : ∀ i, HasUnitMinDegree (A i) k)(α : ℝ) (hα : ∀ i, α * (A i).card ≤ (unitPairs (A i)).card) :∃ P : Finset ℂ, P.card = ∑ i, (A i).card ∧ RadialSupport P ∧0 ∉ P ∧ (P : Set ℂ) ⊆ twoDisks η ∧ HasUnitMinDegree P k ∧α * P.card ≤ (unitPairs P).card := byobtain ⟨θ, _, hd, hs, hl, hn⟩ := small_rotated_copies Q hzero hQ (twoDisks η)(twoDisks_open η) hloc A hA 1 (by norm_num)refine ⟨rotatedUnion A θ, rotatedUnion_card A θ hd, hs, hn, hl,rotatedUnion_degree A θ k hk, ?_⟩have he : (∑ i, ((unitPairs (A i)).card : ℝ)) ≤ (unitPairs (rotatedUnion A θ)).card := byexact_mod_cast rotatedUnion_edges A θ hdrw [rotatedUnion_card A θ hd, Nat.cast_sum, Finset.mul_sum]exact (Finset.sum_le_sum (fun i _ => hα i)).trans he/-- Every sufficiently large integer is a nonnegative combination of two consecutive sizes. -/theorem consecutive_sizes_representation (s n : ℕ) (hs : 2 ≤ s) (hn : s ^ 2 ≤ n) :∃ a b : ℕ, n = a * s + b * (s - 1) := bylet r := n % (s - 1)let t := n / (s - 1)have hs' : 0 < s - 1 := by omegahave hr : r < s - 1 := Nat.mod_lt n hs'have ht : s ≤ t := (Nat.le_div_iff_mul_le hs').mpr((Nat.mul_le_mul_left s (Nat.sub_le s 1)).trans (by simpa [pow_two] using hn))have hrt : r ≤ t := by omegarefine ⟨r, t - r, ?_⟩have he : r + (s - 1) * t = n := Nat.mod_add_div n (s - 1)have hs1 : s - 1 + 1 = s := by omegacalcn = r + (s - 1) * t := he.symm_ = r + (s - 1) * ((t - r) + r) := by rw [Nat.sub_add_cancel hrt]_ = r * (s - 1 + 1) + (t - r) * (s - 1) := by ring_ = r * s + (t - r) * (s - 1) := by rw [hs1]endend Proofend Combined_Gluing/-! ## Source: PrescribedCardinality.lean -/section Combined_PrescribedCardinality/-! Dense configurations of every sufficiently large prescribed cardinality (Proposition 4.3). -/namespace Proofnoncomputable sectionopen Classicaltheorem erase_low_degree_density (Q : Finset ℂ) (hQ : Q.Nonempty) (k : ℕ)(α : ℝ) (hα : (k : ℝ) < α) (hd : HasUnitMinDegree Q (k + 1))(hc : α * Q.card ≤ (unitPairs Q).card) :∃ v ∈ Q, HasUnitMinDegree (Q.erase v) k ∧((k : ℝ) - 1) * (Q.erase v).card ≤ (unitPairs (Q.erase v)).card := byobtain ⟨v, hv, havg⟩ := exists_degree_le_average Q hQhave hsize : k + 2 ≤ Q.card := byhave hlo := hd v hvhave hhi := unitDegree_lt_card hvomegahave hsizeR : (k : ℝ) + 2 ≤ Q.card := by exact_mod_cast hsizehave hspos : (0 : ℝ) < Q.card := by exact_mod_cast Finset.card_pos.mpr hQhave hs2 : (0 : ℝ) ≤ (Q.card : ℝ) - 2 := by linarith [show (0 : ℝ) ≤ k from Nat.cast_nonneg k]have hcard : ((Q.erase v).card : ℝ) = (Q.card : ℝ) - 1 := byhave hh : ((Q.erase v).card : ℝ) + 1 = Q.card := byexact_mod_cast Finset.card_erase_add_one hvlinarithhave he : ((unitPairs (Q.erase v)).card : ℝ) + unitDegree Q v = (unitPairs Q).card := byexact_mod_cast unitPairs_erase_add_degree hvhave heMul := congrArg (fun x : ℝ => x * (Q.card : ℝ)) hehave hm := mul_le_mul_of_nonneg_right hc hs2have hremaining : α * Q.card * ((Q.card : ℝ) - 2) ≤(unitPairs (Q.erase v)).card * (Q.card : ℝ) := by nlinarithhave hcoeff : ((k : ℝ) - 1) * (Q.erase v).card ≤ α * ((Q.card : ℝ) - 2) := bycalc((k : ℝ) - 1) * (Q.erase v).card =(k : ℝ) * ((Q.card : ℝ) - 2) - ((Q.card : ℝ) - k - 1) := by rw [hcard]; ring_ ≤ (k : ℝ) * ((Q.card : ℝ) - 2) := by linarith_ ≤ α * ((Q.card : ℝ) - 2) := mul_le_mul_of_nonneg_right hα.le hs2refine ⟨v, hv, ?_, ?_⟩· intro x hxhave hdx := hd x (Finset.mem_of_mem_erase hx)have her := unitDegree_erase_le Q x vomega· apply (mul_le_mul_iff_left₀ hspos).mpnlinarith [mul_le_mul_of_nonneg_right hcoeff hspos.le]def thresholdSize (k : ℕ) : ℕ := finiteSize (2 * k + 1) (2 * k + 2)theorem thresholdSize_pos (k : ℕ) : 0 < thresholdSize k := finiteSize_pos (by omega)theorem threshold_configuration (k : ℕ) (hk : 1 ≤ k) (n : ℕ)(hn : thresholdSize k ^ 2 ≤ n) (η : ℝ) (hη : 0 < η) :∃ P : Finset ℂ, P.card = n ∧ RadialSupport P ∧ 0 ∉ P ∧(P : Set ℂ) ⊆ twoDisks η ∧ HasUnitMinDegree P k ∧((k : ℝ) - 1) * n ≤ (unitPairs P).card := bylet α : ℝ := (k : ℝ) + 1 / (4 * (k : ℝ) + 4)have hα : (k : ℝ) < α := byhave hh : (0 : ℝ) < 1 / (4 * (k : ℝ) + 4) := by positivitydsimp [α]linarithobtain ⟨P, hPcard, hPcount, hP, hzero, hloc⟩ :=finite_construction_real (2 * k + 1) (2 * k + 2) (by omega) (by omega) η hηhave hratio : ((2 * k + 1 : ℕ) : ℝ) / 2 * (1 - 1 / ((2 * k + 2 : ℕ) : ℝ)) = α := bydsimp [α]push_castfield_simpringrw [hratio] at hPcounthave hPne : P.Nonempty := Finset.card_pos.mp (by rw [hPcard]; exact finiteSize_pos (by omega))obtain ⟨Q, hQP, hQ, hdegree, hcount⟩ := dense_subset_min_degree α k hα P hPne hPcountobtain ⟨v, hv, hminusDegree, hminusCount⟩ := erase_low_degree_density Q hQ k α hα hdegree hcounthave hs : 2 ≤ Q.card := byhave h1 := hdegree v hvhave h2 := unitDegree_lt_card hvomegahave hQM : Q.card ≤ thresholdSize k := byexact (Finset.card_le_card hQP).trans_eq hPcardhave hnQ : Q.card ^ 2 ≤ n := (Nat.pow_le_pow_left hQM 2).trans hnobtain ⟨a, b, hab⟩ := consecutive_sizes_representation Q.card n hs hnQlet A : Fin a ⊕ Fin b → Finset ℂ := Sum.elim (fun _ => Q) (fun _ => Q.erase v)have hA : ∀ i, A i ⊆ Q := byintro icases i· exact Finset.Subset.refl Q· exact Finset.erase_subset _ _have hdA : ∀ i, HasUnitMinDegree (A i) k := byintro icases i· exact fun x hx => (Nat.le_succ k).trans (hdegree x hx)· exact hminusDegreehave hcA : ∀ i, ((k : ℝ) - 1) * (A i).card ≤ (unitPairs (A i)).card := byintro icases i· exact (mul_le_mul_of_nonneg_right (by linarith : (k : ℝ) - 1 ≤ α)(Nat.cast_nonneg Q.card)).trans hcount· exact hminusCountobtain ⟨R, hRc, hRs, hRz, hRl, hRd, hRe⟩ := glue_dense_copies Q(fun h => hzero (hQP h)) (hP.mono hQP) η (fun _ hx => hloc (hQP hx)) A hA k hdA((k : ℝ) - 1) hcAhave hsum : ∑ i, (A i).card = n := bysimpa [A, Fintype.sum_sum_type, Finset.card_erase_of_mem hv] using hab.symmrefine ⟨R, hRc.trans hsum, hRs, hRz, hRl, hRd, ?_⟩rwa [hRc, hsum] at hReendend Proofend Combined_PrescribedCardinality/-! ## Source: CardinalEstimates.lean -/section Combined_CardinalEstimates/-! Explicit cardinality estimates used to invert the construction thresholds. -/namespace Proofnoncomputable sectiondef logTwo (x : ℝ) : ℝ := Real.logb 2 xdef doubleLog (x : ℝ) : ℝ := logTwo (logTwo x)def tripleLog (x : ℝ) : ℝ := logTwo (doubleLog x)theorem logTwo_mono {x y : ℝ} (hx : 0 < x) (hxy : x ≤ y) : logTwo x ≤ logTwo y :=Real.logb_le_logb_of_le (by norm_num) hx hxytheorem logTwo_le_logTwo {x y : ℝ} (hx : 0 < x) (hy : 0 < y) :logTwo x ≤ logTwo y ↔ x ≤ y := Real.logb_le_logb (by norm_num) hx hytheorem logTwo_pos {x : ℝ} (hx : 1 < x) : 0 < logTwo x := Real.logb_pos (by norm_num) hx@[simp] theorem logTwo_two : logTwo 2 = 1 := Real.logb_self_eq_one (by norm_num)@[simp] theorem logTwo_four : logTwo 4 = 2 := byunfold logTworw [show (4 : ℝ) = 2 ^ 2 by norm_num, Real.logb_pow, Real.logb_self_eq_one (by norm_num)]norm_numtheorem middleVertexCount_le_four_pow (d : ℕ) : middleVertexCount d ≤ 4 ^ d := byhave h := Nat.choose_le_two_pow (2 * d) dsimpa only [middleVertexCount, pow_mul, show (2 : ℕ) ^ 2 = 4 from rfl] using htheorem middleEdgeCount_le (d : ℕ) : middleEdgeCount d ≤ d * 4 ^ d := byapply Nat.mul_le_mul_leftcalc(2 * d - 1).choose d ≤ 2 ^ (2 * d - 1) := Nat.choose_le_two_pow _ __ ≤ 2 ^ (2 * d) := Nat.pow_le_pow_right (by norm_num) (Nat.sub_le _ _)_ = 4 ^ d := by rw [pow_mul]; rfltheorem finiteSize_square_bound (d : ℕ) :finiteSize d (d + 1) ^ 2 ≤ 2 ^ (4 * (d + 1) ^ 2 * 4 ^ d) := byhave hq : d + 1 ≤ 2 ^ (d + 1) := Nat.lt_two_pow_self.lehave hN : finiteSize d (d + 1) ≤ 2 ^ (2 * d + (d + 1) * middleEdgeCount d) := bycalcfiniteSize d (d + 1) ≤ 4 ^ d * (2 ^ (d + 1)) ^ middleEdgeCount d :=Nat.mul_le_mul (middleVertexCount_le_four_pow d) (Nat.pow_le_pow_left hq _)_ = 2 ^ (2 * d + (d + 1) * middleEdgeCount d) := byrw [show (4 : ℕ) ^ d = 2 ^ (2 * d) by rw [pow_mul]; rfl, ← pow_mul, ← pow_add]have hR : 1 ≤ 4 ^ d := Nat.one_le_pow d 4 (by norm_num)have hE : 2 * (2 * d + (d + 1) * middleEdgeCount d) ≤ 4 * (d + 1) ^ 2 * 4 ^ d := bycalc2 * (2 * d + (d + 1) * middleEdgeCount d) ≤2 * (2 * d + (d + 1) * (d * 4 ^ d)) := by gcongr; exact middleEdgeCount_le d_ ≤ 2 * ((2 * d) * 4 ^ d + (d + 1) * (d * 4 ^ d)) := byapply Nat.mul_le_mul_leftapply Nat.add_le_add_rightsimpa only [mul_one] using Nat.mul_le_mul_left (2 * d) hR_ = (2 * (2 * d + (d + 1) * d)) * 4 ^ d := by ring_ ≤ (4 * (d + 1) ^ 2) * 4 ^ d := Nat.mul_le_mul_right _ (by nlinarith)calcfiniteSize d (d + 1) ^ 2 ≤ (2 ^ (2 * d + (d + 1) * middleEdgeCount d)) ^ 2 :=Nat.pow_le_pow_left hN __ = 2 ^ (2 * (2 * d + (d + 1) * middleEdgeCount d)) := byrw [← pow_mul, Nat.mul_comm (2 * d + (d + 1) * middleEdgeCount d) 2]_ ≤ _ := Nat.pow_le_pow_right (by norm_num) hEtheorem finiteSize_ge_two {d q : ℕ} (hd : 1 ≤ d) (hq : 1 ≤ q) : 2 ≤ finiteSize d q := byhave hv : 2 ≤ middleVertexCount d := byrw [middleVertexCount_eq_twice hd]have h := Nat.choose_pos (show d ≤ 2 * d - 1 by omega)omegahave hp : 1 ≤ q ^ middleEdgeCount d := Nat.one_le_pow _ _ hqexact hv.trans (by simpa [finiteSize] using Nat.mul_le_mul_left (middleVertexCount d) hp)theorem finiteSize_doubleLog_bound (d : ℕ) (hd : 1 ≤ d) :doubleLog ((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ) ≤2 * (d : ℝ) + 2 * logTwo ((d : ℝ) + 1) + 2 := bylet E := 4 * (d + 1) ^ 2 * 4 ^ dhave hsize := finiteSize_ge_two hd (show 1 ≤ d + 1 by omega)have hN : (1 : ℝ) < ((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ) := byexact_mod_cast (by nlinarith : 1 < finiteSize d (d + 1) ^ 2)have hbound : (((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ)) ≤ (2 : ℝ) ^ E := byexact_mod_cast finiteSize_square_bound dhave hlog : logTwo ((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ) ≤ (E : ℝ) := byhave h := logTwo_mono (by linarith : (0 : ℝ) < ((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ)) hboundsimpa only [logTwo, Real.logb_pow, Real.logb_self_eq_one (by norm_num : (1 : ℝ) < 2), mul_one] using hhave hloglog := logTwo_mono (logTwo_pos hN) hloghave hE : logTwo (E : ℝ) = 2 * (d : ℝ) + 2 * logTwo ((d : ℝ) + 1) + 2 := bysimp only [E, Nat.cast_mul, Nat.cast_pow, Nat.cast_add, Nat.cast_one, Nat.cast_ofNat, logTwo]rw [Real.logb_mul (by positivity) (by positivity),Real.logb_mul (by positivity) (by positivity), Real.logb_pow, Real.logb_pow]change logTwo 4 + 2 * logTwo ((d : ℝ) + 1) + (d : ℝ) * logTwo 4 = _rw [logTwo_four]change 2 + 2 * logTwo ((d : ℝ) + 1) + (d : ℝ) * 2 =2 * (d : ℝ) + 2 * logTwo ((d : ℝ) + 1) + 2ringexact hloglog.trans_eq hEendend Proofend Combined_CardinalEstimates/-! ## Source: AnalyticThresholds.lean -/section Combined_AnalyticThresholds/-! Inversion of the size thresholds with an explicit absolute error constant. -/namespace Proofnoncomputable sectionopen Filtertheorem tendsto_logTwo_atTop : Tendsto logTwo atTop atTop :=Real.tendsto_logb_atTop (by norm_num)theorem tendsto_doubleLog_nat : Tendsto (fun n : ℕ => doubleLog (n : ℝ)) atTop atTop :=(tendsto_logTwo_atTop.comp tendsto_logTwo_atTop).comp tendsto_natCast_atTop_atToptheorem logTwo_sublinear (c : ℝ) (hc : 0 < c) :∀ᶠ x : ℝ in atTop, logTwo x ≤ c * x := byhave hl : 0 < Real.log 2 := Real.log_pos (by norm_num)have h := Real.isLittleO_log_id_atTop.def (mul_pos hc hl)filter_upwards [h, eventually_ge_atTop (0 : ℝ)] with x hx hx0change ‖Real.log x‖ ≤ c * Real.log 2 * ‖x‖ at hxrw [Real.norm_eq_abs, Real.norm_eq_abs, abs_of_nonneg hx0] at hxchange Real.log x / Real.log 2 ≤ c * xapply (div_le_iff₀ hl).mprnlinarith [le_abs_self (Real.log x)]theorem threshold_doubleLog_bound (k : ℕ) :doubleLog ((thresholdSize k ^ 2 : ℕ) : ℝ) ≤4 * (k : ℝ) + 2 * logTwo ((k : ℝ) + 1) + 6 := byhave h := finiteSize_doubleLog_bound (2 * k + 1) (by omega)have he : logTwo ((2 * k + 1 : ℕ) + 1 : ℝ) = 1 + logTwo ((k : ℝ) + 1) := bypush_castrw [show 2 * (k : ℝ) + 1 + 1 = 2 * ((k : ℝ) + 1) by ring]change Real.logb 2 (2 * ((k : ℝ) + 1)) = _rw [Real.logb_mul (by norm_num) (by positivity)]change logTwo 2 + logTwo ((k : ℝ) + 1) = _rw [logTwo_two]change doubleLog ((thresholdSize k ^ 2 : ℕ) : ℝ) ≤ _ at hrw [he] at hpush_cast at h ⊢linariththeorem doubleLog_le_iff {x y : ℝ} (hx : 1 < x) (hy : 1 < y) :doubleLog x ≤ doubleLog y ↔ x ≤ y := byunfold doubleLogrw [logTwo_le_logTwo (logTwo_pos hx) (logTwo_pos hy),logTwo_le_logTwo (by linarith) (by linarith)]theorem logarithmic_index : ∃ n₀ : ℕ, ∀ n ≥ n₀, ∃ k : ℕ,1 ≤ k ∧ thresholdSize k ^ 2 ≤ n ∧doubleLog (n : ℝ) / 4 - 7 * tripleLog (n : ℝ) ≤ (k : ℝ) - 1 := byhave hreal : ∀ᶠ L : ℝ in atTop,40 ≤ L ∧ 1 ≤ logTwo L ∧ logTwo L ≤ L / 8 := byfilter_upwards [eventually_ge_atTop (40 : ℝ),tendsto_logTwo_atTop.eventually (eventually_ge_atTop (1 : ℝ)),logTwo_sublinear (1 / 8) (by norm_num)] with L hL hlog hsmallexact ⟨hL, hlog, by linarith⟩have hnat := tendsto_doubleLog_nat.eventually hrealhave hall : ∀ᶠ n : ℕ in atTop, 2 ≤ n ∧40 ≤ doubleLog (n : ℝ) ∧ 1 ≤ logTwo (doubleLog (n : ℝ)) ∧logTwo (doubleLog (n : ℝ)) ≤ doubleLog (n : ℝ) / 8 :=(eventually_ge_atTop 2).and hnatobtain ⟨n₀, hn₀⟩ := eventually_atTop.mp hallrefine ⟨n₀, ?_⟩intro n hnobtain ⟨hn2, hL, hlog, hsmall⟩ := hn₀ n hnlet L := doubleLog (n : ℝ)let x := L / 4 - logTwo L - 4let k := Nat.floor xhave hx : 1 ≤ x := by dsimp [x, L]; linarithhave hk : 1 ≤ k := Nat.le_floor (by simpa using hx)have hklo : x < (k : ℝ) + 1 := Nat.lt_floor_add_one xhave hkhi : (k : ℝ) ≤ x := Nat.floor_le (by linarith)have hkl : (k : ℝ) + 1 ≤ L := by dsimp [x] at hkhi; dsimp [L]; linarithhave hlogk : logTwo ((k : ℝ) + 1) ≤ logTwo L := logTwo_mono (by positivity) hklhave hT : doubleLog ((thresholdSize k ^ 2 : ℕ) : ℝ) ≤ L := byhave ht := threshold_doubleLog_bound kdsimp [x] at hkhidsimp [L] at *linarithhave hs : 2 ≤ thresholdSize k := finiteSize_ge_two (by omega) (by omega)have hsR : (1 : ℝ) < ((thresholdSize k ^ 2 : ℕ) : ℝ) := byexact_mod_cast (by nlinarith : 1 < thresholdSize k ^ 2)have hnR : (1 : ℝ) < n := by exact_mod_cast (by omega : 1 < n)have hthreshold : thresholdSize k ^ 2 ≤ n := byexact_mod_cast (doubleLog_le_iff hsR hnR).mp hTrefine ⟨k, hk, hthreshold, ?_⟩change L / 4 - 7 * logTwo L ≤ (k : ℝ) - 1dsimp [x] at hklodsimp [L] at *linarithendend Proofend Combined_AnalyticThresholds/-! ## Source: PlaneGeometry.lean -/section Combined_PlaneGeometry/-! Literal Euclidean-plane statements, and bipartiteness of the full unit-distance graph. -/namespace Proofnoncomputable sectionopen Classical EuclideanGeometryopen scoped EuclideanGeometrydef planeLowerCenter : ℝ² := complexToPlane lowerCenterdef planeUpperCenter : ℝ² := complexToPlane upperCenterdef planeTwoDisks (η : ℝ) : Set ℝ² :=Metric.ball planeLowerCenter η ∪ Metric.ball planeUpperCenter η@[simp] theorem planeLowerCenter_first : planeLowerCenter 0 = 0 := rfl@[simp] theorem planeLowerCenter_second : planeLowerCenter 1 = -1 / 2 := rfl@[simp] theorem planeUpperCenter_first : planeUpperCenter 0 = 0 := rfl@[simp] theorem planeUpperCenter_second : planeUpperCenter 1 = 1 / 2 := rfl@[simp] theorem complexToPlane_second (z : ℂ) : complexToPlane z 1 = z.im := rfldef PlaneRadialSupport (P : Finset ℝ²) : Prop :=∀ x ∈ P, ∀ y ∈ P, x ≠ y → inner ℝ x (y - x) < 0def minimumUnitDegree {X : Type*} [MetricSpace X] (P : Finset X) : ℕ :=(unitDistanceGraph P).minDegreetheorem le_minimumUnitDegree {X : Type*} [MetricSpace X] (P : Finset X)(hP : P.Nonempty) (k : ℕ) (hk : HasUnitMinDegree P k) : k ≤ minimumUnitDegree P := byletI : Nonempty P := ⟨⟨hP.choose, hP.choose_spec⟩⟩apply SimpleGraph.le_minDegree_of_forall_le_degreeintro xrw [unitDistanceGraph_degree]exact hk x x.propertytheorem radialSupport_image {P : Finset ℂ} (hP : RadialSupport P) :PlaneRadialSupport (P.image complexToPlane) := byintro x hx y hy hxyobtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hxobtain ⟨b, hb, rfl⟩ := Finset.mem_image.mp hyrw [← map_sub, complexToPlane.inner_map_map, ← support_eq_inner]exact hP a ha b hb (fun h => hxy (congrArg complexToPlane h))theorem twoDisks_image {P : Finset ℂ} {η : ℝ} (hP : (P : Set ℂ) ⊆ twoDisks η) :((P.image complexToPlane : Finset ℝ²) : Set ℝ²) ⊆ planeTwoDisks η := byintro x hxobtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hxhave h := hP hasimpa only [twoDisks, planeTwoDisks, planeLowerCenter, planeUpperCenter,Set.mem_union, Metric.mem_ball, complexToPlane.isometry.dist_eq] using htheorem unitMinDegree_image {P : Finset ℂ} {k : ℕ} (hP : HasUnitMinDegree P k) :HasUnitMinDegree (P.image complexToPlane) k := byintro x hxobtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hxhave he : (unitNeighbors P a).image complexToPlane ⊆unitNeighbors (P.image complexToPlane) (complexToPlane a) := byintro z hzobtain ⟨b, hb, rfl⟩ := Finset.mem_image.mp hzobtain ⟨hbP, hbd⟩ := mem_unitNeighbors.mp hbexact mem_unitNeighbors.mpr ⟨Finset.mem_image_of_mem _ hbP,(complexToPlane.isometry.dist_eq a b).trans hbd⟩have hc := Finset.card_le_card herw [Finset.card_image_of_injective _ complexToPlane.injective] at hcexact (hP a ha).trans hctheorem im_neg_of_lower_ball {z : ℂ} {η : ℝ} (hη : η < 1 / 2)(hz : z ∈ Metric.ball lowerCenter η) : z.im < 0 := byhave hnorm : ‖z - lowerCenter‖ < η := by simpa only [Metric.mem_ball, dist_eq_norm] using hzhave hi := Complex.im_le_norm (z - lowerCenter)simp only [Complex.sub_im, lowerCenter] at hi hnormlinariththeorem im_pos_of_upper_ball {z : ℂ} {η : ℝ} (hη : η < 1 / 2)(hz : z ∈ Metric.ball upperCenter η) : 0 < z.im := byhave hnorm : ‖z - upperCenter‖ < η := by simpa only [Metric.mem_ball, dist_eq_norm] using hzhave hi := (abs_le.mp (Complex.abs_im_le_norm (z - upperCenter))).1simp only [Complex.sub_im, upperCenter] at hi hnormlinariththeorem second_neg_of_lower_ball {x : ℝ²} {η : ℝ} (hη : η < 1 / 2)(hx : x ∈ Metric.ball planeLowerCenter η) : x 1 < 0 := byobtain ⟨z, rfl⟩ := complexToPlane.surjective xapply im_neg_of_lower_ball hηsimpa only [planeLowerCenter, Metric.mem_ball, complexToPlane.isometry.dist_eq] using hxtheorem second_pos_of_upper_ball {x : ℝ²} {η : ℝ} (hη : η < 1 / 2)(hx : x ∈ Metric.ball planeUpperCenter η) : 0 < x 1 := byobtain ⟨z, rfl⟩ := complexToPlane.surjective xapply im_pos_of_upper_ball hηsimpa only [planeUpperCenter, Metric.mem_ball, complexToPlane.isometry.dist_eq] using hxtheorem no_unit_pair_in_ball {X : Type*} [MetricSpace X] {x y c : X} {η : ℝ}(hη : η < 1 / 2) (hx : x ∈ Metric.ball c η) (hy : y ∈ Metric.ball c η) :dist x y ≠ 1 := byhave ht := dist_triangle x c yhave hx' := Metric.mem_ball.mp hxhave hy' := Metric.mem_ball.mp hyrw [dist_comm c y] at htlinarithdef HorizontalBipartition (P : Finset ℝ²) : Prop :=(unitDistanceGraph P).IsBipartiteWith {x | x.val 1 < 0} {x | 0 < x.val 1} ∧∀ x ∈ P, x 1 < 0 ∨ 0 < x 1theorem twoDisks_horizontalBipartition {P : Finset ℝ²} {η : ℝ} (hη : η < 1 / 2)(hP : (P : Set ℝ²) ⊆ planeTwoDisks η) : HorizontalBipartition P := byhave hc : ∀ x ∈ P, x 1 < 0 ∨ 0 < x 1 := byintro x hxrcases hP hx with h | h· exact Or.inl (second_neg_of_lower_ball hη h)· exact Or.inr (second_pos_of_upper_ball hη h)refine ⟨⟨?_, ?_⟩, hc⟩· apply Set.disjoint_left.mprintro x hx hychange x.val 1 < 0 at hxchange 0 < x.val 1 at hyexact lt_asymm hx hy· intro x y hxychange dist x.val y.val = 1 at hxyrcases hP x.property with hx | hx <;> rcases hP y.property with hy | hy· exact False.elim (no_unit_pair_in_ball hη hx hy hxy)· exact Or.inl ⟨second_neg_of_lower_ball hη hx, second_pos_of_upper_ball hη hy⟩· exact Or.inr ⟨second_pos_of_upper_ball hη hx, second_neg_of_lower_ball hη hy⟩· exact False.elim (no_unit_pair_in_ball hη hx hy hxy)theorem HorizontalBipartition.isBipartite {P : Finset ℝ²} (hP : HorizontalBipartition P) :(unitDistanceGraph P).IsBipartite := hP.1.isBipartiteendend Proofend Combined_PlaneGeometry/-! ## Source: MainTheorem.lean -/section Combined_MainTheorem/-! The quantitative theorem in the literal Euclidean plane. -/namespace Proofnoncomputable sectionopen Classical EuclideanGeometryopen scoped EuclideanGeometry/-- The finite construction, with the exact size and density in Theorem 1.3. -/theorem finite_construction_plane (d q : ℕ) (hd : 2 ≤ d) (hq : 2 ≤ q)(η : ℝ) (hη : 0 < η) : ∃ P : Finset ℝ²,P.card = finiteSize d q ∧(d : ℝ) / 2 * (1 - 1 / (q : ℝ)) * P.card ≤ unitDistNum P ∧ConvexIndep P ∧ PlaneRadialSupport P ∧ 0 ∉ P ∧(P : Set ℝ²) ⊆ planeTwoDisks η := byobtain ⟨Q, hc, he, hs, hz, hl⟩ := finite_construction_real d q hd hq η hηhave hcard : (Q.image complexToPlane).card = Q.card :=Finset.card_image_of_injective _ complexToPlane.injectivehave hedge : unitDistNum (Q.image complexToPlane) = (unitPairs Q).card := byrw [unitDistNum_eq_card_unitPairs, unitPairs_card_image_isometry _ complexToPlane.isometry]refine ⟨Q.image complexToPlane, hcard.trans hc, ?_,convexIndep_image_complexToPlane Q hs.convexIndependent, radialSupport_image hs, ?_,twoDisks_image hl⟩· rwa [hcard, hedge]· intro hhobtain ⟨a, ha, he⟩ := Finset.mem_image.mp hhhave ha0 := complexToPlane.injective (he.trans (map_zero complexToPlane).symm)exact hz (ha0 ▸ ha)/-- Proposition 4.3, including strict support and arbitrarily small prescribed disks. -/theorem threshold_configuration_plane (k : ℕ) (hk : 1 ≤ k) (n : ℕ)(hn : thresholdSize k ^ 2 ≤ n) (η : ℝ) (hη : 0 < η) :∃ P : Finset ℝ², P.card = n ∧ ConvexIndep P ∧ PlaneRadialSupport P ∧0 ∉ P ∧ (P : Set ℝ²) ⊆ planeTwoDisks η ∧ HasUnitMinDegree P k ∧((k : ℝ) - 1) * n ≤ unitDistNum P := byobtain ⟨Q, hc, hs, hz, hl, hd, he⟩ := threshold_configuration k hk n hn η hηhave hcard : (Q.image complexToPlane).card = Q.card :=Finset.card_image_of_injective _ complexToPlane.injectivehave hedge : unitDistNum (Q.image complexToPlane) = (unitPairs Q).card := byrw [unitDistNum_eq_card_unitPairs, unitPairs_card_image_isometry _ complexToPlane.isometry]refine ⟨Q.image complexToPlane, hcard.trans hc,convexIndep_image_complexToPlane Q hs.convexIndependent, radialSupport_image hs, ?_,twoDisks_image hl, unitMinDegree_image hd, ?_⟩· intro hhobtain ⟨a, ha, he⟩ := Finset.mem_image.mp hhhave ha0 := complexToPlane.injective (he.trans (map_zero complexToPlane).symm)exact hz (ha0 ▸ ha)· rwa [hedge]/-- Theorem 1.1, with the explicit absolute choice C = 7. Both the minimum degreeand the number of unordered unit-distance pairs have the leading coefficient 1/4. -/theorem main_quantitative : ∃ n₀ : ℕ, ∀ n ≥ n₀, ∀ η : ℝ, 0 < η → η < 1 / 2 →∃ P : Finset ℝ², P.Nonempty ∧ P.card = n ∧ ConvexIndep P ∧PlaneRadialSupport P ∧ 0 ∉ P ∧ (P : Set ℝ²) ⊆ planeTwoDisks η ∧(unitDistanceGraph P).IsBipartite ∧ HorizontalBipartition P ∧doubleLog (n : ℝ) / 4 - 7 * tripleLog (n : ℝ) ≤min (minimumUnitDegree P : ℝ) ((unitDistNum P : ℝ) / n) := byobtain ⟨n₀, hn₀⟩ := logarithmic_indexrefine ⟨n₀, ?_⟩intro n hn η hη hηhalfobtain ⟨k, hk, ht, hbound⟩ := hn₀ n hnobtain ⟨P, hc, hconv, hs, hz, hl, hd, he⟩ :=threshold_configuration_plane k hk n ht η hηhave hnpos : 0 < n := (pow_pos (thresholdSize_pos k) 2).trans_le hthave hP : P.Nonempty := Finset.card_pos.mp (by rwa [hc])have hdeg : (k : ℝ) ≤ minimumUnitDegree P := byexact_mod_cast le_minimumUnitDegree P hP k hdhave hdiv : (k : ℝ) - 1 ≤ (unitDistNum P : ℝ) / n :=(le_div_iff₀ (by exact_mod_cast hnpos)).mpr hehave hb := twoDisks_horizontalBipartition hηhalf hlexact ⟨P, hP, hc, hconv, hs, hz, hl, hb.isBipartite, hb,le_min (by linarith) (hbound.trans hdiv)⟩/-- The exact constant-quantified form of Theorem 1.1. -/theorem main_theorem : ∃ C : ℝ, 0 < C ∧ ∃ n₀ : ℕ,∀ n ≥ n₀, ∀ η : ℝ, 0 < η → η < 1 / 2 →∃ P : Finset ℝ², P.Nonempty ∧ P.card = n ∧ ConvexIndep P ∧(P : Set ℝ²) ⊆ planeTwoDisks η ∧ (unitDistanceGraph P).IsBipartite ∧HorizontalBipartition P ∧doubleLog (n : ℝ) / 4 - C * tripleLog (n : ℝ) ≤min (minimumUnitDegree P : ℝ) ((unitDistNum P : ℝ) / n) := byobtain ⟨n₀, hn₀⟩ := main_quantitativerefine ⟨7, by norm_num, n₀, ?_⟩intro n hn η hη hηhalfobtain ⟨P, hP, hc, hv, _, _, hl, hb, hh, he⟩ := hn₀ n hn η hη hηhalfexact ⟨P, hP, hc, hv, hl, hb, hh, he⟩endend Proofend Combined_MainTheorem/-! ## Source: GrowthEstimates.lean -/section Combined_GrowthEstimates/-! Two-sided growth estimates, including the double-exponential size bound. -/namespace Proofnoncomputable sectionopen Filtertheorem finiteSize_doubleLog_lower (d : ℕ) (hd : 2 ≤ d) :2 * (d : ℝ) - logTwo (2 * (d : ℝ) + 1) ≤doubleLog (finiteSize d (d + 1) : ℝ) := byhave hv := middleVertexCount_pos dhave hvm : middleVertexCount d ≤ middleEdgeCount d := byhave ht := middleEdgeCount_twice (show 1 ≤ d by omega)nlinarithhave hpow : 2 ^ middleEdgeCount d ≤ finiteSize d (d + 1) := bycalc2 ^ middleEdgeCount d ≤ (d + 1) ^ middleEdgeCount d := Nat.pow_le_pow_left (by omega) __ ≤ middleVertexCount d * (d + 1) ^ middleEdgeCount d := bysimpa only [one_mul] using Nat.mul_le_mul_right ((d + 1) ^ middleEdgeCount d) (show 1 ≤ middleVertexCount d by omega)have hpowR : (2 : ℝ) ^ middleEdgeCount d ≤ (finiteSize d (d + 1) : ℝ) := byexact_mod_cast hpowhave hm : (middleEdgeCount d : ℝ) ≤ logTwo (finiteSize d (d + 1) : ℝ) := byhave h := logTwo_mono (by positivity : (0 : ℝ) < 2 ^ middleEdgeCount d) hpowRsimpa only [logTwo, Real.logb_pow, Real.logb_self_eq_one (by norm_num : (1 : ℝ) < 2), mul_one] using hhave hvlog : (middleVertexCount d : ℝ) ≤ logTwo (finiteSize d (d + 1) : ℝ) :=(show (middleVertexCount d : ℝ) ≤ middleEdgeCount d by exact_mod_cast hvm).trans hmhave hlower := logTwo_mono (by exact_mod_cast hv) hvloghave hbin : (4 : ℝ) ^ d ≤ (2 * (d : ℝ) + 1) * (middleVertexCount d : ℝ) := byexact_mod_cast Nat.four_pow_le_two_mul_add_one_mul_central_binom dhave hb := logTwo_mono (by positivity : (0 : ℝ) < 4 ^ d) hbinchange Real.logb 2 ((4 : ℝ) ^ d) ≤ Real.logb 2 ((2 * (d : ℝ) + 1) * ↑(middleVertexCount d)) at hbrw [Real.logb_pow, Real.logb_mul (by positivity) (by exact_mod_cast hv.ne')] at hbchange (d : ℝ) * logTwo 4 ≤ logTwo (2 * (d : ℝ) + 1) + logTwo (middleVertexCount d : ℝ) at hbrw [logTwo_four] at hbchange logTwo (middleVertexCount d : ℝ) ≤ doubleLog (finiteSize d (d + 1) : ℝ) at hlowerlinariththeorem finiteSize_doubleLog_upper (d : ℕ) (hd : 1 ≤ d) :doubleLog (finiteSize d (d + 1) : ℝ) ≤2 * (d : ℝ) + 2 * logTwo ((d : ℝ) + 1) + 2 := byhave hs := finiteSize_ge_two hd (show 1 ≤ d + 1 by omega)have hsR : (1 : ℝ) < (finiteSize d (d + 1) : ℝ) := by exact_mod_cast (by omega : 1 < finiteSize d (d + 1))have hs2R : (1 : ℝ) < ((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ) := by exact_mod_cast (by nlinarith : 1 < finiteSize d (d + 1) ^ 2)have hle : (finiteSize d (d + 1) : ℝ) ≤ ((finiteSize d (d + 1) ^ 2 : ℕ) : ℝ) := byexact_mod_cast (by nlinarith : finiteSize d (d + 1) ≤ finiteSize d (d + 1) ^ 2)exact ((doubleLog_le_iff hsR hs2R).mpr hle).trans (finiteSize_doubleLog_bound d hd)theorem threshold_doubleLog_lower (k : ℕ) (hk : 1 ≤ k) :4 * (k : ℝ) - logTwo ((k : ℝ) + 1) ≤doubleLog ((thresholdSize k ^ 2 : ℕ) : ℝ) := byhave h := finiteSize_doubleLog_lower (2 * k + 1) (by omega)have hm : logTwo (2 * ((2 * k + 1 : ℕ) : ℝ) + 1) ≤ 2 + logTwo ((k : ℝ) + 1) := byhave he : logTwo (4 * ((k : ℝ) + 1)) = 2 + logTwo ((k : ℝ) + 1) := byunfold logTworw [Real.logb_mul (by norm_num) (by positivity)]change logTwo 4 + logTwo ((k : ℝ) + 1) = _rw [logTwo_four]rflrw [← he]apply logTwo_mono (by positivity)push_castlinarithhave hs := finiteSize_ge_two (show 1 ≤ 2 * k + 1 by omega) (show 1 ≤ 2 * k + 2 by omega)change 2 ≤ thresholdSize k at hshave hr : (1 : ℝ) < (thresholdSize k : ℝ) := by exact_mod_cast (by omega : 1 < thresholdSize k)have hr2 : (1 : ℝ) < ((thresholdSize k ^ 2 : ℕ) : ℝ) := by exact_mod_cast (by nlinarith : 1 < thresholdSize k ^ 2)have hle : (thresholdSize k : ℝ) ≤ ((thresholdSize k ^ 2 : ℕ) : ℝ) := byexact_mod_cast (by nlinarith : thresholdSize k ≤ thresholdSize k ^ 2)have ht := (doubleLog_le_iff hr hr2).mpr hlechange 2 * ((2 * k + 1 : ℕ) : ℝ) - _ ≤ doubleLog (thresholdSize k : ℝ) at hpush_cast at h hmlinariththeorem threshold_growth :(fun k : ℕ => doubleLog ((thresholdSize k ^ 2 : ℕ) : ℝ) - 4 * (k : ℝ))=O[atTop] (fun k => logTwo ((k : ℝ) + 1)) := byapply Asymptotics.isBigO_iff.mprrefine ⟨8, ?_⟩filter_upwards [eventually_ge_atTop (1 : ℕ)] with k hkhave hl := threshold_doubleLog_lower k hkhave hu := threshold_doubleLog_bound khave hlog : 1 ≤ logTwo ((k : ℝ) + 1) := bycalc1 = logTwo 2 := logTwo_two.symm_ ≤ logTwo ((k : ℝ) + 1) := logTwo_mono (by norm_num) (by exact_mod_cast (by omega : 2 ≤ k + 1))rw [Real.norm_eq_abs, Real.norm_eq_abs, abs_of_nonneg (by linarith : 0 ≤ logTwo ((k : ℝ) + 1))]exact abs_le.mpr ⟨by linarith, by linarith⟩def degreeSizeBound (k : ℕ) : ℕ := finiteSize (2 * k - 1) (2 * k)theorem degreeSizeBound_growth_estimate (k : ℕ) (hk : 2 ≤ k) :|doubleLog (degreeSizeBound k : ℝ) - 4 * (k : ℝ)| ≤ 5 * logTwo (k : ℝ) := byhave hlow := finiteSize_doubleLog_lower (2 * k - 1) (by omega)have hu := finiteSize_doubleLog_upper (2 * k - 1) (by omega)have he : 2 * k - 1 + 1 = 2 * k := by omegarw [he] at hlow huchange 2 * ((2 * k - 1 : ℕ) : ℝ) - _ ≤ doubleLog (degreeSizeBound k : ℝ) at hlowchange doubleLog (degreeSizeBound k : ℝ) ≤ _ at huhave hkR : (2 : ℝ) ≤ k := by exact_mod_cast hkhave hcast : ((2 * k - 1 : ℕ) : ℝ) = 2 * (k : ℝ) - 1 := byrw [Nat.cast_sub (by omega), Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one]rw [hcast] at hlow huhave hl : logTwo (2 * (k : ℝ)) = 1 + logTwo (k : ℝ) := byunfold logTworw [Real.logb_mul (by norm_num) (by positivity)]change logTwo 2 + logTwo (k : ℝ) = _rw [logTwo_two]rflrw [sub_add_cancel, hl] at huhave hlog : 1 ≤ logTwo (k : ℝ) := byexact logTwo_two ▸ logTwo_mono (by norm_num : (0 : ℝ) < 2) hkRhave hl4 : logTwo (2 * (2 * (k : ℝ) - 1) + 1) ≤ 2 + logTwo (k : ℝ) := byhave hm := logTwo_mono (by linarith : 0 < 2 * (2 * (k : ℝ) - 1) + 1)(by linarith : 2 * (2 * (k : ℝ) - 1) + 1 ≤ 4 * (k : ℝ))change _ ≤ Real.logb 2 (4 * (k : ℝ)) at hmrw [Real.logb_mul (by norm_num) (by positivity)] at hmchange _ ≤ logTwo 4 + logTwo (k : ℝ) at hmrwa [logTwo_four] at hmexact abs_le.mpr ⟨by linarith, by linarith⟩theorem degreeSizeBound_growth :(fun k : ℕ => doubleLog (degreeSizeBound k : ℝ) - 4 * (k : ℝ))=O[atTop] (fun k => logTwo (k : ℝ)) := byapply Asymptotics.isBigO_iff.mprrefine ⟨5, ?_⟩filter_upwards [eventually_ge_atTop (2 : ℕ)] with k hkhave hl : 0 ≤ logTwo (k : ℝ) := (logTwo_pos (by exact_mod_cast (by omega : 1 < k))).lesimpa only [Real.norm_eq_abs, abs_of_nonneg hl] using degreeSizeBound_growth_estimate k hk/-- The double-exponential equality, with the error term separately proved to be O(log k). -/theorem degreeSizeBound_double_exponential (k : ℕ) (hk : 2 ≤ k) :(degreeSizeBound k : ℝ) = (2 : ℝ) ^ ((2 : ℝ) ^(4 * (k : ℝ) + (doubleLog (degreeSizeBound k : ℝ) - 4 * (k : ℝ)))) := byhave hs : 2 ≤ degreeSizeBound k := finiteSize_ge_two (by omega) (by omega)have hr : (1 : ℝ) < (degreeSizeBound k : ℝ) := by exact_mod_cast (by omega : 1 < degreeSizeBound k)rw [add_sub_cancel]unfold doubleLog logTwohave hlogpos : 0 < Real.logb 2 (degreeSizeBound k : ℝ) := logTwo_pos hrrw [Real.rpow_logb (by norm_num) (by norm_num) hlogpos,Real.rpow_logb (by norm_num) (by norm_num) (by linarith)]endend Proofend Combined_GrowthEstimates/-! ## Source: Corollaries.lean -/section Combined_Corollaries/-! The quantitative, fixed-degree, and explicit-size corollaries. -/namespace Proofnoncomputable sectionopen Classical Filter EuclideanGeometryopen scoped EuclideanGeometry/-- Every sufficiently large prescribed cardinality admits any fixed minimum degree. -/theorem eventual_minimum_degree (k : ℕ) (hk : 1 ≤ k) : ∃ n₀ : ℕ,∀ n ≥ n₀, ∀ η : ℝ, 0 < η → η < 1 / 2 →∃ P : Finset ℝ², P.Nonempty ∧ P.card = n ∧ ConvexIndep P ∧HasUnitMinDegree P k ∧ (P : Set ℝ²) ⊆ planeTwoDisks η ∧HorizontalBipartition P := byrefine ⟨thresholdSize k ^ 2, ?_⟩intro n hn η hη hηhalfobtain ⟨P, hc, hv, _, _, hl, hd, _⟩ := threshold_configuration_plane k hk n hn η hηhave hpos : 0 < n := (pow_pos (thresholdSize_pos k) 2).trans_le hnexact ⟨P, Finset.card_pos.mp (by rwa [hc]), hc, hv, hd, hl,twoDisks_horizontalBipartition hηhalf hl⟩/-- The Ω(n log log n) lower bound holds even with the prescribed disk restriction. -/theorem eventual_localized_density : ∃ n₀ : ℕ,∀ n ≥ n₀, ∀ η : ℝ, 0 < η → η < 1 / 2 →∃ P : Finset ℝ², P.Nonempty ∧ P.card = n ∧ ConvexIndep P ∧(P : Set ℝ²) ⊆ planeTwoDisks η ∧ HorizontalBipartition P ∧(n : ℝ) * doubleLog (n : ℝ) / 8 ≤ unitDistNum P := byobtain ⟨n₀, hn₀⟩ := main_quantitativehave hsmall : ∀ᶠ n : ℕ in atTop, 7 * tripleLog (n : ℝ) ≤ doubleLog (n : ℝ) / 8 := byhave h := tendsto_doubleLog_nat.eventually (logTwo_sublinear (1 / 56) (by norm_num))filter_upwards [h] with n hnchange logTwo (doubleLog (n : ℝ)) ≤ _ at hnchange 7 * logTwo (doubleLog (n : ℝ)) ≤ _linarithapply eventually_atTop.mpfilter_upwards [eventually_ge_atTop n₀, hsmall] with n hn hsmallintro η hη hηhalfobtain ⟨P, hP, hc, hv, _, _, hl, _, hh, hb⟩ := hn₀ n hn η hη hηhalfhave hnpos : (0 : ℝ) < n := by exact_mod_cast (hc ▸ Finset.card_pos.mpr hP)have hdiv : doubleLog (n : ℝ) / 8 ≤ (unitDistNum P : ℝ) / n := byhave h := hb.trans (min_le_right _ _)linarithhave he := (le_div_iff₀ hnpos).mp hdivrefine ⟨P, hP, hc, hv, hl, hh, ?_⟩nlinarith/-- In standard asymptotic notation, n log₂ log₂ n = O(U_c(n)). -/theorem convex_unit_distances_omega :(fun n : ℕ => (n : ℝ) * doubleLog (n : ℝ)) =O[atTop](fun n => (Erdos96.maxConvexUnitDistances n : ℝ)) := byobtain ⟨n₀, hn₀⟩ := eventual_localized_densityapply Asymptotics.isBigO_iff.mprrefine ⟨8, ?_⟩filter_upwards [eventually_ge_atTop n₀,tendsto_doubleLog_nat.eventually (eventually_ge_atTop (0 : ℝ))] with n hn hlogobtain ⟨P, _, hc, hv, _, _, he⟩ := hn₀ n hn (1 / 4) (by norm_num) (by norm_num)have hm : (unitDistNum P : ℝ) ≤ Erdos96.maxConvexUnitDistances n := byhave h := unitDistNum_le_max P hvrw [hc] at hexact_mod_cast hrw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (Nat.cast_nonneg n) hlog), Real.norm_natCast]linarith/-- Corollary 4.4: a nonempty convex set of minimum degree k, with the stated size bound. -/theorem bounded_size_minimum_degree (k : ℕ) (hk : 2 ≤ k)(η : ℝ) (hη : 0 < η) (hηhalf : η < 1 / 2) :∃ Q : Finset ℝ², Q.Nonempty ∧ ConvexIndep Q ∧HasUnitMinDegree Q k ∧ Q.card ≤ degreeSizeBound k ∧(Q : Set ℝ²) ⊆ planeTwoDisks η ∧HorizontalBipartition Q := bylet α : ℝ := (k : ℝ) - 1 + 1 / (4 * (k : ℝ))have hkR : (2 : ℝ) ≤ k := by exact_mod_cast hkhave hcast : ((k - 1 : ℕ) : ℝ) = (k : ℝ) - 1 := by rw [Nat.cast_sub (by omega), Nat.cast_one]have hα : ((k - 1 : ℕ) : ℝ) < α := byrw [hcast]dsimp [α]have hp : (0 : ℝ) < 1 / (4 * (k : ℝ)) := by positivitylinarithobtain ⟨P, hc, he, hv, _, _, hl⟩ :=finite_construction_plane (2 * k - 1) (2 * k) (by omega) (by omega) η hηhave hratio : ((2 * k - 1 : ℕ) : ℝ) / 2 * (1 - 1 / ((2 * k : ℕ) : ℝ)) = α := byrw [Nat.cast_sub (by omega), Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one]dsimp [α]field_simpringrw [hratio, unitDistNum_eq_card_unitPairs] at hehave hP : P.Nonempty := Finset.card_pos.mp (by rw [hc]; exact finiteSize_pos (by omega))obtain ⟨Q, hQP, hQ, hd, _⟩ := dense_subset_min_degree α (k - 1) hα P hP hehave hd' : HasUnitMinDegree Q k := by simpa only [Nat.sub_add_cancel (by omega : 1 ≤ k)] using hdhave hloc : (Q : Set ℝ²) ⊆ planeTwoDisks η := fun _ hx => hl (hQP hx)exact ⟨Q, hQ, convexIndep_subset hv hQP, hd', (Finset.card_le_card hQP).trans_eq hc,hloc, twoDisks_horizontalBipartition hηhalf hloc⟩theorem degreeSizeBound_four : degreeSizeBound 4 = 3432 * 2 ^ 36036 := byhave hv : middleVertexCount 7 = 3432 := by norm_num [middleVertexCount, Nat.choose]have hm : middleEdgeCount 7 = 12012 := by norm_num [middleEdgeCount, Nat.choose]change finiteSize 7 8 = _rw [finiteSize, hv, hm, show (8 : ℕ) = 2 ^ 3 from rfl, ← pow_mul]/-- The numerical bound in the manuscript, for the exact equidistance predicate. -/theorem explicit_erdos_97_counterexample (η : ℝ) (hη : 0 < η) (hηhalf : η < 1 / 2) :∃ Q : Finset ℝ², Q.Nonempty ∧ ConvexIndep Q ∧Erdos97.HasNUnitDistanceProperty 4 Q ∧ Erdos97.HasNEquidistantProperty 4 Q ∧Q.card ≤ 3432 * 2 ^ 36036 ∧ (Q : Set ℝ²) ⊆ planeTwoDisks η ∧HorizontalBipartition Q := byobtain ⟨Q, hQ, hv, hd, hc, hl, hh⟩ := bounded_size_minimum_degree 4 (by norm_num) η hη hηhalfrw [degreeSizeBound_four] at hcexact ⟨Q, hQ, hv, hd, fun x hx => ⟨1, by norm_num, hd x hx⟩, hc, hl, hh⟩/-- The logical equivalence noted after Corollary 4.4. -/theorem unbounded_density_iff_unbounded_minimum_degree :(∀ α : ℝ, ∃ P : Finset ℝ², P.Nonempty ∧ ConvexIndep P ∧α * P.card ≤ (unitPairs P).card) ↔(∀ k : ℕ, ∃ P : Finset ℝ², P.Nonempty ∧ ConvexIndep P ∧ HasUnitMinDegree P k) := byconstructor· intro h kobtain ⟨P, hP, hv, hc⟩ := h ((k : ℝ) + 1)obtain ⟨Q, hQP, hQ, hd, _⟩ := dense_subset_min_degree ((k : ℝ) + 1) k(by linarith) P hP hcexact ⟨Q, hQ, convexIndep_subset hv hQP, fun x hx => (Nat.le_succ k).trans (hd x hx)⟩· intro h αobtain ⟨k, hk⟩ := exists_nat_ge (2 * α)obtain ⟨P, hP, hv, hd⟩ := h khave hsum : ∑ x ∈ P, k ≤ ∑ x ∈ P, unitDegree P x := Finset.sum_le_sum (fun x hx => hd x hx)rw [sum_unitDegree, Finset.sum_const, nsmul_eq_mul] at hsumhave hs : (P.card : ℝ) * (k : ℝ) ≤ 2 * (unitPairs P).card := by exact_mod_cast hsumhave hm := mul_le_mul_of_nonneg_right hk (Nat.cast_nonneg P.card : (0 : ℝ) ≤ P.card)exact ⟨P, hP, hv, by nlinarith⟩endend Proofend Combined_Corollaries/-! ## Source: AxiomAudit.lean -/section Combined_AxiomAudit/-! A failing build gate for any nonstandard axiom in an exported result'stransitive proof dependencies. These checks reject sorryAx as well as any new axiom. -/open Lean Elab Command inelab "assert_standard_axioms " n:ident : command => dolet name ← liftCoreM <| Lean.Elab.realizeGlobalConstNoOverloadWithInfo nlet axioms ← Lean.collectAxioms namefor axiomName in axioms dounless [``propext, ``Classical.choice, ``Quot.sound].contains axiomName dothrowError "{name} depends on the disallowed axiom {axiomName}"logInfo m!"Verified {name}: only propext, Classical.choice, and Quot.sound are permitted."assert_standard_axioms Proof.main_theoremassert_standard_axioms Proof.main_quantitativeassert_standard_axioms Proof.finite_construction_planeassert_standard_axioms Proof.finite_construction_realassert_standard_axioms Proof.threshold_configuration_planeassert_standard_axioms Proof.threshold_configurationassert_standard_axioms Proof.logarithmic_indexassert_standard_axioms Proof.threshold_growthassert_standard_axioms Proof.degreeSizeBound_growthassert_standard_axioms Proof.degreeSizeBound_double_exponentialassert_standard_axioms Proof.eventual_minimum_degreeassert_standard_axioms Proof.eventual_localized_densityassert_standard_axioms Proof.convex_unit_distances_omegaassert_standard_axioms Proof.bounded_size_minimum_degreeassert_standard_axioms Proof.degreeSizeBound_fourassert_standard_axioms Proof.explicit_erdos_97_counterexampleassert_standard_axioms Proof.erdos_96_falseassert_standard_axioms Proof.erdos_97_falseassert_standard_axioms Proof.erdos_97_general_falseassert_standard_axioms targetassert_standard_axioms Proof.unbounded_density_iff_unbounded_minimum_degreeassert_standard_axioms Proof.small_rotated_copiesassert_standard_axioms Proof.dense_subset_min_degreeassert_standard_axioms Proof.erase_low_degree_densityassert_standard_axioms Proof.boundedCopy_supportassert_standard_axioms Proof.boundedCopy_displacementassert_standard_axioms Proof.boundedSet_cardassert_standard_axioms Proof.bounded_amplification_unitPairs_boundassert_standard_axioms Proof.exists_injective_boundedProductsassert_standard_axioms Proof.middleVertex_cardassert_standard_axioms Proof.middleEdgeCount_formulaassert_standard_axioms Proof.middlePatternassert_standard_axioms Proof.twoDisks_horizontalBipartitionend Combined_AxiomAudit