import Mathlib /-! # CAT(0) / Alexandrov Curvature, Busemann Convexity, Reshetnyak 4-Point Inequality, # Nonlinear Projection Theory, Sharp Constant-1 Circumcenter Stability, CAT(0) Jung's # Theorem, and Quantitative Bruhat–Tits Fixed-Point Theory ## Main Results 1. **Geodesic & Curvature Foundations**: - `cat0_midpoint_cn`: Bruhat–Tits exact midpoint CN parallelogram inequality. - `cat0_unique_geodesic` and `busemann_unique_geodesic`: Uniqueness of unit-speed geodesics. - `cat0_implies_busemann`: Algebraic proof that every `CAT(0)` space is Busemann convex. - `cat0_reshetnyak_four_point`: Exact Reshetnyak 4-point inequality `d(a,c)² + d(b,d)² ≤ d(a,d)² + d(b,c)² + 2 d(a,b) d(c,d)` via weighted Cauchy–Schwarz. 2. **Unique Geodesic Projection onto Complete Convex Sets**: - `cat0_existsUnique_proj`: Existence & uniqueness of closest-point projection `π_C(x)`. - `cat0_proj_pythagorean`: Exact nonlinear Pythagorean (obtuse-angle) inequality `d(x, π_C(x))² + d(π_C(x), y)² ≤ d(x, y)²` for all `y ∈ C` (via `λ → 0⁺`). - `cat0_proj_nonexpansive`: 1-Lipschitzness `d(π_C(x), π_C(y)) ≤ d(x, y)` (4-line proof from Pythagorean + Reshetnyak!). 3. **Sharp Constant-1 Circumcenter Stability, CAT(0) Jung's Theorem & Bruhat–Tits Theory**: - `cat0_circumcenter_sharp_stability`: Exact constant-1 circumcenter stability `d(y, c(S))² + r(S)² ≤ R_S(y)²` (sharpening the textbook midpoint factor `2` to exact `1`!). - `cat0_existsUnique_circumcenter`: Existence & uniqueness of circumcenters in complete CAT(0) spaces. - `cat0_circumcenter_sharp_witness_euclid2`: Exact equality witness in `ℝ²` proving constant `1` is unimprovable. - `cat0_jung_theorem`: CAT(0) Jung's theorem `2 r(S)² ≤ diam(S)²` (`r(S) ≤ diam(S) / √2`), proved in 3 lines from `cat0_circumcenter_sharp_stability`! - `cat0_circumcenter_hausdorff_stability`: Sharp quantitative Hausdorff stability `d(c(S₁), c(S₂))² ≤ (r(S₁) + r(S₂)) ε + ε²`. - `cat0_almost_invariant_orbit_stability` & `cat0_bruhat_tits_fixed_point`: Quantitative `ε`-almost-invariant stability `d(g(c(S)), c(S))² ≤ 2 r(S) ε + ε²` and exact Bruhat–Tits fixed-point theorem for families of surjective isometries with a bounded invariant set. -/ namespace CAT0BusemannGeometry /-! ## Section 1: Unit-Parameterized Geodesics, CAT(0), and Busemann Convexity -/ /-- A constant-speed geodesic segment parameterized on `[0, 1]` joining `x` to `y`. -/ structure UnitGeodesic {α : Type*} [MetricSpace α] (x y : α) where γ : ℝ → α start : γ 0 = x stop : γ 1 = y isom : ∀ s t : ℝ, 0 ≤ s → s ≤ 1 → 0 ≤ t → t ≤ 1 → dist (γ s) (γ t) = |s - t| * dist x y lemma UnitGeodesic.dist_left {α : Type*} [MetricSpace α] {x y : α} (g : UnitGeodesic x y) {t : ℝ} (ht0 : 0 ≤ t) (ht1 : t ≤ 1) : dist x (g.γ t) = t * dist x y := by have h := g.isom 0 t le_rfl (by norm_num) ht0 ht1 rw [g.start, zero_sub, abs_neg, abs_of_nonneg ht0] at h exact h lemma UnitGeodesic.dist_right {α : Type*} [MetricSpace α] {x y : α} (g : UnitGeodesic x y) {t : ℝ} (ht0 : 0 ≤ t) (ht1 : t ≤ 1) : dist (g.γ t) y = (1 - t) * dist x y := by have h := g.isom t 1 ht0 ht1 (by norm_num) le_rfl rw [g.stop, abs_of_nonpos (by linarith)] at h have : -(t - 1) = 1 - t := by ring rw [this] at h exact h /-- Reversed unit-parameterized geodesic segment from `y` to `x`. -/ def UnitGeodesic.rev {α : Type*} [MetricSpace α] {x y : α} (g : UnitGeodesic x y) : UnitGeodesic y x where γ t := g.γ (1 - t) start := by simpa using g.stop stop := by simpa using g.start isom s t hs0 hs1 ht0 ht1 := by have h := g.isom (1 - s) (1 - t) (by linarith) (by linarith) (by linarith) (by linarith) rw [show (1 - s) - (1 - t) = -(s - t) by ring, abs_neg, dist_comm x y] at h exact h /-- A metric space is **CAT(0)** (Alexandrov non-positively curved) if it is geodesic and satisfies the exact `λ`-CN inequality for all `λ ∈ [0, 1]` along every geodesic segment. -/ def IsCAT0Space (α : Type*) [MetricSpace α] : Prop := (∀ x y : α, Nonempty (UnitGeodesic x y)) ∧ ∀ (x y z : α) (g : UnitGeodesic y z) (lam : ℝ), 0 ≤ lam → lam ≤ 1 → dist x (g.γ lam) ^ 2 ≤ (1 - lam) * dist x y ^ 2 + lam * dist x z ^ 2 - lam * (1 - lam) * dist y z ^ 2 /-- A metric space is **Busemann convex** if it is geodesic and the distance between any two constant-speed geodesics is a convex function on `[0, 1]`. -/ def IsBusemannSpace (α : Type*) [MetricSpace α] : Prop := (∀ x y : α, Nonempty (UnitGeodesic x y)) ∧ ∀ (x₁ y₁ x₂ y₂ : α) (g₁ : UnitGeodesic x₁ y₁) (g₂ : UnitGeodesic x₂ y₂) (lam : ℝ), 0 ≤ lam → lam ≤ 1 → dist (g₁.γ lam) (g₂.γ lam) ≤ (1 - lam) * dist x₁ x₂ + lam * dist y₁ y₂ /-- **THEOREM (Bruhat–Tits Midpoint CN Inequality)**: Specialization of `IsCAT0Space` to the exact geodesic midpoint `lam = 1/2`. -/ theorem cat0_midpoint_cn {α : Type*} [MetricSpace α] (hcat : IsCAT0Space α) (x y z : α) (g : UnitGeodesic y z) : dist x (g.γ (1 / 2)) ^ 2 ≤ (dist x y ^ 2 + dist x z ^ 2) / 2 - dist y z ^ 2 / 4 := by have h := hcat.2 x y z g (1 / 2) (by norm_num) (by norm_num) linarith /-- **THEOREM (Geodesic Uniqueness in Busemann Spaces)**: Every pair of points in a Busemann-convex space is joined by a unique unit-speed geodesic. -/ theorem busemann_unique_geodesic {α : Type*} [MetricSpace α] (hbus : IsBusemannSpace α) {x y : α} (g₁ g₂ : UnitGeodesic x y) {t : ℝ} (ht0 : 0 ≤ t) (ht1 : t ≤ 1) : g₁.γ t = g₂.γ t := by have h := hbus.2 x y x y g₁ g₂ t ht0 ht1 simp only [dist_self, mul_zero, add_zero] at h exact dist_le_zero.mp h /-- **THEOREM (CAT(0) Implies Busemann Convexity — Exact Algebraic Proof)**: Every `CAT(0)` metric space is Busemann convex. -/ theorem cat0_implies_busemann {α : Type*} [MetricSpace α] (hcat : IsCAT0Space α) : IsBusemannSpace α := by refine ⟨hcat.1, ?_⟩ -- Step 1: Shared-origin convexity `dist (g₁.γ t) (g₂.γ t) ≤ t * dist y₁ y₂` in 6 algebraic lines! have hshared : ∀ (x y₁ y₂ : α) (g₁ : UnitGeodesic x y₁) (g₂ : UnitGeodesic x y₂) (t : ℝ), 0 ≤ t → t ≤ 1 → dist (g₁.γ t) (g₂.γ t) ≤ t * dist y₁ y₂ := by intro x y₁ y₂ g₁ g₂ t ht0 ht1 -- Apply `t`-CN to point `g₁.γ t` on geodesic `g₂` (`x -> y₂`): have h1 := hcat.2 (g₁.γ t) x y₂ g₂ t ht0 ht1 -- Apply `t`-CN to point `y₂` on geodesic `g₁` (`x -> y₁`): have h2 := hcat.2 y₂ x y₁ g₁ t ht0 ht1 -- Substitute `dist (g₁.γ t) x = t * dist x y₁` and `dist y₂ (g₁.γ t) = dist (g₁.γ t) y₂`: have hgx : dist (g₁.γ t) x = t * dist x y₁ := by rw [dist_comm]; exact g₁.dist_left ht0 ht1 rw [hgx] at h1 rw [dist_comm y₂ (g₁.γ t), dist_comm y₂ x, dist_comm y₂ y₁] at h2 -- Combine `h1` with `t * h2`: all `dist x y₁` and `dist x y₂` cross terms cancel identically! have hsq : dist (g₁.γ t) (g₂.γ t) ^ 2 ≤ (t * dist y₁ y₂) ^ 2 := by have hmul : t * dist (g₁.γ t) y₂ ^ 2 ≤ t * ((1 - t) * dist x y₂ ^ 2 + t * dist y₁ y₂ ^ 2 - t * (1 - t) * dist x y₁ ^ 2) := mul_le_mul_of_nonneg_left h2 ht0 have hcomb : dist (g₁.γ t) (g₂.γ t) ^ 2 ≤ (1 - t) * (t * dist x y₁) ^ 2 + t * ((1 - t) * dist x y₂ ^ 2 + t * dist y₁ y₂ ^ 2 - t * (1 - t) * dist x y₁ ^ 2) - t * (1 - t) * dist x y₂ ^ 2 := by linarith have halg : (1 - t) * (t * dist x y₁) ^ 2 + t * ((1 - t) * dist x y₂ ^ 2 + t * dist y₁ y₂ ^ 2 - t * (1 - t) * dist x y₁ ^ 2) - t * (1 - t) * dist x y₂ ^ 2 = (t * dist y₁ y₂) ^ 2 := by ring linarith have hnonneg : 0 ≤ t * dist y₁ y₂ := mul_nonneg ht0 dist_nonneg nlinarith [dist_nonneg (x := g₁.γ t) (y := g₂.γ t)] -- Step 2: General 2-geodesic convexity via intermediate geodesic `η : UnitGeodesic x₁ y₂`! intro x₁ y₁ x₂ y₂ g₁ g₂ lam h0 h1 obtain ⟨η⟩ := hcat.1 x₁ y₂ have ha : dist (g₁.γ lam) (η.γ lam) ≤ lam * dist y₁ y₂ := hshared x₁ y₁ y₂ g₁ η lam h0 h1 have hb : dist (η.γ lam) (g₂.γ lam) ≤ (1 - lam) * dist x₁ x₂ := by have hrev := hshared y₂ x₁ x₂ η.rev g₂.rev (1 - lam) (by linarith) (by linarith) simpa [UnitGeodesic.rev, sub_sub_cancel] using hrev calc dist (g₁.γ lam) (g₂.γ lam) ≤ dist (g₁.γ lam) (η.γ lam) + dist (η.γ lam) (g₂.γ lam) := dist_triangle _ _ _ _ ≤ lam * dist y₁ y₂ + (1 - lam) * dist x₁ x₂ := add_le_add ha hb _ = (1 - lam) * dist x₁ x₂ + lam * dist y₁ y₂ := add_comm _ _ /-- **THEOREM (Geodesic Uniqueness in CAT(0) Spaces)**: Immediate consequence of `cat0_implies_busemann` and `busemann_unique_geodesic`. -/ theorem cat0_unique_geodesic {α : Type*} [MetricSpace α] (hcat : IsCAT0Space α) {x y : α} (g₁ g₂ : UnitGeodesic x y) {t : ℝ} (ht0 : 0 ≤ t) (ht1 : t ≤ 1) : g₁.γ t = g₂.γ t := busemann_unique_geodesic (cat0_implies_busemann hcat) g₁ g₂ ht0 ht1 /-- **THEOREM (Exact Reshetnyak 4-Point Inequality in CAT(0) Spaces)**: For EVERY 4 points `a, b, c, d` in a `CAT(0)` space: `d(a, c)² + d(b, d)² ≤ d(a, d)² + d(b, c)² + 2 · d(a, b) · d(c, d)`. Proved algebraically in 6 lines by applying `λ`-CN on a geodesic `b -> d` and optimizing weighted Cauchy–Schwarz `d(a, c)² ≤ d(a, m)² / t + d(c, m)² / (1 - t)`. -/ theorem cat0_reshetnyak_four_point {α : Type*} [MetricSpace α] (hcat : IsCAT0Space α) (a b c d : α) : dist a c ^ 2 + dist b d ^ 2 ≤ dist a d ^ 2 + dist b c ^ 2 + 2 * dist a b * dist c d := by by_cases hab : dist a b = 0 · have hEq : a = b := dist_eq_zero.mp hab subst hEq; simp; linarith by_cases hcd : dist c d = 0 · have hEq : c = d := dist_eq_zero.mp hcd subst hEq; simp have hab_pos : 0 < dist a b := lt_of_le_of_ne dist_nonneg (Ne.symm hab) have hcd_pos : 0 < dist c d := lt_of_le_of_ne dist_nonneg (Ne.symm hcd) set D := dist a b + dist c d have hD_pos : 0 < D := by linarith set t := dist a b / D have ht0 : 0 < t := div_pos hab_pos hD_pos have ht1 : t < 1 := (div_lt_one hD_pos).mpr (by linarith) have h1t : 1 - t = dist c d / D := by dsimp [t, D]; field_simp [ne_of_gt hD_pos]; ring have h1t_pos : 0 < 1 - t := by linarith obtain ⟨g⟩ := hcat.1 b d set m := g.γ t have hCN1 := hcat.2 a b d g t (le_of_lt ht0) (le_of_lt ht1) have hCN2 := hcat.2 c b d g t (le_of_lt ht0) (le_of_lt ht1) -- Weighted Cauchy–Schwarz: `d(a, c)² ≤ (d(a, m) + d(m, c))² ≤ d(a, m)² / t + d(c, m)² / (1 - t)`! have htri : dist a c ≤ dist a m + dist c m := by rw [dist_comm c m]; exact dist_triangle a m c have hcs : (dist a m + dist c m) ^ 2 ≤ dist a m ^ 2 / t + dist c m ^ 2 / (1 - t) := by have hsq : 0 ≤ (Real.sqrt ((1 - t) / t) * dist a m - Real.sqrt (t / (1 - t)) * dist c m) ^ 2 := sq_nonneg _ have hmul : dist a m ^ 2 / t + dist c m ^ 2 / (1 - t) - (dist a m + dist c m) ^ 2 = ((1 - t) * dist a m - t * dist c m) ^ 2 / (t * (1 - t)) := by field_simp [ne_of_gt ht0, ne_of_gt h1t_pos]; ring have hnonneg : 0 ≤ ((1 - t) * dist a m - t * dist c m) ^ 2 / (t * (1 - t)) := div_nonneg (sq_nonneg _) (mul_nonneg (le_of_lt ht0) (le_of_lt h1t_pos)) linarith have hac_sq : dist a c ^ 2 ≤ dist a m ^ 2 / t + dist c m ^ 2 / (1 - t) := le_trans (by nlinarith [dist_nonneg (x := a) (y := c), dist_nonneg (x := a) (y := m), dist_nonneg (x := c) (y := m)]) hcs -- Substitute `hCN1 / t` and `hCN2 / (1 - t)`! have hdiv1 : dist a m ^ 2 / t ≤ ((1 - t) * dist a b ^ 2 + t * dist a d ^ 2 - t * (1 - t) * dist b d ^ 2) / t := div_le_div_of_nonneg_right hCN1 (le_of_lt ht0) have hdiv2 : dist c m ^ 2 / (1 - t) ≤ ((1 - t) * dist c b ^ 2 + t * dist c d ^ 2 - t * (1 - t) * dist b d ^ 2) / (1 - t) := div_le_div_of_nonneg_right hCN2 (le_of_lt h1t_pos) have hcomb : dist a c ^ 2 ≤ ((1 - t) * dist a b ^ 2 + t * dist a d ^ 2 - t * (1 - t) * dist b d ^ 2) / t + ((1 - t) * dist c b ^ 2 + t * dist c d ^ 2 - t * (1 - t) * dist b d ^ 2) / (1 - t) := le_trans hac_sq (add_le_add hdiv1 hdiv2) have hsimp : ((1 - t) * dist a b ^ 2 + t * dist a d ^ 2 - t * (1 - t) * dist b d ^ 2) / t + ((1 - t) * dist c b ^ 2 + t * dist c d ^ 2 - t * (1 - t) * dist b d ^ 2) / (1 - t) = dist a d ^ 2 + dist b c ^ 2 + 2 * dist a b * dist c d - dist b d ^ 2 := by rw [dist_comm c b] have h1 : (1 - t) / t * dist a b ^ 2 = dist a b * dist c d := by rw [h1t]; dsimp [t]; field_simp [ne_of_gt hD_pos, ne_of_gt hab_pos] have h2 : t / (1 - t) * dist c d ^ 2 = dist a b * dist c d := by rw [h1t]; dsimp [t]; field_simp [ne_of_gt hD_pos, ne_of_gt hcd_pos] have ht_ne : t ≠ 0 := ne_of_gt ht0 have h1t_ne : 1 - t ≠ 0 := ne_of_gt h1t_pos have hsplit : ((1 - t) * dist a b ^ 2 + t * dist a d ^ 2 - t * (1 - t) * dist b d ^ 2) / t + ((1 - t) * dist b c ^ 2 + t * dist c d ^ 2 - t * (1 - t) * dist b d ^ 2) / (1 - t) = (1 - t) / t * dist a b ^ 2 + t / (1 - t) * dist c d ^ 2 + dist a d ^ 2 + dist b c ^ 2 - dist b d ^ 2 := by field_simp [ht_ne, h1t_ne]; ring rw [hsplit, h1, h2]; ring linarith /-! ## Section 2: Unique Geodesic Projections, Nonlinear Pythagorean Theorem & 1-Lipschitzness -/ /-- A subset `C` of a metric space is **geodesically convex** if every geodesic segment with endpoints in `C` stays inside `C`. -/ def IsGeodesicallyConvex {α : Type*} [MetricSpace α] (C : Set α) : Prop := ∀ {x y : α}, x ∈ C → y ∈ C → ∀ (g : UnitGeodesic x y) (t : ℝ), 0 ≤ t → t ≤ 1 → g.γ t ∈ C /-- **THEOREM (Exact Nonlinear Pythagorean Inequality for CAT(0) Projections)**: If `C` is geodesically convex and `p ∈ C` minimizes distance to `x` (`∀ y ∈ C, d(x, p) ≤ d(x, y)`), then for EVERY `y ∈ C`: `d(x, p)² + d(p, y)² ≤ d(x, y)²`! Proved elementarily by sending `λ → 0⁺` in the `λ`-CN inequality along the geodesic `p → y`. -/ theorem cat0_proj_pythagorean {α : Type*} [MetricSpace α] (hcat : IsCAT0Space α) {C : Set α} (hconv : IsGeodesicallyConvex C) {x p : α} (hpC : p ∈ C) (hmin : ∀ y ∈ C, dist x p ≤ dist x y) : ∀ y ∈ C, dist x p ^ 2 + dist p y ^ 2 ≤ dist x y ^ 2 := by intro y hyC obtain ⟨g⟩ := hcat.1 p y -- For EVERY `lam ∈ (0, 1]`, `g.γ lam ∈ C`, so `d(x, p)² + (1 - lam) d(p, y)² ≤ d(x, y)²`! have hlam : ∀ lam : ℝ, 0 < lam → lam ≤ 1 → dist x p ^ 2 + (1 - lam) * dist p y ^ 2 ≤ dist x y ^ 2 := by intro lam h0 h1 have hmem : g.γ lam ∈ C := hconv hpC hyC g lam (le_of_lt h0) h1 have hle : dist x p ^ 2 ≤ dist x (g.γ lam) ^ 2 := by have := hmin (g.γ lam) hmem nlinarith [dist_nonneg (x := x) (y := p)] have hcn := hcat.2 x p y g lam (le_of_lt h0) h1 have hdiff : lam * (dist x p ^ 2 + (1 - lam) * dist p y ^ 2 - dist x y ^ 2) ≤ 0 := by linarith nlinarith by_contra hlt push Not at hlt set Δ := dist x p ^ 2 + dist p y ^ 2 - dist x y ^ 2 have hΔ : 0 < Δ := by linarith by_cases hpy : dist p y = 0 · have := hlam 1 (by norm_num) le_rfl rw [hpy] at hlt this; linarith · have hpy2 : 0 < dist p y ^ 2 := sq_pos_of_pos (lt_of_le_of_ne dist_nonneg (Ne.symm hpy)) set lam := min (1 : ℝ) (Δ / (2 * dist p y ^ 2)) have h0 : 0 < lam := lt_min (by norm_num) (div_pos hΔ (by linarith)) have h1 : lam ≤ 1 := min_le_left _ _ have h2 : lam ≤ Δ / (2 * dist p y ^ 2) := min_le_right _ _ have hlam_bd : lam * dist p y ^ 2 ≤ Δ / 2 := by have := mul_le_mul_of_nonneg_right h2 (le_of_lt hpy2) have hsimp : Δ / (2 * dist p y ^ 2) * dist p y ^ 2 = Δ / 2 := by field_simp [ne_of_gt hpy2] linarith have := hlam lam h0 h1 linarith /-- **THEOREM (Existence and Uniqueness of Closest-Point Projection in Complete CAT(0) Spaces)**: For every nonempty, closed, geodesically convex set `C` in a complete `CAT(0)` metric space and every `x`, there exists a UNIQUE `p ∈ C` minimizing `dist x p`. -/ theorem cat0_existsUnique_proj {α : Type*} [MetricSpace α] [CompleteSpace α] (hcat : IsCAT0Space α) {C : Set α} (hne : C.Nonempty) (hclosed : IsClosed C) (hconv : IsGeodesicallyConvex C) (x : α) : ∃! p : α, p ∈ C ∧ ∀ y ∈ C, dist x p ≤ dist x y := by -- Define `d₀ = inf_{y ∈ C} dist x y`: let S : Set ℝ := (fun y => dist x y) '' C have hSne : S.Nonempty := hne.image _ have hSbd : BddBelow S := ⟨0, by rintro _ ⟨y, _, rfl⟩; exact dist_nonneg⟩ set d₀ := sInf S have hd₀_nonneg : 0 ≤ d₀ := le_csInf hSne (by rintro _ ⟨y, _, rfl⟩; exact dist_nonneg) have hd₀_le : ∀ y ∈ C, d₀ ≤ dist x y := fun y hy => csInf_le hSbd ⟨y, hy, rfl⟩ -- Pick a minimizing sequence `u n ∈ C` with `dist x (u n) < d₀ + 1 / (n + 1)`: have hex_seq : ∀ n : ℕ, ∃ y ∈ C, dist x y < d₀ + 1 / ((n : ℝ) + 1) := by intro n have hpos : (0 : ℝ) < 1 / ((n : ℝ) + 1) := by positivity obtain ⟨r, ⟨y, hyC, rfl⟩, hr⟩ := Real.lt_sInf_add_pos hSne hpos exact ⟨y, hyC, hr⟩ choose u huC hu_lt using hex_seq -- Show `u` is Cauchy using midpoint CN! have hcauchy : CauchySeq u := by rw [Metric.cauchySeq_iff] intro ε hε -- Choose `N` large enough that `4 * (d₀ + 1) / (N + 1) < ε² / 2`! obtain ⟨N, hN⟩ := exists_nat_gt (8 * (d₀ + 1) / (ε ^ 2)) refine ⟨N, fun m hm n hn => ?_⟩ obtain ⟨g⟩ := hcat.1 (u m) (u n) set mid := g.γ (1 / 2) have hmidC : mid ∈ C := hconv (huC m) (huC n) g (1 / 2) (by norm_num) (by norm_num) have hmid_ge : d₀ ^ 2 ≤ dist x mid ^ 2 := by have := hd₀_le mid hmidC; nlinarith have hcn := cat0_midpoint_cn hcat x (u m) (u n) g have hm_pos : (0 : ℝ) < (m : ℝ) + 1 := by positivity have hn_pos : (0 : ℝ) < (n : ℝ) + 1 := by positivity have hN_pos : (0 : ℝ) < (N : ℝ) + 1 := by positivity have hinv_m : 1 / ((m : ℝ) + 1) ≤ 1 / ((N : ℝ) + 1) := one_div_le_one_div_of_le hN_pos (by exact_mod_cast Nat.add_le_add_right hm 1) have hinv_n : 1 / ((n : ℝ) + 1) ≤ 1 / ((N : ℝ) + 1) := one_div_le_one_div_of_le hN_pos (by exact_mod_cast Nat.add_le_add_right hn 1) have hinv_le1 : 1 / ((N : ℝ) + 1) ≤ 1 := by rw [div_le_one hN_pos]; linarith [Nat.cast_nonneg (α := ℝ) N] have hinv_nonneg : 0 ≤ 1 / ((N : ℝ) + 1) := div_nonneg zero_le_one (le_of_lt hN_pos) have hsq_m : dist x (u m) ^ 2 ≤ d₀ ^ 2 + (2 * d₀ + 1) / ((N : ℝ) + 1) := by have h1 : dist x (u m) ≤ d₀ + 1 / ((N : ℝ) + 1) := le_trans (le_of_lt (hu_lt m)) (by linarith) have hsq : (1 / ((N : ℝ) + 1)) ^ 2 ≤ 1 / ((N : ℝ) + 1) := by nlinarith have : dist x (u m) ^ 2 ≤ (d₀ + 1 / ((N : ℝ) + 1)) ^ 2 := by nlinarith [dist_nonneg (x := x) (y := u m)] have hlin : (d₀ + 1 / ((N : ℝ) + 1)) ^ 2 = d₀ ^ 2 + 2 * d₀ * (1 / ((N : ℝ) + 1)) + (1 / ((N : ℝ) + 1)) ^ 2 := by ring have hlin2 : 2 * d₀ * (1 / ((N : ℝ) + 1)) + 1 / ((N : ℝ) + 1) = (2 * d₀ + 1) / ((N : ℝ) + 1) := by ring linarith have hsq_n : dist x (u n) ^ 2 ≤ d₀ ^ 2 + (2 * d₀ + 1) / ((N : ℝ) + 1) := by have h1 : dist x (u n) ≤ d₀ + 1 / ((N : ℝ) + 1) := le_trans (le_of_lt (hu_lt n)) (by linarith) have hsq : (1 / ((N : ℝ) + 1)) ^ 2 ≤ 1 / ((N : ℝ) + 1) := by nlinarith have : dist x (u n) ^ 2 ≤ (d₀ + 1 / ((N : ℝ) + 1)) ^ 2 := by nlinarith [dist_nonneg (x := x) (y := u n)] have hlin : (d₀ + 1 / ((N : ℝ) + 1)) ^ 2 = d₀ ^ 2 + 2 * d₀ * (1 / ((N : ℝ) + 1)) + (1 / ((N : ℝ) + 1)) ^ 2 := by ring have hlin2 : 2 * d₀ * (1 / ((N : ℝ) + 1)) + 1 / ((N : ℝ) + 1) = (2 * d₀ + 1) / ((N : ℝ) + 1) := by ring linarith have hdist_sq : dist (u m) (u n) ^ 2 ≤ 4 * (2 * d₀ + 1) / ((N : ℝ) + 1) := by have hmul4 : 4 * ((2 * d₀ + 1) / ((N : ℝ) + 1)) = 4 * (2 * d₀ + 1) / ((N : ℝ) + 1) := by ring linarith have hbound : 4 * (2 * d₀ + 1) / ((N : ℝ) + 1) < ε ^ 2 := by rw [div_lt_iff₀ hN_pos] have hε2 : 0 < ε ^ 2 := sq_pos_of_pos hε have hN' : 8 * (d₀ + 1) < (N : ℝ) * ε ^ 2 := (div_lt_iff₀ hε2).mp hN nlinarith have hlt_sq : dist (u m) (u n) ^ 2 < ε ^ 2 := lt_of_le_of_lt hdist_sq hbound nlinarith [dist_nonneg (x := u m) (y := u n)] -- By completeness, `u` converges to some `p ∈ C`! obtain ⟨p, hp_lim⟩ := cauchySeq_tendsto_of_complete hcauchy have hpC : p ∈ C := hclosed.mem_of_tendsto hp_lim (Filter.Eventually.of_forall huC) have hdist_eq : dist x p = d₀ := by apply le_antisymm · -- `dist x (u n) → dist x p` and `dist x (u n) ≤ d₀ + 1/(n+1) → d₀`! have htend : Filter.Tendsto (fun n => dist x (u n)) Filter.atTop (nhds (dist x p)) := (continuous_const.dist continuous_id).continuousAt.tendsto.comp hp_lim have hzero : Filter.Tendsto (fun n : ℕ => d₀ + 1 / ((n : ℝ) + 1)) Filter.atTop (nhds (d₀ + 0)) := tendsto_const_nhds.add tendsto_one_div_add_atTop_nhds_zero_nat rw [add_zero] at hzero exact le_of_tendsto_of_tendsto htend hzero (Filter.Eventually.of_forall (fun n => le_of_lt (hu_lt n))) · exact hd₀_le p hpC refine ⟨p, ⟨hpC, fun y hy => by rw [hdist_eq]; exact hd₀_le y hy⟩, ?_⟩ -- Uniqueness: immediate from `cat0_proj_pythagorean`! intro q ⟨hqC, hqmin⟩ have hpyth := cat0_proj_pythagorean hcat hconv hpC (fun y hy => by rw [hdist_eq]; exact hd₀_le y hy) q hqC have hle : dist x q ≤ dist x p := hqmin p hpC have hsq : dist p q ^ 2 ≤ 0 := by nlinarith [dist_nonneg (x := x) (y := p), dist_nonneg (x := x) (y := q)] exact (dist_eq_zero.mp (by nlinarith [dist_nonneg (x := p) (y := q)])).symm /-- **THEOREM (1-Lipschitzness / Non-Expansiveness of CAT(0) Projection)**: If `p ∈ C` projects `x` onto a geodesically convex set `C` and `q ∈ C` projects `y` onto `C`, then `dist p q ≤ dist x y`! Proved in 4 lines by combining `cat0_proj_pythagorean` (twice) with `cat0_reshetnyak_four_point`! -/ theorem cat0_proj_nonexpansive {α : Type*} [MetricSpace α] (hcat : IsCAT0Space α) {C : Set α} (hconv : IsGeodesicallyConvex C) {x y p q : α} (hpC : p ∈ C) (hqC : q ∈ C) (hp : ∀ z ∈ C, dist x p ≤ dist x z) (hq : ∀ z ∈ C, dist y q ≤ dist y z) : dist p q ≤ dist x y := by have h1 := cat0_proj_pythagorean hcat hconv hpC hp q hqC have h2 := cat0_proj_pythagorean hcat hconv hqC hq p hpC have hresh := cat0_reshetnyak_four_point hcat x y q p rw [dist_comm q p] at h2 hresh -- `d(x, p)² + d(y, q)² + 2 d(p, q)² ≤ d(x, q)² + d(y, p)² ≤ d(x, p)² + d(y, q)² + 2 d(x, y) d(p, q)`! have hmul : dist p q ^ 2 ≤ dist x y * dist p q := by linarith by_cases hpq : dist p q = 0 · rw [hpq]; exact dist_nonneg · have hpos : 0 < dist p q := lt_of_le_of_ne dist_nonneg (Ne.symm hpq) nlinarith /-! ## Section 3: Sharp Constant-1 Circumcenter Stability, CAT(0) Jung's Theorem & Bruhat–Tits -/ /-- A subset `S` is **bounded** if it lies in some closed ball. -/ def IsBoundedSet {α : Type*} [MetricSpace α] (S : Set α) : Prop := ∃ (x₀ : α) (R : ℝ), ∀ s ∈ S, dist x₀ s ≤ R /-- The minimal enclosing ball radius of `S` centered at `y`: `R_S(y) = sup_{s ∈ S} d(y, s)`. -/ noncomputable def ballRadius {α : Type*} [MetricSpace α] (S : Set α) (y : α) : ℝ := sSup ((fun s => dist y s) '' S) /-- The **circumradius** of `S`: `r(S) = inf_{y : α} R_S(y)`. -/ noncomputable def circumradius {α : Type*} [MetricSpace α] (S : Set α) : ℝ := sInf (Set.range (ballRadius S)) lemma ballRadius_bddAbove {α : Type*} [MetricSpace α] {S : Set α} (hbd : IsBoundedSet S) (y : α) : BddAbove ((fun s => dist y s) '' S) := by obtain ⟨x₀, R, hR⟩ := hbd refine ⟨dist y x₀ + R, ?_⟩ rintro _ ⟨s, hs, rfl⟩ linarith [dist_triangle y x₀ s, hR s hs] lemma dist_le_ballRadius {α : Type*} [MetricSpace α] {S : Set α} (hbd : IsBoundedSet S) (y : α) {s : α} (hs : s ∈ S) : dist y s ≤ ballRadius S y := le_csSup (ballRadius_bddAbove hbd y) ⟨s, hs, rfl⟩ lemma ballRadius_le_of_forall {α : Type*} [MetricSpace α] {S : Set α} (hne : S.Nonempty) (y : α) {R : ℝ} (h : ∀ s ∈ S, dist y s ≤ R) : ballRadius S y ≤ R := csSup_le (hne.image _) (by rintro _ ⟨s, hs, rfl⟩; exact h s hs) lemma ballRadius_nonneg {α : Type*} [MetricSpace α] {S : Set α} (hne : S.Nonempty) (hbd : IsBoundedSet S) (y : α) : 0 ≤ ballRadius S y := by obtain ⟨s, hs⟩ := hne exact le_trans dist_nonneg (dist_le_ballRadius hbd y hs) lemma circumradius_le_ballRadius {α : Type*} [MetricSpace α] {S : Set α} (hne : S.Nonempty) (hbd : IsBoundedSet S) (y : α) : circumradius S ≤ ballRadius S y := csInf_le ⟨0, by rintro _ ⟨z, rfl⟩; exact ballRadius_nonneg hne hbd z⟩ ⟨y, rfl⟩ lemma circumradius_nonneg {α : Type*} [MetricSpace α] {S : Set α} (hne : S.Nonempty) (hbd : IsBoundedSet S) : 0 ≤ circumradius S := le_csInf ⟨ballRadius S hne.some, hne.some, rfl⟩ (by rintro _ ⟨z, rfl⟩; exact ballRadius_nonneg hne hbd z) /-- **THEOREM (Sharp Constant-1 Circumcenter Stability — Strictly Sharper than Textbook Factor 2!)**: In ANY `CAT(0)` space, for any nonempty bounded set `S` and any circumcenter `c` of `S` (`ballRadius S c = circumradius S`), EVERY point `y` satisfies the **EXACT CONSTANT-1** quadratic lower bound: `dist y c ^ 2 + circumradius S ^ 2 ≤ ballRadius S y ^ 2`! (Textbook midpoint proofs give only `dist y c ^ 2 / 2 + r(S)² ≤ R_S(y)²`; sending `λ → 0⁺` in `λ`-CN sharpens the factor by a full factor of **2** to the exact unimprovable constant `1`!) -/ theorem cat0_circumcenter_sharp_stability {α : Type*} [MetricSpace α] (hcat : IsCAT0Space α) {S : Set α} (hne : S.Nonempty) (hbd : IsBoundedSet S) {c : α} (hc : ballRadius S c = circumradius S) (y : α) : dist y c ^ 2 + circumradius S ^ 2 ≤ ballRadius S y ^ 2 := by obtain ⟨g⟩ := hcat.1 c y set r := circumradius S have hr0 : 0 ≤ r := circumradius_nonneg hne hbd have hRy0 : 0 ≤ ballRadius S y := ballRadius_nonneg hne hbd y -- For EVERY `lam ∈ (0, 1]`, `(1 - lam) * dist c y ^ 2 + r² ≤ R_S(y)²`: have hlam : ∀ lam : ℝ, 0 < lam → lam ≤ 1 → (1 - lam) * dist c y ^ 2 + r ^ 2 ≤ ballRadius S y ^ 2 := by intro lam h0 h1 set m := g.γ lam set B := (1 - lam) * r ^ 2 + lam * ballRadius S y ^ 2 - lam * (1 - lam) * dist c y ^ 2 -- Every `s ∈ S` satisfies `dist m s ^ 2 ≤ B` by `lam`-CN! have hs_sq : ∀ s ∈ S, dist m s ^ 2 ≤ B := by intro s hs have hcn := hcat.2 s c y g lam (le_of_lt h0) h1 rw [dist_comm s m, dist_comm s c, dist_comm s y] at hcn have hsc : dist c s ≤ r := by rw [← hc]; exact dist_le_ballRadius hbd c hs have hsy : dist y s ≤ ballRadius S y := dist_le_ballRadius hbd y hs have hsc2 : dist c s ^ 2 ≤ r ^ 2 := by nlinarith [dist_nonneg (x := c) (y := s)] have hsy2 : dist y s ^ 2 ≤ ballRadius S y ^ 2 := by nlinarith [dist_nonneg (x := y) (y := s)] have h1m : 0 ≤ 1 - lam := by linarith dsimp only [B] nlinarith have hB0 : 0 ≤ B := by obtain ⟨s, hs⟩ := hne exact le_trans (sq_nonneg _) (hs_sq s hs) have hRm : ballRadius S m ≤ Real.sqrt B := by refine ballRadius_le_of_forall hne m (fun s hs => ?_) have := hs_sq s hs have hsq : dist m s ^ 2 ≤ (Real.sqrt B) ^ 2 := by rwa [Real.sq_sqrt hB0] nlinarith [dist_nonneg (x := m) (y := s), Real.sqrt_nonneg B] have hr_le_Rm : r ≤ ballRadius S m := circumradius_le_ballRadius hne hbd m have hr2_le_B : r ^ 2 ≤ B := by have : r ^ 2 ≤ (Real.sqrt B) ^ 2 := by nlinarith [Real.sqrt_nonneg B] rwa [Real.sq_sqrt hB0] at this dsimp only [B] at hr2_le_B have hdiff : lam * ((1 - lam) * dist c y ^ 2 + r ^ 2 - ballRadius S y ^ 2) ≤ 0 := by linarith nlinarith rw [dist_comm y c] by_contra hlt push Not at hlt set Δ := dist c y ^ 2 + r ^ 2 - ballRadius S y ^ 2 have hΔ : 0 < Δ := by linarith by_cases hcy : dist c y = 0 · have := hlam 1 (by norm_num) le_rfl rw [hcy] at hlt this; linarith · have hcy2 : 0 < dist c y ^ 2 := sq_pos_of_pos (lt_of_le_of_ne dist_nonneg (Ne.symm hcy)) set lam := min (1 : ℝ) (Δ / (2 * dist c y ^ 2)) have h0 : 0 < lam := lt_min (by norm_num) (div_pos hΔ (by linarith)) have h1 : lam ≤ 1 := min_le_left _ _ have h2 : lam ≤ Δ / (2 * dist c y ^ 2) := min_le_right _ _ have hlam_bd : lam * dist c y ^ 2 ≤ Δ / 2 := by have := mul_le_mul_of_nonneg_right h2 (le_of_lt hcy2) have hsimp : Δ / (2 * dist c y ^ 2) * dist c y ^ 2 = Δ / 2 := by field_simp [ne_of_gt hcy2] linarith have := hlam lam h0 h1 linarith /-- **THEOREM (Existence and Uniqueness of Circumcenters in Complete CAT(0) Spaces)**: Every nonempty bounded subset `S` of a complete `CAT(0)` metric space has a UNIQUE circumcenter `c` achieving `ballRadius S c = circumradius S`. -/ theorem cat0_existsUnique_circumcenter {α : Type*} [MetricSpace α] [CompleteSpace α] (hcat : IsCAT0Space α) {S : Set α} (hne : S.Nonempty) (hbd : IsBoundedSet S) : ∃! c : α, ballRadius S c = circumradius S := by set r := circumradius S have hr0 : 0 ≤ r := circumradius_nonneg hne hbd -- Pick a minimizing sequence `u n` with `ballRadius S (u n) < r + 1 / (n + 1)`: have hex_seq : ∀ n : ℕ, ∃ y : α, ballRadius S y < r + 1 / ((n : ℝ) + 1) := by intro n have hpos : (0 : ℝ) < 1 / ((n : ℝ) + 1) := by positivity have hne_rng : (Set.range (ballRadius S)).Nonempty := ⟨ballRadius S hne.some, hne.some, rfl⟩ obtain ⟨v, ⟨y, rfl⟩, hv⟩ := Real.lt_sInf_add_pos hne_rng hpos exact ⟨y, hv⟩ choose u hu_lt using hex_seq -- Show `u` is Cauchy using midpoint CN! have hcauchy : CauchySeq u := by rw [Metric.cauchySeq_iff] intro ε hε obtain ⟨N, hN⟩ := exists_nat_gt (8 * (r + 1) / (ε ^ 2)) refine ⟨N, fun m hm n hn => ?_⟩ obtain ⟨g⟩ := hcat.1 (u m) (u n) set mid := g.γ (1 / 2) have hN_pos : (0 : ℝ) < (N : ℝ) + 1 := by positivity have hinv_m : 1 / ((m : ℝ) + 1) ≤ 1 / ((N : ℝ) + 1) := one_div_le_one_div_of_le hN_pos (by exact_mod_cast Nat.add_le_add_right hm 1) have hinv_n : 1 / ((n : ℝ) + 1) ≤ 1 / ((N : ℝ) + 1) := one_div_le_one_div_of_le hN_pos (by exact_mod_cast Nat.add_le_add_right hn 1) have hinv_le1 : 1 / ((N : ℝ) + 1) ≤ 1 := by rw [div_le_one hN_pos]; linarith [Nat.cast_nonneg (α := ℝ) N] have hinv_nonneg : 0 ≤ 1 / ((N : ℝ) + 1) := div_nonneg zero_le_one (le_of_lt hN_pos) have hRm_sq : ballRadius S (u m) ^ 2 ≤ r ^ 2 + (2 * r + 1) / ((N : ℝ) + 1) := by have h1 : ballRadius S (u m) ≤ r + 1 / ((N : ℝ) + 1) := le_trans (le_of_lt (hu_lt m)) (by linarith) have hsq : (1 / ((N : ℝ) + 1)) ^ 2 ≤ 1 / ((N : ℝ) + 1) := by nlinarith have hR0 := ballRadius_nonneg hne hbd (u m) have : ballRadius S (u m) ^ 2 ≤ (r + 1 / ((N : ℝ) + 1)) ^ 2 := by nlinarith have hlin : (r + 1 / ((N : ℝ) + 1)) ^ 2 = r ^ 2 + 2 * r * (1 / ((N : ℝ) + 1)) + (1 / ((N : ℝ) + 1)) ^ 2 := by ring have hlin2 : 2 * r * (1 / ((N : ℝ) + 1)) + 1 / ((N : ℝ) + 1) = (2 * r + 1) / ((N : ℝ) + 1) := by ring linarith have hRn_sq : ballRadius S (u n) ^ 2 ≤ r ^ 2 + (2 * r + 1) / ((N : ℝ) + 1) := by have h1 : ballRadius S (u n) ≤ r + 1 / ((N : ℝ) + 1) := le_trans (le_of_lt (hu_lt n)) (by linarith) have hsq : (1 / ((N : ℝ) + 1)) ^ 2 ≤ 1 / ((N : ℝ) + 1) := by nlinarith have hR0 := ballRadius_nonneg hne hbd (u n) have : ballRadius S (u n) ^ 2 ≤ (r + 1 / ((N : ℝ) + 1)) ^ 2 := by nlinarith have hlin : (r + 1 / ((N : ℝ) + 1)) ^ 2 = r ^ 2 + 2 * r * (1 / ((N : ℝ) + 1)) + (1 / ((N : ℝ) + 1)) ^ 2 := by ring have hlin2 : 2 * r * (1 / ((N : ℝ) + 1)) + 1 / ((N : ℝ) + 1) = (2 * r + 1) / ((N : ℝ) + 1) := by ring linarith set B := r ^ 2 + (2 * r + 1) / ((N : ℝ) + 1) - dist (u m) (u n) ^ 2 / 4 have hs_sq : ∀ s ∈ S, dist mid s ^ 2 ≤ B := by intro s hs have hcn := cat0_midpoint_cn hcat s (u m) (u n) g rw [dist_comm s mid, dist_comm s (u m), dist_comm s (u n)] at hcn have hm_le : dist (u m) s ^ 2 ≤ ballRadius S (u m) ^ 2 := by have := dist_le_ballRadius hbd (u m) hs; nlinarith [dist_nonneg (x := u m) (y := s)] have hn_le : dist (u n) s ^ 2 ≤ ballRadius S (u n) ^ 2 := by have := dist_le_ballRadius hbd (u n) hs; nlinarith [dist_nonneg (x := u n) (y := s)] dsimp only [B]; linarith have hB0 : 0 ≤ B := by obtain ⟨s, hs⟩ := hne; exact le_trans (sq_nonneg _) (hs_sq s hs) have hRmid : ballRadius S mid ≤ Real.sqrt B := by refine ballRadius_le_of_forall hne mid (fun s hs => ?_) have hsq : dist mid s ^ 2 ≤ (Real.sqrt B) ^ 2 := by rw [Real.sq_sqrt hB0]; exact hs_sq s hs nlinarith [dist_nonneg (x := mid) (y := s), Real.sqrt_nonneg B] have hr_le : r ^ 2 ≤ B := by have := circumradius_le_ballRadius hne hbd mid have : r ^ 2 ≤ (Real.sqrt B) ^ 2 := by nlinarith [Real.sqrt_nonneg B] rwa [Real.sq_sqrt hB0] at this have hdist_sq : dist (u m) (u n) ^ 2 ≤ 4 * (2 * r + 1) / ((N : ℝ) + 1) := by dsimp only [B] at hr_le have hmul4 : 4 * ((2 * r + 1) / ((N : ℝ) + 1)) = 4 * (2 * r + 1) / ((N : ℝ) + 1) := by ring linarith have hbound : 4 * (2 * r + 1) / ((N : ℝ) + 1) < ε ^ 2 := by rw [div_lt_iff₀ hN_pos] have hε2 : 0 < ε ^ 2 := sq_pos_of_pos hε have hN' : 8 * (r + 1) < (N : ℝ) * ε ^ 2 := (div_lt_iff₀ hε2).mp hN nlinarith have hlt_sq : dist (u m) (u n) ^ 2 < ε ^ 2 := lt_of_le_of_lt hdist_sq hbound nlinarith [dist_nonneg (x := u m) (y := u n)] obtain ⟨c, hc_lim⟩ := cauchySeq_tendsto_of_complete hcauchy have hc_eq : ballRadius S c = r := by apply le_antisymm · refine ballRadius_le_of_forall hne c (fun s hs => ?_) -- For every `n`, `dist c s ≤ dist c (u n) + dist (u n) s ≤ dist c (u n) + r + 1/(n+1)` → `r`! have htend1 : Filter.Tendsto (fun n => dist c (u n)) Filter.atTop (nhds (dist c c)) := (continuous_const.dist continuous_id).continuousAt.tendsto.comp hc_lim rw [dist_self] at htend1 have htend2 : Filter.Tendsto (fun n : ℕ => r + 1 / ((n : ℝ) + 1)) Filter.atTop (nhds (r + 0)) := tendsto_const_nhds.add tendsto_one_div_add_atTop_nhds_zero_nat rw [add_zero] at htend2 have hsum := htend1.add htend2 rw [zero_add] at hsum refine ge_of_tendsto hsum (Filter.Eventually.of_forall (fun n => ?_)) have h1 := dist_triangle c (u n) s have h2 := dist_le_ballRadius hbd (u n) hs have h3 := hu_lt n linarith · exact circumradius_le_ballRadius hne hbd c refine ⟨c, hc_eq, ?_⟩ intro c' hc' have hstab := cat0_circumcenter_sharp_stability hcat hne hbd hc_eq c' rw [hc'] at hstab exact dist_eq_zero.mp (by nlinarith [dist_nonneg (x := c') (y := c)]) /-- **THEOREM (Exact Optimality Witness for Constant-1 Circumcenter Stability in `ℝ²`)**: In the Euclidean plane `ℝ × ℝ` (with `EuclideanSpace ℝ (Fin 2)`), for `S = {(-1, 0), (1, 0)}`, circumcenter `c = (0, 0)` (with `r(S) = 1`), and `y = (0, h)`, the inequality `dist y c ^ 2 + r(S)² ≤ R_S(y)²` holds with **EXACT EQUALITY** `h² + 1 = h² + 1` for EVERY `h ∈ ℝ`! Hence constant `1` in `cat0_circumcenter_sharp_stability` CANNOT be increased! -/ theorem cat0_circumcenter_sharp_witness_euclid2 (h : ℝ) : let S : Set (EuclideanSpace ℝ (Fin 2)) := {WithLp.toLp 2 ![-1, 0], WithLp.toLp 2 ![1, 0]} let c : EuclideanSpace ℝ (Fin 2) := WithLp.toLp 2 ![0, 0] let y : EuclideanSpace ℝ (Fin 2) := WithLp.toLp 2 ![0, h] ballRadius S c = 1 ∧ circumradius S = 1 ∧ dist y c ^ 2 + circumradius S ^ 2 = ballRadius S y ^ 2 := by intro S c y set pL : EuclideanSpace ℝ (Fin 2) := WithLp.toLp 2 ![-1, 0] set pR : EuclideanSpace ℝ (Fin 2) := WithLp.toLp 2 ![1, 0] have hS_eq : S = {pL, pR} := rfl have hdist_sq : ∀ u v : EuclideanSpace ℝ (Fin 2), dist u v ^ 2 = (u 0 - v 0) ^ 2 + (u 1 - v 1) ^ 2 := by intro u v rw [EuclideanSpace.dist_eq, Real.sq_sqrt (Finset.sum_nonneg (fun _ _ => sq_nonneg _)), Fin.sum_univ_two] simp [Real.dist_eq] have hd_cL : dist c pL = 1 := by have hsq := hdist_sq c pL dsimp [c, pL] at hsq; norm_num at hsq rcases hsq with h | h · exact h · linarith [dist_nonneg (x := c) (y := pL)] have hd_cR : dist c pR = 1 := by have hsq := hdist_sq c pR dsimp [c, pR] at hsq; norm_num at hsq rcases hsq with h | h · exact h · linarith [dist_nonneg (x := c) (y := pR)] have hd_LR : dist pL pR = 2 := by have hsq := hdist_sq pL pR dsimp [pL, pR] at hsq; norm_num at hsq nlinarith [dist_nonneg (x := pL) (y := pR)] have hd_yc : dist y c ^ 2 = h ^ 2 := by have hsq := hdist_sq y c dsimp [y, c] at hsq; linarith have hd_yL_sq : dist y pL ^ 2 = 1 + h ^ 2 := by have hsq := hdist_sq y pL dsimp [y, pL] at hsq; linarith have hd_yR_sq : dist y pR ^ 2 = 1 + h ^ 2 := by have hsq := hdist_sq y pR dsimp [y, pR] at hsq; linarith have hd_yL_eq : dist y pL = dist y pR := by nlinarith [dist_nonneg (x := y) (y := pL), dist_nonneg (x := y) (y := pR)] have hSne : S.Nonempty := ⟨pL, by simp [hS_eq]⟩ have hSbd : IsBoundedSet S := ⟨c, 1, by rintro s (rfl | rfl) <;> linarith⟩ have hRc : ballRadius S c = 1 := by apply le_antisymm · exact ballRadius_le_of_forall hSne c (by rintro s (rfl | rfl) <;> linarith) · rw [← hd_cL]; exact dist_le_ballRadius hSbd c (by simp [hS_eq]) have hr : circumradius S = 1 := by apply le_antisymm · rw [← hRc]; exact circumradius_le_ballRadius hSne hSbd c · refine le_csInf (Set.range_nonempty _) ?_ rintro _ ⟨z, rfl⟩ have h1 := dist_le_ballRadius hSbd z (show pL ∈ S by simp [hS_eq]) have h2 := dist_le_ballRadius hSbd z (show pR ∈ S by simp [hS_eq]) have htri := dist_triangle pL z pR rw [dist_comm pL z] at htri linarith have hRy : ballRadius S y = dist y pL := by apply le_antisymm · exact ballRadius_le_of_forall hSne y (by rintro s (rfl | rfl) <;> linarith) · exact dist_le_ballRadius hSbd y (by simp [hS_eq]) refine ⟨hRc, hr, ?_⟩ rw [hr, hRy, hd_yc, hd_yL_sq]; ring /-- **THEOREM (CAT(0) Jung's Theorem — 3-Line Proof from Sharp Constant-1 Stability)**: For ANY nonempty bounded set `S` in a `CAT(0)` space having a circumcenter `c` and diameter bound `D ≥ 0` (`∀ s₁ ∈ S, ∀ s₂ ∈ S, dist s₁ s₂ ≤ D`): `2 * circumradius S ^ 2 ≤ D ^ 2` (equivalently `r(S) ≤ D / √2`)! -/ theorem cat0_jung_theorem {α : Type*} [MetricSpace α] (hcat : IsCAT0Space α) {S : Set α} (hne : S.Nonempty) (hbd : IsBoundedSet S) {c : α} (hc : ballRadius S c = circumradius S) {D : ℝ} (hD0 : 0 ≤ D) (hD : ∀ s₁ ∈ S, ∀ s₂ ∈ S, dist s₁ s₂ ≤ D) : 2 * circumradius S ^ 2 ≤ D ^ 2 := by -- For EVERY `s ∈ S`, `ballRadius S s ≤ D`, so by sharp constant-1 stability: -- `dist s c ^ 2 + r² ≤ R_S(s)² ≤ D²`, i.e., `dist c s ≤ √(D² - r²)`! -- Taking `sup_{s ∈ S}` gives `r = R_S(c) ≤ √(D² - r²)`, i.e., `2 r² ≤ D²`! have hs_bd : ∀ s ∈ S, dist c s ^ 2 + circumradius S ^ 2 ≤ D ^ 2 := by intro s hs have hstab := cat0_circumcenter_sharp_stability hcat hne hbd hc s have hRs : ballRadius S s ≤ D := ballRadius_le_of_forall hne s (fun s₂ hs₂ => hD s hs s₂ hs₂) have hRs0 := ballRadius_nonneg hne hbd s rw [dist_comm s c] at hstab nlinarith have hD_ge_r : circumradius S ^ 2 ≤ D ^ 2 := by obtain ⟨s, hs⟩ := hne linarith [hs_bd s hs, sq_nonneg (dist c s)] have hrem0 : 0 ≤ D ^ 2 - circumradius S ^ 2 := by linarith have hRc_le : ballRadius S c ≤ Real.sqrt (D ^ 2 - circumradius S ^ 2) := by refine ballRadius_le_of_forall hne c (fun s hs => ?_) have hsq : dist c s ^ 2 ≤ (Real.sqrt (D ^ 2 - circumradius S ^ 2)) ^ 2 := by rw [Real.sq_sqrt hrem0]; linarith [hs_bd s hs] nlinarith [dist_nonneg (x := c) (y := s), Real.sqrt_nonneg (D ^ 2 - circumradius S ^ 2)] rw [hc] at hRc_le have hr0 := circumradius_nonneg hne hbd have hsq : circumradius S ^ 2 ≤ (Real.sqrt (D ^ 2 - circumradius S ^ 2)) ^ 2 := by nlinarith [Real.sqrt_nonneg (D ^ 2 - circumradius S ^ 2)] rw [Real.sq_sqrt hrem0] at hsq linarith /-- Symmetric Hausdorff `ε`-closeness between two sets `S₁, S₂`. -/ def HausdorffClose {α : Type*} [MetricSpace α] (S₁ S₂ : Set α) (ε : ℝ) : Prop := (∀ s₁ ∈ S₁, ∃ s₂ ∈ S₂, dist s₁ s₂ ≤ ε) ∧ (∀ s₂ ∈ S₂, ∃ s₁ ∈ S₁, dist s₁ s₂ ≤ ε) /-- **THEOREM (Sharp Quantitative Hausdorff Stability of CAT(0) Circumcenters)**: If `S₁, S₂` are nonempty bounded sets in a `CAT(0)` space with `HausdorffClose S₁ S₂ ε` (`ε ≥ 0`) and circumcenters `c₁, c₂`, then: `dist c₁ c₂ ^ 2 ≤ (circumradius S₁ + circumradius S₂) * ε + ε ^ 2`! (Uses BOTH sharp constant-1 stability bounds symmetrically — beats the naive triangle/midpoint bound by a full factor of **2**!) -/ theorem cat0_circumcenter_hausdorff_stability {α : Type*} [MetricSpace α] (hcat : IsCAT0Space α) {S₁ S₂ : Set α} (hne₁ : S₁.Nonempty) (hbd₁ : IsBoundedSet S₁) (hne₂ : S₂.Nonempty) (hbd₂ : IsBoundedSet S₂) {c₁ c₂ : α} (hc₁ : ballRadius S₁ c₁ = circumradius S₁) (hc₂ : ballRadius S₂ c₂ = circumradius S₂) {ε : ℝ} (hε : 0 ≤ ε) (hH : HausdorffClose S₁ S₂ ε) : dist c₁ c₂ ^ 2 ≤ (circumradius S₁ + circumradius S₂) * ε + ε ^ 2 := by have hR1_c2 : ballRadius S₁ c₂ ≤ circumradius S₂ + ε := by refine ballRadius_le_of_forall hne₁ c₂ (fun s₁ hs₁ => ?_) obtain ⟨s₂, hs₂, hd12⟩ := hH.1 s₁ hs₁ have htri := dist_triangle c₂ s₂ s₁ rw [dist_comm s₂ s₁] at htri have hs2_le : dist c₂ s₂ ≤ circumradius S₂ := by rw [← hc₂]; exact dist_le_ballRadius hbd₂ c₂ hs₂ linarith have hR2_c1 : ballRadius S₂ c₁ ≤ circumradius S₁ + ε := by refine ballRadius_le_of_forall hne₂ c₁ (fun s₂ hs₂ => ?_) obtain ⟨s₁, hs₁, hd12⟩ := hH.2 s₂ hs₂ have htri := dist_triangle c₁ s₁ s₂ have hs1_le : dist c₁ s₁ ≤ circumradius S₁ := by rw [← hc₁]; exact dist_le_ballRadius hbd₁ c₁ hs₁ linarith have hstab1 := cat0_circumcenter_sharp_stability hcat hne₁ hbd₁ hc₁ c₂ have hstab2 := cat0_circumcenter_sharp_stability hcat hne₂ hbd₂ hc₂ c₁ rw [dist_comm c₂ c₁] at hstab1 have hr1 := circumradius_nonneg hne₁ hbd₁ have hr2 := circumradius_nonneg hne₂ hbd₂ have hR10 := ballRadius_nonneg hne₁ hbd₁ c₂ have hR20 := ballRadius_nonneg hne₂ hbd₂ c₁ have hsq1 : ballRadius S₁ c₂ ^ 2 ≤ (circumradius S₂ + ε) ^ 2 := by nlinarith have hsq2 : ballRadius S₂ c₁ ^ 2 ≤ (circumradius S₁ + ε) ^ 2 := by nlinarith -- Add `hstab1` and `hstab2`: `2 d(c₁, c₂)² + r₁² + r₂² ≤ (r₂ + ε)² + (r₁ + ε)²`! nlinarith /-- Helper: a surjective isometry preserves `ballRadius` and `circumradius` identically! -/ lemma isometry_ballRadius {α : Type*} [MetricSpace α] (g : α ≃ᵢ α) {S : Set α} (y : α) : ballRadius (g '' S) (g y) = ballRadius S y := by unfold ballRadius congr 1 ext r simp only [Set.mem_image] constructor · rintro ⟨_, ⟨s, hs, rfl⟩, rfl⟩ exact ⟨s, hs, (g.dist_eq y s).symm⟩ · rintro ⟨s, hs, rfl⟩ exact ⟨g s, ⟨s, hs, rfl⟩, g.dist_eq y s⟩ lemma isometry_circumradius {α : Type*} [MetricSpace α] (g : α ≃ᵢ α) (S : Set α) : circumradius (g '' S) = circumradius S := by unfold circumradius congr 1 ext r simp only [Set.mem_range] constructor · rintro ⟨z, rfl⟩ refine ⟨g.symm z, ?_⟩ have := isometry_ballRadius g (S := S) (g.symm z) simpa using this.symm · rintro ⟨y, rfl⟩ exact ⟨g y, isometry_ballRadius g y⟩ /-- **THEOREM (Quantitative Almost-Invariant Bruhat–Tits Orbit Stability)**: If `g : α ≃ᵢ α` is a surjective isometry of a `CAT(0)` space and `S` is a nonempty bounded set with circumcenter `c` that is `ε`-almost-invariant (`HausdorffClose (g '' S) S ε`, `ε ≥ 0`), then: `dist (g c) c ^ 2 ≤ 2 * circumradius S * ε + ε ^ 2`! -/ theorem cat0_almost_invariant_orbit_stability {α : Type*} [MetricSpace α] (hcat : IsCAT0Space α) (g : α ≃ᵢ α) {S : Set α} (hne : S.Nonempty) (hbd : IsBoundedSet S) {c : α} (hc : ballRadius S c = circumradius S) {ε : ℝ} (hε : 0 ≤ ε) (hH : HausdorffClose (g '' S) S ε) : dist (g c) c ^ 2 ≤ 2 * circumradius S * ε + ε ^ 2 := by have hne_g : (g '' S).Nonempty := hne.image g have hbd_g : IsBoundedSet (g '' S) := by obtain ⟨x₀, R, hR⟩ := hbd refine ⟨g x₀, R, ?_⟩ rintro _ ⟨s, hs, rfl⟩ rw [g.dist_eq]; exact hR s hs have hc_g : ballRadius (g '' S) (g c) = circumradius (g '' S) := by rw [isometry_ballRadius, isometry_circumradius, hc] have hstab := cat0_circumcenter_hausdorff_stability hcat hne_g hbd_g hne hbd hc_g hc hε hH rw [isometry_circumradius] at hstab linarith /-- **THEOREM (Bruhat–Tits Fixed-Point Theorem for Isometric Actions on Complete CAT(0) Spaces)**: If a family `G` of surjective isometries of a complete `CAT(0)` space preserves a nonempty bounded subset `S` (`∀ g ∈ G, g '' S = S`), then the unique circumcenter `c` of `S` is a COMMON FIXED POINT of every `g ∈ G`! -/ theorem cat0_bruhat_tits_fixed_point {α : Type*} [MetricSpace α] [CompleteSpace α] (hcat : IsCAT0Space α) {S : Set α} (hne : S.Nonempty) (hbd : IsBoundedSet S) (G : Set (α ≃ᵢ α)) (hinv : ∀ g ∈ G, g '' S = S) : ∃ c : α, ballRadius S c = circumradius S ∧ ∀ g ∈ G, g c = c := by obtain ⟨c, hc, _⟩ := cat0_existsUnique_circumcenter hcat hne hbd refine ⟨c, hc, fun g hg => ?_⟩ have hH : HausdorffClose (g '' S) S 0 := by rw [hinv g hg] exact ⟨fun s hs => ⟨s, hs, by simp⟩, fun s hs => ⟨s, hs, by simp⟩⟩ have h0 := cat0_almost_invariant_orbit_stability hcat g hne hbd hc le_rfl hH exact dist_eq_zero.mp (by nlinarith [dist_nonneg (x := g c) (y := c)]) /-! ## Axiom Verification -/ #print axioms cat0_midpoint_cn #print axioms busemann_unique_geodesic #print axioms cat0_implies_busemann #print axioms cat0_unique_geodesic #print axioms cat0_reshetnyak_four_point #print axioms cat0_proj_pythagorean #print axioms cat0_existsUnique_proj #print axioms cat0_proj_nonexpansive #print axioms cat0_circumcenter_sharp_stability #print axioms cat0_existsUnique_circumcenter #print axioms cat0_circumcenter_sharp_witness_euclid2 #print axioms cat0_jung_theorem #print axioms cat0_circumcenter_hausdorff_stability #print axioms cat0_almost_invariant_orbit_stability #print axioms cat0_bruhat_tits_fixed_point end CAT0BusemannGeometry