/- Copyright (c) 2026 Arthur Colle. All rights reserved. Released under Apache 2.0 license. # Universal Connected-to-Ultrametric Gromov–Hausdorff Rigidity & Borsuk–Ulam Circle Phase Transition This self-contained Lean 4 module proves sharp, universal Gromov–Hausdorff distance formulas connecting **connected Archimedean metric spaces** to **non-Archimedean (ultrametric / `p`-adic) spaces**: 1. **Universal Connected-to-Ultrametric Rigidity** (`ghDist_ultrametric_connected_ge`): For EVERY bounded ultrametric space `U` of diameter `D` and EVERY connected bounded metric space `X` of diameter `L`, `d_GH(U, X) ≥ (1/2) max(D, L - D) ≥ L / 4`. 2. **Exact Distance to the Entire Moduli Space of Ultrametrics** (`ghDist_to_ultrametrics_eq`): For EVERY connected bounded metric space `X` of diameter `L`, `inf_{U ultrametric} d_GH(X, U) = L / 4` (attained by the discrete ultrametric `(X, (L/2)·1_≠)` and by finite equilateral ultrametrics `Δ_N(L/2)` whenever `X` admits an `N`-cover of diameter `≤ L/2`). 3. **Exact Closed Form for ALL Attained-Diameter Ultrametrics vs `[0, L]`** (`ghDist_ultrametric_Icc`): For EVERY bounded ultrametric space `U` attaining its diameter `D` and EVERY `L ≥ 0`, `d_GH(U, [0, L]) = (1/2) max(D, L - D)`. In particular: - `d_GH(ℤ_p, [0, 1]) = 1/2` for ALL `p ≥ 2` (`ghDist_padic_Icc`), - `d_GH(p^k ℤ_p, [0, 1]) = (1/2) max(p^{-k}, 1 - p^{-k})` (`ghDist_padic_ideal_Icc`), - `d_GH(2 ℤ_2, [0, 1]) = 1/4` achieves the global minimum over ALL ultrametric spaces! 4. **Exact 3-Tier Borsuk–Ulam Phase Transition on the Geodesic Circle `S¹`** (`ghDist_equilateral2_circleGeo`, `ghDist_equilateral3_circleGeo`, `ghDist_equilateral_ge4_circleGeo`): - `n = 2`: `d_GH(Δ_2(D), S¹) = (1/2) max(D, π) ≥ π / 2` (1D Borsuk–Ulam obstruction via IVT!), - `n = 3`: `d_GH(Δ_3(D), S¹) = (1/2) max(max(D, 2π/3), π - D) ≥ π / 3`, - `n ≥ 4`: `d_GH(Δ_n(D), S¹) = (1/2) max(D, π - D) ≥ π / 4 = inf_{U ultrametric} d_GH(S¹, U)`. Self-contained (importing only `Mathlib`), complete kernel-verified proofs using standard axioms only. -/ import Mathlib open scoped Real Classical open Set namespace ConnectedUltrametricRigidity universe u v w noncomputable section /-! ## 1. Bounded Spaces, Real Diameter & Ultrametrics -/ /-- A pseudometric space has finite real diameter. -/ def BoundedSpace (X : Type u) [PseudoMetricSpace X] : Prop := ∃ M : ℝ, ∀ x y : X, dist x y ≤ M /-- Ultrametricity (strong triangle inequality): `d(x, z) ≤ max(d(x, y), d(y, z))`. -/ def IsUltra (X : Type u) [PseudoMetricSpace X] : Prop := ∀ x y z : X, dist x z ≤ max (dist x y) (dist y z) /-- Real-valued diameter `sdiam X := sup_{x, y ∈ X} d(x, y)`. -/ def sdiam (X : Type u) [PseudoMetricSpace X] : ℝ := sSup {d : ℝ | ∃ x y : X, dist x y = d} lemma distSet_nonempty (X : Type u) [PseudoMetricSpace X] [Nonempty X] : {d : ℝ | ∃ x y : X, dist x y = d}.Nonempty := by obtain ⟨x⟩ := ‹Nonempty X› exact ⟨0, x, x, dist_self x⟩ lemma distSet_bddAbove {X : Type u} [PseudoMetricSpace X] (hX : BoundedSpace X) : BddAbove {d : ℝ | ∃ x y : X, dist x y = d} := by obtain ⟨M, hM⟩ := hX exact ⟨M, fun _ ⟨x, y, h⟩ => h ▸ hM x y⟩ lemma dist_le_sdiam {X : Type u} [PseudoMetricSpace X] (hX : BoundedSpace X) (x y : X) : dist x y ≤ sdiam X := le_csSup (distSet_bddAbove hX) ⟨x, y, rfl⟩ lemma sdiam_nonneg {X : Type u} [PseudoMetricSpace X] [Nonempty X] (hX : BoundedSpace X) : 0 ≤ sdiam X := by obtain ⟨x⟩ := ‹Nonempty X› exact le_trans (by rw [dist_self]) (dist_le_sdiam hX x x) lemma sdiam_le_of_forall {X : Type u} [PseudoMetricSpace X] [Nonempty X] {M : ℝ} (hM : ∀ x y : X, dist x y ≤ M) : sdiam X ≤ M := csSup_le (distSet_nonempty X) (fun _ ⟨x, y, h⟩ => h ▸ hM x y) lemma exists_dist_gt_sdiam_sub {X : Type u} [PseudoMetricSpace X] [Nonempty X] (hX : BoundedSpace X) {ε : ℝ} (hε : 0 < ε) : ∃ x y : X, sdiam X - ε < dist x y := by have hlt : sdiam X - ε < sdiam X := by linarith obtain ⟨d, ⟨x, y, rfl⟩, hd⟩ := (lt_csSup_iff (distSet_bddAbove hX) (distSet_nonempty X)).mp hlt exact ⟨x, y, hd⟩ /-! ## 2. Zarichnyi–Mémoli–Smith–Wan Ultrametric `Λ_∞` on `ℝ≥0` -/ /-- The `Λ_∞` ultrametric on nonnegative reals: `0` if `a = b`, else `max a b`. -/ def ultraDiff (a b : ℝ) : ℝ := if a = b then 0 else max a b lemma ultraDiff_self (a : ℝ) : ultraDiff a a = 0 := by simp [ultraDiff] lemma ultraDiff_symm (a b : ℝ) : ultraDiff a b = ultraDiff b a := by unfold ultraDiff by_cases h : a = b · subst h; simp · rw [if_neg h, if_neg (Ne.symm h), max_comm] lemma ultraDiff_nonneg {a b : ℝ} (ha : 0 ≤ a) (_hb : 0 ≤ b) : 0 ≤ ultraDiff a b := by unfold ultraDiff split_ifs · exact le_refl 0 · exact le_trans ha (le_max_left a b) lemma abs_sub_le_ultraDiff {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) : |a - b| ≤ ultraDiff a b := by unfold ultraDiff split_ifs with h · subst h; simp · rw [abs_le] constructor · linarith [le_max_right a b] · linarith [le_max_left a b] lemma ultraDiff_ultrametric {a b c : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hc : 0 ≤ c) : ultraDiff a c ≤ max (ultraDiff a b) (ultraDiff b c) := by unfold ultraDiff by_cases hac : a = c · rw [if_pos hac] exact le_trans (ultraDiff_nonneg ha hb) (le_max_left _ _) · rw [if_neg hac] by_cases hab : a = b · subst hab rw [if_pos rfl, if_neg hac, max_eq_right (le_trans ha (le_max_left a c))] · by_cases hbc : b = c · subst hbc rw [if_neg hab, if_pos rfl, max_eq_left (le_trans ha (le_max_left a b))] · rw [if_neg hab, if_neg hbc] exact max_le (le_trans (le_max_left a b) (le_max_left _ _)) (le_trans (le_max_right b c) (le_max_right _ _)) /-! ## 3. Correspondences, Distortions, `d_GH`, and `u_GH` -/ /-- A correspondence between `X` and `Y` is a left-total and right-total binary relation. -/ structure Correspondence (X : Type u) (Y : Type v) where rel : X → Y → Prop left_total : ∀ x : X, ∃ y : Y, rel x y right_total : ∀ y : Y, ∃ x : X, rel x y /-- Reverse of a correspondence. -/ def Correspondence.symm {X : Type u} {Y : Type v} (R : Correspondence X Y) : Correspondence Y X where rel := fun y x => R.rel x y left_total := R.right_total right_total := R.left_total /-- Identity correspondence on `X`. -/ def Correspondence.refl (X : Type u) : Correspondence X X where rel := fun x y => x = y left_total := fun x => ⟨x, rfl⟩ right_total := fun x => ⟨x, rfl⟩ /-- Composition of correspondences `R : X ↔ Y` and `S : Y ↔ Z`. -/ def Correspondence.comp {X : Type u} {Y : Type v} {Z : Type w} (R : Correspondence X Y) (S : Correspondence Y Z) : Correspondence X Z where rel := fun x z => ∃ y : Y, R.rel x y ∧ S.rel y z left_total := fun x => by obtain ⟨y, hxy⟩ := R.left_total x obtain ⟨z, hyz⟩ := S.left_total y exact ⟨z, y, hxy, hyz⟩ right_total := fun z => by obtain ⟨y, hyz⟩ := S.right_total z obtain ⟨x, hxy⟩ := R.right_total y exact ⟨x, y, hxy, hyz⟩ /-- Total correspondence `X × Y` (exists whenever both spaces are nonempty). -/ def Correspondence.total (X : Type u) (Y : Type v) [Nonempty X] [Nonempty Y] : Correspondence X Y where rel := fun _ _ => True left_total := fun _ => ⟨Classical.arbitrary Y, trivial⟩ right_total := fun _ => ⟨Classical.arbitrary X, trivial⟩ /-- Classical distortion `dis(R) := sup_{(x₁,y₁),(x₂,y₂) ∈ R} |d_X(x₁,x₂) - d_Y(y₁,y₂)|`. -/ def corrDistortion {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] (R : Correspondence X Y) : ℝ := sSup {d : ℝ | ∃ x₁ x₂ : X, ∃ y₁ y₂ : Y, R.rel x₁ y₁ ∧ R.rel x₂ y₂ ∧ |dist x₁ x₂ - dist y₁ y₂| = d} /-- Ultrametric distortion `udis(R) := sup_{(x₁,y₁),(x₂,y₂) ∈ R} Λ_∞(d_X(x₁,x₂), d_Y(y₁,y₂))`. -/ def uCorrDistortion {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] (R : Correspondence X Y) : ℝ := sSup {d : ℝ | ∃ x₁ x₂ : X, ∃ y₁ y₂ : Y, R.rel x₁ y₁ ∧ R.rel x₂ y₂ ∧ ultraDiff (dist x₁ x₂) (dist y₁ y₂) = d} /-- Classical Gromov–Hausdorff distance `d_GH(X, Y) := (1/2) inf_R dis(R)`. -/ def ghDist (X : Type u) (Y : Type v) [PseudoMetricSpace X] [PseudoMetricSpace Y] : ℝ := (1 / 2) * sInf {d : ℝ | ∃ R : Correspondence X Y, corrDistortion R = d} /-- Ultrametric Gromov–Hausdorff distance `u_GH(X, Y) := inf_R udis(R)` (Zarichnyi / Mémoli–Smith–Wan). -/ def uGhDist (X : Type u) (Y : Type v) [PseudoMetricSpace X] [PseudoMetricSpace Y] : ℝ := sInf {d : ℝ | ∃ R : Correspondence X Y, uCorrDistortion R = d} lemma corrDistSet_nonempty {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] (R : Correspondence X Y) : {d : ℝ | ∃ x₁ x₂ : X, ∃ y₁ y₂ : Y, R.rel x₁ y₁ ∧ R.rel x₂ y₂ ∧ |dist x₁ x₂ - dist y₁ y₂| = d}.Nonempty := by obtain ⟨x⟩ := ‹Nonempty X› obtain ⟨y, hxy⟩ := R.left_total x exact ⟨0, x, x, y, y, hxy, hxy, by simp⟩ lemma corrDistSet_bddAbove {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) (R : Correspondence X Y) : BddAbove {d : ℝ | ∃ x₁ x₂ : X, ∃ y₁ y₂ : Y, R.rel x₁ y₁ ∧ R.rel x₂ y₂ ∧ |dist x₁ x₂ - dist y₁ y₂| = d} := by obtain ⟨MX, hMX⟩ := hX obtain ⟨MY, hMY⟩ := hY refine ⟨max MX MY, ?_⟩ rintro _ ⟨x₁, x₂, y₁, y₂, _, _, rfl⟩ rw [abs_le] have h1 := dist_nonneg (x := x₁) (y := x₂) have h2 := dist_nonneg (x := y₁) (y := y₂) have h3 := hMX x₁ x₂ have h4 := hMY y₁ y₂ constructor · linarith [le_max_right MX MY] · linarith [le_max_left MX MY] lemma uCorrDistSet_nonempty {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] (R : Correspondence X Y) : {d : ℝ | ∃ x₁ x₂ : X, ∃ y₁ y₂ : Y, R.rel x₁ y₁ ∧ R.rel x₂ y₂ ∧ ultraDiff (dist x₁ x₂) (dist y₁ y₂) = d}.Nonempty := by obtain ⟨x⟩ := ‹Nonempty X› obtain ⟨y, hxy⟩ := R.left_total x exact ⟨0, x, x, y, y, hxy, hxy, by simp [ultraDiff]⟩ lemma uCorrDistSet_bddAbove {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) (R : Correspondence X Y) : BddAbove {d : ℝ | ∃ x₁ x₂ : X, ∃ y₁ y₂ : Y, R.rel x₁ y₁ ∧ R.rel x₂ y₂ ∧ ultraDiff (dist x₁ x₂) (dist y₁ y₂) = d} := by obtain ⟨MX, hMX⟩ := hX obtain ⟨MY, hMY⟩ := hY refine ⟨max (max MX MY) 0, ?_⟩ rintro _ ⟨x₁, x₂, y₁, y₂, _, _, rfl⟩ unfold ultraDiff split_ifs · exact le_max_right _ _ · exact le_trans (max_le (le_trans (hMX x₁ x₂) (le_max_left MX MY)) (le_trans (hMY y₁ y₂) (le_max_right MX MY))) (le_max_left _ _) lemma le_corrDistortion_of_rel {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) (R : Correspondence X Y) {x₁ x₂ : X} {y₁ y₂ : Y} (h₁ : R.rel x₁ y₁) (h₂ : R.rel x₂ y₂) : |dist x₁ x₂ - dist y₁ y₂| ≤ corrDistortion R := le_csSup (corrDistSet_bddAbove hX hY R) ⟨x₁, x₂, y₁, y₂, h₁, h₂, rfl⟩ lemma corrDistortion_le_of_forall {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] (R : Correspondence X Y) {M : ℝ} (hM : ∀ x₁ x₂ y₁ y₂, R.rel x₁ y₁ → R.rel x₂ y₂ → |dist x₁ x₂ - dist y₁ y₂| ≤ M) : corrDistortion R ≤ M := csSup_le (corrDistSet_nonempty R) (fun _ ⟨x₁, x₂, y₁, y₂, h₁, h₂, h⟩ => h ▸ hM x₁ x₂ y₁ y₂ h₁ h₂) lemma corrDistortion_nonneg {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] (hX : BoundedSpace X) (hY : BoundedSpace Y) (R : Correspondence X Y) : 0 ≤ corrDistortion R := by obtain ⟨x⟩ := ‹Nonempty X› obtain ⟨y, hxy⟩ := R.left_total x exact le_trans (abs_nonneg _) (le_corrDistortion_of_rel hX hY R hxy hxy) lemma le_uCorrDistortion_of_rel {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) (R : Correspondence X Y) {x₁ x₂ : X} {y₁ y₂ : Y} (h₁ : R.rel x₁ y₁) (h₂ : R.rel x₂ y₂) : ultraDiff (dist x₁ x₂) (dist y₁ y₂) ≤ uCorrDistortion R := le_csSup (uCorrDistSet_bddAbove hX hY R) ⟨x₁, x₂, y₁, y₂, h₁, h₂, rfl⟩ lemma uCorrDistortion_le_of_forall {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] (R : Correspondence X Y) {M : ℝ} (hM : ∀ x₁ x₂ y₁ y₂, R.rel x₁ y₁ → R.rel x₂ y₂ → ultraDiff (dist x₁ x₂) (dist y₁ y₂) ≤ M) : uCorrDistortion R ≤ M := csSup_le (uCorrDistSet_nonempty R) (fun _ ⟨x₁, x₂, y₁, y₂, h₁, h₂, h⟩ => h ▸ hM x₁ x₂ y₁ y₂ h₁ h₂) lemma uCorrDistortion_nonneg {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] (hX : BoundedSpace X) (hY : BoundedSpace Y) (R : Correspondence X Y) : 0 ≤ uCorrDistortion R := by obtain ⟨x⟩ := ‹Nonempty X› obtain ⟨y, hxy⟩ := R.left_total x exact le_trans (ultraDiff_nonneg dist_nonneg dist_nonneg) (le_uCorrDistortion_of_rel hX hY R hxy hxy) lemma corrDistortion_le_uCorrDistortion {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] (hX : BoundedSpace X) (hY : BoundedSpace Y) (R : Correspondence X Y) : corrDistortion R ≤ uCorrDistortion R := corrDistortion_le_of_forall R fun _ _ _ _ h₁ h₂ => le_trans (abs_sub_le_ultraDiff dist_nonneg dist_nonneg) (le_uCorrDistortion_of_rel hX hY R h₁ h₂) lemma corrDistortion_symm {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] (R : Correspondence X Y) : corrDistortion R.symm = corrDistortion R := by unfold corrDistortion Correspondence.symm congr 1; ext d constructor · rintro ⟨y₁, y₂, x₁, x₂, h₁, h₂, rfl⟩ exact ⟨x₁, x₂, y₁, y₂, h₁, h₂, abs_sub_comm _ _⟩ · rintro ⟨x₁, x₂, y₁, y₂, h₁, h₂, rfl⟩ exact ⟨y₁, y₂, x₁, x₂, h₁, h₂, abs_sub_comm _ _⟩ lemma uCorrDistortion_symm {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] (R : Correspondence X Y) : uCorrDistortion R.symm = uCorrDistortion R := by unfold uCorrDistortion Correspondence.symm congr 1; ext d constructor · rintro ⟨y₁, y₂, x₁, x₂, h₁, h₂, rfl⟩ exact ⟨x₁, x₂, y₁, y₂, h₁, h₂, ultraDiff_symm _ _⟩ · rintro ⟨x₁, x₂, y₁, y₂, h₁, h₂, rfl⟩ exact ⟨y₁, y₂, x₁, x₂, h₁, h₂, ultraDiff_symm _ _⟩ lemma corrDistortion_comp_le {X : Type u} {Y : Type v} {Z : Type w} [PseudoMetricSpace X] [PseudoMetricSpace Y] [PseudoMetricSpace Z] [Nonempty X] (hX : BoundedSpace X) (hY : BoundedSpace Y) (hZ : BoundedSpace Z) (R : Correspondence X Y) (S : Correspondence Y Z) : corrDistortion (R.comp S) ≤ corrDistortion R + corrDistortion S := by refine corrDistortion_le_of_forall (R.comp S) fun x₁ x₂ z₁ z₂ h₁ h₂ => ?_ obtain ⟨y₁, hR₁, hS₁⟩ := h₁ obtain ⟨y₂, hR₂, hS₂⟩ := h₂ calc |dist x₁ x₂ - dist z₁ z₂| = |(dist x₁ x₂ - dist y₁ y₂) + (dist y₁ y₂ - dist z₁ z₂)| := by ring_nf _ ≤ |dist x₁ x₂ - dist y₁ y₂| + |dist y₁ y₂ - dist z₁ z₂| := abs_add_le _ _ _ ≤ corrDistortion R + corrDistortion S := add_le_add (le_corrDistortion_of_rel hX hY R hR₁ hR₂) (le_corrDistortion_of_rel hY hZ S hS₁ hS₂) lemma uCorrDistortion_comp_le {X : Type u} {Y : Type v} {Z : Type w} [PseudoMetricSpace X] [PseudoMetricSpace Y] [PseudoMetricSpace Z] [Nonempty X] (hX : BoundedSpace X) (hY : BoundedSpace Y) (hZ : BoundedSpace Z) (R : Correspondence X Y) (S : Correspondence Y Z) : uCorrDistortion (R.comp S) ≤ max (uCorrDistortion R) (uCorrDistortion S) := by refine uCorrDistortion_le_of_forall (R.comp S) fun x₁ x₂ z₁ z₂ h₁ h₂ => ?_ obtain ⟨y₁, hR₁, hS₁⟩ := h₁ obtain ⟨y₂, hR₂, hS₂⟩ := h₂ exact le_trans (ultraDiff_ultrametric dist_nonneg dist_nonneg dist_nonneg) (max_le_max (le_uCorrDistortion_of_rel hX hY R hR₁ hR₂) (le_uCorrDistortion_of_rel hY hZ S hS₁ hS₂)) /-! ## 4. Fundamental Metric & Ultrametric Properties of `d_GH` and `u_GH` -/ lemma ghSet_bddBelow {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] (hX : BoundedSpace X) (hY : BoundedSpace Y) : BddBelow {d : ℝ | ∃ R : Correspondence X Y, corrDistortion R = d} := ⟨0, fun _ ⟨R, h⟩ => h ▸ corrDistortion_nonneg hX hY R⟩ lemma ghSet_nonempty {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] [Nonempty Y] : {d : ℝ | ∃ R : Correspondence X Y, corrDistortion R = d}.Nonempty := ⟨corrDistortion (Correspondence.total X Y), Correspondence.total X Y, rfl⟩ lemma uGhSet_bddBelow {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] (hX : BoundedSpace X) (hY : BoundedSpace Y) : BddBelow {d : ℝ | ∃ R : Correspondence X Y, uCorrDistortion R = d} := ⟨0, fun _ ⟨R, h⟩ => h ▸ uCorrDistortion_nonneg hX hY R⟩ lemma uGhSet_nonempty {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] [Nonempty Y] : {d : ℝ | ∃ R : Correspondence X Y, uCorrDistortion R = d}.Nonempty := ⟨uCorrDistortion (Correspondence.total X Y), Correspondence.total X Y, rfl⟩ theorem ghDist_nonneg {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] [Nonempty Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) : 0 ≤ ghDist X Y := by unfold ghDist exact mul_nonneg (by norm_num) (le_csInf ghSet_nonempty (fun _ ⟨R, h⟩ => h ▸ corrDistortion_nonneg hX hY R)) theorem uGhDist_nonneg {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] [Nonempty Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) : 0 ≤ uGhDist X Y := le_csInf uGhSet_nonempty (fun _ ⟨R, h⟩ => h ▸ uCorrDistortion_nonneg hX hY R) lemma ghDist_le_of_corr {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] (hX : BoundedSpace X) (hY : BoundedSpace Y) (R : Correspondence X Y) : ghDist X Y ≤ (1 / 2) * corrDistortion R := by unfold ghDist exact mul_le_mul_of_nonneg_left (csInf_le (ghSet_bddBelow hX hY) ⟨R, rfl⟩) (by norm_num) lemma le_ghDist_of_forall_corr {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] [Nonempty Y] {c : ℝ} (hc : ∀ R : Correspondence X Y, c ≤ corrDistortion R) : (1 / 2) * c ≤ ghDist X Y := by unfold ghDist exact mul_le_mul_of_nonneg_left (le_csInf ghSet_nonempty (fun _ ⟨R, h⟩ => h ▸ hc R)) (by norm_num) lemma uGhDist_le_of_corr {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] (hX : BoundedSpace X) (hY : BoundedSpace Y) (R : Correspondence X Y) : uGhDist X Y ≤ uCorrDistortion R := csInf_le (uGhSet_bddBelow hX hY) ⟨R, rfl⟩ lemma le_uGhDist_of_forall_corr {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] [Nonempty Y] {c : ℝ} (hc : ∀ R : Correspondence X Y, c ≤ uCorrDistortion R) : c ≤ uGhDist X Y := le_csInf uGhSet_nonempty (fun _ ⟨R, h⟩ => h ▸ hc R) theorem ghDist_self (X : Type u) [PseudoMetricSpace X] [Nonempty X] (hX : BoundedSpace X) : ghDist X X = 0 := by apply le_antisymm _ (ghDist_nonneg hX hX) have h0 : corrDistortion (Correspondence.refl X) ≤ 0 := corrDistortion_le_of_forall _ fun _ _ _ _ h₁ h₂ => by subst h₁; subst h₂; simp linarith [ghDist_le_of_corr hX hX (Correspondence.refl X)] theorem uGhDist_self (X : Type u) [PseudoMetricSpace X] [Nonempty X] (hX : BoundedSpace X) : uGhDist X X = 0 := by apply le_antisymm _ (uGhDist_nonneg hX hX) have h0 : uCorrDistortion (Correspondence.refl X) ≤ 0 := uCorrDistortion_le_of_forall _ fun _ _ _ _ h₁ h₂ => by subst h₁; subst h₂; simp [ultraDiff] exact le_trans (uGhDist_le_of_corr hX hX (Correspondence.refl X)) h0 theorem ghDist_symm (X : Type u) (Y : Type v) [PseudoMetricSpace X] [PseudoMetricSpace Y] : ghDist X Y = ghDist Y X := by unfold ghDist; congr 2; ext d constructor · rintro ⟨R, rfl⟩; exact ⟨R.symm, corrDistortion_symm R⟩ · rintro ⟨R, rfl⟩; exact ⟨R.symm, corrDistortion_symm R⟩ theorem uGhDist_symm (X : Type u) (Y : Type v) [PseudoMetricSpace X] [PseudoMetricSpace Y] : uGhDist X Y = uGhDist Y X := by unfold uGhDist; congr 1; ext d constructor · rintro ⟨R, rfl⟩; exact ⟨R.symm, uCorrDistortion_symm R⟩ · rintro ⟨R, rfl⟩; exact ⟨R.symm, uCorrDistortion_symm R⟩ /-- **Triangle Inequality** for classical Gromov–Hausdorff distance `d_GH`. -/ theorem ghDist_triangle (X : Type u) (Y : Type v) (Z : Type w) [PseudoMetricSpace X] [PseudoMetricSpace Y] [PseudoMetricSpace Z] [Nonempty X] [Nonempty Y] [Nonempty Z] (hX : BoundedSpace X) (hY : BoundedSpace Y) (hZ : BoundedSpace Z) : ghDist X Z ≤ ghDist X Y + ghDist Y Z := by refine le_of_forall_pos_le_add fun ε hε => ?_ have hlt1 : sInf {d : ℝ | ∃ R : Correspondence X Y, corrDistortion R = d} < sInf {d : ℝ | ∃ R : Correspondence X Y, corrDistortion R = d} + ε := by linarith have hlt2 : sInf {d : ℝ | ∃ S : Correspondence Y Z, corrDistortion S = d} < sInf {d : ℝ | ∃ S : Correspondence Y Z, corrDistortion S = d} + ε := by linarith obtain ⟨_, ⟨R, rfl⟩, hR⟩ := (csInf_lt_iff (ghSet_bddBelow hX hY) ghSet_nonempty).mp hlt1 obtain ⟨_, ⟨S, rfl⟩, hS⟩ := (csInf_lt_iff (ghSet_bddBelow hY hZ) ghSet_nonempty).mp hlt2 have hcomp := corrDistortion_comp_le hX hY hZ R S have hle := ghDist_le_of_corr hX hZ (R.comp S) unfold ghDist at hle ⊢ linarith /-- **Strong Triangle (Ultrametric) Inequality** for `u_GH` (Zarichnyi 2005; Mémoli–Smith–Wan 2023). -/ theorem uGhDist_ultrametric (X : Type u) (Y : Type v) (Z : Type w) [PseudoMetricSpace X] [PseudoMetricSpace Y] [PseudoMetricSpace Z] [Nonempty X] [Nonempty Y] [Nonempty Z] (hX : BoundedSpace X) (hY : BoundedSpace Y) (hZ : BoundedSpace Z) : uGhDist X Z ≤ max (uGhDist X Y) (uGhDist Y Z) := by refine le_of_forall_pos_le_add fun ε hε => ?_ obtain ⟨_, ⟨R, rfl⟩, hR⟩ := (csInf_lt_iff (uGhSet_bddBelow hX hY) uGhSet_nonempty).mp (show uGhDist X Y < uGhDist X Y + ε by linarith) obtain ⟨_, ⟨S, rfl⟩, hS⟩ := (csInf_lt_iff (uGhSet_bddBelow hY hZ) uGhSet_nonempty).mp (show uGhDist Y Z < uGhDist Y Z + ε by linarith) have hcomp := uCorrDistortion_comp_le hX hY hZ R S have hle := uGhDist_le_of_corr hX hZ (R.comp S) have hmax : max (uCorrDistortion R) (uCorrDistortion S) ≤ max (uGhDist X Y) (uGhDist Y Z) + ε := max_le (le_trans (le_of_lt hR) (add_le_add_left (le_max_left _ _) ε)) (le_trans (le_of_lt hS) (add_le_add_left (le_max_right _ _) ε)) linarith /-- **Universal Comparison**: `2 * d_GH(X, Y) ≤ u_GH(X, Y)` for ALL bounded spaces `X, Y`. -/ theorem two_mul_ghDist_le_uGhDist (X : Type u) (Y : Type v) [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] [Nonempty Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) : 2 * ghDist X Y ≤ uGhDist X Y := by refine le_csInf uGhSet_nonempty ?_ rintro _ ⟨R, rfl⟩ have h1 := ghDist_le_of_corr hX hY R have h2 := corrDistortion_le_uCorrDistortion hX hY R linarith /-- Universal diameter upper bound: `d_GH(X, Y) ≤ (1/2) max(sdiam X, sdiam Y)`. -/ theorem ghDist_le_half_max_sdiam (X : Type u) (Y : Type v) [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] [Nonempty Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) : ghDist X Y ≤ (1 / 2) * max (sdiam X) (sdiam Y) := by refine le_trans (ghDist_le_of_corr hX hY (Correspondence.total X Y)) ?_ refine mul_le_mul_of_nonneg_left (corrDistortion_le_of_forall _ fun x₁ x₂ y₁ y₂ _ _ => ?_) (by norm_num) rw [abs_le] have h1 := dist_nonneg (x := x₁) (y := x₂) have h2 := dist_nonneg (x := y₁) (y := y₂) have h3 := dist_le_sdiam hX x₁ x₂ have h4 := dist_le_sdiam hY y₁ y₂ constructor · linarith [le_max_right (sdiam X) (sdiam Y)] · linarith [le_max_left (sdiam X) (sdiam Y)] /-- Universal diameter lower bound: `|sdiam X - sdiam Y| ≤ 2 * d_GH(X, Y)`. -/ theorem abs_sdiam_sub_le_two_ghDist (X : Type u) (Y : Type v) [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] [Nonempty Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) : |sdiam X - sdiam Y| ≤ 2 * ghDist X Y := by have hmain : ∀ R : Correspondence X Y, |sdiam X - sdiam Y| ≤ corrDistortion R := by intro R rw [abs_le] constructor · refine le_of_forall_pos_le_add fun ε hε => ?_ obtain ⟨y₁, y₂, hy⟩ := exists_dist_gt_sdiam_sub hY hε obtain ⟨x₁, hx₁⟩ := R.right_total y₁ obtain ⟨x₂, hx₂⟩ := R.right_total y₂ have hdis := le_corrDistortion_of_rel hX hY R hx₁ hx₂ have hdx := dist_le_sdiam hX x₁ x₂ rw [abs_le] at hdis linarith · refine le_of_forall_pos_le_add fun ε hε => ?_ obtain ⟨x₁, x₂, hx⟩ := exists_dist_gt_sdiam_sub hX hε obtain ⟨y₁, hy₁⟩ := R.left_total x₁ obtain ⟨y₂, hy₂⟩ := R.left_total x₂ have hdis := le_corrDistortion_of_rel hX hY R hy₁ hy₂ have hdy := dist_le_sdiam hY y₁ y₂ rw [abs_le] at hdis linarith have h := le_ghDist_of_forall_corr hmain linarith /-- Exact isometric invariance of `d_GH` and `u_GH`. -/ theorem ghDist_eq_zero_of_isometry {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] [Nonempty Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) (e : X ≃ᵢ Y) : ghDist X Y = 0 ∧ uGhDist X Y = 0 := by let R : Correspondence X Y := { rel := fun x y => e x = y left_total := fun x => ⟨e x, rfl⟩ right_total := fun y => ⟨e.symm y, e.apply_symm_apply y⟩ } have hu : uCorrDistortion R ≤ 0 := uCorrDistortion_le_of_forall R fun x₁ x₂ y₁ y₂ h₁ h₂ => by subst h₁; subst h₂; rw [e.dist_eq, ultraDiff_self] have hu0 : uGhDist X Y = 0 := le_antisymm (le_trans (uGhDist_le_of_corr hX hY R) hu) (uGhDist_nonneg hX hY) have hg0 : ghDist X Y = 0 := by have h1 := two_mul_ghDist_le_uGhDist X Y hX hY have h2 := ghDist_nonneg hX hY linarith exact ⟨hg0, hu0⟩ theorem ghDist_congr_left {X₁ : Type u} {X₂ : Type v} {Y : Type w} [PseudoMetricSpace X₁] [PseudoMetricSpace X₂] [PseudoMetricSpace Y] [Nonempty X₁] [Nonempty X₂] [Nonempty Y] (hX₁ : BoundedSpace X₁) (hX₂ : BoundedSpace X₂) (hY : BoundedSpace Y) (e : X₁ ≃ᵢ X₂) : ghDist X₁ Y = ghDist X₂ Y := by have he := (ghDist_eq_zero_of_isometry hX₁ hX₂ e).1 have he' := (ghDist_eq_zero_of_isometry hX₂ hX₁ e.symm).1 have h1 := ghDist_triangle X₁ X₂ Y hX₁ hX₂ hY have h2 := ghDist_triangle X₂ X₁ Y hX₂ hX₁ hY linarith theorem ghDist_congr_right {X : Type u} {Y₁ : Type v} {Y₂ : Type w} [PseudoMetricSpace X] [PseudoMetricSpace Y₁] [PseudoMetricSpace Y₂] [Nonempty X] [Nonempty Y₁] [Nonempty Y₂] (hX : BoundedSpace X) (hY₁ : BoundedSpace Y₁) (hY₂ : BoundedSpace Y₂) (e : Y₁ ≃ᵢ Y₂) : ghDist X Y₁ = ghDist X Y₂ := by rw [ghDist_symm X Y₁, ghDist_symm X Y₂] exact ghDist_congr_left hY₁ hY₂ hX e theorem uGhDist_congr_left {X₁ : Type u} {X₂ : Type v} {Y : Type w} [PseudoMetricSpace X₁] [PseudoMetricSpace X₂] [PseudoMetricSpace Y] [Nonempty X₁] [Nonempty X₂] [Nonempty Y] (hX₁ : BoundedSpace X₁) (hX₂ : BoundedSpace X₂) (hY : BoundedSpace Y) (e : X₁ ≃ᵢ X₂) : uGhDist X₁ Y = uGhDist X₂ Y := by have he := (ghDist_eq_zero_of_isometry hX₁ hX₂ e).2 have he' := (ghDist_eq_zero_of_isometry hX₂ hX₁ e.symm).2 have h1 := uGhDist_ultrametric X₁ X₂ Y hX₁ hX₂ hY have h2 := uGhDist_ultrametric X₂ X₁ Y hX₂ hX₁ hY have hnn1 := uGhDist_nonneg hX₁ hY have hnn2 := uGhDist_nonneg hX₂ hY rw [he, max_eq_right hnn2] at h1 rw [he', max_eq_right hnn1] at h2 exact le_antisymm h1 h2 theorem uGhDist_congr_right {X : Type u} {Y₁ : Type v} {Y₂ : Type w} [PseudoMetricSpace X] [PseudoMetricSpace Y₁] [PseudoMetricSpace Y₂] [Nonempty X] [Nonempty Y₁] [Nonempty Y₂] (hX : BoundedSpace X) (hY₁ : BoundedSpace Y₁) (hY₂ : BoundedSpace Y₂) (e : Y₁ ≃ᵢ Y₂) : uGhDist X Y₁ = uGhDist X Y₂ := by rw [uGhDist_symm X Y₁, uGhDist_symm X Y₂] exact uGhDist_congr_left hY₁ hY₂ hX e /-! ## 5. Universal Packing-Number Pigeonhole Obstructions -/ /-- **Universal Packing-Number Pigeonhole Lower Bound for `d_GH`**: if `Y` contains `N` points at pairwise distance `≥ δY` and `X` is partitioned into `M < N` pieces of diameter `≤ δX`, then EVERY correspondence `R : X ↔ Y` has `dis(R) ≥ δY - δX`. -/ theorem pigeonhole_corrDistortion_lower {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) {M N : ℕ} (hMN : M < N) {δX δY : ℝ} (c : X → Fin M) (hc : ∀ x₁ x₂ : X, c x₁ = c x₂ → dist x₁ x₂ ≤ δX) (y : Fin N → Y) (hy : ∀ i j : Fin N, i ≠ j → δY ≤ dist (y i) (y j)) (R : Correspondence X Y) : δY - δX ≤ corrDistortion R := by let x : Fin N → X := fun i => Classical.choose (R.right_total (y i)) have hx : ∀ i : Fin N, R.rel (x i) (y i) := fun i => Classical.choose_spec (R.right_total (y i)) have hnotinj : ¬ Function.Injective (fun i : Fin N => c (x i)) := by intro hinj have hcard := Fintype.card_le_of_injective _ hinj simp only [Fintype.card_fin] at hcard omega unfold Function.Injective at hnotinj push Not at hnotinj obtain ⟨i, j, heq, hne⟩ := hnotinj have hdx : dist (x i) (x j) ≤ δX := hc (x i) (x j) heq have hdy : δY ≤ dist (y i) (y j) := hy i j hne have hdis := le_corrDistortion_of_rel hX hY R (hx i) (hx j) rw [abs_le] at hdis linarith theorem pigeonhole_ghDist_lower {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] [Nonempty Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) {M N : ℕ} (hMN : M < N) {δX δY : ℝ} (c : X → Fin M) (hc : ∀ x₁ x₂ : X, c x₁ = c x₂ → dist x₁ x₂ ≤ δX) (y : Fin N → Y) (hy : ∀ i j : Fin N, i ≠ j → δY ≤ dist (y i) (y j)) : (1 / 2) * (δY - δX) ≤ ghDist X Y := le_ghDist_of_forall_corr fun R => pigeonhole_corrDistortion_lower hX hY hMN c hc y hy R /-- **Universal Packing-Number Pigeonhole Lower Bound for `u_GH`**: under the same hypotheses with `δX < δY`, EVERY correspondence `R : X ↔ Y` has `udis(R) ≥ δY`. -/ theorem pigeonhole_uCorrDistortion_lower {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) {M N : ℕ} (hMN : M < N) {δX δY : ℝ} (hδ : δX < δY) (c : X → Fin M) (hc : ∀ x₁ x₂ : X, c x₁ = c x₂ → dist x₁ x₂ ≤ δX) (y : Fin N → Y) (hy : ∀ i j : Fin N, i ≠ j → δY ≤ dist (y i) (y j)) (R : Correspondence X Y) : δY ≤ uCorrDistortion R := by let x : Fin N → X := fun i => Classical.choose (R.right_total (y i)) have hx : ∀ i : Fin N, R.rel (x i) (y i) := fun i => Classical.choose_spec (R.right_total (y i)) have hnotinj : ¬ Function.Injective (fun i : Fin N => c (x i)) := by intro hinj have hcard := Fintype.card_le_of_injective _ hinj simp only [Fintype.card_fin] at hcard omega unfold Function.Injective at hnotinj push Not at hnotinj obtain ⟨i, j, heq, hne⟩ := hnotinj have hdx : dist (x i) (x j) ≤ δX := hc (x i) (x j) heq have hdy : δY ≤ dist (y i) (y j) := hy i j hne have hdis := le_uCorrDistortion_of_rel hX hY R (hx i) (hx j) have hneq : dist (x i) (x j) ≠ dist (y i) (y j) := by linarith unfold ultraDiff at hdis rw [if_neg hneq] at hdis exact le_trans hdy (le_trans (le_max_right _ _) hdis) theorem pigeonhole_uGhDist_lower {X : Type u} {Y : Type v} [PseudoMetricSpace X] [PseudoMetricSpace Y] [Nonempty X] [Nonempty Y] (hX : BoundedSpace X) (hY : BoundedSpace Y) {M N : ℕ} (hMN : M < N) {δX δY : ℝ} (hδ : δX < δY) (c : X → Fin M) (hc : ∀ x₁ x₂ : X, c x₁ = c x₂ → dist x₁ x₂ ≤ δX) (y : Fin N → Y) (hy : ∀ i j : Fin N, i ≠ j → δY ≤ dist (y i) (y j)) : δY ≤ uGhDist X Y := le_uGhDist_of_forall_corr fun R => pigeonhole_uCorrDistortion_lower hX hY hMN hδ c hc y hy R /-! ## 6. Canonical Non-Archimedean Metric Space Families -/ /-- Valid ultrametric contraction parameter `r ∈ (0, 1)`. -/ structure UltraScale where val : ℝ pos : 0 < val lt_one : val < 1 /-- Nonnegative real radius/scaling parameter `D ≥ 0`. -/ structure NonnegRad where val : ℝ nonneg : 0 ≤ val /-- The canonical `p`-adic scale `r = 1 / p ∈ (0, 1)` for any integer base `p ≥ 2`. -/ def padicScale (p : ℕ) (hp : 2 ≤ p) : UltraScale where val := 1 / (p : ℝ) pos := by have : (0 : ℝ) < p := by exact_mod_cast (by omega : 0 < p) positivity lt_one := by have : (1 : ℝ) < p := by exact_mod_cast (by omega : 1 < p) rw [div_lt_one (by linarith)]; linarith /-! ### 6A. Regular `a`-ary Cantor Ultrametric `CantorUltra a r` (including `ℤ_p`) -/ /-- The regular `a`-ary Cantor ultrametric space `U(a, r)` with distance `r^{min {k : ω k ≠ η k}}`. For `r = 1 / p`, `CantorUltra p (padicScale p hp)` is isometric to the `p`-adic integers `ℤ_p`. -/ structure CantorUltra (a : ℕ) (r : UltraScale) where seq : ℕ → Fin a /-- Canonical `p`-adic integer ring `ℤ_p` as a compact ultrametric space. -/ abbrev PadicRing (p : ℕ) (hp : 2 ≤ p) := CantorUltra p (padicScale p hp) lemma cantor_ne_iff {a : ℕ} {r : UltraScale} {x y : CantorUltra a r} : x ≠ y ↔ ∃ k : ℕ, x.seq k ≠ y.seq k := by constructor · intro hne by_contra hall; push Not at hall apply hne; cases x; cases y; simp only [CantorUltra.mk.injEq]; ext k; exact congrArg Fin.val (hall k) · rintro ⟨k, hk⟩ heq exact hk (congrArg (fun z => z.seq k) heq) /-- Ultrametric distance on `CantorUltra a r`. -/ def cantorDist {a : ℕ} {r : UltraScale} (x y : CantorUltra a r) : ℝ := if h : ∃ k : ℕ, x.seq k ≠ y.seq k then r.val ^ (Nat.find h) else 0 lemma cantorDist_self {a : ℕ} {r : UltraScale} (x : CantorUltra a r) : cantorDist x x = 0 := by unfold cantorDist; split_ifs with h · obtain ⟨k, hk⟩ := h; exact absurd rfl hk · rfl lemma cantorDist_comm {a : ℕ} {r : UltraScale} (x y : CantorUltra a r) : cantorDist x y = cantorDist y x := by unfold cantorDist have heq : (∃ k : ℕ, x.seq k ≠ y.seq k) ↔ (∃ k : ℕ, y.seq k ≠ x.seq k) := ⟨fun ⟨k, hk⟩ => ⟨k, hk.symm⟩, fun ⟨k, hk⟩ => ⟨k, hk.symm⟩⟩ by_cases h : ∃ k : ℕ, x.seq k ≠ y.seq k · have h' := heq.mp h rw [dif_pos h, dif_pos h'] congr 1 apply le_antisymm · exact Nat.find_le (Nat.find_spec h').symm · exact Nat.find_le (Nat.find_spec h).symm · rw [dif_neg h, dif_neg (mt heq.mpr h)] lemma cantorDist_ultra {a : ℕ} {r : UltraScale} (x y z : CantorUltra a r) : cantorDist x z ≤ max (cantorDist x y) (cantorDist y z) := by unfold cantorDist by_cases hxz : ∃ k : ℕ, x.seq k ≠ z.seq k · rw [dif_pos hxz] set k := Nat.find hxz have hk : x.seq k ≠ z.seq k := Nat.find_spec hxz by_cases hxy : x.seq k ≠ y.seq k · have hex : ∃ m, x.seq m ≠ y.seq m := ⟨k, hxy⟩ rw [dif_pos hex] have hle : Nat.find hex ≤ k := Nat.find_le hxy exact le_trans (pow_le_pow_of_le_one (le_of_lt r.pos) (le_of_lt r.lt_one) hle) (le_max_left _ _) · push Not at hxy have hyz : y.seq k ≠ z.seq k := by rw [← hxy]; exact hk have hex : ∃ m, y.seq m ≠ z.seq m := ⟨k, hyz⟩ rw [dif_pos hex] have hle : Nat.find hex ≤ k := Nat.find_le hyz exact le_trans (pow_le_pow_of_le_one (le_of_lt r.pos) (le_of_lt r.lt_one) hle) (le_max_right _ _) · rw [dif_neg hxz] have hnn : 0 ≤ (if h : ∃ k, x.seq k ≠ y.seq k then r.val ^ Nat.find h else 0) := by split_ifs; exact pow_nonneg (le_of_lt r.pos) _; exact le_refl 0 exact le_trans hnn (le_max_left _ _) instance {a : ℕ} {r : UltraScale} : MetricSpace (CantorUltra a r) where dist := cantorDist dist_self := cantorDist_self dist_comm := cantorDist_comm dist_triangle := fun x y z => by have hu := cantorDist_ultra x y z have h1 : 0 ≤ cantorDist x y := by unfold cantorDist; split_ifs; exact pow_nonneg (le_of_lt r.pos) _; exact le_refl 0 have h2 : 0 ≤ cantorDist y z := by unfold cantorDist; split_ifs; exact pow_nonneg (le_of_lt r.pos) _; exact le_refl 0 exact le_trans hu (max_le (by linarith) (by linarith)) eq_of_dist_eq_zero := fun {x y} h => by by_contra hne have hex := cantor_ne_iff.mp hne change cantorDist x y = 0 at h unfold cantorDist at h rw [dif_pos hex] at h exact ne_of_gt (pow_pos r.pos _) h lemma cantorUltra_isUltra (a : ℕ) (r : UltraScale) : IsUltra (CantorUltra a r) := cantorDist_ultra lemma cantorUltra_dist_le_one {a : ℕ} {r : UltraScale} (x y : CantorUltra a r) : dist x y ≤ 1 := by change cantorDist x y ≤ 1 unfold cantorDist split_ifs · exact pow_le_one₀ (le_of_lt r.pos) (le_of_lt r.lt_one) · norm_num lemma cantorUltra_bounded (a : ℕ) (r : UltraScale) : BoundedSpace (CantorUltra a r) := ⟨1, cantorUltra_dist_le_one⟩ lemma cantorUltra_nonempty {a : ℕ} (ha : 0 < a) (r : UltraScale) : Nonempty (CantorUltra a r) := ⟨⟨fun _ => ⟨0, ha⟩⟩⟩ lemma cantorUltra_dist_le_pow_iff {a : ℕ} {r : UltraScale} {x y : CantorUltra a r} (k : ℕ) : (∀ i < k, x.seq i = y.seq i) → dist x y ≤ r.val ^ k := by intro hagree change cantorDist x y ≤ r.val ^ k unfold cantorDist split_ifs with h · have hge : k ≤ Nat.find h := by by_contra hlt; push Not at hlt exact Nat.find_spec h (hagree _ hlt) exact pow_le_pow_of_le_one (le_of_lt r.pos) (le_of_lt r.lt_one) hge · exact pow_nonneg (le_of_lt r.pos) k lemma cantorUltra_dist_ge_pow_of_ne {a : ℕ} {r : UltraScale} {x y : CantorUltra a r} {k : ℕ} (i : ℕ) (hik : i ≤ k) (hne : x.seq i ≠ y.seq i) : r.val ^ k ≤ dist x y := by change r.val ^ k ≤ cantorDist x y unfold cantorDist have hex : ∃ m, x.seq m ≠ y.seq m := ⟨i, hne⟩ rw [dif_pos hex] exact pow_le_pow_of_le_one (le_of_lt r.pos) (le_of_lt r.lt_one) (le_trans (Nat.find_le hne) hik) lemma cantorUltra_sdiam {a : ℕ} (ha : 2 ≤ a) (r : UltraScale) : sdiam (CantorUltra a r) = 1 := by have : Nonempty (CantorUltra a r) := cantorUltra_nonempty (by omega) r apply le_antisymm (sdiam_le_of_forall cantorUltra_dist_le_one) let x : CantorUltra a r := ⟨fun _ => ⟨0, by omega⟩⟩ let y : CantorUltra a r := ⟨fun _ => ⟨1, by omega⟩⟩ have h1 : r.val ^ 0 ≤ dist x y := cantorUltra_dist_ge_pow_of_ne 0 (le_refl 0) (by simp [x, y]) rw [pow_zero] at h1 exact le_trans h1 (dist_le_sdiam (cantorUltra_bounded a r) x y) /-- Encode the first `k` digits of `ω : ℕ → Fin a` as a base-`a` index in `Fin (a ^ k)`. -/ def prefixCode {a : ℕ} : (k : ℕ) → (ℕ → Fin a) → Fin (a ^ k) | 0, _ => ⟨0, by simp⟩ | k + 1, f => ⟨(prefixCode k f).val * a + (f k).val, by have h1 : (prefixCode k f).val < a ^ k := (prefixCode k f).isLt have h2 : (f k).val < a := (f k).isLt have h3 : ((prefixCode k f).val + 1) * a ≤ a ^ k * a := Nat.mul_le_mul_right a h1 calc (prefixCode k f).val * a + (f k).val < (prefixCode k f).val * a + a := by omega _ = ((prefixCode k f).val + 1) * a := by ring _ ≤ a ^ k * a := h3 _ = a ^ (k + 1) := by rw [pow_succ]⟩ lemma prefixCode_eq_iff {a : ℕ} (ha : 0 < a) : ∀ (k : ℕ) (f g : ℕ → Fin a), prefixCode k f = prefixCode k g ↔ ∀ i < k, f i = g i | 0, f, g => by simp [prefixCode] | k + 1, f, g => by constructor · intro h i hi have hval : (prefixCode k f).val * a + (f k).val = (prefixCode k g).val * a + (g k).val := congrArg Fin.val h have hfk : (f k).val < a := (f k).isLt have hgk : (g k).val < a := (g k).isLt have hq : (prefixCode k f).val = (prefixCode k g).val := by have h1 := congrArg (· / a) hval rw [mul_comm (prefixCode k f).val a, mul_comm (prefixCode k g).val a, Nat.mul_add_div ha, Nat.mul_add_div ha, Nat.div_eq_of_lt hfk, Nat.div_eq_of_lt hgk] at h1 omega have hr : (f k).val = (g k).val := by have h1 := congrArg (· % a) hval rw [Nat.mul_add_mod_self_right, Nat.mul_add_mod_self_right, Nat.mod_eq_of_lt hfk, Nat.mod_eq_of_lt hgk] at h1 exact h1 by_cases hik : i < k · exact (prefixCode_eq_iff ha k f g).mp (Fin.ext hq) i hik · have : i = k := by omega subst this; exact Fin.ext hr · intro hall apply Fin.ext have hprev : prefixCode k f = prefixCode k g := (prefixCode_eq_iff ha k f g).mpr (fun i hi => hall i (by omega)) have hcur : f k = g k := hall k (Nat.lt_succ_self k) simp [prefixCode, hprev, hcur] /-- Decode an index `n : Fin (a ^ k)` into its `k` base-`a` digits (padded with `0` for `i ≥ k`). -/ def prefixDecode {a : ℕ} (ha : 0 < a) : (k : ℕ) → Fin (a ^ k) → (ℕ → Fin a) | 0, _ => fun _ => ⟨0, ha⟩ | k + 1, n => let q : Fin (a ^ k) := ⟨n.val / a, by have hn : n.val < a ^ k * a := by simpa [pow_succ] using n.isLt exact Nat.div_lt_of_lt_mul (by rwa [mul_comm])⟩ let rem : Fin a := ⟨n.val % a, Nat.mod_lt _ ha⟩ fun i => if i = k then rem else prefixDecode ha k q i lemma prefixCode_prefixDecode {a : ℕ} (ha : 0 < a) : ∀ (k : ℕ) (n : Fin (a ^ k)), prefixCode k (prefixDecode ha k n) = n | 0, n => Fin.ext (by have h := n.isLt; simp only [prefixCode, pow_zero] at h ⊢; omega) | k + 1, n => by apply Fin.ext have hq_lt : n.val / a < a ^ k := by have hn : n.val < a ^ k * a := by simpa [pow_succ] using n.isLt exact Nat.div_lt_of_lt_mul (by rwa [mul_comm]) let q : Fin (a ^ k) := ⟨n.val / a, hq_lt⟩ change (prefixCode k (fun i => if i = k then ⟨n.val % a, Nat.mod_lt _ ha⟩ else prefixDecode ha k q i)).val * a + (if k = k then (⟨n.val % a, Nat.mod_lt _ ha⟩ : Fin a) else prefixDecode ha k q k).val = n.val have heq_prev : prefixCode k (fun i => if i = k then ⟨n.val % a, Nat.mod_lt _ ha⟩ else prefixDecode ha k q i) = prefixCode k (prefixDecode ha k q) := by rw [prefixCode_eq_iff ha k] intro i hi; simp [ne_of_lt hi] rw [heq_prev, prefixCode_prefixDecode ha k] simp only [ite_true] have hdiv := Nat.div_add_mod n.val a dsimp only [q] linarith [mul_comm a (n.val / a)] /-- Exact level-`k` ball partition of `CantorUltra a r` into `a ^ k` balls of diameter `≤ r ^ k`. -/ def cantorBallCode {a : ℕ} {r : UltraScale} (k : ℕ) (x : CantorUltra a r) : Fin (a ^ k) := prefixCode k x.seq lemma cantorBallCode_dist_le {a : ℕ} (ha : 0 < a) {r : UltraScale} (k : ℕ) {x y : CantorUltra a r} (h : cantorBallCode k x = cantorBallCode k y) : dist x y ≤ r.val ^ k := cantorUltra_dist_le_pow_iff k ((prefixCode_eq_iff ha k x.seq y.seq).mp h) /-- Exact `a ^ (k + 1)` points in `CantorUltra a r` at pairwise distance `≥ r ^ k`. -/ def cantorNet {a : ℕ} (ha : 0 < a) (r : UltraScale) (k : ℕ) (n : Fin (a ^ (k + 1))) : CantorUltra a r := ⟨prefixDecode ha (k + 1) n⟩ lemma cantorNet_dist_ge {a : ℕ} (ha : 0 < a) (r : UltraScale) (k : ℕ) {i j : Fin (a ^ (k + 1))} (hne : i ≠ j) : r.val ^ k ≤ dist (cantorNet ha r k i) (cantorNet ha r k j) := by have hcode : prefixCode (k + 1) (cantorNet ha r k i).seq ≠ prefixCode (k + 1) (cantorNet ha r k j).seq := by dsimp only [cantorNet] rw [prefixCode_prefixDecode ha (k + 1) i, prefixCode_prefixDecode ha (k + 1) j] exact hne have hex : ∃ t < k + 1, (cantorNet ha r k i).seq t ≠ (cantorNet ha r k j).seq t := by by_contra hall; push Not at hall exact hcode ((prefixCode_eq_iff ha (k + 1) _ _).mpr hall) obtain ⟨t, ht, hneq⟩ := hex exact cantorUltra_dist_ge_pow_of_ne t (by omega) hneq /-! ### 6B. Finite-Depth Regular Ultrametric `FinUltra a r m` (including `ℤ / p^m ℤ`) -/ /-- Finite-depth regular `a`-ary ultrametric `U_m(a, r)` (modeling `ℤ / p^m ℤ` with `p`-adic metric). -/ structure FinUltra (a : ℕ) (r : UltraScale) (m : ℕ) where digits : Fin m → Fin a /-- Canonical finite `p`-adic quotient `ℤ / p^m ℤ` with the `p`-adic ultrametric. -/ abbrev PadicQuot (p : ℕ) (hp : 2 ≤ p) (m : ℕ) := FinUltra p (padicScale p hp) m /-- Isometric embedding of `FinUltra a r m` into `CantorUltra a r` (zero-padded beyond `m` when `a > 0`). -/ def finUltraDist {a : ℕ} {r : UltraScale} {m : ℕ} (x y : FinUltra a r m) : ℝ := if h : ∃ k : ℕ, ∃ hk : k < m, x.digits ⟨k, hk⟩ ≠ y.digits ⟨k, hk⟩ then r.val ^ (Nat.find h) else 0 lemma finUltraDist_self {a : ℕ} {r : UltraScale} {m : ℕ} (x : FinUltra a r m) : finUltraDist x x = 0 := by unfold finUltraDist; split_ifs with h · obtain ⟨_, _, hk⟩ := h; exact absurd rfl hk · rfl lemma finUltraDist_comm {a : ℕ} {r : UltraScale} {m : ℕ} (x y : FinUltra a r m) : finUltraDist x y = finUltraDist y x := by unfold finUltraDist have heq : (∃ k, ∃ hk : k < m, x.digits ⟨k, hk⟩ ≠ y.digits ⟨k, hk⟩) ↔ (∃ k, ∃ hk : k < m, y.digits ⟨k, hk⟩ ≠ x.digits ⟨k, hk⟩) := ⟨fun ⟨k, hk, h⟩ => ⟨k, hk, h.symm⟩, fun ⟨k, hk, h⟩ => ⟨k, hk, h.symm⟩⟩ by_cases h : ∃ k, ∃ hk : k < m, x.digits ⟨k, hk⟩ ≠ y.digits ⟨k, hk⟩ · have h' := heq.mp h rw [dif_pos h, dif_pos h'] congr 1 apply le_antisymm · obtain ⟨hk, hne⟩ := Nat.find_spec h'; exact Nat.find_le ⟨hk, hne.symm⟩ · obtain ⟨hk, hne⟩ := Nat.find_spec h; exact Nat.find_le ⟨hk, hne.symm⟩ · rw [dif_neg h, dif_neg (mt heq.mpr h)] lemma finUltraDist_ultra {a : ℕ} {r : UltraScale} {m : ℕ} (x y z : FinUltra a r m) : finUltraDist x z ≤ max (finUltraDist x y) (finUltraDist y z) := by unfold finUltraDist by_cases hxz : ∃ k, ∃ hk : k < m, x.digits ⟨k, hk⟩ ≠ z.digits ⟨k, hk⟩ · rw [dif_pos hxz] set k := Nat.find hxz obtain ⟨hk, hne⟩ := Nat.find_spec hxz by_cases hxy : x.digits ⟨k, hk⟩ ≠ y.digits ⟨k, hk⟩ · have hex : ∃ t, ∃ ht : t < m, x.digits ⟨t, ht⟩ ≠ y.digits ⟨t, ht⟩ := ⟨k, hk, hxy⟩ rw [dif_pos hex] exact le_trans (pow_le_pow_of_le_one (le_of_lt r.pos) (le_of_lt r.lt_one) (Nat.find_le ⟨hk, hxy⟩)) (le_max_left _ _) · push Not at hxy have hyz : y.digits ⟨k, hk⟩ ≠ z.digits ⟨k, hk⟩ := by rw [← hxy]; exact hne have hex : ∃ t, ∃ ht : t < m, y.digits ⟨t, ht⟩ ≠ z.digits ⟨t, ht⟩ := ⟨k, hk, hyz⟩ rw [dif_pos hex] exact le_trans (pow_le_pow_of_le_one (le_of_lt r.pos) (le_of_lt r.lt_one) (Nat.find_le ⟨hk, hyz⟩)) (le_max_right _ _) · rw [dif_neg hxz] have hnn : 0 ≤ (if h : ∃ k, ∃ hk : k < m, x.digits ⟨k, hk⟩ ≠ y.digits ⟨k, hk⟩ then r.val ^ Nat.find h else 0) := by split_ifs; exact pow_nonneg (le_of_lt r.pos) _; exact le_refl 0 exact le_trans hnn (le_max_left _ _) instance {a : ℕ} {r : UltraScale} {m : ℕ} : MetricSpace (FinUltra a r m) where dist := finUltraDist dist_self := finUltraDist_self dist_comm := finUltraDist_comm dist_triangle := fun x y z => by have hu := finUltraDist_ultra x y z have h1 : 0 ≤ finUltraDist x y := by unfold finUltraDist; split_ifs; exact pow_nonneg (le_of_lt r.pos) _; exact le_refl 0 have h2 : 0 ≤ finUltraDist y z := by unfold finUltraDist; split_ifs; exact pow_nonneg (le_of_lt r.pos) _; exact le_refl 0 exact le_trans hu (max_le (by linarith) (by linarith)) eq_of_dist_eq_zero := fun {x y} h => by by_contra hne have hex : ∃ k, ∃ hk : k < m, x.digits ⟨k, hk⟩ ≠ y.digits ⟨k, hk⟩ := by by_contra hall; push Not at hall apply hne; cases x; cases y; simp only [FinUltra.mk.injEq]; ext ⟨k, hk⟩; exact congrArg Fin.val (hall k hk) change finUltraDist x y = 0 at h unfold finUltraDist at h rw [dif_pos hex] at h exact ne_of_gt (pow_pos r.pos _) h lemma finUltra_isUltra (a : ℕ) (r : UltraScale) (m : ℕ) : IsUltra (FinUltra a r m) := finUltraDist_ultra lemma finUltra_dist_le_one {a : ℕ} {r : UltraScale} {m : ℕ} (x y : FinUltra a r m) : dist x y ≤ 1 := by change finUltraDist x y ≤ 1 unfold finUltraDist split_ifs · exact pow_le_one₀ (le_of_lt r.pos) (le_of_lt r.lt_one) · norm_num lemma finUltra_bounded (a : ℕ) (r : UltraScale) (m : ℕ) : BoundedSpace (FinUltra a r m) := ⟨1, finUltra_dist_le_one⟩ lemma finUltra_nonempty {a : ℕ} (ha : 0 < a) (r : UltraScale) (m : ℕ) : Nonempty (FinUltra a r m) := ⟨⟨fun _ => ⟨0, ha⟩⟩⟩ /-! ### 6C. Equilateral Ultrametric `Equilateral n D`, Discrete Ultrametric & Metric Rescaling -/ /-- The `n`-point equilateral ultrametric `Δ_n(D)` with all distinct pairs at distance `D`. -/ structure Equilateral (n : ℕ) (D : NonnegRad) where idx : Fin n instance {n : ℕ} {D : NonnegRad} : PseudoMetricSpace (Equilateral n D) where dist := fun x y => if x.idx = y.idx then 0 else D.val dist_self := fun x => by simp dist_comm := fun x y => by by_cases h : x.idx = y.idx <;> simp [h, eq_comm] dist_triangle := fun x y z => by by_cases hxz : x.idx = z.idx · simp only [hxz, ite_true] split_ifs <;> linarith [D.nonneg] · simp only [hxz, ite_false] by_cases hxy : x.idx = y.idx · have hyz : y.idx ≠ z.idx := by rw [← hxy]; exact hxz simp [hxy, hyz] · simp only [hxy, ite_false] split_ifs <;> linarith [D.nonneg] lemma equilateral_isUltra (n : ℕ) (D : NonnegRad) : IsUltra (Equilateral n D) := by intro x y z change (if x.idx = z.idx then 0 else D.val) ≤ max (if x.idx = y.idx then 0 else D.val) (if y.idx = z.idx then 0 else D.val) by_cases hxz : x.idx = z.idx · rw [if_pos hxz] have h1 : 0 ≤ (if x.idx = y.idx then (0 : ℝ) else D.val) := by split_ifs; exact le_refl 0; exact D.nonneg exact le_trans h1 (le_max_left _ _) · rw [if_neg hxz] by_cases hxy : x.idx = y.idx · have hyz : y.idx ≠ z.idx := by rw [← hxy]; exact hxz rw [if_pos hxy, if_neg hyz]; exact le_max_right _ _ · rw [if_neg hxy]; exact le_max_left _ _ lemma equilateral_bounded (n : ℕ) (D : NonnegRad) : BoundedSpace (Equilateral n D) := ⟨D.val, fun x y => by change (if x.idx = y.idx then 0 else D.val) ≤ D.val; split_ifs; exact D.nonneg; exact le_refl _⟩ lemma equilateral_sdiam {n : ℕ} (hn : 2 ≤ n) (D : NonnegRad) : sdiam (Equilateral n D) = D.val := by have : Nonempty (Equilateral n D) := ⟨⟨⟨0, by omega⟩⟩⟩ apply le_antisymm (sdiam_le_of_forall (fun x y => by change (if x.idx = y.idx then 0 else D.val) ≤ D.val; split_ifs; exact D.nonneg; exact le_refl _)) let x : Equilateral n D := ⟨⟨0, by omega⟩⟩ let y : Equilateral n D := ⟨⟨1, by omega⟩⟩ have hd : dist x y = D.val := by change (if x.idx = y.idx then 0 else D.val) = D.val; simp [x, y] rw [← hd] exact dist_le_sdiam (equilateral_bounded n D) x y /-- The `D`-discrete ultrametric on an arbitrary carrier `X`: `d(x, y) = 0` if `x = y`, else `D`. -/ structure DiscreteUltra (X : Type u) (D : NonnegRad) where pt : X instance {X : Type u} {D : NonnegRad} : PseudoMetricSpace (DiscreteUltra X D) where dist := fun x y => if x.pt = y.pt then 0 else D.val dist_self := fun x => by simp dist_comm := fun x y => by by_cases h : x.pt = y.pt <;> simp [h, eq_comm] dist_triangle := fun x y z => by by_cases hxz : x.pt = z.pt · simp only [hxz, ite_true] split_ifs <;> linarith [D.nonneg] · simp only [hxz, ite_false] by_cases hxy : x.pt = y.pt · have hyz : y.pt ≠ z.pt := by rw [← hxy]; exact hxz simp [hxy, hyz] · simp only [hxy, ite_false] split_ifs <;> linarith [D.nonneg] lemma discreteUltra_isUltra (X : Type u) (D : NonnegRad) : IsUltra (DiscreteUltra X D) := by intro x y z change (if x.pt = z.pt then 0 else D.val) ≤ max (if x.pt = y.pt then 0 else D.val) (if y.pt = z.pt then 0 else D.val) by_cases hxz : x.pt = z.pt · rw [if_pos hxz] have h1 : 0 ≤ (if x.pt = y.pt then (0 : ℝ) else D.val) := by split_ifs; exact le_refl 0; exact D.nonneg exact le_trans h1 (le_max_left _ _) · rw [if_neg hxz] by_cases hxy : x.pt = y.pt · have hyz : y.pt ≠ z.pt := by rw [← hxy]; exact hxz rw [if_pos hxy, if_neg hyz]; exact le_max_right _ _ · rw [if_neg hxy]; exact le_max_left _ _ lemma discreteUltra_bounded (X : Type u) (D : NonnegRad) : BoundedSpace (DiscreteUltra X D) := ⟨D.val, fun x y => by change (if x.pt = y.pt then 0 else D.val) ≤ D.val; split_ifs; exact D.nonneg; exact le_refl _⟩ /-- Rescaling a pseudometric space `X` by a factor `c ≥ 0` (modeling `p^k ℤ_p` via `c = p^{-k}`). -/ structure ScaleMetric (X : Type u) (c : NonnegRad) where pt : X instance {X : Type u} [PseudoMetricSpace X] {c : NonnegRad} : PseudoMetricSpace (ScaleMetric X c) where dist := fun x y => c.val * dist x.pt y.pt dist_self := fun x => by simp dist_comm := fun x y => by rw [dist_comm] dist_triangle := fun x y z => by calc c.val * dist x.pt z.pt ≤ c.val * (dist x.pt y.pt + dist y.pt z.pt) := mul_le_mul_of_nonneg_left (dist_triangle _ _ _) c.nonneg _ = c.val * dist x.pt y.pt + c.val * dist y.pt z.pt := mul_add _ _ _ lemma scaleMetric_isUltra {X : Type u} [PseudoMetricSpace X] (hU : IsUltra X) (c : NonnegRad) : IsUltra (ScaleMetric X c) := fun x y z => by change c.val * dist x.pt z.pt ≤ max (c.val * dist x.pt y.pt) (c.val * dist y.pt z.pt) rw [← mul_max_of_nonneg _ _ c.nonneg] exact mul_le_mul_of_nonneg_left (hU x.pt y.pt z.pt) c.nonneg lemma scaleMetric_bounded {X : Type u} [PseudoMetricSpace X] (hX : BoundedSpace X) (c : NonnegRad) : BoundedSpace (ScaleMetric X c) := by obtain ⟨M, hM⟩ := hX exact ⟨c.val * M, fun x y => mul_le_mul_of_nonneg_left (hM x.pt y.pt) c.nonneg⟩ lemma scaleMetric_sdiam {X : Type u} [PseudoMetricSpace X] [Nonempty X] (hX : BoundedSpace X) (c : NonnegRad) : sdiam (ScaleMetric X c) = c.val * sdiam X := by have : Nonempty (ScaleMetric X c) := ⟨⟨Classical.arbitrary X⟩⟩ apply le_antisymm · refine sdiam_le_of_forall fun x y => ?_ exact mul_le_mul_of_nonneg_left (dist_le_sdiam hX x.pt y.pt) c.nonneg · by_cases hc : c.val = 0 · rw [hc, zero_mul]; exact sdiam_nonneg (scaleMetric_bounded hX c) · have hc_pos : 0 < c.val := lt_of_le_of_ne c.nonneg (Ne.symm hc) refine le_of_forall_pos_le_add fun ε hε => ?_ obtain ⟨x, y, hxy⟩ := exists_dist_gt_sdiam_sub hX (div_pos hε hc_pos) have h1 : dist (ScaleMetric.mk (c := c) x) (ScaleMetric.mk (c := c) y) ≤ sdiam (ScaleMetric X c) := dist_le_sdiam (scaleMetric_bounded hX c) _ _ change c.val * dist x y ≤ sdiam (ScaleMetric X c) at h1 have h2 : c.val * (sdiam X - ε / c.val) < c.val * dist x y := mul_lt_mul_of_pos_left hxy hc_pos have h3 : c.val * (sdiam X - ε / c.val) = c.val * sdiam X - ε := by rw [mul_sub, mul_div_cancel₀ _ (ne_of_gt hc_pos)] linarith /-- The `p`-adic ideal `p^k ℤ_p` as a rescaled compact ultrametric space of diameter `p^{-k}`. -/ def padicIdealRad (p : ℕ) (k : ℕ) : NonnegRad where val := (1 / (p : ℝ)) ^ k nonneg := pow_nonneg (by positivity) k abbrev PadicIdeal (p : ℕ) (hp : 2 ≤ p) (k : ℕ) := ScaleMetric (PadicRing p hp) (padicIdealRad p k) lemma padicIdeal_sdiam {p : ℕ} (hp : 2 ≤ p) (k : ℕ) : sdiam (PadicIdeal p hp k) = (1 / (p : ℝ)) ^ k := by have : Nonempty (PadicRing p hp) := cantorUltra_nonempty (by omega) _ rw [scaleMetric_sdiam (cantorUltra_bounded p _) _, cantorUltra_sdiam hp _, mul_one] rfl /-! ## 7. Universal Connected-to-Ultrametric Rigidity & Distance to the Ultrametric Moduli Space -/ /-- Connectedness separation lemma: if `A₁ ∪ A₂ = univ` in a connected pseudometric space `X` with both `A₁, A₂` nonempty, then for every `η > 0` there exist `x₁ ∈ A₁, x₂ ∈ A₂` with `dist x₁ x₂ < η`. -/ lemma connected_exists_close_pair {X : Type v} [PseudoMetricSpace X] [ConnectedSpace X] {A₁ A₂ : Set X} (h₁ : A₁.Nonempty) (h₂ : A₂.Nonempty) (hcov : A₁ ∪ A₂ = Set.univ) {η : ℝ} (hη : 0 < η) : ∃ x₁ ∈ A₁, ∃ x₂ ∈ A₂, dist x₁ x₂ < η := by by_contra hall push Not at hall have hopen1 : IsOpen A₁ := by rw [Metric.isOpen_iff] intro x₁ hx₁ refine ⟨η, hη, fun z hz => ?_⟩ by_contra hz1 have hz2 : z ∈ A₂ := by have : z ∈ A₁ ∪ A₂ := by rw [hcov]; trivial exact this.resolve_left hz1 have hfar := hall x₁ hx₁ z hz2 have hlt : dist x₁ z < η := by rw [dist_comm]; exact Metric.mem_ball.mp hz linarith have hopen2 : IsOpen A₂ := by rw [Metric.isOpen_iff] intro x₂ hx₂ refine ⟨η, hη, fun z hz => ?_⟩ by_contra hz2 have hz1 : z ∈ A₁ := by have : z ∈ A₁ ∪ A₂ := by rw [hcov]; trivial exact this.resolve_right hz2 have hfar := hall z hz1 x₂ hx₂ have hlt : dist z x₂ < η := Metric.mem_ball.mp hz linarith have hne := isPreconnected_univ A₁ A₂ hopen1 hopen2 (by rw [hcov]) (by simpa using h₁) (by simpa using h₂) obtain ⟨x, _, hx1, hx2⟩ := hne have hfar := hall x hx1 x hx2 rw [dist_self] at hfar linarith /-- Core ultrametric-vs-connected lower bound: EVERY correspondence between a bounded ultrametric space `U` and a connected bounded space `X` has distortion `≥ sdiam U`. -/ theorem corrDistortion_ultrametric_connected_ge_sdiam {U : Type u} {X : Type v} [PseudoMetricSpace U] [PseudoMetricSpace X] [Nonempty U] [ConnectedSpace X] (hU_ultra : IsUltra U) (hU : BoundedSpace U) (hX : BoundedSpace X) (R : Correspondence U X) : sdiam U ≤ corrDistortion R := by by_cases hD : sdiam U ≤ 0 · exact le_trans hD (corrDistortion_nonneg hU hX R) · push Not at hD refine le_of_forall_pos_le_add fun ε hε => ?_ set ε' := min (ε / 2) (sdiam U / 2) have hε' : 0 < ε' := lt_min (by linarith) (by linarith) obtain ⟨u₀, u₁, hu⟩ := exists_dist_gt_sdiam_sub hU hε' set δ := dist u₀ u₁ have hδ_pos : 0 < δ := by have : ε' ≤ sdiam U / 2 := min_le_right _ _ linarith set B : Set U := {u : U | dist u u₀ < δ} set Bc : Set U := Bᶜ have hu₀ : u₀ ∈ B := by show dist u₀ u₀ < δ; rw [dist_self]; exact hδ_pos have hu₁ : u₁ ∈ Bc := by show ¬ (dist u₁ u₀ < δ); rw [dist_comm]; exact lt_irrefl _ have hsep : ∀ u ∈ B, ∀ v ∈ Bc, δ ≤ dist u v := by intro u huB v hvBc by_contra hlt; push Not at hlt apply hvBc show dist v u₀ < δ have htri := hU_ultra v u u₀ rw [dist_comm v u] at htri exact lt_of_le_of_lt htri (max_lt hlt huB) set A₁ : Set X := {x : X | ∃ u ∈ B, R.rel u x} set A₂ : Set X := {x : X | ∃ v ∈ Bc, R.rel v x} obtain ⟨x₀, hx₀⟩ := R.left_total u₀ obtain ⟨x₁, hx₁⟩ := R.left_total u₁ have hA₁ : A₁.Nonempty := ⟨x₀, u₀, hu₀, hx₀⟩ have hA₂ : A₂.Nonempty := ⟨x₁, u₁, hu₁, hx₁⟩ have hcov : A₁ ∪ A₂ = Set.univ := by ext x; simp only [mem_union, mem_univ, iff_true] obtain ⟨u, huR⟩ := R.right_total x by_cases huB : u ∈ B · left; exact ⟨u, huB, huR⟩ · right; exact ⟨u, huB, huR⟩ obtain ⟨a, haA₁, b, hbA₂, hab⟩ := connected_exists_close_pair hA₁ hA₂ hcov (by linarith : 0 < ε / 2) obtain ⟨u, huB, huR⟩ := haA₁ obtain ⟨v, hvBc, hvR⟩ := hbA₂ have hduv : δ ≤ dist u v := hsep u huB v hvBc have hdis := le_corrDistortion_of_rel hU hX R huR hvR rw [abs_le] at hdis have hε'le : ε' ≤ ε / 2 := min_le_left _ _ linarith /-- **Theorem 1 — Universal Connected-to-Ultrametric Gromov–Hausdorff Rigidity**: for EVERY bounded ultrametric space `U` of diameter `D` and EVERY connected bounded metric space `X` of diameter `L`, `d_GH(U, X) ≥ (1/2) max(D, L - D) ≥ L / 4`. -/ theorem ghDist_ultrametric_connected_ge {U : Type u} {X : Type v} [PseudoMetricSpace U] [PseudoMetricSpace X] [Nonempty U] [ConnectedSpace X] (hU_ultra : IsUltra U) (hU : BoundedSpace U) (hX : BoundedSpace X) : (1 / 2) * max (sdiam U) (sdiam X - sdiam U) ≤ ghDist U X ∧ sdiam X / 4 ≤ ghDist U X := by have h1 : (1 / 2) * sdiam U ≤ ghDist U X := le_ghDist_of_forall_corr fun R => corrDistortion_ultrametric_connected_ge_sdiam hU_ultra hU hX R have h2 := abs_sdiam_sub_le_two_ghDist U X hU hX rw [abs_le] at h2 have hmax : (1 / 2) * max (sdiam U) (sdiam X - sdiam U) ≤ ghDist U X := by rw [mul_max_of_nonneg _ _ (by norm_num)] exact max_le h1 (by linarith) refine ⟨hmax, ?_⟩ have h3 : sdiam X / 2 ≤ max (sdiam U) (sdiam X - sdiam U) := by rcases le_total (sdiam U) (sdiam X / 2) with h | h · exact le_trans (by linarith) (le_max_right _ _) · exact le_trans h (le_max_left _ _) linarith /-- Exact attainment of `d_GH(X, DiscreteUltra X (L/2)) = L / 4` for ANY connected bounded space `X`. -/ theorem ghDist_connected_discreteUltra {X : Type u} [PseudoMetricSpace X] [ConnectedSpace X] (hX : BoundedSpace X) : let D : NonnegRad := ⟨sdiam X / 2, div_nonneg (sdiam_nonneg hX) (by norm_num)⟩ ghDist X (DiscreteUltra X D) = sdiam X / 4 := by intro D have : Nonempty (DiscreteUltra X D) := ⟨⟨Classical.arbitrary X⟩⟩ apply le_antisymm · let R : Correspondence X (DiscreteUltra X D) := { rel := fun x u => u.pt = x left_total := fun x => ⟨⟨x⟩, rfl⟩ right_total := fun u => ⟨u.pt, rfl⟩ } have hdis : corrDistortion R ≤ sdiam X / 2 := by refine corrDistortion_le_of_forall R fun x₁ x₂ u₁ u₂ h₁ h₂ => ?_ change |dist x₁ x₂ - (if u₁.pt = u₂.pt then 0 else D.val)| ≤ sdiam X / 2 rw [h₁, h₂] by_cases heq : x₁ = x₂ · subst heq; simp; exact div_nonneg (sdiam_nonneg hX) (by norm_num) · rw [if_neg heq, abs_le] have h0 := dist_nonneg (x := x₁) (y := x₂) have hL := dist_le_sdiam hX x₁ x₂ dsimp only [D] constructor <;> linarith have hle := ghDist_le_of_corr hX (discreteUltra_bounded X D) R linarith · rw [ghDist_symm] exact (ghDist_ultrametric_connected_ge (discreteUltra_isUltra X D) (discreteUltra_bounded X D) hX).2 /-- **Theorem 2 — Exact Distance to the Entire Moduli Space of Ultrametrics**: for EVERY connected bounded pseudometric space `X : Type u` of diameter `L`, `inf {d_GH(X, U) | U ultrametric} = L / 4`. -/ theorem ghDist_to_ultrametrics_eq {X : Type u} [PseudoMetricSpace X] [ConnectedSpace X] (hX : BoundedSpace X) : sInf {c : ℝ | ∃ (U : Type u) (_ : PseudoMetricSpace U) (_ : Nonempty U), IsUltra U ∧ BoundedSpace U ∧ ghDist X U = c} = sdiam X / 4 := by let D : NonnegRad := ⟨sdiam X / 2, div_nonneg (sdiam_nonneg hX) (by norm_num)⟩ have hmem : sdiam X / 4 ∈ {c : ℝ | ∃ (U : Type u) (_ : PseudoMetricSpace U) (_ : Nonempty U), IsUltra U ∧ BoundedSpace U ∧ ghDist X U = c} := ⟨DiscreteUltra X D, inferInstance, ⟨⟨Classical.arbitrary X⟩⟩, discreteUltra_isUltra X D, discreteUltra_bounded X D, ghDist_connected_discreteUltra hX⟩ have hlb : ∀ c ∈ {c : ℝ | ∃ (U : Type u) (_ : PseudoMetricSpace U) (_ : Nonempty U), IsUltra U ∧ BoundedSpace U ∧ ghDist X U = c}, sdiam X / 4 ≤ c := by rintro _ ⟨U, _, _, hU_ultra, hU_bdd, rfl⟩ rw [ghDist_symm] exact (ghDist_ultrametric_connected_ge hU_ultra hU_bdd hX).2 exact le_antisymm (csInf_le ⟨sdiam X / 4, hlb⟩ hmem) (le_csInf ⟨_, hmem⟩ hlb) /-- Finite equilateral upper bound from an `n`-cover of `X` with piece diameter `≤ ρ`. -/ lemma ghDist_equilateral_le_of_cover {X : Type u} [PseudoMetricSpace X] [Nonempty X] (hX : BoundedSpace X) {n : ℕ} (hn : 1 ≤ n) (D : NonnegRad) {ρ : ℝ} (f : X → Fin n) (hsurj : Function.Surjective f) (hρ : ∀ x₁ x₂ : X, f x₁ = f x₂ → dist x₁ x₂ ≤ ρ) : ghDist (Equilateral n D) X ≤ (1 / 2) * max (max D.val ρ) (sdiam X - D.val) := by have : Nonempty (Equilateral n D) := ⟨⟨⟨0, by omega⟩⟩⟩ let R : Correspondence (Equilateral n D) X := { rel := fun u x => f x = u.idx left_total := fun u => hsurj u.idx right_total := fun x => ⟨⟨f x⟩, rfl⟩ } have hdis : corrDistortion R ≤ max (max D.val ρ) (sdiam X - D.val) := by refine corrDistortion_le_of_forall R fun u₁ u₂ x₁ x₂ h₁ h₂ => ?_ change |(if u₁.idx = u₂.idx then 0 else D.val) - dist x₁ x₂| ≤ max (max D.val ρ) (sdiam X - D.val) by_cases heq : u₁.idx = u₂.idx · rw [if_pos heq, zero_sub, abs_neg, abs_of_nonneg dist_nonneg] have hfx : f x₁ = f x₂ := by rw [h₁, h₂, heq] exact le_trans (hρ x₁ x₂ hfx) (le_trans (le_max_right D.val ρ) (le_max_left _ _)) · rw [if_neg heq, abs_le] have h0 := dist_nonneg (x := x₁) (y := x₂) have hL := dist_le_sdiam hX x₁ x₂ constructor · linarith [le_max_right (max D.val ρ) (sdiam X - D.val)] · linarith [le_trans (le_max_left D.val ρ) (le_max_left (max D.val ρ) (sdiam X - D.val))] have hle := ghDist_le_of_corr (equilateral_bounded n D) hX R linarith /-! ## 8. Exact Closed Form for ALL Attained-Diameter Ultrametrics vs `[0, L]` -/ /-- Closed real interval `[0, L]` as a connected bounded pseudometric space of diameter `L`. -/ abbrev ClosedInterval (L : NonnegRad) := Set.Icc (0 : ℝ) L.val lemma closedInterval_connected (L : NonnegRad) : ConnectedSpace (ClosedInterval L) := by have hconn : IsConnected (Set.Icc (0 : ℝ) L.val) := isConnected_Icc L.nonneg exact Subtype.connectedSpace hconn lemma closedInterval_bounded (L : NonnegRad) : BoundedSpace (ClosedInterval L) := by refine ⟨L.val, fun x y => ?_⟩ rw [Subtype.dist_eq, Real.dist_eq, abs_le] rcases x.property with ⟨hx0, hxL⟩ rcases y.property with ⟨hy0, hyL⟩ constructor <;> linarith lemma closedInterval_sdiam (L : NonnegRad) : sdiam (ClosedInterval L) = L.val := by have : Nonempty (ClosedInterval L) := ⟨⟨0, le_refl 0, L.nonneg⟩⟩ apply le_antisymm · refine sdiam_le_of_forall fun x y => ?_ rw [Subtype.dist_eq, Real.dist_eq, abs_le] rcases x.property with ⟨hx0, hxL⟩ rcases y.property with ⟨hy0, hyL⟩ constructor <;> linarith · let a : ClosedInterval L := ⟨0, le_refl 0, L.nonneg⟩ let b : ClosedInterval L := ⟨L.val, L.nonneg, le_refl L.val⟩ have hd : dist a b = L.val := by rw [Subtype.dist_eq, Real.dist_eq]; dsimp only [a, b] rw [zero_sub, abs_neg, abs_of_nonneg L.nonneg] rw [← hd] exact dist_le_sdiam (closedInterval_bounded L) a b /-- **Theorem 3 — Exact Gromov–Hausdorff Distance between ANY Attained-Diameter Ultrametric Space and `[0, L]`**: `d_GH(U, [0, L]) = (1/2) max(diam(U), L - diam(U))`. -/ theorem ghDist_ultrametric_Icc {U : Type u} [PseudoMetricSpace U] [Nonempty U] (hU_ultra : IsUltra U) (hU : BoundedSpace U) (hatt : ∃ u₀ u₁ : U, dist u₀ u₁ = sdiam U) (L : NonnegRad) : ghDist U (ClosedInterval L) = (1 / 2) * max (sdiam U) (L.val - sdiam U) := by have : ConnectedSpace (ClosedInterval L) := closedInterval_connected L have hX := closedInterval_bounded L have hL := closedInterval_sdiam L apply le_antisymm · by_cases hD0 : sdiam U = 0 · have hle := ghDist_le_half_max_sdiam U (ClosedInterval L) hU hX rw [hD0, hL] at hle rw [hD0, sub_zero] exact hle · have hD_pos : 0 < sdiam U := lt_of_le_of_ne (sdiam_nonneg hU) (Ne.symm hD0) obtain ⟨u₀, u₁, hu₀₁⟩ := hatt set B : Set U := {u : U | dist u u₀ < sdiam U} set Bc : Set U := Bᶜ have hu₀ : u₀ ∈ B := by show dist u₀ u₀ < sdiam U; rw [dist_self]; exact hD_pos have hu₁ : u₁ ∈ Bc := by show ¬ (dist u₁ u₀ < sdiam U); rw [dist_comm, hu₀₁]; exact lt_irrefl _ have hsep : ∀ u ∈ B, ∀ v ∈ Bc, dist u v = sdiam U := by intro u huB v hvBc apply le_antisymm (dist_le_sdiam hU u v) by_contra hlt; push Not at hlt apply hvBc show dist v u₀ < sdiam U have htri := hU_ultra v u u₀ rw [dist_comm v u] at htri exact lt_of_le_of_lt htri (max_lt hlt huB) let t0 : ClosedInterval L := ⟨0, le_refl 0, L.nonneg⟩ let t1 : ClosedInterval L := ⟨L.val, L.nonneg, le_refl L.val⟩ let R : Correspondence U (ClosedInterval L) := { rel := fun u t => (u ∈ B ∧ t.val ≤ L.val / 2) ∨ (u ∈ Bc ∧ L.val / 2 ≤ t.val) left_total := fun u => by by_cases huB : u ∈ B · exact ⟨t0, Or.inl ⟨huB, by dsimp only [t0]; linarith [L.nonneg]⟩⟩ · exact ⟨t1, Or.inr ⟨huB, by dsimp only [t1]; linarith [L.nonneg]⟩⟩ right_total := fun t => by rcases le_total t.val (L.val / 2) with ht | ht · exact ⟨u₀, Or.inl ⟨hu₀, ht⟩⟩ · exact ⟨u₁, Or.inr ⟨hu₁, ht⟩⟩ } have hhalf_le : L.val / 2 ≤ max (sdiam U) (L.val - sdiam U) := by rcases le_total (sdiam U) (L.val / 2) with h | h · exact le_trans (by linarith) (le_max_right _ _) · exact le_trans h (le_max_left _ _) have hdis : corrDistortion R ≤ max (sdiam U) (L.val - sdiam U) := by refine corrDistortion_le_of_forall R fun x₁ x₂ y₁ y₂ h₁ h₂ => ?_ have hdx0 : 0 ≤ dist x₁ x₂ := dist_nonneg have hdxD : dist x₁ x₂ ≤ sdiam U := dist_le_sdiam hU x₁ x₂ have hdy0 : 0 ≤ dist y₁ y₂ := dist_nonneg have hdyL : dist y₁ y₂ ≤ L.val := by rw [← hL]; exact dist_le_sdiam hX y₁ y₂ rcases h₁ with ⟨hx₁, hy₁⟩ | ⟨hx₁, hy₁⟩ <;> rcases h₂ with ⟨hx₂, hy₂⟩ | ⟨hx₂, hy₂⟩ · have hdy_half : dist y₁ y₂ ≤ L.val / 2 := by rw [Subtype.dist_eq, Real.dist_eq, abs_le] constructor <;> linarith [y₁.property.1, y₂.property.1] rw [abs_le] constructor · linarith [hhalf_le] · linarith [le_max_left (sdiam U) (L.val - sdiam U)] · have hdx : dist x₁ x₂ = sdiam U := hsep x₁ hx₁ x₂ hx₂ rw [hdx, abs_le] constructor · linarith [le_max_right (sdiam U) (L.val - sdiam U)] · linarith [le_max_left (sdiam U) (L.val - sdiam U)] · have hdx : dist x₁ x₂ = sdiam U := by rw [dist_comm]; exact hsep x₂ hx₂ x₁ hx₁ rw [hdx, abs_le] constructor · linarith [le_max_right (sdiam U) (L.val - sdiam U)] · linarith [le_max_left (sdiam U) (L.val - sdiam U)] · have hdy_half : dist y₁ y₂ ≤ L.val / 2 := by rw [Subtype.dist_eq, Real.dist_eq, abs_le] constructor <;> linarith [y₁.property.2, y₂.property.2] rw [abs_le] constructor · linarith [hhalf_le] · linarith [le_max_left (sdiam U) (L.val - sdiam U)] have hle := ghDist_le_of_corr hU hX R linarith · have hge := (ghDist_ultrametric_connected_ge hU_ultra hU hX).1 rwa [hL] at hge def unitRad : NonnegRad := ⟨1, by norm_num⟩ /-- **Corollary**: For EVERY `p ≥ 2`, `d_GH(ℤ_p, [0, 1]) = 1 / 2`. -/ theorem ghDist_padic_Icc {p : ℕ} (hp : 2 ≤ p) : ghDist (PadicRing p hp) (ClosedInterval unitRad) = 1 / 2 := by have : Nonempty (PadicRing p hp) := cantorUltra_nonempty (by omega) _ have hatt : ∃ u₀ u₁ : PadicRing p hp, dist u₀ u₁ = sdiam (PadicRing p hp) := by let u₀ : PadicRing p hp := ⟨fun _ => ⟨0, by omega⟩⟩ let u₁ : PadicRing p hp := ⟨fun _ => ⟨1, by omega⟩⟩ refine ⟨u₀, u₁, ?_⟩ rw [cantorUltra_sdiam hp] apply le_antisymm (cantorUltra_dist_le_one u₀ u₁) have h1 := cantorUltra_dist_ge_pow_of_ne (x := u₀) (y := u₁) 0 (le_refl 0) (by simp [u₀, u₁]) simpa using h1 rw [ghDist_ultrametric_Icc (cantorUltra_isUltra p _) (cantorUltra_bounded p _) hatt unitRad, cantorUltra_sdiam hp] dsimp only [unitRad]; norm_num /-- **Corollary**: For EVERY `p ≥ 2` and `k : ℕ`, `d_GH(p^k ℤ_p, [0, 1]) = (1/2) max(p^{-k}, 1 - p^{-k})`. -/ theorem ghDist_padic_ideal_Icc {p : ℕ} (hp : 2 ≤ p) (k : ℕ) : ghDist (PadicIdeal p hp k) (ClosedInterval unitRad) = (1 / 2) * max ((1 / (p : ℝ)) ^ k) (1 - (1 / (p : ℝ)) ^ k) := by have : Nonempty (PadicIdeal p hp k) := ⟨⟨⟨fun _ => ⟨0, by omega⟩⟩⟩⟩ have hatt : ∃ u₀ u₁ : PadicIdeal p hp k, dist u₀ u₁ = sdiam (PadicIdeal p hp k) := by let x₀ : PadicRing p hp := ⟨fun _ => ⟨0, by omega⟩⟩ let x₁ : PadicRing p hp := ⟨fun _ => ⟨1, by omega⟩⟩ have hx01 : dist x₀ x₁ = 1 := by apply le_antisymm (cantorUltra_dist_le_one x₀ x₁) simpa using cantorUltra_dist_ge_pow_of_ne (x := x₀) (y := x₁) 0 (le_refl 0) (by simp [x₀, x₁]) refine ⟨⟨x₀⟩, ⟨x₁⟩, ?_⟩ rw [padicIdeal_sdiam hp k] change (padicIdealRad p k).val * dist x₀ x₁ = (1 / (p : ℝ)) ^ k rw [hx01, mul_one]; rfl rw [ghDist_ultrametric_Icc (scaleMetric_isUltra (cantorUltra_isUltra p _) _) (scaleMetric_bounded (cantorUltra_bounded p _) _) hatt unitRad, padicIdeal_sdiam hp k] rfl /-- **Exact Optimality of the 2-adic Ideal `2 ℤ_2`**: `d_GH(2 ℤ_2, [0, 1]) = 1 / 4`, attaining the global minimum over ALL ultrametric spaces! -/ theorem ghDist_two_adic_ideal_optimal : ghDist (PadicIdeal 2 (by omega) 1) (ClosedInterval unitRad) = 1 / 4 := by rw [ghDist_padic_ideal_Icc (by omega) 1] norm_num /-! ## 9. Exact 3-Tier Borsuk–Ulam Phase Transition on the Geodesic Circle `S¹` -/ /-- The geodesic unit circle `S¹ = ℝ / 2πℤ` of circumference `2π` and diameter `π`, realized on `[0, 2π)` with metric `d(x, y) = min(|x - y|, 2π - |x - y|)`. -/ structure CircleGeo where angle : ℝ nonneg : 0 ≤ angle lt_two_pi : angle < 2 * Real.pi def circleDist (x y : CircleGeo) : ℝ := min |x.angle - y.angle| (2 * Real.pi - |x.angle - y.angle|) lemma circleDist_self (x : CircleGeo) : circleDist x x = 0 := by unfold circleDist; simp [le_of_lt Real.pi_pos] lemma circleDist_comm (x y : CircleGeo) : circleDist x y = circleDist y x := by unfold circleDist; rw [abs_sub_comm] lemma circleDist_nonneg (x y : CircleGeo) : 0 ≤ circleDist x y := by unfold circleDist apply le_min (abs_nonneg _) rw [sub_nonneg, abs_le] constructor <;> linarith [x.nonneg, x.lt_two_pi, y.nonneg, y.lt_two_pi] lemma circleDist_le_pi (x y : CircleGeo) : circleDist x y ≤ Real.pi := by unfold circleDist rcases le_total |x.angle - y.angle| Real.pi with h | h · exact le_trans (min_le_left _ _) h · exact le_trans (min_le_right _ _) (by linarith) lemma circleDist_triangle (x y z : CircleGeo) : circleDist x z ≤ circleDist x y + circleDist y z := by unfold circleDist set a := |x.angle - y.angle| set b := |y.angle - z.angle| set c := |x.angle - z.angle| have htri1 : c ≤ a + b := by have : x.angle - z.angle = (x.angle - y.angle) + (y.angle - z.angle) := by ring dsimp only [a, b, c]; rw [this]; exact abs_add_le _ _ have htri2 : a ≤ b + c := by have : x.angle - y.angle = (x.angle - z.angle) + (z.angle - y.angle) := by ring dsimp only [a, b, c]; rw [this, abs_sub_comm y.angle z.angle] have := abs_add_le (x.angle - z.angle) (z.angle - y.angle); linarith have htri3 : b ≤ a + c := by have : y.angle - z.angle = (y.angle - x.angle) + (x.angle - z.angle) := by ring dsimp only [a, b, c]; rw [this, abs_sub_comm x.angle y.angle] have := abs_add_le (y.angle - x.angle) (x.angle - z.angle); linarith rcases le_total a (2 * Real.pi - a) with ha | ha <;> rcases le_total b (2 * Real.pi - b) with hb | hb · rw [min_eq_left ha, min_eq_left hb] exact le_trans (min_le_left _ _) htri1 · rw [min_eq_left ha, min_eq_right hb] exact le_trans (min_le_right _ _) (by linarith) · rw [min_eq_right ha, min_eq_left hb] exact le_trans (min_le_right _ _) (by linarith) · rw [min_eq_right ha, min_eq_right hb] have h4pi : c ≤ (2 * Real.pi - a) + (2 * Real.pi - b) := by have hxa0 := x.nonneg; have hxa1 := x.lt_two_pi have hya0 := y.nonneg; have hya1 := y.lt_two_pi have hza0 := z.nonneg; have hza1 := z.lt_two_pi dsimp only [a, b, c] at ha hb ⊢ rcases le_or_gt x.angle y.angle with hxy | hxy <;> rcases le_or_gt y.angle z.angle with hyz | hyz · rw [abs_of_nonpos (by linarith)] at ha rw [abs_of_nonpos (by linarith)] at hb linarith · rw [abs_of_nonpos (by linarith)] at ha rw [abs_of_pos (by linarith)] at hb rw [abs_of_nonpos (by linarith : x.angle - y.angle ≤ 0), abs_of_pos (by linarith : 0 < y.angle - z.angle), abs_le] constructor <;> linarith · rw [abs_of_pos (by linarith)] at ha rw [abs_of_nonpos (by linarith)] at hb rw [abs_of_pos (by linarith : 0 < x.angle - y.angle), abs_of_nonpos (by linarith : y.angle - z.angle ≤ 0), abs_le] constructor <;> linarith · rw [abs_of_pos (by linarith)] at ha rw [abs_of_pos (by linarith)] at hb linarith exact le_trans (min_le_left _ _) h4pi instance : MetricSpace CircleGeo where dist := circleDist dist_self := circleDist_self dist_comm := circleDist_comm dist_triangle := circleDist_triangle eq_of_dist_eq_zero := fun {x y} h => by change circleDist x y = 0 at h unfold circleDist at h have hpos : 0 < 2 * Real.pi - |x.angle - y.angle| := by have : |x.angle - y.angle| < 2 * Real.pi := by rw [abs_lt]; constructor <;> linarith [x.nonneg, x.lt_two_pi, y.nonneg, y.lt_two_pi] linarith have habs : |x.angle - y.angle| = 0 := by rcases min_cases |x.angle - y.angle| (2 * Real.pi - |x.angle - y.angle|) with ⟨heq, _⟩ | ⟨heq, _⟩ · linarith · linarith have hsub : x.angle = y.angle := sub_eq_zero.mp (abs_eq_zero.mp habs) cases x; cases y; simp only [CircleGeo.mk.injEq]; exact hsub /-- Canonical 1-Lipschitz wrapping map `ℝ → S¹` (`t ↦ t mod 2π`). -/ def circleWrap (t : ℝ) : CircleGeo where angle := t - (⌊t / (2 * Real.pi)⌋ : ℝ) * (2 * Real.pi) nonneg := by have h2pi : 0 < 2 * Real.pi := by positivity have hfl := Int.floor_le (t / (2 * Real.pi)) have := (le_div_iff₀ h2pi).mp hfl linarith lt_two_pi := by have h2pi : 0 < 2 * Real.pi := by positivity have hfl := Int.lt_floor_add_one (t / (2 * Real.pi)) have := (div_lt_iff₀ h2pi).mp hfl linarith lemma circleWrap_eq_of_mem {t : ℝ} (ht0 : 0 ≤ t) (ht1 : t < 2 * Real.pi) : (circleWrap t).angle = t := by have h2pi : 0 < 2 * Real.pi := by positivity have hfl : ⌊t / (2 * Real.pi)⌋ = 0 := by rw [Int.floor_eq_iff] refine ⟨?_, ?_⟩ · simp only [Int.cast_zero]; exact div_nonneg ht0 (le_of_lt h2pi) · simp only [Int.cast_zero, zero_add]; rwa [div_lt_one h2pi] dsimp only [circleWrap]; rw [hfl]; simp lemma circleWrap_mk {a : ℝ} (h0 : 0 ≤ a) (h1 : a < 2 * Real.pi) : circleWrap a = ⟨a, h0, h1⟩ := by cases h : circleWrap a simp only [CircleGeo.mk.injEq] have ha := congrArg CircleGeo.angle h rw [circleWrap_eq_of_mem h0 h1] at ha exact ha.symm lemma circleWrap_add_two_pi (t : ℝ) : circleWrap (t + 2 * Real.pi) = circleWrap t := by have h2pi : (2 * Real.pi : ℝ) ≠ 0 := by positivity have hdiv : (t + 2 * Real.pi) / (2 * Real.pi) = t / (2 * Real.pi) + 1 := by field_simp [h2pi] cases h1 : circleWrap (t + 2 * Real.pi) cases h2 : circleWrap t simp only [CircleGeo.mk.injEq] have ha1 := congrArg CircleGeo.angle h1 have ha2 := congrArg CircleGeo.angle h2 dsimp only [circleWrap] at ha1 ha2 rw [hdiv, Int.floor_add_one] at ha1 push_cast at ha1 linarith lemma circleWrap_surjective : Function.Surjective circleWrap := by intro x refine ⟨x.angle, ?_⟩ cases x with | mk a h0 h1 => exact circleWrap_mk h0 h1 lemma circleWrap_antipode_dist (t : ℝ) : dist (circleWrap t) (circleWrap (t + Real.pi)) = Real.pi := by have h2pi : 0 < 2 * Real.pi := by positivity set a := (circleWrap t).angle have ha0 : 0 ≤ a := (circleWrap t).nonneg have ha1 : a < 2 * Real.pi := (circleWrap t).lt_two_pi have hwrap : circleWrap (t + Real.pi) = circleWrap (a + Real.pi) := by have hdiff : t + Real.pi = (a + Real.pi) + (⌊t / (2 * Real.pi)⌋ : ℝ) * (2 * Real.pi) := by dsimp only [a, circleWrap]; ring have hfl : ⌊(t + Real.pi) / (2 * Real.pi)⌋ = ⌊(a + Real.pi) / (2 * Real.pi)⌋ + ⌊t / (2 * Real.pi)⌋ := by have hdiv : (t + Real.pi) / (2 * Real.pi) = (a + Real.pi) / (2 * Real.pi) + (⌊t / (2 * Real.pi)⌋ : ℝ) := by rw [hdiff]; field_simp [ne_of_gt h2pi] rw [hdiv, Int.floor_add_intCast] cases h1 : circleWrap (t + Real.pi) cases h2 : circleWrap (a + Real.pi) simp only [CircleGeo.mk.injEq] have ha' := congrArg CircleGeo.angle h1 have hb' := congrArg CircleGeo.angle h2 dsimp only [circleWrap] at ha' hb' rw [hfl, hdiff] at ha' push_cast at ha' linarith rw [hwrap] change circleDist (circleWrap t) (circleWrap (a + Real.pi)) = Real.pi unfold circleDist by_cases hlt : a < Real.pi · have heq := circleWrap_eq_of_mem (t := a + Real.pi) (by linarith) (by linarith) rw [heq] have habs : |a - (a + Real.pi)| = Real.pi := by rw [show a - (a + Real.pi) = -Real.pi by ring, abs_neg, abs_of_pos Real.pi_pos] rw [habs, show 2 * Real.pi - Real.pi = Real.pi by ring, min_self] · push Not at hlt have heq2 : circleWrap (a + Real.pi) = circleWrap (a - Real.pi) := by rw [← circleWrap_add_two_pi (a - Real.pi)]; congr 1; ring rw [heq2, circleWrap_eq_of_mem (t := a - Real.pi) (by linarith) (by linarith)] have habs : |a - (a - Real.pi)| = Real.pi := by rw [show a - (a - Real.pi) = Real.pi by ring, abs_of_pos Real.pi_pos] rw [habs, show 2 * Real.pi - Real.pi = Real.pi by ring, min_self] lemma circleWrap_dist_le (s t : ℝ) : dist (circleWrap s) (circleWrap t) ≤ |s - t| := by by_cases hbig : Real.pi ≤ |s - t| · exact le_trans (circleDist_le_pi _ _) hbig · push Not at hbig have h2pi : 0 < 2 * Real.pi := by positivity set ks := ⌊s / (2 * Real.pi)⌋ set kt := ⌊t / (2 * Real.pi)⌋ have hdiff_eq : (circleWrap s).angle - (circleWrap t).angle = (s - t) - ((ks - kt : ℤ) : ℝ) * (2 * Real.pi) := by dsimp only [circleWrap, ks, kt]; push_cast; ring have hbound : |(circleWrap s).angle - (circleWrap t).angle| < 2 * Real.pi := by rw [abs_lt]; constructor <;> linarith [(circleWrap s).nonneg, (circleWrap s).lt_two_pi, (circleWrap t).nonneg, (circleWrap t).lt_two_pi] have hk_cases : ks - kt = 0 ∨ ks - kt = 1 ∨ ks - kt = -1 := by have h1 : |((ks - kt : ℤ) : ℝ)| * (2 * Real.pi) < 3 * Real.pi := by have htri : |((ks - kt : ℤ) : ℝ) * (2 * Real.pi)| ≤ |(circleWrap s).angle - (circleWrap t).angle| + |s - t| := by have : ((ks - kt : ℤ) : ℝ) * (2 * Real.pi) = (s - t) - ((circleWrap s).angle - (circleWrap t).angle) := by linarith rw [this] calc |(s - t) - ((circleWrap s).angle - (circleWrap t).angle)| ≤ |s - t| + |(circleWrap s).angle - (circleWrap t).angle| := abs_sub _ _ _ = |(circleWrap s).angle - (circleWrap t).angle| + |s - t| := add_comm _ _ rw [abs_mul, abs_of_pos h2pi] at htri linarith have h2 : |((ks - kt : ℤ) : ℝ)| < 2 := by nlinarith [Real.pi_pos] have h3 : (|ks - kt| : ℝ) < 2 := by exact_mod_cast h2 have h4 : |ks - kt| < 2 := by exact_mod_cast h3 rw [abs_lt] at h4; omega change circleDist (circleWrap s) (circleWrap t) ≤ |s - t| unfold circleDist rcases hk_cases with h0 | h1 | hm1 · rw [h0] at hdiff_eq; simp only [Int.cast_zero, zero_mul, sub_zero] at hdiff_eq rw [hdiff_eq]; exact min_le_left _ _ · rw [h1] at hdiff_eq; simp only [Int.cast_one, one_mul] at hdiff_eq have hneg : (circleWrap s).angle - (circleWrap t).angle ≤ 0 := by have : s - t < Real.pi := (abs_lt.mp hbig).2 linarith rw [hdiff_eq, abs_of_nonpos (by linarith)] have : 2 * Real.pi - -((s - t) - 2 * Real.pi) = s - t := by ring rw [this] exact le_trans (min_le_right _ _) (le_abs_self _) · rw [hm1] at hdiff_eq; simp only [Int.cast_neg, Int.cast_one, neg_mul, one_mul, sub_neg_eq_add] at hdiff_eq have hpos : 0 ≤ (circleWrap s).angle - (circleWrap t).angle := by have : -Real.pi < s - t := (abs_lt.mp hbig).1 linarith rw [hdiff_eq, abs_of_nonneg (by linarith)] have : 2 * Real.pi - ((s - t) + 2 * Real.pi) = -(s - t) := by ring rw [this] exact le_trans (min_le_right _ _) (neg_le_abs _) lemma circleWrap_continuous : Continuous circleWrap := by rw [Metric.continuous_iff] intro t ε hε exact ⟨ε, hε, fun s hs => lt_of_le_of_lt (circleWrap_dist_le s t) hs⟩ instance : ConnectedSpace CircleGeo := by have hne : Nonempty CircleGeo := ⟨circleWrap 0⟩ have hpre : IsPreconnected (Set.univ : Set CircleGeo) := by have himg : circleWrap '' (Set.univ : Set ℝ) = Set.univ := by rw [Set.image_univ, Set.range_eq_univ.mpr circleWrap_surjective] rw [← himg] exact isPreconnected_univ.image circleWrap circleWrap_continuous.continuousOn exact { isPreconnected_univ := hpre, toNonempty := hne } lemma circleGeo_bounded : BoundedSpace CircleGeo := ⟨Real.pi, circleDist_le_pi⟩ lemma circleGeo_sdiam : sdiam CircleGeo = Real.pi := by apply le_antisymm (sdiam_le_of_forall circleDist_le_pi) have h := circleWrap_antipode_dist 0 rw [← h] exact dist_le_sdiam circleGeo_bounded _ _ /-- **1D Borsuk–Ulam / Lusternik–Schnirelmann 2-Cover Obstruction on `S¹`**: for ANY two sets `A₁, A₂` covering `S¹`, `max(diam A₁, diam A₂) = π`. -/ theorem circleGeo_two_cover_diam {A₁ A₂ : Set CircleGeo} (hcov : A₁ ∪ A₂ = Set.univ) {ρ : ℝ} (h₁ : ∀ x ∈ A₁, ∀ y ∈ A₁, dist x y ≤ ρ) (h₂ : ∀ x ∈ A₂, ∀ y ∈ A₂, dist x y ≤ ρ) : Real.pi ≤ ρ := by by_contra hlt; push Not at hlt have hA₁_ne : A₁.Nonempty := by by_contra hemp; rw [Set.not_nonempty_iff_eq_empty] at hemp rw [hemp, Set.empty_union] at hcov have h0 : circleWrap 0 ∈ A₂ := by rw [hcov]; trivial have hpi : circleWrap (0 + Real.pi) ∈ A₂ := by rw [hcov]; trivial have hd := h₂ _ h0 _ hpi rw [circleWrap_antipode_dist] at hd linarith let g : ℝ → ℝ := fun t => Metric.infDist (circleWrap t) A₁ - Metric.infDist (circleWrap (t + Real.pi)) A₁ have hg_cont : Continuous g := (Metric.continuous_infDist_pt A₁ |>.comp circleWrap_continuous).sub (Metric.continuous_infDist_pt A₁ |>.comp (circleWrap_continuous.comp (continuous_id.add continuous_const))) have hg_anti : g Real.pi = -g 0 := by dsimp only [g] rw [zero_add, show Real.pi + Real.pi = 0 + 2 * Real.pi by ring, circleWrap_add_two_pi] ring have hzero : ∃ t₀ ∈ Set.Icc (0 : ℝ) Real.pi, g t₀ = 0 := by rcases le_total (g 0) 0 with hle | hge · have hmem : (0 : ℝ) ∈ Set.Icc (g 0) (g Real.pi) := ⟨hle, by linarith⟩ exact intermediate_value_Icc (le_of_lt Real.pi_pos) hg_cont.continuousOn hmem · have hmem : (0 : ℝ) ∈ Set.Icc (g Real.pi) (g 0) := ⟨by linarith, hge⟩ exact intermediate_value_Icc' (le_of_lt Real.pi_pos) hg_cont.continuousOn hmem obtain ⟨t₀, _, hgt₀⟩ := hzero have heq : Metric.infDist (circleWrap t₀) A₁ = Metric.infDist (circleWrap (t₀ + Real.pi)) A₁ := by dsimp only [g] at hgt₀; linarith by_cases h0 : Metric.infDist (circleWrap t₀) A₁ = 0 · have h0' : Metric.infDist (circleWrap (t₀ + Real.pi)) A₁ = 0 := by linarith have hε : 0 < (Real.pi - ρ) / 3 := by linarith have hcl1 : circleWrap t₀ ∈ closure A₁ := (Metric.mem_closure_iff_infDist_zero hA₁_ne).mpr h0 have hcl2 : circleWrap (t₀ + Real.pi) ∈ closure A₁ := (Metric.mem_closure_iff_infDist_zero hA₁_ne).mpr h0' obtain ⟨a, haA₁, ha_dist⟩ := Metric.mem_closure_iff.mp hcl1 ((Real.pi - ρ) / 3) hε obtain ⟨b, hbA₁, hb_dist⟩ := Metric.mem_closure_iff.mp hcl2 ((Real.pi - ρ) / 3) hε have hab := h₁ a haA₁ b hbA₁ have htri := dist_triangle (circleWrap t₀) a (circleWrap (t₀ + Real.pi)) have htri2 := dist_triangle a b (circleWrap (t₀ + Real.pi)) rw [circleWrap_antipode_dist] at htri rw [dist_comm b (circleWrap (t₀ + Real.pi))] at htri2 linarith · have hpos : 0 < Metric.infDist (circleWrap t₀) A₁ := lt_of_le_of_ne Metric.infDist_nonneg (Ne.symm h0) have hnot1 : circleWrap t₀ ∉ A₁ := fun hm => by have := Metric.infDist_zero_of_mem hm; linarith have hnot2 : circleWrap (t₀ + Real.pi) ∉ A₁ := fun hm => by have := Metric.infDist_zero_of_mem hm; linarith have hm1 : circleWrap t₀ ∈ A₂ := (by rw [hcov]; trivial : circleWrap t₀ ∈ A₁ ∪ A₂).resolve_left hnot1 have hm2 : circleWrap (t₀ + Real.pi) ∈ A₂ := (by rw [hcov]; trivial : circleWrap (t₀ + Real.pi) ∈ A₁ ∪ A₂).resolve_left hnot2 have hd := h₂ _ hm1 _ hm2 rw [circleWrap_antipode_dist] at hd linarith /-- **Tier 1 (`n = 2`, Borsuk–Ulam Barrier on `S¹`)**: for EVERY `D ≥ 0`, `d_GH(Δ_2(D), S¹) = (1/2) max(D, π) ≥ π / 2` (NO improvement over a single point!). -/ theorem ghDist_equilateral2_circleGeo (D : NonnegRad) : ghDist (Equilateral 2 D) CircleGeo = (1 / 2) * max D.val Real.pi := by have : Nonempty (Equilateral 2 D) := ⟨⟨⟨0, by omega⟩⟩⟩ apply le_antisymm · have h := ghDist_le_half_max_sdiam (Equilateral 2 D) CircleGeo (equilateral_bounded 2 D) circleGeo_bounded rwa [equilateral_sdiam (by omega), circleGeo_sdiam] at h · refine le_ghDist_of_forall_corr fun R => ?_ have h1 := corrDistortion_ultrametric_connected_ge_sdiam (equilateral_isUltra 2 D) (equilateral_bounded 2 D) circleGeo_bounded R rw [equilateral_sdiam (by omega)] at h1 have h2 : Real.pi ≤ corrDistortion R := by let u0 : Equilateral 2 D := ⟨⟨0, by omega⟩⟩ let u1 : Equilateral 2 D := ⟨⟨1, by omega⟩⟩ let A₁ : Set CircleGeo := {x | R.rel u0 x} let A₂ : Set CircleGeo := {x | R.rel u1 x} have hcov : A₁ ∪ A₂ = Set.univ := by ext x; simp only [mem_union, mem_univ, iff_true] obtain ⟨u, hu⟩ := R.right_total x have hlt := u.idx.isLt have h01 : u.idx.val = 0 ∨ u.idx.val = 1 := by omega rcases h01 with h | h · left; change R.rel u0 x have hu_eq : u = u0 := by cases u; simp only [u0, Equilateral.mk.injEq]; exact Fin.ext h rwa [← hu_eq] · right; change R.rel u1 x have hu_eq : u = u1 := by cases u; simp only [u1, Equilateral.mk.injEq]; exact Fin.ext h rwa [← hu_eq] refine circleGeo_two_cover_diam hcov ?_ ?_ · intro x hx y hy have hdis := le_corrDistortion_of_rel (equilateral_bounded 2 D) circleGeo_bounded R hx hy rw [dist_self, zero_sub, abs_neg, abs_of_nonneg dist_nonneg] at hdis exact hdis · intro x hx y hy have hdis := le_corrDistortion_of_rel (equilateral_bounded 2 D) circleGeo_bounded R hx hy rw [dist_self, zero_sub, abs_neg, abs_of_nonneg dist_nonneg] at hdis exact hdis exact max_le h1 h2 /-- Arc-containment lemma: any subset of `S¹` of diameter `≤ ρ < 2π / 3` lies in a closed arc of length `≤ ρ`. -/ lemma circleGeo_subset_arc_of_diam_lt {A : Set CircleGeo} {ρ : ℝ} (hρ0 : 0 ≤ ρ) (hρ : ρ < 2 * Real.pi / 3) (hdiam : ∀ x ∈ A, ∀ y ∈ A, dist x y ≤ ρ) : ∃ a : ℝ, ∀ x ∈ A, ∃ t ∈ Set.Icc a (a + ρ), circleWrap t = x := by by_cases hemp : A = ∅ · exact ⟨0, fun x hx => by rw [hemp] at hx; exact False.elim hx⟩ · obtain ⟨x₀, hx₀⟩ := Set.nonempty_iff_ne_empty.mpr hemp -- Unwrap each `x ∈ A` into `I = [x₀.angle - ρ, x₀.angle + ρ]`! have hunwrap : ∀ x ∈ A, ∃ t ∈ Set.Icc (x₀.angle - ρ) (x₀.angle + ρ), circleWrap t = x := by intro x hx have hd : circleDist x x₀ ≤ ρ := hdiam x hx x₀ hx₀ unfold circleDist at hd rcases min_le_iff.mp hd with h1 | h2 · rw [abs_le] at h1 refine ⟨x.angle, ⟨by linarith, by linarith⟩, ?_⟩ cases x with | mk ang h0 hlt => exact circleWrap_mk h0 hlt · by_cases hlt : x.angle < x₀.angle · have habs : |x.angle - x₀.angle| = x₀.angle - x.angle := by rw [abs_of_neg (by linarith)]; ring rw [habs] at h2 refine ⟨x.angle + 2 * Real.pi, ⟨by linarith [x.nonneg, x₀.lt_two_pi], by linarith⟩, ?_⟩ rw [circleWrap_add_two_pi] cases x with | mk ang h0 hlt' => exact circleWrap_mk h0 hlt' · push Not at hlt have habs : |x.angle - x₀.angle| = x.angle - x₀.angle := abs_of_nonneg (by linarith) rw [habs] at h2 refine ⟨x.angle - 2 * Real.pi, ⟨by linarith, by linarith [x.lt_two_pi, x₀.nonneg]⟩, ?_⟩ have heq : circleWrap (x.angle - 2 * Real.pi) = circleWrap x.angle := by rw [← circleWrap_add_two_pi (x.angle - 2 * Real.pi)]; congr 1; ring rw [heq] cases x with | mk ang h0 hlt' => exact circleWrap_mk h0 hlt' let S : Set ℝ := {t | t ∈ Set.Icc (x₀.angle - ρ) (x₀.angle + ρ) ∧ circleWrap t ∈ A} have hSne : S.Nonempty := ⟨x₀.angle, ⟨by linarith, by linarith⟩, by have : circleWrap x₀.angle = x₀ := by cases x₀ with | mk ang h0 hlt => exact circleWrap_mk h0 hlt rwa [this]⟩ have hSbdd : BddBelow S := ⟨x₀.angle - ρ, fun t ht => ht.1.1⟩ set a := sInf S refine ⟨a, fun x hx => ?_⟩ obtain ⟨t, htI, htw⟩ := hunwrap x hx have htS : t ∈ S := ⟨htI, htw.symm ▸ hx⟩ refine ⟨t, ⟨csInf_le hSbdd htS, ?_⟩, htw⟩ -- Show `t - s ≤ ρ` for every `s ∈ S`, hence `t - ρ ≤ a`! have hle_all : ∀ s ∈ S, t - ρ ≤ s := by intro s hs have hdist : dist (circleWrap t) (circleWrap s) ≤ ρ := hdiam _ (htw.symm ▸ hx) _ hs.2 have hts_bound : |t - s| ≤ 2 * ρ := by rw [abs_le]; constructor <;> linarith [htI.1, htI.2, hs.1.1, hs.1.2] -- Since `|t - s| ≤ 2ρ < 4π/3`, `dist (wrap t) (wrap s) = |t - s|` (cannot wrap the long way `2π - |t-s| > 2π/3 > ρ`)! have hwrap_eq : dist (circleWrap t) (circleWrap s) = |t - s| := by have h2pi : 0 < 2 * Real.pi := by positivity have hsub_lt : |t - s| < 2 * Real.pi := by linarith -- Compute `circleDist (circleWrap t) (circleWrap s)` directly via `ks - kt ∈ {-1, 0, 1}`! set kt := ⌊t / (2 * Real.pi)⌋ set ks := ⌊s / (2 * Real.pi)⌋ have hdiff : (circleWrap t).angle - (circleWrap s).angle = (t - s) - ((kt - ks : ℤ) : ℝ) * (2 * Real.pi) := by dsimp only [circleWrap, kt, ks]; push_cast; ring have hbound : |(circleWrap t).angle - (circleWrap s).angle| < 2 * Real.pi := by rw [abs_lt]; constructor <;> linarith [(circleWrap t).nonneg, (circleWrap t).lt_two_pi, (circleWrap s).nonneg, (circleWrap s).lt_two_pi] have hk : kt - ks = 0 ∨ kt - ks = 1 ∨ kt - ks = -1 := by have htri : |((kt - ks : ℤ) : ℝ) * (2 * Real.pi)| ≤ |(circleWrap t).angle - (circleWrap s).angle| + |t - s| := by have : ((kt - ks : ℤ) : ℝ) * (2 * Real.pi) = (t - s) - ((circleWrap t).angle - (circleWrap s).angle) := by linarith rw [this] calc |(t - s) - ((circleWrap t).angle - (circleWrap s).angle)| ≤ |t - s| + |(circleWrap t).angle - (circleWrap s).angle| := abs_sub _ _ _ = |(circleWrap t).angle - (circleWrap s).angle| + |t - s| := add_comm _ _ rw [abs_mul, abs_of_pos h2pi] at htri have h1 : |((kt - ks : ℤ) : ℝ)| < 2 := by nlinarith [Real.pi_pos] have h2 : (|kt - ks| : ℝ) < 2 := by exact_mod_cast h1 have h3 : |kt - ks| < 2 := by exact_mod_cast h2 rw [abs_lt] at h3; omega change circleDist (circleWrap t) (circleWrap s) = |t - s| unfold circleDist have hts_abs := abs_le.mp hts_bound rcases hk with h0 | h1 | hm1 · rw [h0] at hdiff; simp only [Int.cast_zero, zero_mul, sub_zero] at hdiff rw [hdiff] rcases le_total |t - s| Real.pi with hle | hgt · exact min_eq_left (by linarith) · exfalso have h3 : circleDist (circleWrap t) (circleWrap s) ≤ ρ := hdist unfold circleDist at h3 rw [hdiff] at h3 rcases min_le_iff.mp h3 with ha | hb <;> linarith · rw [h1] at hdiff; simp only [Int.cast_one, one_mul] at hdiff have hneg : (circleWrap t).angle - (circleWrap s).angle < 0 := by linarith [(abs_lt.mp hsub_lt).2] rw [hdiff, abs_of_neg (by linarith)] have : 2 * Real.pi - -((t - s) - 2 * Real.pi) = t - s := by ring rw [this] have hts_pos : 0 < t - s := by have := (circleWrap t).nonneg; have := (circleWrap s).lt_two_pi; linarith rw [abs_of_pos hts_pos] rcases le_total (t - s) Real.pi with hle | hgt · exact min_eq_right (by linarith) · exfalso have h3 : circleDist (circleWrap t) (circleWrap s) ≤ ρ := hdist unfold circleDist at h3 rw [hdiff, abs_of_neg (by linarith), this] at h3 rcases min_le_iff.mp h3 with ha | hb <;> linarith · rw [hm1] at hdiff; simp only [Int.cast_neg, Int.cast_one, neg_mul, one_mul, sub_neg_eq_add] at hdiff have hpos : 0 < (circleWrap t).angle - (circleWrap s).angle := by linarith [(abs_lt.mp hsub_lt).1] rw [hdiff, abs_of_pos (by linarith)] have : 2 * Real.pi - ((t - s) + 2 * Real.pi) = -(t - s) := by ring rw [this] have hts_neg : t - s < 0 := by have := (circleWrap s).nonneg; have := (circleWrap t).lt_two_pi; linarith rw [abs_of_neg hts_neg] rcases le_total (-(t - s)) Real.pi with hle | hgt · exact min_eq_right (by linarith) · exfalso have h3 : circleDist (circleWrap t) (circleWrap s) ≤ ρ := hdist unfold circleDist at h3 rw [hdiff, abs_of_pos (by linarith), this] at h3 rcases min_le_iff.mp h3 with ha | hb <;> linarith rw [hwrap_eq, abs_le] at hdist linarith have ha_ge : t - ρ ≤ a := le_csInf hSne hle_all linarith /-- Discrete grid counting bound: a closed arc of length `≤ ρ < 2π` contains at most `⌊ρ * N / (2π)⌋₊ + 1` points of the `N`-point uniform grid on `S¹`. -/ lemma arc_grid_card_le {N : ℕ} (hN : 0 < N) {a ρ : ℝ} (hρ0 : 0 ≤ ρ) (hρ : ρ < 2 * Real.pi) : (Finset.univ.filter fun j : Fin N => ∃ t ∈ Set.Icc a (a + ρ), circleWrap t = circleWrap ((j.val : ℝ) * (2 * Real.pi / N))).card ≤ ⌊ρ * (N : ℝ) / (2 * Real.pi)⌋₊ + 1 := by have h2pi : 0 < 2 * Real.pi := by positivity have hNpos : (0 : ℝ) < N := by exact_mod_cast hN set step : ℝ := 2 * Real.pi / N have hstep : 0 < step := div_pos h2pi hNpos set m : ℕ := ⌊ρ * (N : ℝ) / (2 * Real.pi)⌋₊ -- Every `j` in the filtered set has an integer `z` with `z * step ∈ [a, a + ρ]` and `z ≡ j (mod N)`! -- Actually, shift `z` by `⌈a / step⌉`: `z - ⌈a / step⌉ ∈ {0, ..., m}`! set z0 : ℤ := ⌈a / step⌉ let idxOf : Fin N → ℕ := fun j => if h : ∃ z : ℤ, a ≤ (z : ℝ) * step ∧ (z : ℝ) * step ≤ a + ρ ∧ circleWrap ((z : ℝ) * step) = circleWrap ((j.val : ℝ) * step) then (Classical.choose h - z0).toNat else 0 have hmem_range : ∀ j ∈ Finset.univ.filter (fun j : Fin N => ∃ t ∈ Set.Icc a (a + ρ), circleWrap t = circleWrap ((j.val : ℝ) * step)), ∃ z : ℤ, a ≤ (z : ℝ) * step ∧ (z : ℝ) * step ≤ a + ρ ∧ circleWrap ((z : ℝ) * step) = circleWrap ((j.val : ℝ) * step) := by intro j hj obtain ⟨t, ⟨hta, htb⟩, htw⟩ := (Finset.mem_filter.mp hj).2 -- Since `circleWrap t = circleWrap (j * step)`, `t - j * step = k * 2π = (k * N) * step` for some `k : ℤ`! set kt : ℤ := ⌊t / (2 * Real.pi)⌋ set kj : ℤ := ⌊((j.val : ℝ) * step) / (2 * Real.pi)⌋ have hang : (circleWrap t).angle = (circleWrap ((j.val : ℝ) * step)).angle := congrArg CircleGeo.angle htw dsimp only [circleWrap] at hang set z : ℤ := (j.val : ℤ) + (kt - kj) * (N : ℤ) have hz_eq : (z : ℝ) * step = t := by dsimp only [z, step] push_cast have hNne : (N : ℝ) ≠ 0 := ne_of_gt hNpos have h1 : ((j.val : ℝ) + ((kt : ℝ) - (kj : ℝ)) * (N : ℝ)) * (2 * Real.pi / (N : ℝ)) = (j.val : ℝ) * (2 * Real.pi / (N : ℝ)) + ((kt : ℝ) - (kj : ℝ)) * (2 * Real.pi) := by field_simp [hNne] rw [h1]; linarith exact ⟨z, hz_eq.symm ▸ hta, hz_eq.symm ▸ htb, hz_eq.symm ▸ htw⟩ -- `idxOf` maps the filtered set injectively into `Finset.range (m + 1)`! have hmaps : ∀ j ∈ Finset.univ.filter (fun j : Fin N => ∃ t ∈ Set.Icc a (a + ρ), circleWrap t = circleWrap ((j.val : ℝ) * step)), idxOf j ∈ Finset.range (m + 1) := by intro j hj have hex := hmem_range j hj dsimp only [idxOf]; rw [dif_pos hex] obtain ⟨hza, hzb, _⟩ := Classical.choose_spec hex set z := Classical.choose hex have hz0_le : z0 ≤ z := Int.ceil_le.mpr ((div_le_iff₀ hstep).mpr hza) have hdiff_le : ((z - z0 : ℤ) : ℝ) ≤ ρ * (N : ℝ) / (2 * Real.pi) := by have hz0_ge : a / step ≤ (z0 : ℝ) := Int.le_ceil _ have ha_le : a ≤ (z0 : ℝ) * step := (div_le_iff₀ hstep).mp hz0_ge have h1 : ((z - z0 : ℤ) : ℝ) * step ≤ ρ := by push_cast; linarith have h2 : ((z - z0 : ℤ) : ℝ) ≤ ρ / step := (le_div_iff₀ hstep).mpr h1 have h3 : ρ / step = ρ * (N : ℝ) / (2 * Real.pi) := by dsimp only [step]; field_simp [ne_of_gt hNpos, ne_of_gt h2pi] linarith have hnat_le : (z - z0).toNat ≤ m := by have hcast : ((z - z0).toNat : ℝ) = ((z - z0 : ℤ) : ℝ) := by exact_mod_cast Int.toNat_of_nonneg (by omega : 0 ≤ z - z0) exact Nat.le_floor (by rw [hcast]; exact hdiff_le) rw [Finset.mem_range]; omega have hinj : Set.InjOn idxOf (Finset.univ.filter (fun j : Fin N => ∃ t ∈ Set.Icc a (a + ρ), circleWrap t = circleWrap ((j.val : ℝ) * step)) : Set (Fin N)) := by intro j₁ hj₁ j₂ hj₂ heq have hex1 := hmem_range j₁ hj₁ have hex2 := hmem_range j₂ hj₂ dsimp only [idxOf] at heq rw [dif_pos hex1, dif_pos hex2] at heq set z₁ := Classical.choose hex1 set z₂ := Classical.choose hex2 obtain ⟨h1a, _, h1w⟩ := Classical.choose_spec hex1 obtain ⟨h2a, _, h2w⟩ := Classical.choose_spec hex2 have hz1_ge : z0 ≤ z₁ := Int.ceil_le.mpr ((div_le_iff₀ hstep).mpr h1a) have hz2_ge : z0 ≤ z₂ := Int.ceil_le.mpr ((div_le_iff₀ hstep).mpr h2a) have hz_eq : z₁ = z₂ := by have h1 : ((z₁ - z0).toNat : ℤ) = z₁ - z0 := Int.toNat_of_nonneg (by omega) have h2 : ((z₂ - z0).toNat : ℤ) = z₂ - z0 := Int.toNat_of_nonneg (by omega) omega have hw_eq : circleWrap ((j₁.val : ℝ) * step) = circleWrap ((j₂.val : ℝ) * step) := by rw [← h1w, ← h2w] change circleWrap ((z₁ : ℝ) * step) = circleWrap ((z₂ : ℝ) * step) rw [hz_eq] have h1_lt : (j₁.val : ℝ) * step < 2 * Real.pi := by dsimp only [step] have hj : (j₁.val : ℝ) < N := by exact_mod_cast j₁.isLt rw [mul_div_assoc', div_lt_iff₀ hNpos]; nlinarith [Real.pi_pos] have h2_lt : (j₂.val : ℝ) * step < 2 * Real.pi := by dsimp only [step] have hj : (j₂.val : ℝ) < N := by exact_mod_cast j₂.isLt rw [mul_div_assoc', div_lt_iff₀ hNpos]; nlinarith [Real.pi_pos] have hang := congrArg CircleGeo.angle hw_eq rw [circleWrap_eq_of_mem (by positivity) h1_lt, circleWrap_eq_of_mem (by positivity) h2_lt] at hang have hj_real : (j₁.val : ℝ) = (j₂.val : ℝ) := mul_right_cancel₀ (ne_of_gt hstep) hang exact Fin.ext (by exact_mod_cast hj_real) calc (Finset.univ.filter fun j : Fin N => ∃ t ∈ Set.Icc a (a + ρ), circleWrap t = circleWrap ((j.val : ℝ) * step)).card ≤ (Finset.range (m + 1)).card := Finset.card_le_card_of_injOn idxOf hmaps hinj _ = m + 1 := Finset.card_range (m + 1) /-- **3-Cover Obstruction on `S¹`**: for ANY three sets `A₁, A₂, A₃` covering `S¹`, `max(diam A₁, diam A₂, diam A₃) ≥ 2π / 3`. -/ theorem circleGeo_three_cover_diam {A₁ A₂ A₃ : Set CircleGeo} (hcov : A₁ ∪ A₂ ∪ A₃ = Set.univ) {ρ : ℝ} (h₁ : ∀ x ∈ A₁, ∀ y ∈ A₁, dist x y ≤ ρ) (h₂ : ∀ x ∈ A₂, ∀ y ∈ A₂, dist x y ≤ ρ) (h₃ : ∀ x ∈ A₃, ∀ y ∈ A₃, dist x y ≤ ρ) : 2 * Real.pi / 3 ≤ ρ := by by_contra hlt; push Not at hlt have hρ0 : 0 ≤ ρ := by have hx : circleWrap 0 ∈ A₁ ∪ A₂ ∪ A₃ := by rw [hcov]; trivial rcases hx with (h | h) | h · linarith [h₁ _ h _ h, dist_self (circleWrap 0)] · linarith [h₂ _ h _ h, dist_self (circleWrap 0)] · linarith [h₃ _ h _ h, dist_self (circleWrap 0)] obtain ⟨a₁, ha₁⟩ := circleGeo_subset_arc_of_diam_lt hρ0 hlt h₁ obtain ⟨a₂, ha₂⟩ := circleGeo_subset_arc_of_diam_lt hρ0 hlt h₂ obtain ⟨a₃, ha₃⟩ := circleGeo_subset_arc_of_diam_lt hρ0 hlt h₃ have hgap : 0 < 1 - 3 * ρ / (2 * Real.pi) := by have h2pi : 0 < 2 * Real.pi := by positivity rw [sub_pos, div_lt_one h2pi]; linarith obtain ⟨N, hN_gt⟩ := exists_nat_gt (4 / (1 - 3 * ρ / (2 * Real.pi))) have hN_pos : 0 < N := by by_contra h0; have : N = 0 := by omega subst this; simp at hN_gt have : 0 < 4 / (1 - 3 * ρ / (2 * Real.pi)) := div_pos (by norm_num) hgap linarith let F : ℝ → Finset (Fin N) := fun a => Finset.univ.filter fun j : Fin N => ∃ t ∈ Set.Icc a (a + ρ), circleWrap t = circleWrap ((j.val : ℝ) * (2 * Real.pi / N)) have hunion : Finset.univ ⊆ F a₁ ∪ F a₂ ∪ F a₃ := by intro j _ have hm : circleWrap ((j.val : ℝ) * (2 * Real.pi / N)) ∈ A₁ ∪ A₂ ∪ A₃ := by rw [hcov]; trivial rcases hm with (hm | hm) | hm · exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨Finset.mem_univ _, ha₁ _ hm⟩)) · exact Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨Finset.mem_univ _, ha₂ _ hm⟩)) · exact Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨Finset.mem_univ _, ha₃ _ hm⟩) have hcard : N ≤ (F a₁).card + (F a₂).card + (F a₃).card := by calc N = (Finset.univ : Finset (Fin N)).card := (Fintype.card_fin N).symm _ ≤ (F a₁ ∪ F a₂ ∪ F a₃).card := Finset.card_le_card hunion _ ≤ (F a₁ ∪ F a₂).card + (F a₃).card := Finset.card_union_le _ _ _ ≤ (F a₁).card + (F a₂).card + (F a₃).card := Nat.add_le_add_right (Finset.card_union_le _ _) _ have hb1 := arc_grid_card_le (a := a₁) hN_pos hρ0 (by linarith [Real.pi_pos]) have hb2 := arc_grid_card_le (a := a₂) hN_pos hρ0 (by linarith [Real.pi_pos]) have hb3 := arc_grid_card_le (a := a₃) hN_pos hρ0 (by linarith [Real.pi_pos]) have hfl : (⌊ρ * (N : ℝ) / (2 * Real.pi)⌋₊ : ℝ) ≤ ρ * (N : ℝ) / (2 * Real.pi) := Nat.floor_le (by positivity) have hcard_r : (N : ℝ) ≤ 3 * (ρ * (N : ℝ) / (2 * Real.pi) + 1) := by have hcard_nat : N ≤ 3 * (⌊ρ * (N : ℝ) / (2 * Real.pi)⌋₊ + 1) := by dsimp only [F] at hcard; omega have h1 : (N : ℝ) ≤ 3 * ((⌊ρ * (N : ℝ) / (2 * Real.pi)⌋₊ : ℝ) + 1) := by exact_mod_cast hcard_nat linarith have hbig : 4 < (N : ℝ) * (1 - 3 * ρ / (2 * Real.pi)) := by rwa [div_lt_iff₀ hgap] at hN_gt have hident : (N : ℝ) * (1 - 3 * ρ / (2 * Real.pi)) = (N : ℝ) - 3 * (ρ * (N : ℝ) / (2 * Real.pi)) := by ring linarith /-- Uniform `n`-arc partition of `S¹` (`n ≥ 2`), with each arc having diameter `≤ 2π / n`. -/ lemma circleGeo_uniform_cover {n : ℕ} (hn : 2 ≤ n) : ∃ f : CircleGeo → Fin n, Function.Surjective f ∧ ∀ x₁ x₂ : CircleGeo, f x₁ = f x₂ → dist x₁ x₂ ≤ 2 * Real.pi / n := by have hn_pos : (0 : ℝ) < n := by exact_mod_cast (by omega : 0 < n) have h2pi : 0 < 2 * Real.pi := by positivity let f : CircleGeo → Fin n := fun x => ⟨⌊x.angle * (n : ℝ) / (2 * Real.pi)⌋₊, by rw [Nat.floor_lt (div_nonneg (mul_nonneg x.nonneg (le_of_lt hn_pos)) (le_of_lt h2pi))] rw [div_lt_iff₀ h2pi] nlinarith [x.lt_two_pi]⟩ refine ⟨f, ?_, ?_⟩ · intro j let t : ℝ := (j.val : ℝ) * (2 * Real.pi / n) have ht0 : 0 ≤ t := by positivity have ht1 : t < 2 * Real.pi := by dsimp only [t] have hj : (j.val : ℝ) < n := by exact_mod_cast j.isLt rw [mul_div_assoc', div_lt_iff₀ hn_pos]; nlinarith [Real.pi_pos] refine ⟨⟨t, ht0, ht1⟩, Fin.ext ?_⟩ dsimp only [f, t] have hcalc : (j.val : ℝ) * (2 * Real.pi / (n : ℝ)) * (n : ℝ) / (2 * Real.pi) = (j.val : ℝ) := by field_simp [ne_of_gt hn_pos, ne_of_gt h2pi] rw [hcalc, Nat.floor_natCast] · intro x₁ x₂ hfeq have hval : ⌊x₁.angle * (n : ℝ) / (2 * Real.pi)⌋₊ = ⌊x₂.angle * (n : ℝ) / (2 * Real.pi)⌋₊ := congrArg Fin.val hfeq set k := ⌊x₁.angle * (n : ℝ) / (2 * Real.pi)⌋₊ have h1a : (k : ℝ) ≤ x₁.angle * (n : ℝ) / (2 * Real.pi) := Nat.floor_le (div_nonneg (mul_nonneg x₁.nonneg (le_of_lt hn_pos)) (le_of_lt h2pi)) have h1b : x₁.angle * (n : ℝ) / (2 * Real.pi) < (k : ℝ) + 1 := Nat.lt_floor_add_one _ have h2a : (k : ℝ) ≤ x₂.angle * (n : ℝ) / (2 * Real.pi) := by rw [hval]; exact Nat.floor_le (div_nonneg (mul_nonneg x₂.nonneg (le_of_lt hn_pos)) (le_of_lt h2pi)) have h2b : x₂.angle * (n : ℝ) / (2 * Real.pi) < (k : ℝ) + 1 := by rw [hval]; exact Nat.lt_floor_add_one _ have habs : |x₁.angle - x₂.angle| ≤ 2 * Real.pi / n := by rw [abs_le] have h1a' := (le_div_iff₀ h2pi).mp h1a have h1b' := (div_lt_iff₀ h2pi).mp h1b have h2a' := (le_div_iff₀ h2pi).mp h2a have h2b' := (div_lt_iff₀ h2pi).mp h2b constructor · rw [neg_le, neg_sub, le_div_iff₀ hn_pos]; linarith · rw [le_div_iff₀ hn_pos]; linarith exact le_trans (min_le_left _ _) habs /-- **Tier 2 (`n = 3` on `S¹`)**: for EVERY `D ≥ 0`, `d_GH(Δ_3(D), S¹) = (1/2) max(max(D, 2π / 3), π - D) ≥ π / 3`. -/ theorem ghDist_equilateral3_circleGeo (D : NonnegRad) : ghDist (Equilateral 3 D) CircleGeo = (1 / 2) * max (max D.val (2 * Real.pi / 3)) (Real.pi - D.val) := by have : Nonempty (Equilateral 3 D) := ⟨⟨⟨0, by omega⟩⟩⟩ apply le_antisymm · obtain ⟨f, hsurj, hρ⟩ := circleGeo_uniform_cover (n := 3) (by omega) have h := ghDist_equilateral_le_of_cover circleGeo_bounded (by omega) D f hsurj hρ rw [circleGeo_sdiam] at h simpa using h · refine le_ghDist_of_forall_corr fun R => ?_ have h1 := corrDistortion_ultrametric_connected_ge_sdiam (equilateral_isUltra 3 D) (equilateral_bounded 3 D) circleGeo_bounded R rw [equilateral_sdiam (by omega)] at h1 have h2 : Real.pi - D.val ≤ corrDistortion R := by have habs := abs_sdiam_sub_le_two_ghDist (Equilateral 3 D) CircleGeo (equilateral_bounded 3 D) circleGeo_bounded rw [equilateral_sdiam (by omega), circleGeo_sdiam, abs_le] at habs have hle := ghDist_le_of_corr (equilateral_bounded 3 D) circleGeo_bounded R linarith have h3 : 2 * Real.pi / 3 ≤ corrDistortion R := by let u0 : Equilateral 3 D := ⟨⟨0, by omega⟩⟩ let u1 : Equilateral 3 D := ⟨⟨1, by omega⟩⟩ let u2 : Equilateral 3 D := ⟨⟨2, by omega⟩⟩ let A₁ : Set CircleGeo := {x | R.rel u0 x} let A₂ : Set CircleGeo := {x | R.rel u1 x} let A₃ : Set CircleGeo := {x | R.rel u2 x} have hcov : A₁ ∪ A₂ ∪ A₃ = Set.univ := by ext x; simp only [mem_union, mem_univ, iff_true] obtain ⟨u, hu⟩ := R.right_total x have hlt := u.idx.isLt have hcases : u.idx.val = 0 ∨ u.idx.val = 1 ∨ u.idx.val = 2 := by omega rcases hcases with h | h | h · left; left; change R.rel u0 x have hu_eq : u = u0 := by cases u; simp only [u0, Equilateral.mk.injEq]; exact Fin.ext h rwa [← hu_eq] · left; right; change R.rel u1 x have hu_eq : u = u1 := by cases u; simp only [u1, Equilateral.mk.injEq]; exact Fin.ext h rwa [← hu_eq] · right; change R.rel u2 x have hu_eq : u = u2 := by cases u; simp only [u2, Equilateral.mk.injEq]; exact Fin.ext h rwa [← hu_eq] refine circleGeo_three_cover_diam hcov ?_ ?_ ?_ · intro x hx y hy have hdis := le_corrDistortion_of_rel (equilateral_bounded 3 D) circleGeo_bounded R hx hy rw [dist_self, zero_sub, abs_neg, abs_of_nonneg dist_nonneg] at hdis; exact hdis · intro x hx y hy have hdis := le_corrDistortion_of_rel (equilateral_bounded 3 D) circleGeo_bounded R hx hy rw [dist_self, zero_sub, abs_neg, abs_of_nonneg dist_nonneg] at hdis; exact hdis · intro x hx y hy have hdis := le_corrDistortion_of_rel (equilateral_bounded 3 D) circleGeo_bounded R hx hy rw [dist_self, zero_sub, abs_neg, abs_of_nonneg dist_nonneg] at hdis; exact hdis exact max_le (max_le h1 h3) h2 /-- **Tier 3 (`n ≥ 4` on `S¹`, Global Optimum Achieved)**: for EVERY `n ≥ 4` and `D ≥ 0`, `d_GH(Δ_n(D), S¹) = (1/2) max(D, π - D)`, achieving the global minimum `π / 4 = inf_{U ultrametric} d_GH(S¹, U)` at `D = π / 2`! -/ theorem ghDist_equilateral_ge4_circleGeo {n : ℕ} (hn : 4 ≤ n) (D : NonnegRad) : ghDist (Equilateral n D) CircleGeo = (1 / 2) * max D.val (Real.pi - D.val) := by have : Nonempty (Equilateral n D) := ⟨⟨⟨0, by omega⟩⟩⟩ apply le_antisymm · obtain ⟨f, hsurj, hρ⟩ := circleGeo_uniform_cover (n := n) (by omega) have h := ghDist_equilateral_le_of_cover circleGeo_bounded (by omega) D f hsurj hρ rw [circleGeo_sdiam] at h have h2pi_le : 2 * Real.pi / (n : ℝ) ≤ Real.pi / 2 := by have hn_r : (4 : ℝ) ≤ n := by exact_mod_cast hn rw [div_le_div_iff₀ (by linarith) (by norm_num)] nlinarith [Real.pi_pos] have hhalf : Real.pi / 2 ≤ max D.val (Real.pi - D.val) := by rcases le_total D.val (Real.pi / 2) with hle | hge · exact le_trans (by linarith) (le_max_right _ _) · exact le_trans hge (le_max_left _ _) have hmax_le : max (max D.val (2 * Real.pi / (n : ℝ))) (Real.pi - D.val) ≤ max D.val (Real.pi - D.val) := max_le (max_le (le_max_left _ _) (le_trans h2pi_le hhalf)) (le_max_right _ _) linarith · have h := (ghDist_ultrametric_connected_ge (equilateral_isUltra n D) (equilateral_bounded n D) circleGeo_bounded).1 rwa [equilateral_sdiam (by omega), circleGeo_sdiam] at h #print axioms ghDist_ultrametric_connected_ge #print axioms ghDist_connected_discreteUltra #print axioms ghDist_to_ultrametrics_eq #print axioms ghDist_ultrametric_Icc #print axioms ghDist_padic_Icc #print axioms ghDist_padic_ideal_Icc #print axioms ghDist_two_adic_ideal_optimal #print axioms circleGeo_two_cover_diam #print axioms circleGeo_three_cover_diam #print axioms ghDist_equilateral2_circleGeo #print axioms ghDist_equilateral3_circleGeo #print axioms ghDist_equilateral_ge4_circleGeo end end ConnectedUltrametricRigidity