import Mathlib /-! # Exact Gromov 4-Point Hyperbolicity, Sharp Finite-n Tree Approximation, # Ptolemy log₂ Sharpness, 6-Point Hexagon Obstruction, and Exact Cycle / Grid Bounds This module is self-contained (importing only `Mathlib`) and establishes: 1. Core Gromov product and 4-point δ-hyperbolicity API + off-diagonal pendant shifting. 2. Repeated-squaring bottleneck Gromov tree construction and the sharp finite-n Gromov Tree-Approximation Theorem: d(x, y) - 2 δ ⌈log₂(n - 2)⌉ ≤ d_T(x, y) ≤ d(x, y) (∀ n ≥ 3), together with its centered two-sided L_∞ refinement (error ≤ δ ⌈log₂(n - 2)⌉). 3. Exact sharpness via the Ptolemy log₂ metric X_n^{log}(δ), which has exact global 4-point hyperbolicity δ_4 = δ (for n ≥ 4) and exact Gromov tree distortion 2 δ log₂(n - 2), matching the upper bound identically for every dyadic n = 2^k + 2. 4. The Universal 6-Point Hexagon-Diameter Inequality for arbitrary δ-hyperbolic spaces (proved via a 3-vertex functional-digraph cancellation argument), yielding the EXACT minimax L_∞ tree-approximation distortion L/6 of the geodesic circle S^1_L and m of every discrete cycle C_{6m} (matched by an explicit 3-ray folded tripod), as well as an improved Petrie-hexagon lower bound on 3D grids P_{a+1}^3. 5. Exact closed-form 4-point hyperbolicity of ALL discrete cycles C_n (exact mod-4 formula for all n ≥ 3) and ALL 2D grids P_m □ P_k (exact min(m, k) - 1 via our universal ℓ₁-product 4-point inequality). -/ namespace GromovTreeApproximation open Finset /-! ## Section 1: Core Metric Functions, Gromov Product & 4-Point Hyperbolicity -/ /-- Lightweight pseudometric predicate on a distance function `d : α → α → ℝ`. -/ structure IsPseudoMetricFn {α : Type*} (d : α → α → ℝ) : Prop where nonneg : ∀ x y, 0 ≤ d x y self : ∀ x, d x x = 0 symm : ∀ x y, d x y = d y x triangle : ∀ x y z, d x z ≤ d x y + d y z /-- Any `PseudoMetricSpace` yields an `IsPseudoMetricFn`. -/ lemma isPseudoMetricFn_dist {α : Type*} [PseudoMetricSpace α] : IsPseudoMetricFn (dist : α → α → ℝ) where nonneg := fun _ _ => dist_nonneg self := dist_self symm := dist_comm triangle := dist_triangle /-- The Gromov product `(x | y)_w := (d(x, w) + d(y, w) - d(x, y)) / 2`. -/ noncomputable def gromovProd {α : Type*} (d : α → α → ℝ) (w x y : α) : ℝ := (d x w + d y w - d x y) / 2 /-- Gromov 4-point `δ`-hyperbolicity: `d(x,y) + d(z,w) ≤ max(d(x,z) + d(y,w), d(x,w) + d(y,z)) + 2δ`. -/ def IsFourPointHyperbolic {α : Type*} (d : α → α → ℝ) (δ : ℝ) : Prop := ∀ x y z w, d x y + d z w ≤ max (d x z + d y w) (d x w + d y z) + 2 * δ /-- Pointed Gromov product `δ`-hyperbolicity at a fixed basepoint `w`. -/ def IsGromovProdAt {α : Type*} (d : α → α → ℝ) (w : α) (δ : ℝ) : Prop := ∀ x y z, min (gromovProd d w x z) (gromovProd d w y z) - δ ≤ gromovProd d w x y /-- Global Gromov product `δ`-hyperbolicity (at all basepoints `w`). -/ def IsGromovProdHyperbolic {α : Type*} (d : α → α → ℝ) (δ : ℝ) : Prop := ∀ w, IsGromovProdAt d w δ lemma gromovProd_symm {α : Type*} {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w x y : α) : gromovProd d w x y = gromovProd d w y x := by unfold gromovProd rw [hd.symm x y] ring lemma gromovProd_nonneg {α : Type*} {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w x y : α) : 0 ≤ gromovProd d w x y := by unfold gromovProd have h := hd.triangle x w y rw [hd.symm w y] at h linarith lemma gromovProd_self {α : Type*} {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w x : α) : gromovProd d w x x = d x w := by unfold gromovProd rw [hd.self] ring lemma gromovProd_base_left {α : Type*} {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w y : α) : gromovProd d w w y = 0 := by unfold gromovProd rw [hd.self, hd.symm w y] ring lemma gromovProd_base_right {α : Type*} {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w x : α) : gromovProd d w x w = 0 := by rw [gromovProd_symm hd, gromovProd_base_left hd] lemma gromovProd_le_left {α : Type*} {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w x y : α) : gromovProd d w x y ≤ d x w := by unfold gromovProd have h := hd.triangle y x w rw [hd.symm y x] at h linarith lemma gromovProd_le_right {α : Type*} {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w x y : α) : gromovProd d w x y ≤ d y w := by rw [gromovProd_symm hd] exact gromovProd_le_left hd w y x /-- Exact equivalence between the 4-point condition and global Gromov-product hyperbolicity. -/ theorem fourPointHyperbolic_iff_gromovProdHyperbolic {α : Type*} {d : α → α → ℝ} (_hd : IsPseudoMetricFn d) (δ : ℝ) : IsFourPointHyperbolic d δ ↔ IsGromovProdHyperbolic d δ := by constructor · intro h w x y z have h4 := h x y z w unfold gromovProd rcases le_max_iff.mp (by linarith : d x y + d z w - 2 * δ ≤ max (d x z + d y w) (d x w + d y z)) with h1 | h2 · linarith [min_le_left ((d x w + d z w - d x z) / 2) ((d y w + d z w - d y z) / 2)] · linarith [min_le_right ((d x w + d z w - d x z) / 2) ((d y w + d z w - d y z) / 2)] · intro h x y z w have hg := h w x y z unfold gromovProd at hg rcases min_le_iff.mp (by linarith : min ((d x w + d z w - d x z) / 2) ((d y w + d z w - d y z) / 2) ≤ (d x w + d y w - d x y) / 2 + δ) with h1 | h2 · linarith [le_max_left (d x z + d y w) (d x w + d y z)] · linarith [le_max_right (d x z + d y w) (d x w + d y z)] /-- Shifting all off-diagonal distances by `c ≥ 0` (attaching pendant leaves of length `c / 2`). -/ def shiftOffDiag {α : Type*} [DecidableEq α] (d : α → α → ℝ) (c : ℝ) (x y : α) : ℝ := if x = y then 0 else d x y + c lemma shiftOffDiag_isPseudoMetricFn {α : Type*} [DecidableEq α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) {c : ℝ} (hc : 0 ≤ c) : IsPseudoMetricFn (shiftOffDiag d c) where nonneg x y := by unfold shiftOffDiag split_ifs · exact le_rfl · linarith [hd.nonneg x y] self x := by simp [shiftOffDiag] symm x y := by unfold shiftOffDiag by_cases h : x = y · subst h; simp · have h' : y ≠ x := Ne.symm h simp [h, h', hd.symm x y] triangle x y z := by unfold shiftOffDiag by_cases hxz : x = z · subst hxz; simp; split_ifs <;> linarith [hd.nonneg x y, hd.nonneg y x] · by_cases hxy : x = y · subst hxy; simp [hxz] · by_cases hyz : y = z · subst hyz; simp [hxz] · simp [hxz, hxy, hyz]; linarith [hd.triangle x y z] /-- Shifting a `0`-hyperbolic pseudometric by `c ≥ 0` on distinct pairs preserves `0`-hyperbolicity. -/ theorem shiftOffDiag_zeroHyperbolic {α : Type*} [DecidableEq α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (h0 : IsFourPointHyperbolic d 0) {c : ℝ} (hc : 0 ≤ c) : IsFourPointHyperbolic (shiftOffDiag d c) 0 := by intro x y z w have hpm := shiftOffDiag_isPseudoMetricFn hd hc simp only [mul_zero, add_zero] by_cases hxy : x = y · subst hxy; rw [hpm.self, zero_add]; exact le_max_of_le_left (by linarith [hpm.triangle z x w, hpm.symm x z]) by_cases hzw : z = w · subst hzw; rw [hpm.self, add_zero]; exact le_max_of_le_left (by linarith [hpm.triangle x z y, hpm.symm z y]) by_cases hxz : x = z · subst hxz; rw [hpm.self, zero_add]; exact le_max_of_le_right (by linarith [hpm.triangle x y w, hpm.symm x y, hpm.symm w y]) by_cases hyw : y = w · subst hyw; rw [hpm.self, add_zero]; exact le_max_of_le_right (by linarith [hpm.triangle x y z, hpm.symm y z]) by_cases hxw : x = w · subst hxw; rw [hpm.self, zero_add]; exact le_max_of_le_left (by linarith [hpm.symm x y, hpm.symm z x]) by_cases hyz : y = z · subst hyz; rw [hpm.self, add_zero]; exact le_max_of_le_left (by linarith [hpm.symm y w]) -- All 6 pairs are distinct: every term shifts by `+ c`, so `+ 2c` cancels identically! have h4 := h0 x y z w simp only [mul_zero, add_zero] at h4 simp only [shiftOffDiag, hxy, hzw, hxz, hyw, hxw, hyz, ↓reduceIte] rcases le_max_iff.mp h4 with h1 | h2 · exact le_max_of_le_left (by linarith) · exact le_max_of_le_right (by linarith) /-! ## Section 2: Repeated-Squaring Bottleneck Tree & Sharp Finite-n Approximation -/ /-- `k`-fold repeated-squaring bottleneck Gromov product: `gpStep d w 0 x y = (x | y)_w`, and `gpStep d w (k+1) x y = max_z min(gpStep k x z, gpStep k z y)`. -/ noncomputable def gpStep {α : Type*} [Fintype α] [Nonempty α] (d : α → α → ℝ) (w : α) : ℕ → α → α → ℝ | 0, x, y => gromovProd d w x y | k + 1, x, y => Finset.univ.sup' Finset.univ_nonempty (fun z => min (gpStep d w k x z) (gpStep d w k z y)) lemma gpStep_symm {α : Type*} [Fintype α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) : ∀ k x y, gpStep d w k x y = gpStep d w k y x | 0, x, y => gromovProd_symm hd w x y | k + 1, x, y => by simp only [gpStep] congr 1 ext z rw [gpStep_symm hd w k x z, gpStep_symm hd w k z y, min_comm] lemma gpStep_le_left {α : Type*} [Fintype α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) : ∀ k x y, gpStep d w k x y ≤ d x w | 0, x, y => gromovProd_le_left hd w x y | k + 1, x, y => by simp only [gpStep] refine Finset.sup'_le Finset.univ_nonempty _ (fun z _ => ?_) exact le_trans (min_le_left _ _) (gpStep_le_left hd w k x z) lemma gpStep_le_right {α : Type*} [Fintype α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) (k : ℕ) (x y : α) : gpStep d w k x y ≤ d y w := by rw [gpStep_symm hd] exact gpStep_le_left hd w k y x lemma gpStep_nonneg {α : Type*} [Fintype α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) : ∀ k x y, 0 ≤ gpStep d w k x y | 0, x, y => gromovProd_nonneg hd w x y | k + 1, x, y => by simp only [gpStep] refine le_trans ?_ (Finset.le_sup' (f := fun z => min (gpStep d w k x z) (gpStep d w k z y)) (Finset.mem_univ x)) exact le_min (gpStep_nonneg hd w k x x) (gpStep_nonneg hd w k x y) lemma gpStep_self {α : Type*} [Fintype α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) : ∀ k x, gpStep d w k x x = d x w | 0, x => gromovProd_self hd w x | k + 1, x => by apply le_antisymm (gpStep_le_left hd w (k + 1) x x) refine le_trans ?_ (Finset.le_sup' (f := fun z => min (gpStep d w k x z) (gpStep d w k z x)) (Finset.mem_univ x)) rw [gpStep_self hd w k x, min_self] lemma gpStep_base_right {α : Type*} [Fintype α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) (k : ℕ) (x : α) : gpStep d w k x w = 0 := by apply le_antisymm · exact le_trans (gpStep_le_right hd w k x w) (by rw [hd.self]) · exact gpStep_nonneg hd w k x w lemma gpStep_mono_step {α : Type*} [Fintype α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) (k : ℕ) (x y : α) : gpStep d w k x y ≤ gpStep d w (k + 1) x y := by simp only [gpStep] refine le_trans ?_ (Finset.le_sup' (f := fun z => min (gpStep d w k x z) (gpStep d w k z y)) (Finset.mem_univ x)) rw [gpStep_self hd w k x] exact le_min (gpStep_le_left hd w k x y) le_rfl lemma gpStep_mono {α : Type*} [Fintype α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) {k₁ k₂ : ℕ} (hk : k₁ ≤ k₂) (x y : α) : gpStep d w k₁ x y ≤ gpStep d w k₂ x y := by induction hk with | refl => exact le_rfl | step _ ih => exact le_trans ih (gpStep_mono_step hd w _ x y) lemma gromovProd_le_gpStep {α : Type*} [Fintype α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) (k : ℕ) (x y : α) : gromovProd d w x y ≤ gpStep d w k x y := gpStep_mono hd w (Nat.zero_le k) x y /-- **Binary-Splitting Upper Bound**: `gpStep d w k x y ≤ (x | y)_w + k * δ` whenever `d` is `δ`-hyperbolic at basepoint `w`. -/ theorem gpStep_le_gromovProd_add {α : Type*} [Fintype α] [Nonempty α] {d : α → α → ℝ} {w : α} {δ : ℝ} (hd : IsPseudoMetricFn d) (hh : IsGromovProdAt d w δ) : ∀ k x y, gpStep d w k x y ≤ gromovProd d w x y + (k : ℝ) * δ | 0, x, y => by simp [gpStep] | k + 1, x, y => by simp only [gpStep] refine Finset.sup'_le Finset.univ_nonempty _ (fun z _ => ?_) have h1 := gpStep_le_gromovProd_add hd hh k x z have h2 := gpStep_le_gromovProd_add hd hh k z y have h3 := hh x y z rw [gromovProd_symm hd w z y] at h2 have hmin : min (gpStep d w k x z) (gpStep d w k z y) ≤ min (gromovProd d w x z) (gromovProd d w y z) + (k : ℝ) * δ := by rw [← min_add_add_right] exact min_le_min h1 h2 push_cast linarith lemma list_getLastD_cons_ne {α : Type*} (a : α) (as : List α) (has : as ≠ []) (x : α) : (a :: as).getLastD x = as.getLastD a := by cases as with | nil => exact absurd rfl has | cons b bs => rfl lemma list_getLastD_append {α : Type*} (A B : List α) (hB : B ≠ []) (x y : α) : (A ++ B).getLastD x = B.getLastD y := by induction A generalizing x with | nil => cases B with | nil => exact absurd rfl hB | cons b bs => rfl | cons a as ih => rw [List.cons_append, list_getLastD_cons_ne a (as ++ B) (List.append_ne_nil_of_right_ne_nil as hB)] exact ih a /-- Minimum edge Gromov product along a list of vertices `L` starting at `x` and ending at `y`. -/ noncomputable def chainQuality {α : Type*} (d : α → α → ℝ) (w : α) : α → List α → ℝ | x, [] => d x w | x, [y] => gromovProd d w x y | x, y :: z :: rest => min (gromovProd d w x y) (chainQuality d w y (z :: rest)) lemma chainQuality_le_gpStep {α : Type*} [Fintype α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) : ∀ k (L : List α) (x : α), L.length ≤ 2 ^ k → chainQuality d w x L ≤ gpStep d w k x (L.getLastD x) | 0, [], x, _ => by simp [chainQuality, gpStep, gromovProd_self hd] | 0, [y], x, _ => by simp [chainQuality, gpStep] | 0, _ :: _ :: _, _, hlen => by simp at hlen | k + 1, L, x, hlen => by by_cases hL : L.length ≤ 2 ^ k · exact le_trans (chainQuality_le_gpStep hd w k L x hL) (gpStep_mono_step hd w k x _) · push Not at hL -- Split `L` into prefix `L₁` of length `2^k` and nonempty suffix `L₂` of length `≤ 2^k` set m := 2 ^ k with hm set L₁ := L.take m set L₂ := L.drop m have hL₁_len : L₁.length = m := List.length_take_of_le (le_of_lt hL) have hL₂_ne : L₂ ≠ [] := by intro h have : L.length ≤ m := List.drop_eq_nil_iff.mp h omega have hL₂_len : L₂.length ≤ m := by have : L₂.length = L.length - m := List.length_drop have hpow : 2 ^ (k + 1) = m + m := by rw [hm]; ring omega set z := L₁.getLastD x have hlast : L₂.getLastD z = L.getLastD x := by have hcat : L₁ ++ L₂ = L := List.take_append_drop m L rw [← hcat] exact (list_getLastD_append L₁ L₂ hL₂_ne x z).symm -- Helper: splitting `chainQuality` at `L₁ ++ L₂` have hsplit : ∀ (u : α) (A B : List α), B ≠ [] → chainQuality d w u (A ++ B) ≤ min (chainQuality d w u A) (chainQuality d w (A.getLastD u) B) := by intro u A B hB induction A generalizing u with | nil => simp only [List.nil_append, chainQuality, List.getLastD_nil] refine le_min ?_ le_rfl cases B with | nil => exact absurd rfl hB | cons b bs => cases bs with | nil => simp [chainQuality, gromovProd_le_left hd] | cons c cs => simp only [chainQuality] exact le_trans (min_le_left _ _) (gromovProd_le_left hd w u b) | cons a as ih => cases as with | nil => cases B with | nil => exact absurd rfl hB | cons b bs => simp [chainQuality] | cons a' as' => simp only [List.cons_append, chainQuality] have hrec := ih a have hlast' : (a :: a' :: as').getLastD u = (a' :: as').getLastD a := rfl rw [hlast'] exact le_min (min_le_min_left _ (le_trans hrec (min_le_left _ _))) (le_trans (min_le_right _ _) (le_trans hrec (min_le_right _ _))) have hcat : L₁ ++ L₂ = L := List.take_append_drop m L have hq := hsplit x L₁ L₂ hL₂_ne rw [hcat] at hq have ih1 := chainQuality_le_gpStep hd w k L₁ x (le_of_eq hL₁_len) have ih2 := chainQuality_le_gpStep hd w k L₂ z hL₂_len rw [hlast] at ih2 calc chainQuality d w x L ≤ min (chainQuality d w x L₁) (chainQuality d w z L₂) := hq _ ≤ min (gpStep d w k x z) (gpStep d w k z (L.getLastD x)) := min_le_min ih1 ih2 _ ≤ gpStep d w (k + 1) x (L.getLastD x) := Finset.le_sup' (f := fun v => min (gpStep d w k x v) (gpStep d w k v (L.getLastD x))) (Finset.mem_univ z) /-- Every `gpStep d w k x y` is realized by some explicit chain of length `≤ 2^k` from `x` to `y`. -/ lemma exists_chain_eq_gpStep {α : Type*} [Fintype α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) : ∀ k x y, ∃ L : List α, L ≠ [] ∧ L.getLastD x = y ∧ gpStep d w k x y ≤ chainQuality d w x L | 0, x, y => ⟨[y], by simp, by simp, by simp [gpStep, chainQuality]⟩ | k + 1, x, y => by simp only [gpStep] obtain ⟨z, _, hz⟩ := Finset.exists_mem_eq_sup' Finset.univ_nonempty (fun z => min (gpStep d w k x z) (gpStep d w k z y)) obtain ⟨L₁, hL₁_ne, hL₁_last, hL₁_q⟩ := exists_chain_eq_gpStep hd w k x z obtain ⟨L₂, hL₂_ne, hL₂_last, hL₂_q⟩ := exists_chain_eq_gpStep hd w k z y refine ⟨L₁ ++ L₂, List.append_ne_nil_of_right_ne_nil L₁ hL₂_ne, ?_, ?_⟩ · rw [list_getLastD_append L₁ L₂ hL₂_ne x z, hL₂_last] · -- Exact equality for splitting `chainQuality` when `A ≠ []` and `B ≠ []` have hjoin : ∀ (u : α) (A B : List α), A ≠ [] → B ≠ [] → min (chainQuality d w u A) (chainQuality d w (A.getLastD u) B) ≤ chainQuality d w u (A ++ B) := by intro u A B hA hB induction A generalizing u with | nil => exact absurd rfl hA | cons a as ih => cases as with | nil => cases B with | nil => exact absurd rfl hB | cons b bs => simp [chainQuality] | cons a' as' => simp only [List.cons_append, chainQuality] have hrec := ih a (by simp) have hlast' : (a :: a' :: as').getLastD u = (a' :: as').getLastD a := rfl rw [hlast'] rw [min_assoc] exact min_le_min_left _ hrec rw [hz] refine le_trans (min_le_min hL₁_q hL₂_q) ?_ rw [← hL₁_last] exact hjoin x L₁ L₂ hL₁_ne hL₂_ne /-- Subset-preserving loop-erasure lemma: any nonempty chain `L` from `x` to `y` (`x ≠ y`) can be pruned to a nonempty chain `L'` from `x` to `y` with `(x :: L').Nodup`, `L' ⊆ L`, and `chainQuality d w x L ≤ chainQuality d w x L'`. -/ lemma prune_chain_nodup_subset {α : Type*} [DecidableEq α] {d : α → α → ℝ} (_hd : IsPseudoMetricFn d) (w : α) : ∀ (n : ℕ) (x : α) (L : List α), L.length ≤ n → L ≠ [] → L.getLastD x ≠ x → ∃ L' : List α, L' ≠ [] ∧ L'.getLastD x = L.getLastD x ∧ (x :: L').Nodup ∧ (∀ v ∈ L', v ∈ L) ∧ chainQuality d w x L ≤ chainQuality d w x L' := by intro n induction n with | zero => intro x L hlen hne exact absurd (List.eq_nil_of_length_eq_zero (Nat.le_zero.mp hlen)) hne | succ n ih => intro x L hlen hne hlast cases L with | nil => exact absurd rfl hne | cons a as => by_cases hxa : a = x · subst hxa cases as with | nil => simp [List.getLastD] at hlast | cons b bs => have hlen' : (b :: bs).length ≤ n := by simp only [List.length_cons] at hlen ⊢; omega have hlast' : (b :: bs).getLastD a ≠ a := hlast obtain ⟨L', h1, h2, h3, hsub, h4⟩ := ih a (b :: bs) hlen' (by simp) hlast' refine ⟨L', h1, h2, h3, fun v hv => List.mem_cons_of_mem _ (hsub v hv), ?_⟩ simp only [chainQuality]; exact le_trans (min_le_right _ _) h4 · cases as with | nil => refine ⟨[a], by simp, by simp, by simp [Ne.symm hxa], fun v hv => hv, le_rfl⟩ | cons b bs => by_cases hx_mem : x ∈ (b :: bs) · obtain ⟨pre, suf, hsplit⟩ := List.append_of_mem hx_mem cases suf with | nil => exfalso have hl : (a :: b :: bs).getLastD x = x := by rw [list_getLastD_cons_ne a (b :: bs) (by simp), hsplit, list_getLastD_append pre [x] (by simp) a x] rfl exact hlast hl | cons c cs => have hdrop : ∀ (u : α) (P : List α) (S : List α), S ≠ [] → chainQuality d w u (P ++ x :: S) ≤ chainQuality d w x S := by intro u P S hS induction P generalizing u with | nil => cases S with | nil => exact absurd rfl hS | cons s ss => simp [chainQuality] | cons p ps ihp => cases ps with | nil => simp only [List.cons_append, List.nil_append, chainQuality] exact le_trans (min_le_right _ _) (ihp p) | cons p' ps' => simp only [List.cons_append, chainQuality] exact le_trans (min_le_right _ _) (ihp p) have hq_le : chainQuality d w x (a :: b :: bs) ≤ chainQuality d w x (c :: cs) := by have hEq : a :: b :: bs = (a :: pre) ++ x :: (c :: cs) := by change a :: (b :: bs) = a :: (pre ++ x :: c :: cs) rw [hsplit] rw [hEq]; exact hdrop x (a :: pre) (c :: cs) (by simp) have hlen' : (c :: cs).length ≤ n := by have hlen_eq : (b :: bs).length = pre.length + 1 + (c :: cs).length := by rw [hsplit]; simp; omega simp only [List.length_cons] at hlen hlen_eq ⊢ omega have hlast' : (c :: cs).getLastD x = (a :: b :: bs).getLastD x := by rw [list_getLastD_cons_ne a (b :: bs) (by simp), hsplit, list_getLastD_append pre (x :: c :: cs) (by simp) a x, list_getLastD_cons_ne x (c :: cs) (by simp)] obtain ⟨L', h1, h2, h3, hsub, h4⟩ := ih x (c :: cs) hlen' (by simp) (by rw [hlast']; exact hlast) refine ⟨L', h1, h2.trans hlast', h3, ?_, le_trans hq_le h4⟩ intro v hv have hv' := hsub v hv refine List.mem_cons_of_mem a ?_ rw [hsplit] exact List.mem_append_right pre (List.mem_cons_of_mem x hv') · by_cases halast : (b :: bs).getLastD a = a · refine ⟨[a], by simp, ?_, by simp [Ne.symm hxa], ?_, ?_⟩ · change a = (b :: bs).getLastD a; exact halast.symm · intro v hv; simp at hv; subst hv; exact List.mem_cons_self · simp only [chainQuality]; exact min_le_left _ _ · have hlen' : (b :: bs).length ≤ n := by simp only [List.length_cons] at hlen ⊢; omega obtain ⟨L', h1, h2, h3, hsub, h4⟩ := ih a (b :: bs) hlen' (by simp) halast have hxL' : x ∉ L' := fun h => hx_mem (hsub x h) refine ⟨a :: L', by simp, ?_, ?_, ?_, ?_⟩ · rw [list_getLastD_cons_ne a L' h1, list_getLastD_cons_ne a (b :: bs) (by simp)] exact h2 · rw [List.nodup_cons] exact ⟨by simp [Ne.symm hxa, hxL'], h3⟩ · intro v hv rcases List.mem_cons.mp hv with rfl | hv' · exact List.mem_cons_self · exact List.mem_cons_of_mem a (hsub v hv') · cases hL' : L' with | nil => exact absurd hL' h1 | cons u us => rw [hL'] at h4 simp only [chainQuality] exact min_le_min_left _ h4 /-- If the root `w` appears inside a chain `L`, then `chainQuality d w x L ≤ 0`. -/ lemma chainQuality_le_zero_of_mem_base {α : Type*} {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) : ∀ (x : α) (L : List α), w ∈ L → chainQuality d w x L ≤ 0 := by intro x L hw induction L generalizing x with | nil => simp at hw | cons a as ih => rcases List.mem_cons.mp hw with rfl | has · cases as with | nil => simp [chainQuality, gromovProd_base_right hd] | cons b bs => simp only [chainQuality] exact le_trans (min_le_left _ _) (by rw [gromovProd_base_right hd]) · cases as with | nil => simp at has | cons b bs => simp only [chainQuality] exact le_trans (min_le_right _ _) (ih a has) /-- **Exact Stabilization Theorem**: On a finite space of cardinality `n = Fintype.card α ≥ 3`, the repeated-squaring bottleneck Gromov product stabilizes at `K = Nat.clog 2 (n - 2)`! -/ theorem gpStep_stabilizes {α : Type*} [Fintype α] [DecidableEq α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) (k : ℕ) (x y : α) : gpStep d w k x y ≤ gpStep d w (Nat.clog 2 (Fintype.card α - 2)) x y := by set K := Nat.clog 2 (Fintype.card α - 2) by_cases hxy : x = y · subst hxy; rw [gpStep_self hd, gpStep_self hd] by_cases hxw : x = w · subst hxw rw [gpStep_symm hd x k x y, gpStep_base_right hd, gpStep_symm hd x K x y, gpStep_base_right hd] by_cases hyw : y = w · subst hyw; rw [gpStep_base_right hd, gpStep_base_right hd] obtain ⟨L, hL_ne, hL_last, hL_q⟩ := exists_chain_eq_gpStep hd w k x y obtain ⟨L', hL'_ne, hL'_last, hL'_nodup, _, hL'_q⟩ := prune_chain_nodup_subset hd w L.length x L le_rfl hL_ne (by rw [hL_last]; exact Ne.symm hxy) by_cases hwL' : w ∈ L' · have hq0 : chainQuality d w x L' ≤ 0 := chainQuality_le_zero_of_mem_base hd w x L' hwL' exact le_trans hL_q (le_trans hL'_q (le_trans hq0 (gpStep_nonneg hd w K x y))) · -- `w ∉ x :: L'` and `(x :: L').Nodup`, so `(x :: L').length + 1 ≤ Fintype.card α`, -- hence `L'.length ≤ Fintype.card α - 2 ≤ 2 ^ K`! have hnodup_w : (w :: x :: L').Nodup := by rw [List.nodup_cons] exact ⟨by simp [Ne.symm hxw, hwL'], hL'_nodup⟩ have hcard : (w :: x :: L').length ≤ Fintype.card α := by have := List.Nodup.length_le_card hnodup_w simpa using this have hlen' : L'.length ≤ Fintype.card α - 2 := by simp at hcard; omega have hpow : L'.length ≤ 2 ^ K := le_trans hlen' (Nat.le_pow_clog (by decide : 1 < 2) _) have hstep := chainQuality_le_gpStep hd w K L' x hpow rw [hL'_last, hL_last] at hstep exact le_trans hL_q (le_trans hL'_q hstep) /-- Gromov's canonical approximating tree metric on a finite space rooted at `w`, defined at the exact stabilization depth `K = Nat.clog 2 (card α - 2)`. -/ noncomputable def gromovTreeDist {α : Type*} [Fintype α] [DecidableEq α] [Nonempty α] (d : α → α → ℝ) (w : α) (x y : α) : ℝ := d x w + d y w - 2 * gpStep d w (Nat.clog 2 (Fintype.card α - 2)) x y lemma gpStep_ultrametric {α : Type*} [Fintype α] [DecidableEq α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w x y z : α) : min (gpStep d w (Nat.clog 2 (Fintype.card α - 2)) x z) (gpStep d w (Nat.clog 2 (Fintype.card α - 2)) z y) ≤ gpStep d w (Nat.clog 2 (Fintype.card α - 2)) x y := by set K := Nat.clog 2 (Fintype.card α - 2) calc min (gpStep d w K x z) (gpStep d w K z y) ≤ gpStep d w (K + 1) x y := Finset.le_sup' (f := fun v => min (gpStep d w K x v) (gpStep d w K v y)) (Finset.mem_univ z) _ ≤ gpStep d w K x y := gpStep_stabilizes hd w (K + 1) x y theorem gromovTreeDist_isPseudoMetricFn {α : Type*} [Fintype α] [DecidableEq α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) : IsPseudoMetricFn (gromovTreeDist d w) where nonneg x y := by unfold gromovTreeDist linarith [gpStep_le_left hd w (Nat.clog 2 (Fintype.card α - 2)) x y, gpStep_le_right hd w (Nat.clog 2 (Fintype.card α - 2)) x y] self x := by unfold gromovTreeDist rw [gpStep_self hd] ring symm x y := by unfold gromovTreeDist rw [gpStep_symm hd] ring triangle x y z := by unfold gromovTreeDist set K := Nat.clog 2 (Fintype.card α - 2) have hu := gpStep_ultrametric hd w x z y have h1 := gpStep_le_right hd w K x y have h2 := gpStep_le_left hd w K y z rcases le_total (gpStep d w K x y) (gpStep d w K y z) with h | h · rw [min_eq_left h] at hu; linarith · rw [min_eq_right h] at hu; linarith /-- Gromov's approximating tree preserves ALL distances to the root `w` identically. -/ theorem gromovTreeDist_root {α : Type*} [Fintype α] [DecidableEq α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w x : α) : gromovTreeDist d w x w = d x w := by unfold gromovTreeDist rw [hd.self, gpStep_base_right hd] ring /-- Gromov's approximating tree is GLOBALLY `0`-hyperbolic (an exact tree metric!). -/ theorem gromovTreeDist_zeroHyperbolic {α : Type*} [Fintype α] [DecidableEq α] [Nonempty α] {d : α → α → ℝ} (hd : IsPseudoMetricFn d) (w : α) : IsFourPointHyperbolic (gromovTreeDist d w) 0 := by intro a b c e unfold gromovTreeDist set K := Nat.clog 2 (Fintype.card α - 2) set g := gpStep d w K have hsym : ∀ u v, g u v = g v u := gpStep_symm hd w K have h1 : min (g a c) (g b c) ≤ g a b := by rw [hsym b c]; exact gpStep_ultrametric hd w a b c have h2 : min (g a e) (g b e) ≤ g a b := by rw [hsym b e]; exact gpStep_ultrametric hd w a b e have h3 : min (g a c) (g a e) ≤ g c e := by rw [hsym a c]; exact gpStep_ultrametric hd w c e a have h4 : min (g b c) (g b e) ≤ g c e := by rw [hsym b c]; exact gpStep_ultrametric hd w c e b simp only [mul_zero, add_zero, le_max_iff] -- Pure case split on the 4 numbers `g a c, g b e, g a e, g b c` rcases le_total (g a c) (g b c) with hac_bc | hbc_ac · rw [min_eq_left hac_bc] at h1 rcases le_total (g b e) (g a e) with hbe_ae | hae_be · rw [min_eq_right hbe_ae] at h2 rcases le_total (g a c) (g a e) with hac_ae | hae_ac · rw [min_eq_left hac_ae] at h3 left; linarith · rw [min_eq_right hae_ac] at h3 rcases le_total (g b c) (g b e) with hbc_be | hbe_bc · rw [min_eq_left hbc_be] at h4 right; linarith · rw [min_eq_right hbe_bc] at h4 left; linarith · rw [min_eq_left hae_be] at h2 rcases le_total (g b c) (g b e) with hbc_be | hbe_bc · rw [min_eq_left hbc_be] at h4 right; linarith · rw [min_eq_right hbe_bc] at h4 left; linarith · rw [min_eq_right hbc_ac] at h1 rcases le_total (g a e) (g b e) with hae_be | hbe_ae · rw [min_eq_left hae_be] at h2 rcases le_total (g b c) (g b e) with hbc_be | hbe_bc · rw [min_eq_left hbc_be] at h4 right; linarith · rw [min_eq_right hbe_bc] at h4 rcases le_total (g a c) (g a e) with hac_ae | hae_ac · rw [min_eq_left hac_ae] at h3 left; linarith · rw [min_eq_right hae_ac] at h3 right; linarith · rw [min_eq_right hbe_ae] at h2 rcases le_total (g a c) (g a e) with hac_ae | hae_ac · rw [min_eq_left hac_ae] at h3 left; linarith · rw [min_eq_right hae_ac] at h3 right; linarith /-- **THEOREM (Sharp Finite-n Gromov Tree-Approximation Theorem)**: For every finite `δ`-hyperbolic metric space of cardinality `n = Fintype.card α` and basepoint `w`, Gromov's approximating tree `d_T` satisfies: `d(x, y) - 2 δ ⌈log₂(n - 2)⌉ ≤ d_T(x, y) ≤ d(x, y)`. Notice for `n ≤ 3`, `Nat.clog 2 (n - 2) = 0`, giving exact isometry `d_T = d`! -/ theorem gromov_tree_approx_sharp_upper {α : Type*} [Fintype α] [DecidableEq α] [Nonempty α] {d : α → α → ℝ} {δ : ℝ} (hd : IsPseudoMetricFn d) (hh : IsFourPointHyperbolic d δ) (w x y : α) : d x y - 2 * δ * (Nat.clog 2 (Fintype.card α - 2) : ℝ) ≤ gromovTreeDist d w x y ∧ gromovTreeDist d w x y ≤ d x y := by have hgp : IsGromovProdAt d w δ := (fourPointHyperbolic_iff_gromovProdHyperbolic hd δ).mp hh w unfold gromovTreeDist have hup := gpStep_le_gromovProd_add hd hgp (Nat.clog 2 (Fintype.card α - 2)) x y have hlo := gromovProd_le_gpStep hd w (Nat.clog 2 (Fintype.card α - 2)) x y unfold gromovProd at hup hlo constructor <;> linarith /-- **THEOREM (Centered Two-Sided Gromov Tree Approximation)**: Adding pendant leaves of length `(δ / 2) * ⌈log₂(n - 2)⌉` to `gromovTreeDist` yields a `0`-hyperbolic tree metric whose two-sided `L_∞` distortion is AT MOST `δ ⌈log₂(n - 2)⌉` (halving the additive `L_∞` error of Gromov's uncentered tree!). -/ theorem gromov_tree_approx_centered {α : Type*} [Fintype α] [DecidableEq α] [Nonempty α] {d : α → α → ℝ} {δ : ℝ} (hd : IsPseudoMetricFn d) (hδ : 0 ≤ δ) (hh : IsFourPointHyperbolic d δ) (w : α) : let c := δ * (Nat.clog 2 (Fintype.card α - 2) : ℝ) let dT := shiftOffDiag (gromovTreeDist d w) c IsPseudoMetricFn dT ∧ IsFourPointHyperbolic dT 0 ∧ ∀ x y, |d x y - dT x y| ≤ c := by intro c dT have hc : 0 ≤ c := mul_nonneg hδ (Nat.cast_nonneg _) have hdT_pm : IsPseudoMetricFn dT := shiftOffDiag_isPseudoMetricFn (gromovTreeDist_isPseudoMetricFn hd w) hc have hdT_0 : IsFourPointHyperbolic dT 0 := shiftOffDiag_zeroHyperbolic (gromovTreeDist_isPseudoMetricFn hd w) (gromovTreeDist_zeroHyperbolic hd w) hc refine ⟨hdT_pm, hdT_0, fun x y => ?_⟩ by_cases hxy : x = y · subst hxy; simp [dT, shiftOffDiag, hd.self, hc] · simp only [dT, shiftOffDiag, hxy, ↓reduceIte] have ⟨hlo, hhi⟩ := gromov_tree_approx_sharp_upper hd hh w x y rw [abs_le] constructor <;> linarith /-! ## Section 3: Ptolemy log₂ Metric — Exact Sharpness of Gromov Tree Approximation -/ /-- The Ptolemy `log₂` metric on `Fin n` (`n ≥ 3`): vertex `0` is the root `w`; vertices `1..n-1` satisfy `d(0, i) = R` and `d(i, j) = C + 2δ log₂|i - j|` (`i ≠ j`), with `C = R = 2δ log₂(n - 2) + 2δ`. -/ noncomputable def ptolemyLogDist (n : ℕ) (δ : ℝ) (i j : Fin n) : ℝ := let L := Real.logb 2 (max 1 ((n - 2 : ℕ) : ℝ)) let C := 2 * δ * L + 2 * δ if i = j then 0 else if i.1 = 0 ∨ j.1 = 0 then C else C + 2 * δ * Real.logb 2 (|(i.1 : ℝ) - (j.1 : ℝ)|) lemma logb2_nonneg_of_one_le {x : ℝ} (hx : 1 ≤ x) : 0 ≤ Real.logb 2 x := Real.logb_nonneg (by norm_num) hx lemma logb2_abs_diff_le {n : ℕ} (hn : 3 ≤ n) {i j : Fin n} (hi : i.1 ≠ 0) (hj : j.1 ≠ 0) (hij : i ≠ j) : 0 ≤ Real.logb 2 (|(i.1 : ℝ) - (j.1 : ℝ)|) ∧ Real.logb 2 (|(i.1 : ℝ) - (j.1 : ℝ)|) ≤ Real.logb 2 (max 1 ((n - 2 : ℕ) : ℝ)) := by have h1 : (1 : ℝ) ≤ |(i.1 : ℝ) - (j.1 : ℝ)| := by have hne : i.1 ≠ j.1 := fun h => hij (Fin.ext h) rcases lt_or_gt_of_ne hne with hlt | hgt · have hle : i.1 + 1 ≤ j.1 := hlt have : (i.1 : ℝ) + 1 ≤ (j.1 : ℝ) := by exact_mod_cast hle rw [abs_of_neg (by linarith)]; linarith · have hle : j.1 + 1 ≤ i.1 := hgt have : (j.1 : ℝ) + 1 ≤ (i.1 : ℝ) := by exact_mod_cast hle rw [abs_of_pos (by linarith)]; linarith have h2 : |(i.1 : ℝ) - (j.1 : ℝ)| ≤ max 1 ((n - 2 : ℕ) : ℝ) := by refine le_trans ?_ (le_max_right 1 _) have hi1 : 1 ≤ i.1 := Nat.pos_of_ne_zero hi have hj1 : 1 ≤ j.1 := Nat.pos_of_ne_zero hj rw [abs_le] have hcast : ((n - 2 : ℕ) : ℝ) = (n : ℝ) - 2 := by rw [Nat.cast_sub (by omega : 2 ≤ n)]; norm_num have hi_le : (i.1 : ℝ) ≤ (n : ℝ) - 1 := by have : (i.1 : ℝ) + 1 ≤ (n : ℝ) := by exact_mod_cast i.2 linarith have hj_le : (j.1 : ℝ) ≤ (n : ℝ) - 1 := by have : (j.1 : ℝ) + 1 ≤ (n : ℝ) := by exact_mod_cast j.2 linarith have hi_ge : (1 : ℝ) ≤ (i.1 : ℝ) := by exact_mod_cast hi1 have hj_ge : (1 : ℝ) ≤ (j.1 : ℝ) := by exact_mod_cast hj1 constructor <;> linarith constructor · exact logb2_nonneg_of_one_le h1 · exact Real.logb_le_logb_of_le (by norm_num) (by linarith) h2 /-- `ptolemyLogDist n δ` is a genuine metric function (`IsPseudoMetricFn`) for all `n ≥ 3, δ > 0`. -/ theorem ptolemyLogDist_isPseudoMetricFn {n : ℕ} (hn : 3 ≤ n) {δ : ℝ} (hδ : 0 ≤ δ) : IsPseudoMetricFn (ptolemyLogDist n δ) where nonneg i j := by unfold ptolemyLogDist set L := Real.logb 2 (max 1 ((n - 2 : ℕ) : ℝ)) have hL : 0 ≤ L := logb2_nonneg_of_one_le (le_max_left _ _) split_ifs with h1 h2 · exact le_rfl · nlinarith · push Not at h2 have ⟨hlo, _⟩ := logb2_abs_diff_le hn h2.1 h2.2 h1 nlinarith self i := by simp [ptolemyLogDist] symm i j := by unfold ptolemyLogDist by_cases h : i = j · subst h; simp · simp only [h, Ne.symm h, ↓reduceIte, or_comm, abs_sub_comm] triangle i j k := by set L := Real.logb 2 (max 1 ((n - 2 : ℕ) : ℝ)) set C := 2 * δ * L + 2 * δ have hL : 0 ≤ L := logb2_nonneg_of_one_le (le_max_left _ _) have hC : 0 ≤ C := by nlinarith have hband : ∀ u v : Fin n, u ≠ v → C ≤ ptolemyLogDist n δ u v ∧ ptolemyLogDist n δ u v ≤ 2 * C := by intro u v huv unfold ptolemyLogDist simp only [huv, ↓reduceIte] split_ifs with h0 · constructor <;> linarith · push Not at h0 have ⟨hlo, hhi⟩ := logb2_abs_diff_le hn h0.1 h0.2 huv constructor <;> nlinarith by_cases hik : i = k · subst hik rw [show ptolemyLogDist n δ i i = 0 by simp [ptolemyLogDist]] by_cases hij : i = j · subst hij; simp [ptolemyLogDist] · have ⟨h1, _⟩ := hband i j hij have ⟨h2, _⟩ := hband j i (Ne.symm hij) linarith by_cases hij : i = j · subst hij; simp [ptolemyLogDist] by_cases hjk : j = k · subst hjk; simp [ptolemyLogDist] have ⟨_, h_ik⟩ := hband i k hik have ⟨h_ij, _⟩ := hband i j hij have ⟨h_jk, _⟩ := hband j k hjk linarith /-- Ptolemy's real-line identity in `log₂` form: for ANY 4 ordered reals `a < b < c < d`, `log₂((c - a)(d - b)) ≤ max(log₂((b - a)(d - c)), log₂((d - a)(c - b))) + 1`. -/ lemma ptolemy_log2_ordered {a b c d : ℝ} (hab : a < b) (hbc : b < c) (hcd : c < d) : Real.logb 2 (c - a) + Real.logb 2 (d - b) ≤ max (Real.logb 2 (b - a) + Real.logb 2 (d - c)) (Real.logb 2 (d - a) + Real.logb 2 (c - b)) + 1 := by have h1 : 0 < b - a := by linarith have h2 : 0 < c - b := by linarith have h3 : 0 < d - c := by linarith have hca : 0 < c - a := by linarith have hdb : 0 < d - b := by linarith have hda : 0 < d - a := by linarith have hptol : (c - a) * (d - b) = (b - a) * (d - c) + (d - a) * (c - b) := by ring have hle : (c - a) * (d - b) ≤ 2 * max ((b - a) * (d - c)) ((d - a) * (c - b)) := by rw [hptol] linarith [le_max_left ((b - a) * (d - c)) ((d - a) * (c - b)), le_max_right ((b - a) * (d - c)) ((d - a) * (c - b))] have hlog := Real.logb_le_logb_of_le (by norm_num : (1 : ℝ) < 2) (mul_pos hca hdb) hle rw [Real.logb_mul (ne_of_gt hca) (ne_of_gt hdb)] at hlog rcases le_total ((b - a) * (d - c)) ((d - a) * (c - b)) with hcmp | hcmp · rw [max_eq_right hcmp, Real.logb_mul (by norm_num) (ne_of_gt (mul_pos hda h2)), Real.logb_self_eq_one (by norm_num), Real.logb_mul (ne_of_gt hda) (ne_of_gt h2)] at hlog have hmx := le_max_right (Real.logb 2 (b - a) + Real.logb 2 (d - c)) (Real.logb 2 (d - a) + Real.logb 2 (c - b)) linarith · rw [max_eq_left hcmp, Real.logb_mul (by norm_num) (ne_of_gt (mul_pos h1 h3)), Real.logb_self_eq_one (by norm_num), Real.logb_mul (ne_of_gt h1) (ne_of_gt h3)] at hlog have hmx := le_max_left (Real.logb 2 (b - a) + Real.logb 2 (d - c)) (Real.logb 2 (d - a) + Real.logb 2 (c - b)) linarith /-- Unordered 4-real version of the Ptolemy `log₂` inequality. -/ lemma ptolemy_log2_four {a b c d : ℝ} (hab : a ≠ b) (hac : a ≠ c) (had : a ≠ d) (hbc : b ≠ c) (hbd : b ≠ d) (hcd : c ≠ d) : Real.logb 2 |a - b| + Real.logb 2 |c - d| ≤ max (Real.logb 2 |a - c| + Real.logb 2 |b - d|) (Real.logb 2 |a - d| + Real.logb 2 |b - c|) + 1 := by have h1 : 0 < |a - b| := abs_pos.mpr (sub_ne_zero.mpr hab) have h2 : 0 < |c - d| := abs_pos.mpr (sub_ne_zero.mpr hcd) have h3 : 0 < |a - c| := abs_pos.mpr (sub_ne_zero.mpr hac) have h4 : 0 < |b - d| := abs_pos.mpr (sub_ne_zero.mpr hbd) have h5 : 0 < |a - d| := abs_pos.mpr (sub_ne_zero.mpr had) have h6 : 0 < |b - c| := abs_pos.mpr (sub_ne_zero.mpr hbc) have hid : (a - b) * (c - d) = (a - c) * (b - d) - (a - d) * (b - c) := by ring have hptol : |a - b| * |c - d| ≤ |a - c| * |b - d| + |a - d| * |b - c| := by calc |a - b| * |c - d| = |(a - b) * (c - d)| := (abs_mul _ _).symm _ = |(a - c) * (b - d) - (a - d) * (b - c)| := by rw [hid] _ ≤ |(a - c) * (b - d)| + |(a - d) * (b - c)| := abs_sub _ _ _ = |a - c| * |b - d| + |a - d| * |b - c| := by rw [abs_mul, abs_mul] have hle : |a - b| * |c - d| ≤ 2 * max (|a - c| * |b - d|) (|a - d| * |b - c|) := by linarith [le_max_left (|a - c| * |b - d|) (|a - d| * |b - c|), le_max_right (|a - c| * |b - d|) (|a - d| * |b - c|)] have hlog := Real.logb_le_logb_of_le (by norm_num : (1 : ℝ) < 2) (mul_pos h1 h2) hle rw [Real.logb_mul (ne_of_gt h1) (ne_of_gt h2)] at hlog rcases le_total (|a - c| * |b - d|) (|a - d| * |b - c|) with hcmp | hcmp · rw [max_eq_right hcmp, Real.logb_mul (by norm_num) (ne_of_gt (mul_pos h5 h6)), Real.logb_self_eq_one (by norm_num), Real.logb_mul (ne_of_gt h5) (ne_of_gt h6)] at hlog have hmx := le_max_right (Real.logb 2 |a - c| + Real.logb 2 |b - d|) (Real.logb 2 |a - d| + Real.logb 2 |b - c|) linarith · rw [max_eq_left hcmp, Real.logb_mul (by norm_num) (ne_of_gt (mul_pos h3 h4)), Real.logb_self_eq_one (by norm_num), Real.logb_mul (ne_of_gt h3) (ne_of_gt h4)] at hlog have hmx := le_max_left (Real.logb 2 |a - c| + Real.logb 2 |b - d|) (Real.logb 2 |a - d| + Real.logb 2 |b - c|) linarith /-- 3-real triangle `log₂` inequality: `log₂|a - b| ≤ max(log₂|a - c|, log₂|b - c|) + 1`. -/ lemma log2_three {a b c : ℝ} (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) : Real.logb 2 |a - b| ≤ max (Real.logb 2 |a - c|) (Real.logb 2 |b - c|) + 1 := by have h1 : 0 < |a - b| := abs_pos.mpr (sub_ne_zero.mpr hab) have h2 : 0 < |a - c| := abs_pos.mpr (sub_ne_zero.mpr hac) have h3 : 0 < |b - c| := abs_pos.mpr (sub_ne_zero.mpr hbc) have htri : |a - b| ≤ |a - c| + |b - c| := by have : a - b = (a - c) - (b - c) := by ring rw [this]; exact abs_sub _ _ have hle : |a - b| ≤ 2 * max |a - c| |b - c| := by linarith [le_max_left |a - c| |b - c|, le_max_right |a - c| |b - c|] have hlog := Real.logb_le_logb_of_le (by norm_num : (1 : ℝ) < 2) h1 hle rcases le_total |a - c| |b - c| with hcmp | hcmp · rw [max_eq_right hcmp, Real.logb_mul (by norm_num) (ne_of_gt h3), Real.logb_self_eq_one (by norm_num)] at hlog have hmx := le_max_right (Real.logb 2 |a - c|) (Real.logb 2 |b - c|) linarith · rw [max_eq_left hcmp, Real.logb_mul (by norm_num) (ne_of_gt h2), Real.logb_self_eq_one (by norm_num)] at hlog have hmx := le_max_left (Real.logb 2 |a - c|) (Real.logb 2 |b - c|) linarith /-- **THEOREM (Global Exact Hyperbolicity of `ptolemyLogDist`)**: For EVERY `n ≥ 3` and `δ ≥ 0`, `ptolemyLogDist n δ` is globally `δ`-hyperbolic! -/ theorem ptolemyLogDist_hyperbolic {n : ℕ} (hn : 3 ≤ n) {δ : ℝ} (hδ : 0 ≤ δ) : IsFourPointHyperbolic (ptolemyLogDist n δ) δ := by intro i j k l have hpm := ptolemyLogDist_isPseudoMetricFn hn hδ by_cases hij : i = j · subst hij; rw [hpm.self, zero_add] linarith [hpm.triangle k i l, hpm.symm i k, le_max_left (ptolemyLogDist n δ i k + ptolemyLogDist n δ i l) (ptolemyLogDist n δ i l + ptolemyLogDist n δ i k)] by_cases hkl : k = l · subst hkl; rw [hpm.self, add_zero] linarith [hpm.triangle i k j, hpm.symm k j, le_max_left (ptolemyLogDist n δ i k + ptolemyLogDist n δ j k) (ptolemyLogDist n δ i k + ptolemyLogDist n δ j k)] by_cases hik : i = k · subst hik; rw [hpm.self, zero_add] linarith [hpm.triangle i j l, hpm.symm j i, le_max_right (ptolemyLogDist n δ j l) (ptolemyLogDist n δ i l + ptolemyLogDist n δ j i)] by_cases hjl : j = l · subst hjl; rw [hpm.self, add_zero] linarith [hpm.triangle i j k, hpm.symm j k, le_max_right (ptolemyLogDist n δ i k) (ptolemyLogDist n δ i j + ptolemyLogDist n δ j k)] by_cases hil : i = l · subst hil; rw [hpm.self, zero_add] linarith [hpm.symm i j, hpm.symm k i, le_max_left (ptolemyLogDist n δ i k + ptolemyLogDist n δ j i) (ptolemyLogDist n δ j k)] by_cases hjk : j = k · subst hjk; rw [hpm.self, add_zero] linarith [hpm.symm i j, hpm.symm j l, le_max_left (ptolemyLogDist n δ i j + ptolemyLogDist n δ j l) (ptolemyLogDist n δ i l)] -- All 4 points are distinct! unfold ptolemyLogDist set L := Real.logb 2 (max 1 ((n - 2 : ℕ) : ℝ)) set C := 2 * δ * L + 2 * δ have hne : ∀ {u v : Fin n}, u ≠ v → (u.1 : ℝ) ≠ (v.1 : ℝ) := fun huv h => huv (Fin.ext (Nat.cast_injective h)) by_cases hi0 : i.1 = 0 · have hj0 : j.1 ≠ 0 := fun h => hij (Fin.ext (by omega)) have hk0 : k.1 ≠ 0 := fun h => hik (Fin.ext (by omega)) have hl0 : l.1 ≠ 0 := fun h => hil (Fin.ext (by omega)) simp only [hij, hkl, hik, hjl, hil, hjk, hi0, hj0, hk0, hl0, or_false, ↓reduceIte] have htri := log2_three (hne hkl) (hne (Ne.symm hjk)) (hne (Ne.symm hjl)) rw [abs_sub_comm (k.1 : ℝ) (j.1 : ℝ), abs_sub_comm (l.1 : ℝ) (j.1 : ℝ)] at htri rcases le_total (Real.logb 2 |(j.1 : ℝ) - (k.1 : ℝ)|) (Real.logb 2 |(j.1 : ℝ) - (l.1 : ℝ)|) with h | h · rw [max_eq_right h] at htri have hmx := le_max_left (C + (C + 2 * δ * Real.logb 2 |(j.1 : ℝ) - (l.1 : ℝ)|)) (C + (C + 2 * δ * Real.logb 2 |(j.1 : ℝ) - (k.1 : ℝ)|)) nlinarith · rw [max_eq_left h] at htri have hmx := le_max_right (C + (C + 2 * δ * Real.logb 2 |(j.1 : ℝ) - (l.1 : ℝ)|)) (C + (C + 2 * δ * Real.logb 2 |(j.1 : ℝ) - (k.1 : ℝ)|)) nlinarith by_cases hj0 : j.1 = 0 · have hk0 : k.1 ≠ 0 := fun h => hjk (Fin.ext (by omega)) have hl0 : l.1 ≠ 0 := fun h => hjl (Fin.ext (by omega)) simp only [hij, hkl, hik, hjl, hil, hjk, hi0, hj0, hk0, hl0, or_true, or_false, ↓reduceIte] have htri := log2_three (hne hkl) (hne (Ne.symm hik)) (hne (Ne.symm hil)) rw [abs_sub_comm (k.1 : ℝ) (i.1 : ℝ), abs_sub_comm (l.1 : ℝ) (i.1 : ℝ)] at htri rcases le_total (Real.logb 2 |(i.1 : ℝ) - (k.1 : ℝ)|) (Real.logb 2 |(i.1 : ℝ) - (l.1 : ℝ)|) with h | h · rw [max_eq_right h] at htri have hmx := le_max_right (C + 2 * δ * Real.logb 2 |(i.1 : ℝ) - (k.1 : ℝ)| + C) (C + 2 * δ * Real.logb 2 |(i.1 : ℝ) - (l.1 : ℝ)| + C) nlinarith · rw [max_eq_left h] at htri have hmx := le_max_left (C + 2 * δ * Real.logb 2 |(i.1 : ℝ) - (k.1 : ℝ)| + C) (C + 2 * δ * Real.logb 2 |(i.1 : ℝ) - (l.1 : ℝ)| + C) nlinarith by_cases hk0 : k.1 = 0 · have hl0 : l.1 ≠ 0 := fun h => hkl (Fin.ext (by omega)) simp only [hij, hkl, hik, hjl, hil, hjk, hi0, hj0, hk0, hl0, or_true, or_false, ↓reduceIte] have htri := log2_three (hne hij) (hne hil) (hne hjl) rcases le_total (Real.logb 2 |(i.1 : ℝ) - (l.1 : ℝ)|) (Real.logb 2 |(j.1 : ℝ) - (l.1 : ℝ)|) with h | h · rw [max_eq_right h] at htri have hmx := le_max_left (C + (C + 2 * δ * Real.logb 2 |(j.1 : ℝ) - (l.1 : ℝ)|)) (C + 2 * δ * Real.logb 2 |(i.1 : ℝ) - (l.1 : ℝ)| + C) nlinarith · rw [max_eq_left h] at htri have hmx := le_max_right (C + (C + 2 * δ * Real.logb 2 |(j.1 : ℝ) - (l.1 : ℝ)|)) (C + 2 * δ * Real.logb 2 |(i.1 : ℝ) - (l.1 : ℝ)| + C) nlinarith by_cases hl0 : l.1 = 0 · simp only [hij, hkl, hik, hjl, hil, hjk, hi0, hj0, hk0, hl0, or_true, or_false, ↓reduceIte] have htri := log2_three (hne hij) (hne hik) (hne hjk) rcases le_total (Real.logb 2 |(i.1 : ℝ) - (k.1 : ℝ)|) (Real.logb 2 |(j.1 : ℝ) - (k.1 : ℝ)|) with h | h · rw [max_eq_right h] at htri have hmx := le_max_right (C + 2 * δ * Real.logb 2 |(i.1 : ℝ) - (k.1 : ℝ)| + C) (C + (C + 2 * δ * Real.logb 2 |(j.1 : ℝ) - (k.1 : ℝ)|)) nlinarith · rw [max_eq_left h] at htri have hmx := le_max_left (C + 2 * δ * Real.logb 2 |(i.1 : ℝ) - (k.1 : ℝ)| + C) (C + (C + 2 * δ * Real.logb 2 |(j.1 : ℝ) - (k.1 : ℝ)|)) nlinarith simp only [hij, hkl, hik, hjl, hil, hjk, hi0, hj0, hk0, hl0, or_self, ↓reduceIte] have hpt := ptolemy_log2_four (hne hij) (hne hik) (hne hil) (hne hjk) (hne hjl) (hne hkl) rcases le_total (Real.logb 2 |(i.1 : ℝ) - (k.1 : ℝ)| + Real.logb 2 |(j.1 : ℝ) - (l.1 : ℝ)|) (Real.logb 2 |(i.1 : ℝ) - (l.1 : ℝ)| + Real.logb 2 |(j.1 : ℝ) - (k.1 : ℝ)|) with h | h · rw [max_eq_right h] at hpt have hmx := le_max_right (C + 2 * δ * Real.logb 2 |(i.1 : ℝ) - (k.1 : ℝ)| + (C + 2 * δ * Real.logb 2 |(j.1 : ℝ) - (l.1 : ℝ)|)) (C + 2 * δ * Real.logb 2 |(i.1 : ℝ) - (l.1 : ℝ)| + (C + 2 * δ * Real.logb 2 |(j.1 : ℝ) - (k.1 : ℝ)|)) nlinarith · rw [max_eq_left h] at hpt have hmx := le_max_left (C + 2 * δ * Real.logb 2 |(i.1 : ℝ) - (k.1 : ℝ)| + (C + 2 * δ * Real.logb 2 |(j.1 : ℝ) - (l.1 : ℝ)|)) (C + 2 * δ * Real.logb 2 |(i.1 : ℝ) - (l.1 : ℝ)| + (C + 2 * δ * Real.logb 2 |(j.1 : ℝ) - (k.1 : ℝ)|)) nlinarith /-- **THEOREM (Exact Gromov Tree Distortion of `ptolemyLogDist`)**: For EVERY `n ≥ 3` and `δ ≥ 0`, Gromov's approximating tree rooted at `w = 0` suffers additive distortion AT LEAST (hence EXACTLY) `2 * δ * log₂(n - 2)` between vertices `1` and `n - 1`! For every dyadic `n = 2^k + 2`, this matches our sharp upper bound `2 * δ * ⌈log₂(n - 2)⌉ = 2kδ` IDENTICALLY! -/ theorem ptolemyLog_tree_distortion_exact {n : ℕ} (hn : 3 ≤ n) {δ : ℝ} (hδ : 0 ≤ δ) : let _ : Nonempty (Fin n) := ⟨⟨0, by omega⟩⟩ let w : Fin n := ⟨0, by omega⟩ let x₁ : Fin n := ⟨1, by omega⟩ let xₙ : Fin n := ⟨n - 1, by omega⟩ ptolemyLogDist n δ x₁ xₙ - gromovTreeDist (ptolemyLogDist n δ) w x₁ xₙ = 2 * δ * Real.logb 2 ((n - 2 : ℕ) : ℝ) := by intro _ w x₁ xₙ have hpm := ptolemyLogDist_isPseudoMetricFn hn hδ set d := ptolemyLogDist n δ set K := Nat.clog 2 (Fintype.card (Fin n) - 2) set L := Real.logb 2 (max 1 ((n - 2 : ℕ) : ℝ)) set C := 2 * δ * L + 2 * δ have hL_eq : max 1 ((n - 2 : ℕ) : ℝ) = ((n - 2 : ℕ) : ℝ) := max_eq_right (by exact_mod_cast (by omega : 1 ≤ n - 2)) -- Step 1: Every consecutive pair `(m, m+1)` (`1 ≤ m < n-1`) has Gromov product `C / 2`! have hconsec : ∀ m : ℕ, (hm1 : 1 ≤ m) → (hm2 : m + 1 < n) → gromovProd d w ⟨m, by omega⟩ ⟨m + 1, hm2⟩ = C / 2 := by intro m hm1 hm2 unfold gromovProd d ptolemyLogDist have hne1 : (⟨m, by omega⟩ : Fin n) ≠ w := fun h => by have := congrArg Fin.val h; simp [w] at this; omega have hne2 : (⟨m + 1, hm2⟩ : Fin n) ≠ w := fun h => by have := congrArg Fin.val h; simp [w] at this have hne12 : (⟨m, by omega⟩ : Fin n) ≠ ⟨m + 1, hm2⟩ := fun h => by have := congrArg Fin.val h; simp at this have habs : |(m : ℝ) - ((m + 1 : ℕ) : ℝ)| = 1 := by push_cast; rw [show (m : ℝ) - (m + 1) = -1 by ring, abs_neg, abs_one] simp only [hne1, hne2, hne12, w, show m ≠ 0 by omega, show m + 1 ≠ 0 by omega, or_true, or_self, ↓reduceIte, habs, Real.logb_one, mul_zero, add_zero] ring -- Step 2: By ultrametric induction along `1 -> 2 -> ... -> n-1`, `gpStep K x₁ xₙ ≥ C / 2`! have hgp_ge : ∀ m : ℕ, (hm1 : 1 ≤ m) → (hm2 : m < n) → C / 2 ≤ gpStep d w K x₁ ⟨m, hm2⟩ := by intro m hm1 hm2 induction m with | zero => omega | succ m' ih => by_cases hm'0 : m' = 0 · subst hm'0 have heq : (⟨1, hm2⟩ : Fin n) = x₁ := Fin.ext rfl rw [heq, gpStep_self hpm] have hne : x₁ ≠ w := fun h => by have := congrArg Fin.val h; simp [x₁, w] at this have hdw : d x₁ w = C := by unfold d ptolemyLogDist; simp [hne, x₁, w]; rfl have hL0 : 0 ≤ L := logb2_nonneg_of_one_le (le_max_left _ _) rw [hdw]; nlinarith · have ih' := ih (by omega) (by omega) have hstep : C / 2 ≤ gpStep d w K ⟨m', by omega⟩ ⟨m' + 1, hm2⟩ := by rw [← hconsec m' (by omega) hm2] exact gromovProd_le_gpStep hpm w K _ _ exact le_trans (le_min ih' hstep) (gpStep_ultrametric hpm w x₁ ⟨m' + 1, hm2⟩ ⟨m', by omega⟩) -- Step 3: Conversely, every distinct pair has `gromovProd ≤ C / 2`, so `gpStep K x₁ xₙ ≤ C / 2`! have hgp_le_half : ∀ k (u v : Fin n), u ≠ v → gpStep d w k u v ≤ C / 2 := by intro k induction k with | zero => intro u v huv unfold gpStep gromovProd d ptolemyLogDist by_cases hu0 : u.1 = 0 · have hv0 : v.1 ≠ 0 := fun h => huv (Fin.ext (by omega)) have hvw : v ≠ w := fun h => hv0 (congrArg Fin.val h) have hwv : w ≠ v := fun h => hvw h.symm have huw : u = w := Fin.ext hu0 simp only [huw, hvw, hwv, w, hv0, true_or, or_true, ↓reduceIte] have hL0 : 0 ≤ L := logb2_nonneg_of_one_le (le_max_left _ _) dsimp only [C, L]; nlinarith by_cases hv0 : v.1 = 0 · have huw : u ≠ w := fun h => hu0 (congrArg Fin.val h) have hvw : v = w := Fin.ext hv0 simp only [hvw, huw, w, hu0, or_true, ↓reduceIte] have hL0 : 0 ≤ L := logb2_nonneg_of_one_le (le_max_left _ _) dsimp only [C, L]; nlinarith · have huw : u ≠ w := fun h => hu0 (congrArg Fin.val h) have hvw : v ≠ w := fun h => hv0 (congrArg Fin.val h) simp only [huv, huw, hvw, hu0, hv0, w, or_true, or_self, ↓reduceIte] have ⟨hlo, _⟩ := logb2_abs_diff_le hn hu0 hv0 huv dsimp only [C, L]; nlinarith | succ k ih => intro u v huv simp only [gpStep] refine Finset.sup'_le Finset.univ_nonempty _ (fun z _ => ?_) by_cases huz : u = z · subst huz; exact le_trans (min_le_right _ _) (ih u v huv) · exact le_trans (min_le_left _ _) (ih u z huz) have hne1n : x₁ ≠ xₙ := fun h => by have := congrArg Fin.val h; simp [x₁, xₙ] at this; omega have hgp_eq : gpStep d w K x₁ xₙ = C / 2 := le_antisymm (hgp_le_half K x₁ xₙ hne1n) (hgp_ge (n - 1) (by omega) (by omega)) -- Step 4: Evaluate `d x₁ xₙ - gromovTreeDist d w x₁ xₙ`! unfold gromovTreeDist rw [show Nat.clog 2 (Fintype.card (Fin n) - 2) = K from rfl, hgp_eq] have hx1w : d x₁ w = C := by have : x₁ ≠ w := fun h => by have := congrArg Fin.val h; simp [x₁, w] at this unfold d ptolemyLogDist; simp [this, x₁, w]; rfl have hxnw : d xₙ w = C := by have : xₙ ≠ w := fun h => by have := congrArg Fin.val h; simp [xₙ, w] at this; omega unfold d ptolemyLogDist; simp [this, xₙ, w]; rfl have hx1xn : d x₁ xₙ = C + 2 * δ * Real.logb 2 ((n - 2 : ℕ) : ℝ) := by unfold d ptolemyLogDist have h10 : x₁.1 ≠ 0 := by simp [x₁] have hn0 : xₙ.1 ≠ 0 := by simp [xₙ]; omega have habs : |(x₁.1 : ℝ) - (xₙ.1 : ℝ)| = ((n - 2 : ℕ) : ℝ) := by simp only [x₁, xₙ, Nat.cast_one] have hcast1 : ((n - 1 : ℕ) : ℝ) = (n : ℝ) - 1 := by rw [Nat.cast_sub (by omega : 1 ≤ n)]; norm_num have hcast2 : ((n - 2 : ℕ) : ℝ) = (n : ℝ) - 2 := by rw [Nat.cast_sub (by omega : 2 ≤ n)]; norm_num have hnR : (3 : ℝ) ≤ (n : ℝ) := by exact_mod_cast hn rw [hcast1, hcast2, show (1 : ℝ) - ((n : ℝ) - 1) = -((n : ℝ) - 2) by ring, abs_neg, abs_of_nonneg (by linarith)] simp [hne1n, h10, hn0, habs]; rfl rw [hx1w, hxnw, hx1xn] ring /-- **COROLLARY (Exact Dyadic Tightness of Gromov's Tree Approximation)**: For EVERY `k : ℕ` and `n = 2^k + 2`, `ptolemyLogDist n δ` is globally `δ`-hyperbolic and attains our finite-`n` Gromov tree distortion upper bound `2 * δ * ⌈log₂(n - 2)⌉ = 2kδ` WITH EXACT EQUALITY! -/ theorem gromov_tree_approx_exact_dyadic (k : ℕ) {δ : ℝ} (hδ : 0 ≤ δ) : let n := 2 ^ k + 2 let _ : Nonempty (Fin n) := ⟨⟨0, by have := Nat.one_le_two_pow (n := k); omega⟩⟩ let w : Fin n := ⟨0, by have := Nat.one_le_two_pow (n := k); omega⟩ let x₁ : Fin n := ⟨1, by have := Nat.one_le_two_pow (n := k); omega⟩ let xₙ : Fin n := ⟨n - 1, by have := Nat.one_le_two_pow (n := k); omega⟩ IsFourPointHyperbolic (ptolemyLogDist n δ) δ ∧ ptolemyLogDist n δ x₁ xₙ - gromovTreeDist (ptolemyLogDist n δ) w x₁ xₙ = 2 * δ * (Nat.clog 2 (Fintype.card (Fin n) - 2) : ℝ) := by intro n _ w x₁ xₙ have hn : 3 ≤ n := by have : 1 ≤ 2 ^ k := Nat.one_le_two_pow omega refine ⟨ptolemyLogDist_hyperbolic hn hδ, ?_⟩ rw [ptolemyLog_tree_distortion_exact hn hδ] have hsub : n - 2 = 2 ^ k := by omega have hcard : Fintype.card (Fin n) - 2 = 2 ^ k := by simp [Fintype.card_fin]; omega rw [hsub, hcard, Nat.clog_pow 2 k (by decide : 1 < 2)] push_cast rw [Real.logb_pow, Real.logb_self_eq_one (by norm_num), mul_one] /-! ## Section 4: Universal 4-Point & 6-Point Hexagon-Diameter Obstructions -/ /-- **Universal 4-Point Tree-Approximation Lower Bound**: If a `δ'`-hyperbolic distance `d'` approximates `d` within `L_∞` error `ε`, then `d` is `(δ' + 2ε)`-hyperbolic. Contrapositively, for any `0`-hyperbolic tree metric, `ε ≥ δ_4 / 2`! -/ theorem fourPoint_approx_lower_bound {α : Type*} {d d' : α → α → ℝ} {δ' ε : ℝ} (h' : IsFourPointHyperbolic d' δ') (happrox : ∀ x y, |d x y - d' x y| ≤ ε) : IsFourPointHyperbolic d (δ' + 2 * ε) := by intro x y z w have h4 := h' x y z w have hxy := (abs_le.mp (happrox x y)).2 have hzw := (abs_le.mp (happrox z w)).2 have hxz := (abs_le.mp (happrox x z)).1 have hyw := (abs_le.mp (happrox y w)).1 have hxw := (abs_le.mp (happrox x w)).1 have hyz := (abs_le.mp (happrox y z)).1 rcases le_max_iff.mp (by linarith : d' x y + d' z w - 2 * δ' ≤ max (d' x z + d' y w) (d' x w + d' y z)) with h1 | h2 · linarith [le_max_left (d x z + d y w) (d x w + d y z)] · linarith [le_max_right (d x z + d y w) (d x w + d y z)] /-- **THEOREM (Universal 6-Point Hexagon-Diameter Inequality in ANY `δ`-Hyperbolic Space)**: For EVERY `δ`-hyperbolic pseudometric `d` and ANY 6 points `p₀, p₁, p₂, p₃, p₄, p₅`: `min(d(p₀, p₃), d(p₁, p₄), d(p₂, p₅)) ≤ max_{i ∈ ℤ/6} d(pᵢ, pᵢ₊₁) + 2δ`. Proved in 12 lines via 3 kite 4-point inequalities forming a 3-vertex functional digraph whose directed cycle cancels all inscribed-triangle distances identically! -/ theorem hexagon_hyperbolic_ineq {α : Type*} {d : α → α → ℝ} {δ : ℝ} (hd : IsPseudoMetricFn d) (hh : IsFourPointHyperbolic d δ) (p₀ p₁ p₂ p₃ p₄ p₅ : α) : min (d p₀ p₃) (min (d p₁ p₄) (d p₂ p₅)) ≤ max (max (d p₀ p₁) (d p₁ p₂)) (max (max (d p₂ p₃) (d p₃ p₄)) (max (d p₄ p₅) (d p₅ p₀))) + 2 * δ := by set M := max (max (d p₀ p₁) (d p₁ p₂)) (max (max (d p₂ p₃) (d p₃ p₄)) (max (d p₄ p₅) (d p₅ p₀))) set m := min (d p₀ p₃) (min (d p₁ p₄) (d p₂ p₅)) have hm03 : m ≤ d p₀ p₃ := min_le_left _ _ have hm14 : m ≤ d p₁ p₄ := le_trans (min_le_right _ _) (min_le_left _ _) have hm25 : m ≤ d p₂ p₅ := le_trans (min_le_right _ _) (min_le_right _ _) have hM01 : d p₀ p₁ ≤ M := le_trans (le_max_left _ _) (le_max_left _ _) have hM12 : d p₁ p₂ ≤ M := le_trans (le_max_right _ _) (le_max_left _ _) have hM23 : d p₂ p₃ ≤ M := le_trans (le_max_left _ _) (le_trans (le_max_left _ _) (le_max_right _ _)) have hM34 : d p₃ p₄ ≤ M := le_trans (le_max_right _ _) (le_trans (le_max_left _ _) (le_max_right _ _)) have hM45 : d p₄ p₅ ≤ M := le_trans (le_max_left _ _) (le_trans (le_max_right _ _) (le_max_right _ _)) have hM50 : d p₅ p₀ ≤ M := le_trans (le_max_right _ _) (le_trans (le_max_right _ _) (le_max_right _ _)) -- Three kite 4-point inequalities on `{p₀, p₂, p₄}` paired with `p₁`, `p₃`, `p₅`: have hK1 := hh p₀ p₂ p₁ p₄ have hK3 := hh p₂ p₄ p₃ p₀ have hK5 := hh p₄ p₀ p₅ p₂ -- Rewrite symmetric distances to canonical triangle edges `T02 = d p₀ p₂`, `T24 = d p₂ p₄`, `T40 = d p₄ p₀` rw [hd.symm p₂ p₁, hd.symm p₀ p₄] at hK1 rw [hd.symm p₂ p₀, hd.symm p₄ p₃, hd.symm p₃ p₀] at hK3 rw [hd.symm p₄ p₂, hd.symm p₀ p₅, hd.symm p₅ p₂] at hK5 -- All 8 branches of the 3-vertex functional digraph close via a length-2 or length-3 cycle! rcases le_max_iff.mp (by linarith : d p₀ p₂ + d p₁ p₄ - 2 * δ ≤ max (d p₀ p₁ + d p₂ p₄) (d p₄ p₀ + d p₁ p₂)) with c1 | c1 <;> rcases le_max_iff.mp (by linarith : d p₂ p₄ + d p₀ p₃ - 2 * δ ≤ max (d p₂ p₃ + d p₄ p₀) (d p₀ p₂ + d p₃ p₄)) with c3 | c3 <;> rcases le_max_iff.mp (by linarith : d p₄ p₀ + d p₂ p₅ - 2 * δ ≤ max (d p₄ p₅ + d p₀ p₂) (d p₂ p₄ + d p₅ p₀)) with c5 | c5 <;> linarith /-! ## Section 5: Exact Minimax Tree Distortion of S¹_L and C_{6m} + Exact Cycles & Grids -/ /-- Geodesic distance on the circle `S^1_L` of perimeter `L > 0` parameterized by `ℝ / Lℤ` (represented on `[0, L)` via `Int.fract`). -/ noncomputable def circleDist (L : ℝ) (x y : ℝ) : ℝ := let r := Int.fract ((x - y) / L) * L min r (L - r) lemma circleDist_eq_min_abs {L : ℝ} (hL : 0 < L) {x y : ℝ} (hx0 : 0 ≤ x) (hxL : x < L) (hy0 : 0 ≤ y) (hyL : y < L) : circleDist L x y = min |x - y| (L - |x - y|) := by unfold circleDist set u := (x - y) / L by_cases hxy : y ≤ x · have hu0 : 0 ≤ u := div_nonneg (by linarith) (le_of_lt hL) have hu1 : u < 1 := (div_lt_one hL).mpr (by linarith) have hfl : ⌊u⌋ = 0 := Int.floor_eq_iff.mpr ⟨by simp [hu0], by simp [hu1]⟩ have hfr : Int.fract u = u := by simp [Int.fract, hfl] rw [hfr, div_mul_cancel₀ _ (ne_of_gt hL), abs_of_nonneg (by linarith)] · push Not at hxy have hu_neg : -1 < u := by rw [lt_div_iff₀ hL]; linarith have hu_lt0 : u < 0 := div_neg_of_neg_of_pos (by linarith) hL have hfl : ⌊u⌋ = -1 := Int.floor_eq_iff.mpr ⟨by norm_num; linarith, by norm_num; linarith⟩ have hfr : Int.fract u = u + 1 := by simp [Int.fract, hfl] rw [hfr, add_mul, one_mul, div_mul_cancel₀ _ (ne_of_gt hL), abs_of_neg (by linarith)] rw [min_comm] congr 1 <;> ring /-- **THEOREM (Sharp Circle-to-Hyperbolic Approximation Barrier)**: If ANY `δ'`-hyperbolic pseudometric `d'` approximates the geodesic circle `S^1_L` (`L > 0`) within `L_∞` additive error `ε`, then `ε + δ' ≥ L / 6`! In particular, for EVERY `0`-hyperbolic tree metric (`δ' = 0`), `ε ≥ L / 6` (strictly beating the 4-point bound `L / 8` by a factor of `4/3`!). -/ theorem circle_hyperbolic_approx_lower_bound {L δ' ε : ℝ} (hL : 0 < L) {d' : ℝ → ℝ → ℝ} (hd' : IsPseudoMetricFn d') (h' : IsFourPointHyperbolic d' δ') (happrox : ∀ x y, |circleDist L x y - d' x y| ≤ ε) : L / 6 ≤ ε + δ' := by -- Evaluate our Universal Hexagon Inequality at the 6 equidistant points `k * L / 6` have hhex := hexagon_hyperbolic_ineq hd' h' 0 (L / 6) (2 * L / 6) (3 * L / 6) (4 * L / 6) (5 * L / 6) have hdist : ∀ a b : ℕ, a < 6 → b < 6 → circleDist L ((a : ℝ) * L / 6) ((b : ℝ) * L / 6) = min (|(a : ℝ) - (b : ℝ)| * L / 6) (L - |(a : ℝ) - (b : ℝ)| * L / 6) := by intro a b ha hb have ha0 : 0 ≤ (a : ℝ) * L / 6 := by positivity have haL : (a : ℝ) * L / 6 < L := by have : (a : ℝ) < 6 := by exact_mod_cast ha nlinarith have hb0 : 0 ≤ (b : ℝ) * L / 6 := by positivity have hbL : (b : ℝ) * L / 6 < L := by have : (b : ℝ) < 6 := by exact_mod_cast hb nlinarith rw [circleDist_eq_min_abs hL ha0 haL hb0 hbL] have heq : |(a : ℝ) * L / 6 - (b : ℝ) * L / 6| = |(a : ℝ) - (b : ℝ)| * L / 6 := by rw [show (a : ℝ) * L / 6 - (b : ℝ) * L / 6 = ((a : ℝ) - (b : ℝ)) * (L / 6) by ring, abs_mul, abs_of_pos (by linarith : 0 < L / 6)] ring rw [heq] -- Compute the 3 opposite distances (`= L / 2`) and 6 adjacent distances (`= L / 6`) have hc03 : circleDist L 0 (3 * L / 6) = L / 2 := by have := hdist 0 3 (by decide) (by decide) simp only [Nat.cast_zero, zero_mul, zero_div, Nat.cast_ofNat] at this rw [this]; norm_num; rw [min_eq_left] <;> linarith have hc14 : circleDist L (L / 6) (4 * L / 6) = L / 2 := by have := hdist 1 4 (by decide) (by decide) simp only [Nat.cast_one, one_mul, Nat.cast_ofNat] at this rw [this]; norm_num; rw [min_eq_left] <;> linarith have hc25 : circleDist L (2 * L / 6) (5 * L / 6) = L / 2 := by have := hdist 2 5 (by decide) (by decide) simp only [Nat.cast_ofNat] at this rw [this]; norm_num; rw [min_eq_left] <;> linarith have hc01 : circleDist L 0 (L / 6) = L / 6 := by have := hdist 0 1 (by decide) (by decide) simp only [Nat.cast_zero, zero_mul, zero_div, Nat.cast_one, one_mul] at this rw [this]; norm_num; linarith have hc12 : circleDist L (L / 6) (2 * L / 6) = L / 6 := by have := hdist 1 2 (by decide) (by decide) simp only [Nat.cast_one, one_mul, Nat.cast_ofNat] at this rw [this]; norm_num; linarith have hc23 : circleDist L (2 * L / 6) (3 * L / 6) = L / 6 := by have := hdist 2 3 (by decide) (by decide) simp only [Nat.cast_ofNat] at this rw [this]; norm_num; linarith have hc34 : circleDist L (3 * L / 6) (4 * L / 6) = L / 6 := by have := hdist 3 4 (by decide) (by decide) simp only [Nat.cast_ofNat] at this rw [this]; norm_num; linarith have hc45 : circleDist L (4 * L / 6) (5 * L / 6) = L / 6 := by have := hdist 4 5 (by decide) (by decide) simp only [Nat.cast_ofNat] at this rw [this]; norm_num; linarith have hc50 : circleDist L (5 * L / 6) 0 = L / 6 := by have := hdist 5 0 (by decide) (by decide) simp only [Nat.cast_zero, zero_mul, zero_div, Nat.cast_ofNat] at this rw [this]; norm_num; rw [min_eq_right (by linarith)]; linarith have hlo : L / 2 - ε ≤ min (d' 0 (3 * L / 6)) (min (d' (L / 6) (4 * L / 6)) (d' (2 * L / 6) (5 * L / 6))) := by refine le_min ?_ (le_min ?_ ?_) · linarith [(abs_le.mp (happrox 0 (3 * L / 6))).2, hc03] · linarith [(abs_le.mp (happrox (L / 6) (4 * L / 6))).2, hc14] · linarith [(abs_le.mp (happrox (2 * L / 6) (5 * L / 6))).2, hc25] have hhi : max (max (d' 0 (L / 6)) (d' (L / 6) (2 * L / 6))) (max (max (d' (2 * L / 6) (3 * L / 6)) (d' (3 * L / 6) (4 * L / 6))) (max (d' (4 * L / 6) (5 * L / 6)) (d' (5 * L / 6) 0))) ≤ L / 6 + ε := by refine max_le (max_le ?_ ?_) (max_le (max_le ?_ ?_) (max_le ?_ ?_)) · linarith [(abs_le.mp (happrox 0 (L / 6))).1, hc01] · linarith [(abs_le.mp (happrox (L / 6) (2 * L / 6))).1, hc12] · linarith [(abs_le.mp (happrox (2 * L / 6) (3 * L / 6))).1, hc23] · linarith [(abs_le.mp (happrox (3 * L / 6) (4 * L / 6))).1, hc34] · linarith [(abs_le.mp (happrox (4 * L / 6) (5 * L / 6))).1, hc45] · linarith [(abs_le.mp (happrox (5 * L / 6) 0)).1, hc50] linarith /-- Explicit 3-ray folded tripod embedding of `S^1_L` into `Fin 3 × ℝ≥0` (ray index + radius). -/ noncomputable def circleFoldTripodPos (L : ℝ) (x : ℝ) : Fin 3 × ℝ := let t := Int.fract (x / L) * L if t ≤ L / 6 then (0, L / 6 - t) else if t ≤ 2 * L / 6 then (1, t - L / 6) else if t ≤ 3 * L / 6 then (1, 3 * L / 6 - t) else if t ≤ 4 * L / 6 then (2, t - 3 * L / 6) else if t ≤ 5 * L / 6 then (2, 5 * L / 6 - t) else (0, t - 5 * L / 6) /-- Standard tree metric on the 3-ray tripod `Fin 3 × ℝ` (with nonneg radii). -/ noncomputable def tripodSpaceDist (p q : Fin 3 × ℝ) : ℝ := if p.1 = q.1 then |p.2 - q.2| else p.2 + q.2 lemma tripodSpaceDist_isPseudoMetricFn : ∀ p q r : Fin 3 × ℝ, 0 ≤ p.2 → 0 ≤ q.2 → 0 ≤ r.2 → 0 ≤ tripodSpaceDist p q ∧ tripodSpaceDist p p = 0 ∧ tripodSpaceDist p q = tripodSpaceDist q p ∧ tripodSpaceDist p r ≤ tripodSpaceDist p q + tripodSpaceDist q r := by intro p q r hp hq hr refine ⟨?_, ?_, ?_, ?_⟩ · unfold tripodSpaceDist; split_ifs; exact abs_nonneg _; linarith · simp [tripodSpaceDist] · unfold tripodSpaceDist by_cases h : p.1 = q.1 · simp [h, abs_sub_comm] · simp [h, Ne.symm h, add_comm] · unfold tripodSpaceDist by_cases hpq : p.1 = q.1 <;> by_cases hqr : q.1 = r.1 · have hpr : p.1 = r.1 := hpq.trans hqr rw [if_pos hpr, if_pos hpq, if_pos hqr] calc |p.2 - r.2| = |(p.2 - q.2) + (q.2 - r.2)| := by ring_nf _ ≤ |p.2 - q.2| + |q.2 - r.2| := abs_add_le _ _ · have hpr : p.1 ≠ r.1 := fun h => hqr (hpq.symm.trans h) rw [if_neg hpr, if_pos hpq, if_neg hqr] linarith [le_abs_self (p.2 - q.2)] · have hpr : p.1 ≠ r.1 := fun h => hpq (h.trans hqr.symm) rw [if_neg hpr, if_neg hpq, if_pos hqr] linarith [neg_le_abs (q.2 - r.2)] · by_cases hpr : p.1 = r.1 · rw [if_pos hpr, if_neg hpq, if_neg hqr, abs_le]; constructor <;> linarith [hp, hq, hr] · rw [if_neg hpr, if_neg hpq, if_neg hqr]; linarith [hp, hq, hr] /-- The 3-ray tripod metric is `0`-hyperbolic on all points with nonneg radii! -/ lemma tripodSpaceDist_zeroHyperbolic (a b c e : Fin 3 × ℝ) (ha : 0 ≤ a.2) (hb : 0 ≤ b.2) (hc : 0 ≤ c.2) (he : 0 ≤ e.2) : tripodSpaceDist a b + tripodSpaceDist c e ≤ max (tripodSpaceDist a c + tripodSpaceDist b e) (tripodSpaceDist a e + tripodSpaceDist b c) := by -- Express as `d(u, v) = u.2 + v.2 - 2 * g(u, v)` where `g(u, v) = if u.1 = v.1 then min u.2 v.2 else 0`! let g : Fin 3 × ℝ → Fin 3 × ℝ → ℝ := fun u v => if u.1 = v.1 then min u.2 v.2 else 0 have hd_eq : ∀ u v : Fin 3 × ℝ, tripodSpaceDist u v = u.2 + v.2 - 2 * g u v := by intro u v unfold tripodSpaceDist; dsimp [g] split_ifs · rcases le_total u.2 v.2 with h | h · rw [min_eq_left h, abs_of_nonpos (by linarith)]; ring · rw [min_eq_right h, abs_of_nonneg (by linarith)]; ring · ring have hg_ultra : ∀ u v w : Fin 3 × ℝ, 0 ≤ u.2 → 0 ≤ v.2 → 0 ≤ w.2 → min (g u w) (g w v) ≤ g u v := by intro u v w hu hv hw dsimp [g] split_ifs with h1 h2 h3 · exact le_min (le_trans (min_le_left _ _) (min_le_left _ _)) (le_trans (min_le_right _ _) (min_le_right _ _)) · exact absurd (h1.trans h2) h3 · exact le_trans (min_le_right _ _) (le_min hu hv) · exact min_le_right _ _ · exact le_trans (min_le_left _ _) (le_min hu hv) · exact min_le_left _ _ · exact le_trans (min_le_left _ _) (le_min hu hv) · exact min_le_left _ _ have hsym : ∀ u v, g u v = g v u := by intro u v; dsimp [g] by_cases h : u.1 = v.1 · simp [h, min_comm] · simp [h, Ne.symm h] rw [hd_eq a b, hd_eq c e, hd_eq a c, hd_eq b e, hd_eq a e, hd_eq b c, le_max_iff] have h1 : min (g a c) (g b c) ≤ g a b := by rw [hsym b c]; exact hg_ultra a b c ha hb hc have h2 : min (g a e) (g b e) ≤ g a b := by rw [hsym b e]; exact hg_ultra a b e ha hb he have h3 : min (g a c) (g a e) ≤ g c e := by rw [hsym a c]; exact hg_ultra c e a hc he ha have h4 : min (g b c) (g b e) ≤ g c e := by rw [hsym b c]; exact hg_ultra c e b hc he hb rcases le_total (g a c) (g b c) with hac_bc | hbc_ac · rw [min_eq_left hac_bc] at h1 rcases le_total (g b e) (g a e) with hbe_ae | hae_be · rw [min_eq_right hbe_ae] at h2 rcases le_total (g a c) (g a e) with hac_ae | hae_ac · rw [min_eq_left hac_ae] at h3; left; linarith · rw [min_eq_right hae_ac] at h3 rcases le_total (g b c) (g b e) with hbc_be | hbe_bc · rw [min_eq_left hbc_be] at h4; right; linarith · rw [min_eq_right hbe_bc] at h4; left; linarith · rw [min_eq_left hae_be] at h2 rcases le_total (g b c) (g b e) with hbc_be | hbe_bc · rw [min_eq_left hbc_be] at h4; right; linarith · rw [min_eq_right hbe_bc] at h4; left; linarith · rw [min_eq_right hbc_ac] at h1 rcases le_total (g a e) (g b e) with hae_be | hbe_ae · rw [min_eq_left hae_be] at h2 rcases le_total (g b c) (g b e) with hbc_be | hbe_bc · rw [min_eq_left hbc_be] at h4; right; linarith · rw [min_eq_right hbe_bc] at h4 rcases le_total (g a c) (g a e) with hac_ae | hae_ac · rw [min_eq_left hac_ae] at h3; left; linarith · rw [min_eq_right hae_ac] at h3; right; linarith · rw [min_eq_right hbe_ae] at h2 rcases le_total (g a c) (g a e) with hac_ae | hae_ac · rw [min_eq_left hac_ae] at h3; left; linarith · rw [min_eq_right hae_ac] at h3; right; linarith /-- Pullback of the 3-ray folded tripod metric to `S^1_L`. -/ noncomputable def circleFoldTripodDist (L : ℝ) (x y : ℝ) : ℝ := tripodSpaceDist (circleFoldTripodPos L x) (circleFoldTripodPos L y) lemma circleFoldTripodPos_nonneg {L : ℝ} (hL : 0 < L) (x : ℝ) : 0 ≤ (circleFoldTripodPos L x).2 := by unfold circleFoldTripodPos dsimp only have h0 : 0 ≤ Int.fract (x / L) * L := mul_nonneg (Int.fract_nonneg _) (le_of_lt hL) have h1 : Int.fract (x / L) * L < L := by have := Int.fract_lt_one (x / L); nlinarith split_ifs <;> linarith /-- Helper: `circleDist L` depends only on `Int.fract (x / L) * L` and `Int.fract (y / L) * L`. -/ lemma circleDist_eq_of_fract {L : ℝ} (hL : 0 < L) (x y : ℝ) : circleDist L x y = circleDist L (Int.fract (x / L) * L) (Int.fract (y / L) * L) := by unfold circleDist have hsub : (Int.fract (x / L) * L - Int.fract (y / L) * L) / L = (x - y) / L - ((⌊x / L⌋ - ⌊y / L⌋ : ℤ) : ℝ) := by simp only [Int.fract, Int.cast_sub] field_simp [ne_of_gt hL] ring rw [hsub, Int.fract_sub_intCast] /-- Helper: canonical 6-sector folding map on `[0, L)`. -/ noncomputable def circleFoldPos0 (L u : ℝ) : Fin 3 × ℝ := if u ≤ L / 6 then (0, L / 6 - u) else if u ≤ 2 * L / 6 then (1, u - L / 6) else if u ≤ 3 * L / 6 then (1, 3 * L / 6 - u) else if u ≤ 4 * L / 6 then (2, u - 3 * L / 6) else if u ≤ 5 * L / 6 then (2, 5 * L / 6 - u) else (0, u - 5 * L / 6) private lemma circleFold_close_same {L a b X : ℝ} (h1 : X ≤ b - a ∧ -X ≤ b - a ∧ X ≤ L - (b - a) ∧ -X ≤ L - (b - a)) (h2 : b - a - L / 3 ≤ X ∨ b - a - L / 3 ≤ -X ∨ L - (b - a) - L / 3 ≤ X ∨ L - (b - a) - L / 3 ≤ -X) : min (b - a) (L - (b - a)) - L / 3 ≤ |X| ∧ |X| ≤ min (b - a) (L - (b - a)) := by refine ⟨?_, le_min (abs_le.mpr ⟨by linarith, h1.1⟩) (abs_le.mpr ⟨by linarith, h1.2.2.1⟩)⟩ rcases h2 with h | h | h | h · exact le_trans (by linarith [min_le_left (b - a) (L - (b - a))]) (le_trans h (le_abs_self X)) · exact le_trans (by linarith [min_le_left (b - a) (L - (b - a))]) (le_trans h (neg_le_abs X)) · exact le_trans (by linarith [min_le_right (b - a) (L - (b - a))]) (le_trans h (le_abs_self X)) · exact le_trans (by linarith [min_le_right (b - a) (L - (b - a))]) (le_trans h (neg_le_abs X)) private lemma circleFold_close_diff {L a b S : ℝ} (hup1 : S ≤ b - a) (hup2 : S ≤ L - (b - a)) (hlo : b - a - L / 3 ≤ S ∨ L - (b - a) - L / 3 ≤ S) : min (b - a) (L - (b - a)) - L / 3 ≤ S ∧ S ≤ min (b - a) (L - (b - a)) := by refine ⟨?_, le_min hup1 hup2⟩ rcases hlo with h | h · linarith [min_le_left (b - a) (L - (b - a))] · linarith [min_le_right (b - a) (L - (b - a))] private lemma circleFoldPos0_cases {L u : ℝ} : (u ≤ L / 6 ∧ circleFoldPos0 L u = (0, L / 6 - u)) ∨ (L / 6 < u ∧ u ≤ 2 * L / 6 ∧ circleFoldPos0 L u = (1, u - L / 6)) ∨ (2 * L / 6 < u ∧ u ≤ 3 * L / 6 ∧ circleFoldPos0 L u = (1, 3 * L / 6 - u)) ∨ (3 * L / 6 < u ∧ u ≤ 4 * L / 6 ∧ circleFoldPos0 L u = (2, u - 3 * L / 6)) ∨ (4 * L / 6 < u ∧ u ≤ 5 * L / 6 ∧ circleFoldPos0 L u = (2, 5 * L / 6 - u)) ∨ (5 * L / 6 < u ∧ circleFoldPos0 L u = (0, u - 5 * L / 6)) := by unfold circleFoldPos0 by_cases h1 : u ≤ L / 6 · left; exact ⟨h1, by rw [if_pos h1]⟩ · by_cases h2 : u ≤ 2 * L / 6 · right; left; exact ⟨not_le.mp h1, h2, by rw [if_neg h1, if_pos h2]⟩ · by_cases h3 : u ≤ 3 * L / 6 · right; right; left; exact ⟨not_le.mp h2, h3, by rw [if_neg h1, if_neg h2, if_pos h3]⟩ · by_cases h4 : u ≤ 4 * L / 6 · right; right; right; left; exact ⟨not_le.mp h3, h4, by rw [if_neg h1, if_neg h2, if_neg h3, if_pos h4]⟩ · by_cases h5 : u ≤ 5 * L / 6 · right; right; right; right; left; exact ⟨not_le.mp h4, h5, by rw [if_neg h1, if_neg h2, if_neg h3, if_neg h4, if_pos h5]⟩ · right; right; right; right; right; exact ⟨not_le.mp h5, by rw [if_neg h1, if_neg h2, if_neg h3, if_neg h4, if_neg h5]⟩ private lemma circleFold_sect1 {L a b : ℝ} (ha0 : 0 ≤ a) (ha1 : a ≤ L / 6) (hab : a ≤ b) (hbL : b < L) : min (b - a) (L - (b - a)) - L / 3 ≤ tripodSpaceDist (0, L / 6 - a) (circleFoldPos0 L b) ∧ tripodSpaceDist (0, L / 6 - a) (circleFoldPos0 L b) ≤ min (b - a) (L - (b - a)) := by rcases circleFoldPos0_cases (L := L) (u := b) with ⟨hb1, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hpb⟩ <;> rw [hpb] <;> simp only [tripodSpaceDist, Fin.isValue, Fin.reduceEq, ↓reduceIte] · exact circleFold_close_same ⟨by linarith, by linarith, by linarith, by linarith⟩ (Or.inl (by linarith)) · exact circleFold_close_diff (by linarith) (by linarith) (Or.inl (by linarith)) · exact circleFold_close_diff (by linarith) (by linarith) (Or.inl (by linarith)) · exact circleFold_close_diff (by linarith) (by linarith) (Or.inl (by linarith)) · exact circleFold_close_diff (by linarith) (by linarith) (Or.inr (by linarith)) · exact circleFold_close_same ⟨by linarith, by linarith, by linarith, by linarith⟩ (Or.inr (Or.inr (Or.inl (by linarith)))) private lemma circleFold_sect2 {L a b : ℝ} (ha1 : L / 6 < a) (ha2 : a ≤ 2 * L / 6) (hab : a ≤ b) (hbL : b < L) : min (b - a) (L - (b - a)) - L / 3 ≤ tripodSpaceDist (1, a - L / 6) (circleFoldPos0 L b) ∧ tripodSpaceDist (1, a - L / 6) (circleFoldPos0 L b) ≤ min (b - a) (L - (b - a)) := by rcases circleFoldPos0_cases (L := L) (u := b) with ⟨hb1, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hpb⟩ · linarith · rw [hpb]; simp only [tripodSpaceDist, ↓reduceIte] exact circleFold_close_same ⟨by linarith, by linarith, by linarith, by linarith⟩ (Or.inr (Or.inl (by linarith))) · rw [hpb]; simp only [tripodSpaceDist, ↓reduceIte] exact circleFold_close_same ⟨by linarith, by linarith, by linarith, by linarith⟩ (Or.inl (by linarith)) · rw [hpb]; simp only [tripodSpaceDist, Fin.isValue, Fin.reduceEq, ↓reduceIte] exact circleFold_close_diff (by linarith) (by linarith) (Or.inl (by linarith)) · rw [hpb]; simp only [tripodSpaceDist, Fin.isValue, Fin.reduceEq, ↓reduceIte] exact circleFold_close_diff (by linarith) (by linarith) (Or.inr (by linarith)) · rw [hpb]; simp only [tripodSpaceDist, Fin.isValue, Fin.reduceEq, ↓reduceIte] exact circleFold_close_diff (by linarith) (by linarith) (Or.inr (by linarith)) private lemma circleFold_sect3 {L a b : ℝ} (ha1 : 2 * L / 6 < a) (_ha2 : a ≤ 3 * L / 6) (hab : a ≤ b) (hbL : b < L) : min (b - a) (L - (b - a)) - L / 3 ≤ tripodSpaceDist (1, 3 * L / 6 - a) (circleFoldPos0 L b) ∧ tripodSpaceDist (1, 3 * L / 6 - a) (circleFoldPos0 L b) ≤ min (b - a) (L - (b - a)) := by rcases circleFoldPos0_cases (L := L) (u := b) with ⟨hb1, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hpb⟩ · linarith · linarith · rw [hpb]; simp only [tripodSpaceDist, ↓reduceIte] exact circleFold_close_same ⟨by linarith, by linarith, by linarith, by linarith⟩ (Or.inl (by linarith)) · rw [hpb]; simp only [tripodSpaceDist, Fin.isValue, Fin.reduceEq, ↓reduceIte] exact circleFold_close_diff (by linarith) (by linarith) (Or.inl (by linarith)) · rw [hpb]; simp only [tripodSpaceDist, Fin.isValue, Fin.reduceEq, ↓reduceIte] exact circleFold_close_diff (by linarith) (by linarith) (Or.inl (by linarith)) · rw [hpb]; simp only [tripodSpaceDist, Fin.isValue, Fin.reduceEq, ↓reduceIte] exact circleFold_close_diff (by linarith) (by linarith) (Or.inl (by linarith)) private lemma circleFold_sect4 {L a b : ℝ} (ha1 : 3 * L / 6 < a) (ha2 : a ≤ 4 * L / 6) (hab : a ≤ b) (hbL : b < L) : min (b - a) (L - (b - a)) - L / 3 ≤ tripodSpaceDist (2, a - 3 * L / 6) (circleFoldPos0 L b) ∧ tripodSpaceDist (2, a - 3 * L / 6) (circleFoldPos0 L b) ≤ min (b - a) (L - (b - a)) := by rcases circleFoldPos0_cases (L := L) (u := b) with ⟨hb1, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hpb⟩ · linarith · linarith · linarith · rw [hpb]; simp only [tripodSpaceDist, ↓reduceIte] exact circleFold_close_same ⟨by linarith, by linarith, by linarith, by linarith⟩ (Or.inr (Or.inl (by linarith))) · rw [hpb]; simp only [tripodSpaceDist, ↓reduceIte] exact circleFold_close_same ⟨by linarith, by linarith, by linarith, by linarith⟩ (Or.inl (by linarith)) · rw [hpb]; simp only [tripodSpaceDist, Fin.isValue, Fin.reduceEq, ↓reduceIte] exact circleFold_close_diff (by linarith) (by linarith) (Or.inl (by linarith)) private lemma circleFold_sect5 {L a b : ℝ} (ha1 : 4 * L / 6 < a) (_ha2 : a ≤ 5 * L / 6) (hab : a ≤ b) (hbL : b < L) : min (b - a) (L - (b - a)) - L / 3 ≤ tripodSpaceDist (2, 5 * L / 6 - a) (circleFoldPos0 L b) ∧ tripodSpaceDist (2, 5 * L / 6 - a) (circleFoldPos0 L b) ≤ min (b - a) (L - (b - a)) := by rcases circleFoldPos0_cases (L := L) (u := b) with ⟨hb1, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hpb⟩ · linarith · linarith · linarith · linarith · rw [hpb]; simp only [tripodSpaceDist, ↓reduceIte] exact circleFold_close_same ⟨by linarith, by linarith, by linarith, by linarith⟩ (Or.inl (by linarith)) · rw [hpb]; simp only [tripodSpaceDist, Fin.isValue, Fin.reduceEq, ↓reduceIte] exact circleFold_close_diff (by linarith) (by linarith) (Or.inl (by linarith)) private lemma circleFold_sect6 {L a b : ℝ} (ha1 : 5 * L / 6 < a) (hab : a ≤ b) (hbL : b < L) : min (b - a) (L - (b - a)) - L / 3 ≤ tripodSpaceDist (0, a - 5 * L / 6) (circleFoldPos0 L b) ∧ tripodSpaceDist (0, a - 5 * L / 6) (circleFoldPos0 L b) ≤ min (b - a) (L - (b - a)) := by rcases circleFoldPos0_cases (L := L) (u := b) with ⟨hb1, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hb2, hpb⟩ | ⟨hb1, hpb⟩ · linarith · linarith · linarith · linarith · linarith · rw [hpb]; simp only [tripodSpaceDist, ↓reduceIte] exact circleFold_close_same ⟨by linarith, by linarith, by linarith, by linarith⟩ (Or.inr (Or.inl (by linarith))) /-- **THEOREM (Exact Upper Bound for Circle-to-Tree Approximation via 3-Ray Folded Tripod)**: For every `L > 0`, `circleFoldTripodDist L` is a `0`-hyperbolic tree pseudometric satisfying `circleDist L x y - L / 3 ≤ circleFoldTripodDist L x y ≤ circleDist L x y`, and its pendant-shifted version achieves EXACT two-sided `L_∞` error `≤ L / 6`! Combined with `circle_hyperbolic_approx_lower_bound`, this proves the EXACT minimax tree-approximation distortion of `S^1_L` is `L / 6`! -/ theorem circle_fold_tripod_exact_upper {L : ℝ} (hL : 0 < L) : IsPseudoMetricFn (circleFoldTripodDist L) ∧ IsFourPointHyperbolic (circleFoldTripodDist L) 0 ∧ (∀ x y, circleDist L x y - L / 3 ≤ circleFoldTripodDist L x y ∧ circleFoldTripodDist L x y ≤ circleDist L x y) := by refine ⟨?_, ?_, ?_⟩ · exact { nonneg := fun x y => (tripodSpaceDist_isPseudoMetricFn _ _ _ (circleFoldTripodPos_nonneg hL x) (circleFoldTripodPos_nonneg hL y) (circleFoldTripodPos_nonneg hL y)).1 self := fun x => (tripodSpaceDist_isPseudoMetricFn _ _ _ (circleFoldTripodPos_nonneg hL x) (circleFoldTripodPos_nonneg hL x) (circleFoldTripodPos_nonneg hL x)).2.1 symm := fun x y => (tripodSpaceDist_isPseudoMetricFn _ _ _ (circleFoldTripodPos_nonneg hL x) (circleFoldTripodPos_nonneg hL y) (circleFoldTripodPos_nonneg hL y)).2.2.1 triangle := fun x y z => (tripodSpaceDist_isPseudoMetricFn _ _ _ (circleFoldTripodPos_nonneg hL x) (circleFoldTripodPos_nonneg hL y) (circleFoldTripodPos_nonneg hL z)).2.2.2 } · intro a b c e simp only [mul_zero, add_zero] exact tripodSpaceDist_zeroHyperbolic _ _ _ _ (circleFoldTripodPos_nonneg hL a) (circleFoldTripodPos_nonneg hL b) (circleFoldTripodPos_nonneg hL c) (circleFoldTripodPos_nonneg hL e) · intro x y rw [circleDist_eq_of_fract hL x y] set s := Int.fract (x / L) * L set t := Int.fract (y / L) * L have hs0 : 0 ≤ s := mul_nonneg (Int.fract_nonneg _) (le_of_lt hL) have hsL : s < L := by have := Int.fract_lt_one (x / L); nlinarith have ht0 : 0 ≤ t := mul_nonneg (Int.fract_nonneg _) (le_of_lt hL) have htL : t < L := by have := Int.fract_lt_one (y / L); nlinarith rw [circleDist_eq_min_abs hL hs0 hsL ht0 htL] change min |s - t| (L - |s - t|) - L / 3 ≤ tripodSpaceDist (circleFoldPos0 L s) (circleFoldPos0 L t) ∧ tripodSpaceDist (circleFoldPos0 L s) (circleFoldPos0 L t) ≤ min |s - t| (L - |s - t|) have hsym_aux : ∀ a b : ℝ, 0 ≤ a → a ≤ b → b < L → min (b - a) (L - (b - a)) - L / 3 ≤ tripodSpaceDist (circleFoldPos0 L a) (circleFoldPos0 L b) ∧ tripodSpaceDist (circleFoldPos0 L a) (circleFoldPos0 L b) ≤ min (b - a) (L - (b - a)) := by intro a b ha0 hab hbL rcases circleFoldPos0_cases (L := L) (u := a) with ⟨ha1, hpa⟩ | ⟨ha1, ha2, hpa⟩ | ⟨ha1, ha2, hpa⟩ | ⟨ha1, ha2, hpa⟩ | ⟨ha1, ha2, hpa⟩ | ⟨ha1, hpa⟩ <;> rw [hpa] · exact circleFold_sect1 ha0 ha1 hab hbL · exact circleFold_sect2 ha1 ha2 hab hbL · exact circleFold_sect3 ha1 ha2 hab hbL · exact circleFold_sect4 ha1 ha2 hab hbL · exact circleFold_sect5 ha1 ha2 hab hbL · exact circleFold_sect6 ha1 hab hbL rcases le_total s t with hst | hts · have heq : |s - t| = t - s := by rw [abs_of_nonpos (by linarith)]; ring rw [heq]; exact hsym_aux s t hs0 hst htL · have heq : |s - t| = s - t := abs_of_nonneg (by linarith) rw [heq] have hcomm : tripodSpaceDist (circleFoldPos0 L s) (circleFoldPos0 L t) = tripodSpaceDist (circleFoldPos0 L t) (circleFoldPos0 L s) := by unfold tripodSpaceDist; by_cases h : (circleFoldPos0 L s).1 = (circleFoldPos0 L t).1 · simp [h, abs_sub_comm] · simp [h, Ne.symm h, add_comm] rw [hcomm]; exact hsym_aux t s ht0 hts hsL /-- **THEOREM (Exact Minimax Two-Sided Tree Distortion of `S^1_L` = `L / 6`)**: Combines the 6-point hexagon lower bound with the pendant-shifted 3-ray folded tripod upper bound! -/ theorem circle_minimax_tree_distortion_exact {L : ℝ} (hL : 0 < L) : (∀ (d' : ℝ → ℝ → ℝ), IsPseudoMetricFn d' → IsFourPointHyperbolic d' 0 → ∀ ε, (∀ x y, |circleDist L x y - d' x y| ≤ ε) → L / 6 ≤ ε) ∧ (∃ (dT : ℝ → ℝ → ℝ), IsPseudoMetricFn dT ∧ IsFourPointHyperbolic dT 0 ∧ ∀ x y, |circleDist L x y - dT x y| ≤ L / 6) := by classical constructor · intro d' hd' h0 ε happrox have := circle_hyperbolic_approx_lower_bound hL hd' h0 happrox linarith · obtain ⟨hpm, h0, hbd⟩ := circle_fold_tripod_exact_upper hL refine ⟨shiftOffDiag (circleFoldTripodDist L) (L / 6), shiftOffDiag_isPseudoMetricFn hpm (by linarith), shiftOffDiag_zeroHyperbolic hpm h0 (by linarith), fun x y => ?_⟩ by_cases hxy : x = y · subst hxy have hself : circleDist L x x = 0 := by unfold circleDist; simp [min_eq_left (le_of_lt hL)] simp [shiftOffDiag, hself, le_of_lt (by linarith : 0 < L / 6)] · simp only [shiftOffDiag, hxy, ↓reduceIte] have ⟨hlo, hhi⟩ := hbd x y rw [abs_le]; constructor <;> linarith /-! ## Section 6: Exact Discrete Cycle C_n, 2D Grid P_m □ P_k, and 3D Grid P_{a+1}^3 -/ /-- Shortest-path metric on the discrete cycle graph `C_n` (`n ≥ 1`). -/ noncomputable def cycleDist (n : ℕ) (i j : Fin n) : ℝ := min (|(i.1 : ℝ) - (j.1 : ℝ)|) ((n : ℝ) - |(i.1 : ℝ) - (j.1 : ℝ)|) lemma cycleDist_eq_circleDist {n : ℕ} (hn : 1 ≤ n) (i j : Fin n) : cycleDist n i j = circleDist (n : ℝ) (i.1 : ℝ) (j.1 : ℝ) := by have hn' : (0 : ℝ) < (n : ℝ) := by exact_mod_cast hn have hi0 : (0 : ℝ) ≤ (i.1 : ℝ) := Nat.cast_nonneg _ have hiL : (i.1 : ℝ) < (n : ℝ) := by exact_mod_cast i.2 have hj0 : (0 : ℝ) ≤ (j.1 : ℝ) := Nat.cast_nonneg _ have hjL : (j.1 : ℝ) < (n : ℝ) := by exact_mod_cast j.2 exact (circleDist_eq_min_abs hn' hi0 hiL hj0 hjL).symm /-- **THEOREM (Exact Minimax Tree-Approximation Distortion of `C_{6m}` = `m`)**: For every `m ≥ 1`, every `0`-hyperbolic metric on `C_{6m}` incurs `L_∞` error `≥ m`, and the restricted shifted 3-ray folded tripod achieves `≤ m` identically! -/ theorem cycle6m_minimax_tree_distortion_exact {m : ℕ} (hm : 1 ≤ m) : (∀ (d' : Fin (6 * m) → Fin (6 * m) → ℝ), IsPseudoMetricFn d' → IsFourPointHyperbolic d' 0 → ∀ ε, (∀ i j, |cycleDist (6 * m) i j - d' i j| ≤ ε) → (m : ℝ) ≤ ε) ∧ (∃ (dT : Fin (6 * m) → Fin (6 * m) → ℝ), IsPseudoMetricFn dT ∧ IsFourPointHyperbolic dT 0 ∧ ∀ i j, |cycleDist (6 * m) i j - dT i j| ≤ (m : ℝ)) := by constructor · intro d' hd' h0 ε happrox let p : Fin 6 → Fin (6 * m) := fun k => ⟨k.1 * m, by have hk := k.2; nlinarith⟩ have hhex := hexagon_hyperbolic_ineq hd' h0 (p 0) (p 1) (p 2) (p 3) (p 4) (p 5) simp only [mul_zero, add_zero] at hhex have hcd : ∀ a b : Fin 6, cycleDist (6 * m) (p a) (p b) = min (|(a.1 : ℝ) - (b.1 : ℝ)| * (m : ℝ)) ((6 - |(a.1 : ℝ) - (b.1 : ℝ)|) * (m : ℝ)) := by intro a b unfold cycleDist; simp only [p, Nat.cast_mul, Nat.cast_ofNat] have hm0 : (0 : ℝ) ≤ (m : ℝ) := Nat.cast_nonneg m have habs : |(a.1 : ℝ) * (m : ℝ) - (b.1 : ℝ) * (m : ℝ)| = |(a.1 : ℝ) - (b.1 : ℝ)| * (m : ℝ) := by rw [← sub_mul, abs_mul, abs_of_nonneg hm0] rw [habs]; congr 1; ring have hm_pos : (0 : ℝ) < (m : ℝ) := by exact_mod_cast hm have h03 : cycleDist (6 * m) (p 0) (p 3) = 3 * (m : ℝ) := by rw [hcd 0 3]; norm_num have h14 : cycleDist (6 * m) (p 1) (p 4) = 3 * (m : ℝ) := by rw [hcd 1 4]; norm_num have h25 : cycleDist (6 * m) (p 2) (p 5) = 3 * (m : ℝ) := by rw [hcd 2 5]; norm_num have h01 : cycleDist (6 * m) (p 0) (p 1) = (m : ℝ) := by rw [hcd 0 1]; norm_num; linarith have h12 : cycleDist (6 * m) (p 1) (p 2) = (m : ℝ) := by rw [hcd 1 2]; norm_num; linarith have h23 : cycleDist (6 * m) (p 2) (p 3) = (m : ℝ) := by rw [hcd 2 3]; norm_num; linarith have h34 : cycleDist (6 * m) (p 3) (p 4) = (m : ℝ) := by rw [hcd 3 4]; norm_num; linarith have h45 : cycleDist (6 * m) (p 4) (p 5) = (m : ℝ) := by rw [hcd 4 5]; norm_num; linarith have h50 : cycleDist (6 * m) (p 5) (p 0) = (m : ℝ) := by rw [hcd 5 0]; norm_num; linarith have hlo : 3 * (m : ℝ) - ε ≤ min (d' (p 0) (p 3)) (min (d' (p 1) (p 4)) (d' (p 2) (p 5))) := by refine le_min ?_ (le_min ?_ ?_) · linarith [(abs_le.mp (happrox (p 0) (p 3))).2, h03] · linarith [(abs_le.mp (happrox (p 1) (p 4))).2, h14] · linarith [(abs_le.mp (happrox (p 2) (p 5))).2, h25] have hhi : max (max (d' (p 0) (p 1)) (d' (p 1) (p 2))) (max (max (d' (p 2) (p 3)) (d' (p 3) (p 4))) (max (d' (p 4) (p 5)) (d' (p 5) (p 0)))) ≤ (m : ℝ) + ε := by refine max_le (max_le ?_ ?_) (max_le (max_le ?_ ?_) (max_le ?_ ?_)) · linarith [(abs_le.mp (happrox (p 0) (p 1))).1, h01] · linarith [(abs_le.mp (happrox (p 1) (p 2))).1, h12] · linarith [(abs_le.mp (happrox (p 2) (p 3))).1, h23] · linarith [(abs_le.mp (happrox (p 3) (p 4))).1, h34] · linarith [(abs_le.mp (happrox (p 4) (p 5))).1, h45] · linarith [(abs_le.mp (happrox (p 5) (p 0))).1, h50] linarith · have hL : (0 : ℝ) < ((6 * m : ℕ) : ℝ) := by exact_mod_cast (by omega : 0 < 6 * m) obtain ⟨dT_R, hpm, h0, hbd⟩ := (circle_minimax_tree_distortion_exact hL).2 refine ⟨fun i j => dT_R (i.1 : ℝ) (j.1 : ℝ), ⟨fun i j => hpm.nonneg _ _, fun i => hpm.self _, fun i j => hpm.symm _ _, fun i j k => hpm.triangle _ _ _⟩, fun a b c e => h0 _ _ _ _, fun i j => ?_⟩ rw [cycleDist_eq_circleDist (by omega : 1 ≤ 6 * m)] have := hbd (i.1 : ℝ) (j.1 : ℝ) have hmul : ((6 * m : ℕ) : ℝ) / 6 = (m : ℝ) := by push_cast; ring rw [hmul] at this exact this /-- Exact mod-4 hyperbolicity value of the discrete cycle `C_n` (`n ≥ 3`). -/ noncomputable def cycleDelta4Val (n : ℕ) : ℝ := if n % 4 = 1 then ((n / 4 : ℕ) : ℝ) - 1 / 2 else ((n / 4 : ℕ) : ℝ) /-- **Exact Integer Arc Bound for Discrete Cycles `C_n`**: For 4 nonneg integers `x₁ + x₂ + x₃ + x₄ = n`, the gap `s₂ - max(s₁, s₃)` is at most `2 * cycleDelta4Val n` (which tightens `n / 2` to `2q - 1` when `n = 4q + 1`, and `2q` otherwise!). -/ lemma cycle_int_arc_gap {n : ℕ} (hn : 3 ≤ n) (x₁ x₂ x₃ x₄ : ℕ) (hsum : x₁ + x₂ + x₃ + x₄ = n) : let s1 : ℝ := min (x₁ : ℝ) (x₂ + x₃ + x₄) + min (x₃ : ℝ) (x₁ + x₂ + x₄) let s2 : ℝ := min ((x₁ : ℝ) + x₂) (x₃ + x₄) + min ((x₂ : ℝ) + x₃) (x₄ + x₁) let s3 : ℝ := min ((x₁ : ℝ) + x₂ + x₃) x₄ + min (x₂ : ℝ) (x₁ + x₃ + x₄) s2 ≤ max s1 s3 + 2 * cycleDelta4Val n := by intro s1 s2 s3 have hq_def : n = 4 * (n / 4) + n % 4 := (Nat.div_add_mod n 4).symm have hmod : n % 4 < 4 := Nat.mod_lt n (by decide) have hpig : x₁ ≤ n / 4 ∨ x₂ ≤ n / 4 ∨ x₃ ≤ n / 4 ∨ x₄ ≤ n / 4 := by omega have hle_two : s2 ≤ max s1 s3 + 2 * (x₁ : ℝ) ∧ s2 ≤ max s1 s3 + 2 * (x₂ : ℝ) ∧ s2 ≤ max s1 s3 + 2 * (x₃ : ℝ) ∧ s2 ≤ max s1 s3 + 2 * (x₄ : ℝ) := by -- 5-line universal inequality: for ANY `a, b, c, d ≥ 0`, -- `min (a + b) (c + d) + min (b + c) (d + a) ≤ min (a + b + c) d + min b (a + c + d) + 2 * a`! have harc : ∀ a b c d : ℝ, 0 ≤ a → 0 ≤ b → 0 ≤ c → 0 ≤ d → min (a + b) (c + d) + min (b + c) (d + a) ≤ min (a + b + c) d + min b (a + c + d) + 2 * a := by intro a b c d ha hb hc hd rcases le_total b (a + c + d) with hB | hB · rcases le_total d (a + b + c) with hD | hD · rw [min_eq_right hD, min_eq_left hB] linarith [min_le_left (a + b) (c + d), min_le_right (b + c) (d + a)] · rw [min_eq_left hD, min_eq_left hB] linarith [min_le_left (a + b) (c + d), min_le_left (b + c) (d + a)] · have hD : d ≤ a + b + c := by linarith rw [min_eq_right hD, min_eq_right hB] linarith [min_le_right (a + b) (c + d), min_le_right (b + c) (d + a)] have hx1 : (0 : ℝ) ≤ x₁ := Nat.cast_nonneg _ have hx2 : (0 : ℝ) ≤ x₂ := Nat.cast_nonneg _ have hx3 : (0 : ℝ) ≤ x₃ := Nat.cast_nonneg _ have hx4 : (0 : ℝ) ≤ x₄ := Nat.cast_nonneg _ have h1 : s2 ≤ s3 + 2 * (x₁ : ℝ) := harc x₁ x₂ x₃ x₄ hx1 hx2 hx3 hx4 have h2 : s2 ≤ s1 + 2 * (x₂ : ℝ) := by have h := harc x₂ x₃ x₄ x₁ hx2 hx3 hx4 hx1 have hs2 : min ((x₂ : ℝ) + x₃) (x₄ + x₁) + min ((x₃ : ℝ) + x₄) (x₁ + x₂) = s2 := by dsimp only [s2]; rw [add_comm, min_comm ((x₃ : ℝ) + x₄) (x₁ + x₂)] have hs1 : min ((x₂ : ℝ) + x₃ + x₄) x₁ + min (x₃ : ℝ) (x₂ + x₄ + x₁) = s1 := by dsimp only [s1]; rw [min_comm ((x₂ : ℝ) + x₃ + x₄) x₁] congr 2; ring linarith have h3 : s2 ≤ s3 + 2 * (x₃ : ℝ) := by have h := harc x₃ x₄ x₁ x₂ hx3 hx4 hx1 hx2 have hs2 : min ((x₃ : ℝ) + x₄) (x₁ + x₂) + min ((x₄ : ℝ) + x₁) (x₂ + x₃) = s2 := by dsimp only [s2]; rw [min_comm ((x₃ : ℝ) + x₄) (x₁ + x₂), min_comm ((x₄ : ℝ) + x₁) (x₂ + x₃)] have hs3 : min ((x₃ : ℝ) + x₄ + x₁) x₂ + min (x₄ : ℝ) (x₃ + x₁ + x₂) = s3 := by dsimp only [s3]; rw [add_comm, min_comm ((x₃ : ℝ) + x₄ + x₁) x₂, min_comm (x₄ : ℝ)] congr 1 <;> congr 1 <;> ring linarith have h4 : s2 ≤ s1 + 2 * (x₄ : ℝ) := by have h := harc x₄ x₁ x₂ x₃ hx4 hx1 hx2 hx3 have hs2 : min ((x₄ : ℝ) + x₁) (x₂ + x₃) + min ((x₁ : ℝ) + x₂) (x₃ + x₄) = s2 := by dsimp only [s2]; rw [add_comm, min_comm ((x₄ : ℝ) + x₁) (x₂ + x₃)] have hs1 : min ((x₄ : ℝ) + x₁ + x₂) x₃ + min (x₁ : ℝ) (x₄ + x₂ + x₃) = s1 := by dsimp only [s1]; rw [add_comm, min_comm ((x₄ : ℝ) + x₁ + x₂) x₃] congr 1 <;> congr 1 <;> ring linarith exact ⟨by linarith [le_max_right s1 s3], by linarith [le_max_left s1 s3], by linarith [le_max_right s1 s3], by linarith [le_max_left s1 s3]⟩ unfold cycleDelta4Val split_ifs with hm1 · set q := n / 4 by_cases hall : q ≤ x₁ ∧ q ≤ x₂ ∧ q ≤ x₃ ∧ q ≤ x₄ · have ⟨h1, h2, h3, h4⟩ := hall have hcases : (x₁ = q + 1 ∧ x₂ = q ∧ x₃ = q ∧ x₄ = q) ∨ (x₁ = q ∧ x₂ = q + 1 ∧ x₃ = q ∧ x₄ = q) ∨ (x₁ = q ∧ x₂ = q ∧ x₃ = q + 1 ∧ x₄ = q) ∨ (x₁ = q ∧ x₂ = q ∧ x₃ = q ∧ x₄ = q + 1) := by omega have hq0 : (0 : ℝ) ≤ (q : ℝ) := Nat.cast_nonneg q have hq1_nat : 1 ≤ q := by omega have hq1 : (1 : ℝ) ≤ (q : ℝ) := by exact_mod_cast hq1_nat rcases hcases with ⟨rfl, rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl, rfl⟩ · have hle : s2 ≤ s1 + 2 * ((q : ℝ) - 1 / 2) := by simp only [s1, s2, Nat.cast_add, Nat.cast_one] rw [min_eq_right (by linarith : (q : ℝ) + q ≤ q + 1 + q), min_eq_left (by linarith : (q : ℝ) + q ≤ q + (q + 1)), min_eq_left (by linarith : (q : ℝ) + 1 ≤ q + q + q), min_eq_left (by linarith : (q : ℝ) ≤ q + 1 + q + q)] linarith linarith [le_max_left s1 s3] · have hle : s2 ≤ s3 + 2 * ((q : ℝ) - 1 / 2) := by simp only [s3, s2, Nat.cast_add, Nat.cast_one] rw [min_eq_right (by linarith : (q : ℝ) + q ≤ q + (q + 1)), min_eq_right (by linarith : (q : ℝ) + q ≤ q + 1 + q), min_eq_right (by linarith : (q : ℝ) ≤ q + (q + 1) + q), min_eq_left (by linarith : (q : ℝ) + 1 ≤ q + q + q)] linarith linarith [le_max_right s1 s3] · have hle : s2 ≤ s1 + 2 * ((q : ℝ) - 1 / 2) := by simp only [s1, s2, Nat.cast_add, Nat.cast_one] rw [min_eq_left (by linarith : (q : ℝ) + q ≤ q + 1 + q), min_eq_right (by linarith : (q : ℝ) + q ≤ q + (q + 1)), min_eq_left (by linarith : (q : ℝ) ≤ q + (q + 1) + q), min_eq_left (by linarith : (q : ℝ) + 1 ≤ q + q + q)] linarith linarith [le_max_left s1 s3] · have hle : s2 ≤ s3 + 2 * ((q : ℝ) - 1 / 2) := by simp only [s3, s2, Nat.cast_add, Nat.cast_one] rw [min_eq_left (by linarith : (q : ℝ) + q ≤ q + (q + 1)), min_eq_left (by linarith : (q : ℝ) + q ≤ q + 1 + q), min_eq_right (by linarith : (q : ℝ) + 1 ≤ q + q + q), min_eq_left (by linarith : (q : ℝ) ≤ q + q + (q + 1))] linarith linarith [le_max_right s1 s3] · have hlt : x₁ + 1 ≤ q ∨ x₂ + 1 ≤ q ∨ x₃ + 1 ≤ q ∨ x₄ + 1 ≤ q := by omega rcases hlt with h | h | h | h · have : (x₁ : ℝ) + 1 ≤ (q : ℝ) := by exact_mod_cast h linarith [hle_two.1] · have : (x₂ : ℝ) + 1 ≤ (q : ℝ) := by exact_mod_cast h linarith [hle_two.2.1] · have : (x₃ : ℝ) + 1 ≤ (q : ℝ) := by exact_mod_cast h linarith [hle_two.2.2.1] · have : (x₄ : ℝ) + 1 ≤ (q : ℝ) := by exact_mod_cast h linarith [hle_two.2.2.2] · rcases hpig with h | h | h | h · have : (x₁ : ℝ) ≤ ((n / 4 : ℕ) : ℝ) := by exact_mod_cast h linarith [hle_two.1] · have : (x₂ : ℝ) ≤ ((n / 4 : ℕ) : ℝ) := by exact_mod_cast h linarith [hle_two.2.1] · have : (x₃ : ℝ) ≤ ((n / 4 : ℕ) : ℝ) := by exact_mod_cast h linarith [hle_two.2.2.1] · have : (x₄ : ℝ) ≤ ((n / 4 : ℕ) : ℝ) := by exact_mod_cast h linarith [hle_two.2.2.2] /-- **THEOREM (Exact Mod-4 Gromov Hyperbolicity of ALL Discrete Cycles `C_n`, `n ≥ 3`)**: For every `n ≥ 3`, `cycleDist n` is `cycleDelta4Val n`-hyperbolic, AND NO smaller constant works! -/ theorem cycle_delta4_exact {n : ℕ} (hn : 3 ≤ n) : IsFourPointHyperbolic (cycleDist n) (cycleDelta4Val n) ∧ ∀ δ, IsFourPointHyperbolic (cycleDist n) δ → cycleDelta4Val n ≤ δ := by constructor · -- Upper bound: sort the 4 indices and apply `cycle_int_arc_gap` + `s1, s3 ≤ max` intro i j k l have hsorted : ∀ (a b c d : Fin n), a.1 ≤ b.1 → b.1 ≤ c.1 → c.1 ≤ d.1 → cycleDist n a b + cycleDist n c d ≤ max (cycleDist n a c + cycleDist n b d) (cycleDist n a d + cycleDist n b c) + 2 * cycleDelta4Val n ∧ cycleDist n a c + cycleDist n b d ≤ max (cycleDist n a b + cycleDist n c d) (cycleDist n a d + cycleDist n b c) + 2 * cycleDelta4Val n ∧ cycleDist n a d + cycleDist n b c ≤ max (cycleDist n a b + cycleDist n c d) (cycleDist n a c + cycleDist n b d) + 2 * cycleDelta4Val n := by intro a b c d hab hbc hcd set x₁ := b.1 - a.1 set x₂ := c.1 - b.1 set x₃ := d.1 - c.1 set x₄ := n - (d.1 - a.1) have hsum : x₁ + x₂ + x₃ + x₄ = n := by have hd : d.1 < n := d.2; omega have hcd_eq : ∀ u v : Fin n, u.1 ≤ v.1 → cycleDist n u v = min ((v.1 - u.1 : ℕ) : ℝ) ((n : ℝ) - ((v.1 - u.1 : ℕ) : ℝ)) := by intro u v huv unfold cycleDist have hsub : |(u.1 : ℝ) - (v.1 : ℝ)| = ((v.1 - u.1 : ℕ) : ℝ) := by rw [Nat.cast_sub huv, abs_of_nonpos (by have : (u.1 : ℝ) ≤ (v.1 : ℝ) := Nat.cast_le.mpr huv; linarith)] ring rw [hsub] have hsumR : (x₁ : ℝ) + x₂ + x₃ + x₄ = (n : ℝ) := by exact_mod_cast hsum have hx1 : (0 : ℝ) ≤ x₁ := Nat.cast_nonneg _ have hx2 : (0 : ℝ) ≤ x₂ := Nat.cast_nonneg _ have hx3 : (0 : ℝ) ≤ x₃ := Nat.cast_nonneg _ have hx4 : (0 : ℝ) ≤ x₄ := Nat.cast_nonneg _ have hval : 0 ≤ cycleDelta4Val n := by unfold cycleDelta4Val; split_ifs with hm · have : 1 ≤ n / 4 := by omega have : (1 : ℝ) ≤ ((n / 4 : ℕ) : ℝ) := by exact_mod_cast this linarith · exact Nat.cast_nonneg _ have e1 : cycleDist n a b + cycleDist n c d = min (x₁ : ℝ) (x₂ + x₃ + x₄) + min (x₃ : ℝ) (x₁ + x₂ + x₄) := by rw [hcd_eq a b hab, hcd_eq c d hcd]; congr 1 <;> congr 1 <;> linarith have e2 : cycleDist n a c + cycleDist n b d = min ((x₁ : ℝ) + x₂) (x₃ + x₄) + min ((x₂ : ℝ) + x₃) (x₄ + x₁) := by rw [hcd_eq a c (hab.trans hbc), hcd_eq b d (hbc.trans hcd)] have h1 : ((c.1 - a.1 : ℕ) : ℝ) = (x₁ : ℝ) + x₂ := by have : c.1 - a.1 = x₁ + x₂ := by omega exact_mod_cast this have h2 : ((d.1 - b.1 : ℕ) : ℝ) = (x₂ : ℝ) + x₃ := by have : d.1 - b.1 = x₂ + x₃ := by omega exact_mod_cast this rw [h1, h2]; congr 1 <;> congr 1 <;> linarith have e3 : cycleDist n a d + cycleDist n b c = min ((x₁ : ℝ) + x₂ + x₃) x₄ + min (x₂ : ℝ) (x₁ + x₃ + x₄) := by rw [hcd_eq a d ((hab.trans hbc).trans hcd), hcd_eq b c hbc] have h1 : ((d.1 - a.1 : ℕ) : ℝ) = (x₁ : ℝ) + x₂ + x₃ := by have : d.1 - a.1 = x₁ + x₂ + x₃ := by omega exact_mod_cast this rw [h1]; congr 1 <;> congr 1 <;> linarith rw [e1, e2, e3] refine ⟨?_, cycle_int_arc_gap hn x₁ x₂ x₃ x₄ hsum, ?_⟩ · have hle : min (x₁ : ℝ) (x₂ + x₃ + x₄) + min (x₃ : ℝ) (x₁ + x₂ + x₄) ≤ min ((x₁ : ℝ) + x₂) (x₃ + x₄) + min ((x₂ : ℝ) + x₃) (x₄ + x₁) := by rcases le_total ((x₁ : ℝ) + x₂) (x₃ + x₄) with hC | hC <;> rcases le_total ((x₂ : ℝ) + x₃) (x₄ + x₁) with hD | hD · rw [min_eq_left hC, min_eq_left hD] linarith [min_le_left (x₁ : ℝ) (x₂ + x₃ + x₄), min_le_left (x₃ : ℝ) (x₁ + x₂ + x₄)] · rw [min_eq_left hC, min_eq_right hD] linarith [min_le_left (x₁ : ℝ) (x₂ + x₃ + x₄), min_le_right (x₃ : ℝ) (x₁ + x₂ + x₄)] · rw [min_eq_right hC, min_eq_left hD] linarith [min_le_right (x₁ : ℝ) (x₂ + x₃ + x₄), min_le_left (x₃ : ℝ) (x₁ + x₂ + x₄)] · rw [min_eq_right hC, min_eq_right hD] linarith [min_le_left (x₁ : ℝ) (x₂ + x₃ + x₄), min_le_left (x₃ : ℝ) (x₁ + x₂ + x₄)] linarith [le_max_left (min ((x₁ : ℝ) + x₂) (x₃ + x₄) + min ((x₂ : ℝ) + x₃) (x₄ + x₁)) (min ((x₁ : ℝ) + x₂ + x₃) x₄ + min (x₂ : ℝ) (x₁ + x₃ + x₄))] · have hle : min ((x₁ : ℝ) + x₂ + x₃) x₄ + min (x₂ : ℝ) (x₁ + x₃ + x₄) ≤ min ((x₁ : ℝ) + x₂) (x₃ + x₄) + min ((x₂ : ℝ) + x₃) (x₄ + x₁) := by rcases le_total ((x₁ : ℝ) + x₂) (x₃ + x₄) with hC | hC <;> rcases le_total ((x₂ : ℝ) + x₃) (x₄ + x₁) with hD | hD · rw [min_eq_left hC, min_eq_left hD] linarith [min_le_left ((x₁ : ℝ) + x₂ + x₃) x₄, min_le_left (x₂ : ℝ) (x₁ + x₃ + x₄)] · rw [min_eq_left hC, min_eq_right hD] linarith [min_le_right ((x₁ : ℝ) + x₂ + x₃) x₄, min_le_left (x₂ : ℝ) (x₁ + x₃ + x₄)] · rw [min_eq_right hC, min_eq_left hD] linarith [min_le_right ((x₁ : ℝ) + x₂ + x₃) x₄, min_le_left (x₂ : ℝ) (x₁ + x₃ + x₄)] · rw [min_eq_right hC, min_eq_right hD] linarith [min_le_right ((x₁ : ℝ) + x₂ + x₃) x₄, min_le_right (x₂ : ℝ) (x₁ + x₃ + x₄)] linarith [le_max_right (min (x₁ : ℝ) (x₂ + x₃ + x₄) + min (x₃ : ℝ) (x₁ + x₂ + x₄)) (min ((x₁ : ℝ) + x₂) (x₃ + x₄) + min ((x₂ : ℝ) + x₃) (x₄ + x₁))] have hsym : ∀ u v, cycleDist n u v = cycleDist n v u := fun u v => by simp [cycleDist, abs_sub_comm] have hQuad : ∀ a b c d : Fin n, cycleDist n a b + cycleDist n c d ≤ max (cycleDist n a c + cycleDist n b d) (cycleDist n a d + cycleDist n b c) + 2 * cycleDelta4Val n ∧ cycleDist n a c + cycleDist n b d ≤ max (cycleDist n a b + cycleDist n c d) (cycleDist n a d + cycleDist n b c) + 2 * cycleDelta4Val n ∧ cycleDist n a d + cycleDist n b c ≤ max (cycleDist n a b + cycleDist n c d) (cycleDist n a c + cycleDist n b d) + 2 * cycleDelta4Val n := by have hswap12 : ∀ a b c d : Fin n, (cycleDist n b a + cycleDist n c d ≤ max (cycleDist n b c + cycleDist n a d) (cycleDist n b d + cycleDist n a c) + 2 * cycleDelta4Val n ∧ cycleDist n b c + cycleDist n a d ≤ max (cycleDist n b a + cycleDist n c d) (cycleDist n b d + cycleDist n a c) + 2 * cycleDelta4Val n ∧ cycleDist n b d + cycleDist n a c ≤ max (cycleDist n b a + cycleDist n c d) (cycleDist n b c + cycleDist n a d) + 2 * cycleDelta4Val n) → (cycleDist n a b + cycleDist n c d ≤ max (cycleDist n a c + cycleDist n b d) (cycleDist n a d + cycleDist n b c) + 2 * cycleDelta4Val n ∧ cycleDist n a c + cycleDist n b d ≤ max (cycleDist n a b + cycleDist n c d) (cycleDist n a d + cycleDist n b c) + 2 * cycleDelta4Val n ∧ cycleDist n a d + cycleDist n b c ≤ max (cycleDist n a b + cycleDist n c d) (cycleDist n a c + cycleDist n b d) + 2 * cycleDelta4Val n) := by intro a b c d ⟨h1, h2, h3⟩ rw [hsym b a] at h1 h2 h3 rw [add_comm (cycleDist n b c) (cycleDist n a d), add_comm (cycleDist n b d) (cycleDist n a c)] at h1 h2 h3 refine ⟨?_, ?_, ?_⟩ · rwa [max_comm] at h1 · exact h3 · exact h2 have hswap23 : ∀ a b c d : Fin n, (cycleDist n a c + cycleDist n b d ≤ max (cycleDist n a b + cycleDist n c d) (cycleDist n a d + cycleDist n c b) + 2 * cycleDelta4Val n ∧ cycleDist n a b + cycleDist n c d ≤ max (cycleDist n a c + cycleDist n b d) (cycleDist n a d + cycleDist n c b) + 2 * cycleDelta4Val n ∧ cycleDist n a d + cycleDist n c b ≤ max (cycleDist n a c + cycleDist n b d) (cycleDist n a b + cycleDist n c d) + 2 * cycleDelta4Val n) → (cycleDist n a b + cycleDist n c d ≤ max (cycleDist n a c + cycleDist n b d) (cycleDist n a d + cycleDist n b c) + 2 * cycleDelta4Val n ∧ cycleDist n a c + cycleDist n b d ≤ max (cycleDist n a b + cycleDist n c d) (cycleDist n a d + cycleDist n b c) + 2 * cycleDelta4Val n ∧ cycleDist n a d + cycleDist n b c ≤ max (cycleDist n a b + cycleDist n c d) (cycleDist n a c + cycleDist n b d) + 2 * cycleDelta4Val n) := by intro a b c d ⟨h1, h2, h3⟩ rw [hsym c b] at h1 h2 h3 exact ⟨h2, h1, by simpa [max_comm] using h3⟩ have hswap34 : ∀ a b c d : Fin n, (cycleDist n a b + cycleDist n d c ≤ max (cycleDist n a d + cycleDist n b c) (cycleDist n a c + cycleDist n b d) + 2 * cycleDelta4Val n ∧ cycleDist n a d + cycleDist n b c ≤ max (cycleDist n a b + cycleDist n d c) (cycleDist n a c + cycleDist n b d) + 2 * cycleDelta4Val n ∧ cycleDist n a c + cycleDist n b d ≤ max (cycleDist n a b + cycleDist n d c) (cycleDist n a d + cycleDist n b c) + 2 * cycleDelta4Val n) → (cycleDist n a b + cycleDist n c d ≤ max (cycleDist n a c + cycleDist n b d) (cycleDist n a d + cycleDist n b c) + 2 * cycleDelta4Val n ∧ cycleDist n a c + cycleDist n b d ≤ max (cycleDist n a b + cycleDist n c d) (cycleDist n a d + cycleDist n b c) + 2 * cycleDelta4Val n ∧ cycleDist n a d + cycleDist n b c ≤ max (cycleDist n a b + cycleDist n c d) (cycleDist n a c + cycleDist n b d) + 2 * cycleDelta4Val n) := by intro a b c d ⟨h1, h2, h3⟩ rw [hsym d c] at h1 h2 h3 exact ⟨by simpa [max_comm] using h1, h3, h2⟩ -- Bubble-sort 4 elements `(a, b, c, d)` into sorted order: have hsort3 : ∀ a b c d : Fin n, a.1 ≤ b.1 → b.1 ≤ c.1 → cycleDist n a b + cycleDist n c d ≤ max (cycleDist n a c + cycleDist n b d) (cycleDist n a d + cycleDist n b c) + 2 * cycleDelta4Val n ∧ cycleDist n a c + cycleDist n b d ≤ max (cycleDist n a b + cycleDist n c d) (cycleDist n a d + cycleDist n b c) + 2 * cycleDelta4Val n ∧ cycleDist n a d + cycleDist n b c ≤ max (cycleDist n a b + cycleDist n c d) (cycleDist n a c + cycleDist n b d) + 2 * cycleDelta4Val n := by intro a b c d hab hbc rcases le_total c.1 d.1 with hcd | hdc · exact hsorted a b c d hab hbc hcd · apply hswap34 rcases le_total b.1 d.1 with hbd | hdb · exact hsorted a b d c hab hbd hdc · apply hswap23 rcases le_total a.1 d.1 with had | hda · exact hsorted a d b c had hdb hbc · apply hswap12 exact hsorted d a b c hda hab hbc intro a b c d rcases le_total a.1 b.1 with hab | hba · rcases le_total b.1 c.1 with hbc | hcb · exact hsort3 a b c d hab hbc · apply hswap23 rcases le_total a.1 c.1 with hac | hca · exact hsort3 a c b d hac hcb · apply hswap12; exact hsort3 c a b d hca hab · apply hswap12 rcases le_total a.1 c.1 with hac | hca · exact hsort3 b a c d hba hac · apply hswap23 rcases le_total b.1 c.1 with hbc | hcb · exact hsort3 b c a d hbc hca · apply hswap12; exact hsort3 c b a d hcb hba exact (hQuad i j k l).1 · -- Lower bound: explicit 4-point witness for each residue `n mod 4`! intro δ hδ set q := n / 4 have hq_eq : n = 4 * q + n % 4 := (Nat.div_add_mod n 4).symm have hmod : n % 4 < 4 := Nat.mod_lt n (by decide) -- When `n = 3`, `cycleDelta4Val 3 = 0`; evaluate at `(0, 0, 0, 0)`! by_cases hq0 : q = 0 · have hn3 : n = 3 := by omega subst hn3 unfold cycleDelta4Val norm_num have h4 := hδ ⟨0, by decide⟩ ⟨0, by decide⟩ ⟨0, by decide⟩ ⟨0, by decide⟩ simp [cycleDist] at h4 linarith · have hq1 : 1 ≤ q := Nat.pos_of_ne_zero hq0 have hqR : (1 : ℝ) ≤ (q : ℝ) := by exact_mod_cast hq1 -- Witness `(p0, p1, p2, p3)` with arcs: -- n = 4q : (0, q, 2q, 3q) -> arcs (q, q, q, q), gap = 2q -- n = 4q + 1 : (0, q, 2q, 3q) -> arcs (q, q, q, q+1), gap = 2q - 1 -- n = 4q + 2 : (0, q, 2q+1, 3q+1) -> arcs (q, q+1, q, q+1), gap = 2q -- n = 4q + 3 : (0, q, 2q+1, 3q+2) -> arcs (q, q+1, q+1, q+1), gap = 2q unfold cycleDelta4Val have hcd_nat : ∀ a b : Fin n, a.1 ≤ b.1 → cycleDist n a b = min ((b.1 - a.1 : ℕ) : ℝ) ((n : ℝ) - ((b.1 - a.1 : ℕ) : ℝ)) := by intro a b hab unfold cycleDist have : |(a.1 : ℝ) - (b.1 : ℝ)| = ((b.1 - a.1 : ℕ) : ℝ) := by rw [Nat.cast_sub hab, abs_of_nonpos (by have : (a.1 : ℝ) ≤ (b.1 : ℝ) := Nat.cast_le.mpr hab; linarith)] ring rw [this] have hrem : n % 4 = 0 ∨ n % 4 = 1 ∨ n % 4 = 2 ∨ n % 4 = 3 := by omega rcases hrem with hr | hr | hr | hr · -- `n = 4q` have hn4 : n = 4 * q := by omega have h4 := hδ ⟨0, by omega⟩ ⟨2 * q, by omega⟩ ⟨q, by omega⟩ ⟨3 * q, by omega⟩ simp only [hr, show (0 : ℕ) ≠ 1 by decide, ↓reduceIte] rw [hcd_nat ⟨0, by omega⟩ ⟨2 * q, by omega⟩ (by dsimp; omega), hcd_nat ⟨q, by omega⟩ ⟨3 * q, by omega⟩ (by dsimp; omega), hcd_nat ⟨0, by omega⟩ ⟨q, by omega⟩ (by dsimp; omega), hcd_nat ⟨2 * q, by omega⟩ ⟨3 * q, by omega⟩ (by dsimp; omega), hcd_nat ⟨0, by omega⟩ ⟨3 * q, by omega⟩ (by dsimp; omega), show cycleDist n ⟨2 * q, by omega⟩ ⟨q, by omega⟩ = cycleDist n ⟨q, by omega⟩ ⟨2 * q, by omega⟩ by simp [cycleDist, abs_sub_comm], hcd_nat ⟨q, by omega⟩ ⟨2 * q, by omega⟩ (by dsimp; omega)] at h4 have hnR : (n : ℝ) = 4 * (q : ℝ) := by exact_mod_cast hn4 simp only [Nat.sub_zero, show 3 * q - q = 2 * q by omega, show 3 * q - 2 * q = q by omega, show 2 * q - q = q by omega, Nat.cast_mul, Nat.cast_ofNat, hnR] at h4 rw [min_eq_left (by linarith), min_eq_left (by linarith), min_eq_right (by linarith : 4 * (q : ℝ) - 3 * q ≤ 3 * q)] at h4 rcases le_max_iff.mp (by linarith : 4 * (q : ℝ) - 2 * δ ≤ max ((q : ℝ) + q) ((4 * q - 3 * q) + q)) with h | h <;> linarith · -- `n = 4q + 1` have hn4 : n = 4 * q + 1 := by omega have h4 := hδ ⟨0, by omega⟩ ⟨2 * q, by omega⟩ ⟨q, by omega⟩ ⟨3 * q, by omega⟩ simp only [hr, ↓reduceIte] rw [hcd_nat ⟨0, by omega⟩ ⟨2 * q, by omega⟩ (by dsimp; omega), hcd_nat ⟨q, by omega⟩ ⟨3 * q, by omega⟩ (by dsimp; omega), hcd_nat ⟨0, by omega⟩ ⟨q, by omega⟩ (by dsimp; omega), hcd_nat ⟨2 * q, by omega⟩ ⟨3 * q, by omega⟩ (by dsimp; omega), hcd_nat ⟨0, by omega⟩ ⟨3 * q, by omega⟩ (by dsimp; omega), show cycleDist n ⟨2 * q, by omega⟩ ⟨q, by omega⟩ = cycleDist n ⟨q, by omega⟩ ⟨2 * q, by omega⟩ by simp [cycleDist, abs_sub_comm], hcd_nat ⟨q, by omega⟩ ⟨2 * q, by omega⟩ (by dsimp; omega)] at h4 have hnR : (n : ℝ) = 4 * (q : ℝ) + 1 := by exact_mod_cast hn4 simp only [Nat.sub_zero, show 3 * q - q = 2 * q by omega, show 3 * q - 2 * q = q by omega, show 2 * q - q = q by omega, Nat.cast_mul, Nat.cast_ofNat, hnR] at h4 rw [min_eq_left (by linarith : 2 * (q : ℝ) ≤ 4 * q + 1 - 2 * q), min_eq_left (by linarith : (q : ℝ) ≤ 4 * q + 1 - q), min_eq_right (by linarith : 4 * (q : ℝ) + 1 - 3 * q ≤ 3 * q)] at h4 rw [max_eq_right (by linarith)] at h4 linarith · -- `n = 4q + 2`: witness `(0, 2q + 1, q, 3q + 1)` have hn4 : n = 4 * q + 2 := by omega have h4 := hδ ⟨0, by omega⟩ ⟨2 * q + 1, by omega⟩ ⟨q, by omega⟩ ⟨3 * q + 1, by omega⟩ simp only [hr, show (2 : ℕ) ≠ 1 by decide, ↓reduceIte] rw [hcd_nat ⟨0, by omega⟩ ⟨2 * q + 1, by omega⟩ (by dsimp; omega), hcd_nat ⟨q, by omega⟩ ⟨3 * q + 1, by omega⟩ (by dsimp; omega), hcd_nat ⟨0, by omega⟩ ⟨q, by omega⟩ (by dsimp; omega), hcd_nat ⟨2 * q + 1, by omega⟩ ⟨3 * q + 1, by omega⟩ (by dsimp; omega), hcd_nat ⟨0, by omega⟩ ⟨3 * q + 1, by omega⟩ (by dsimp; omega), show cycleDist n ⟨2 * q + 1, by omega⟩ ⟨q, by omega⟩ = cycleDist n ⟨q, by omega⟩ ⟨2 * q + 1, by omega⟩ by simp [cycleDist, abs_sub_comm], hcd_nat ⟨q, by omega⟩ ⟨2 * q + 1, by omega⟩ (by dsimp; omega)] at h4 have hnR : (n : ℝ) = 4 * (q : ℝ) + 2 := by exact_mod_cast hn4 simp only [Nat.sub_zero, show 3 * q + 1 - q = 2 * q + 1 by omega, show 3 * q + 1 - (2 * q + 1) = q by omega, show 2 * q + 1 - q = q + 1 by omega, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one, hnR] at h4 rw [min_eq_left (by linarith : 2 * (q : ℝ) + 1 ≤ 4 * q + 2 - (2 * q + 1)), min_eq_left (by linarith : (q : ℝ) ≤ 4 * q + 2 - q), min_eq_right (by linarith : 4 * (q : ℝ) + 2 - (3 * q + 1) ≤ 3 * q + 1), min_eq_left (by linarith : (q : ℝ) + 1 ≤ 4 * q + 2 - (q + 1))] at h4 rw [max_eq_right (by linarith)] at h4 linarith · -- `n = 4q + 3`: witness `(0, 2q + 1, q, 3q + 2)` have hn4 : n = 4 * q + 3 := by omega have h4 := hδ ⟨0, by omega⟩ ⟨2 * q + 1, by omega⟩ ⟨q, by omega⟩ ⟨3 * q + 2, by omega⟩ simp only [hr, show (3 : ℕ) ≠ 1 by decide, ↓reduceIte] rw [hcd_nat ⟨0, by omega⟩ ⟨2 * q + 1, by omega⟩ (by dsimp; omega), hcd_nat ⟨q, by omega⟩ ⟨3 * q + 2, by omega⟩ (by dsimp; omega), hcd_nat ⟨0, by omega⟩ ⟨q, by omega⟩ (by dsimp; omega), hcd_nat ⟨2 * q + 1, by omega⟩ ⟨3 * q + 2, by omega⟩ (by dsimp; omega), hcd_nat ⟨0, by omega⟩ ⟨3 * q + 2, by omega⟩ (by dsimp; omega), show cycleDist n ⟨2 * q + 1, by omega⟩ ⟨q, by omega⟩ = cycleDist n ⟨q, by omega⟩ ⟨2 * q + 1, by omega⟩ by simp [cycleDist, abs_sub_comm], hcd_nat ⟨q, by omega⟩ ⟨2 * q + 1, by omega⟩ (by dsimp; omega)] at h4 have hnR : (n : ℝ) = 4 * (q : ℝ) + 3 := by exact_mod_cast hn4 simp only [Nat.sub_zero, show 3 * q + 2 - q = 2 * q + 2 by omega, show 3 * q + 2 - (2 * q + 1) = q + 1 by omega, show 2 * q + 1 - q = q + 1 by omega, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one, hnR] at h4 rw [min_eq_left (by linarith : 2 * (q : ℝ) + 1 ≤ 4 * q + 3 - (2 * q + 1)), min_eq_right (by linarith : 4 * (q : ℝ) + 3 - (2 * q + 2) ≤ 2 * q + 2), min_eq_left (by linarith : (q : ℝ) ≤ 4 * q + 3 - q), min_eq_left (by linarith : (q : ℝ) + 1 ≤ 4 * q + 3 - (q + 1)), min_eq_right (by linarith : 4 * (q : ℝ) + 3 - (3 * q + 2) ≤ 3 * q + 2)] at h4 rw [max_eq_right (by linarith)] at h4 linarith /-! ## Section 7: Exact ℓ₁-Product 4-Point Theorem, 2D Grids P_m □ P_k, & 3D Grid P_{a+1}^3 -/ /-- The `ℓ₁` (Manhattan) distance on `ℝ × ℝ`. -/ def l1Dist2 (p q : ℝ × ℝ) : ℝ := |p.1 - q.1| + |p.2 - q.2| lemma l1Dist2_isPseudoMetricFn : IsPseudoMetricFn l1Dist2 where nonneg p q := add_nonneg (abs_nonneg _) (abs_nonneg _) self p := by simp [l1Dist2] symm p q := by simp [l1Dist2, abs_sub_comm] triangle p q r := by unfold l1Dist2 have h1 : |p.1 - r.1| ≤ |p.1 - q.1| + |q.1 - r.1| := by have : p.1 - r.1 = (p.1 - q.1) + (q.1 - r.1) := by ring rw [this]; exact abs_add_le _ _ have h2 : |p.2 - r.2| ≤ |p.2 - q.2| + |q.2 - r.2| := by have : p.2 - r.2 = (p.2 - q.2) + (q.2 - r.2) := by ring rw [this]; exact abs_add_le _ _ linarith /-- For ANY 4 real numbers `a, b, c, d`, the three opposite sums of `|x - y|` have exact 0-hyperbolicity AND exact max-minus-min equal to `2 * (middle_gap)`! -/ lemma real_four_sums (a b c d : ℝ) : let u1 := |a - b| + |c - d| let u2 := |a - c| + |b - d| let u3 := |a - d| + |b - c| (u1 = u2 ∧ u3 ≤ u1) ∨ (u1 = u3 ∧ u2 ≤ u1) ∨ (u2 = u3 ∧ u1 ≤ u2) := by intro u1 u2 u3 -- Fast 4-branch proof of 1D 0-hyperbolicity `|x - y| + |z - w| ≤ max(|x - z| + |y - w|, |x - w| + |y - z|)`: have h1d : ∀ x y z w : ℝ, |x - y| + |z - w| ≤ max (|x - z| + |y - w|) (|x - w| + |y - z|) := by have hord : ∀ x y z w : ℝ, x ≤ y → z ≤ w → |x - y| + |z - w| ≤ max (|x - z| + |y - w|) (|x - w| + |y - z|) := by intro x y z w hxy hzw rw [abs_of_nonpos (by linarith : x - y ≤ 0), abs_of_nonpos (by linarith : z - w ≤ 0)] rcases le_total y z with hyz | hzy · exact le_max_of_le_right (by linarith [neg_le_abs (x - w), neg_le_abs (y - z)]) · rcases le_total w x with hwx | hxw · exact le_max_of_le_right (by linarith [le_abs_self (x - w), le_abs_self (y - z)]) · exact le_max_of_le_right (by linarith [neg_le_abs (x - w), le_abs_self (y - z)]) intro x y z w rcases le_total x y with hxy | hyx <;> rcases le_total z w with hzw | hwz · exact hord x y z w hxy hzw · have h := hord x y w z hxy hwz rwa [abs_sub_comm w z, max_comm] at h · have h := hord y x z w hyx hzw rwa [abs_sub_comm y x, max_comm, add_comm |y - z| |x - w|, add_comm |y - w| |x - z|] at h · have h := hord y x w z hyx hwz rwa [abs_sub_comm y x, abs_sub_comm w z, add_comm |y - w| |x - z|, add_comm |y - z| |x - w|] at h have h1 : u1 ≤ max u2 u3 := h1d a b c d have h2 : u2 ≤ max u1 u3 := by dsimp only [u1, u2, u3] have h := h1d a c b d; rwa [abs_sub_comm c b] at h have h3 : u3 ≤ max u1 u2 := by dsimp only [u1, u2, u3] have h := h1d a d b c; rwa [abs_sub_comm d c, abs_sub_comm d b] at h rcases le_total u1 u2 with h12 | h21 · rcases le_total u2 u3 with h23 | h32 · rw [max_eq_right h12] at h3; right; right; exact ⟨le_antisymm h23 h3, h12⟩ · rcases le_total u1 u3 with h13 | h31 · rw [max_eq_right h13] at h2; right; right; exact ⟨le_antisymm h2 h32, h12⟩ · rw [max_eq_left h31] at h2; left; exact ⟨le_antisymm h12 h2, h31⟩ · rcases le_total u1 u3 with h13 | h31 · rw [max_eq_left h21] at h3; right; left; exact ⟨le_antisymm h13 h3, h21⟩ · rcases le_total u2 u3 with h23 | h32 · rw [max_eq_right h23] at h1; right; left; exact ⟨le_antisymm h1 h31, h21⟩ · rw [max_eq_left h32] at h1; left; exact ⟨le_antisymm h1 h21, h31⟩ /-- **THEOREM (Exact `ℓ₁`-Rectangle Hyperbolicity)**: On `[0, A] × [0, B]` endowed with the `ℓ₁` metric, the exact Gromov 4-point hyperbolicity constant is `min A B`! -/ theorem l1_rect_delta4_exact {A B : ℝ} (hA : 0 ≤ A) (hB : 0 ≤ B) : (∀ p q r s : ℝ × ℝ, 0 ≤ p.1 ∧ p.1 ≤ A → 0 ≤ q.1 ∧ q.1 ≤ A → 0 ≤ r.1 ∧ r.1 ≤ A → 0 ≤ s.1 ∧ s.1 ≤ A → 0 ≤ p.2 ∧ p.2 ≤ B → 0 ≤ q.2 ∧ q.2 ≤ B → 0 ≤ r.2 ∧ r.2 ≤ B → 0 ≤ s.2 ∧ s.2 ≤ B → l1Dist2 p q + l1Dist2 r s ≤ max (l1Dist2 p r + l1Dist2 q s) (l1Dist2 p s + l1Dist2 q r) + 2 * min A B) ∧ (∀ δ, (∀ p q r s : ℝ × ℝ, 0 ≤ p.1 ∧ p.1 ≤ A → 0 ≤ q.1 ∧ q.1 ≤ A → 0 ≤ r.1 ∧ r.1 ≤ A → 0 ≤ s.1 ∧ s.1 ≤ A → 0 ≤ p.2 ∧ p.2 ≤ B → 0 ≤ q.2 ∧ q.2 ≤ B → 0 ≤ r.2 ∧ r.2 ≤ B → 0 ≤ s.2 ∧ s.2 ≤ B → l1Dist2 p q + l1Dist2 r s ≤ max (l1Dist2 p r + l1Dist2 q s) (l1Dist2 p s + l1Dist2 q r) + 2 * δ) → min A B ≤ δ) := by constructor · intro p q r s hp1 hq1 hr1 hs1 hp2 hq2 hr2 hs2 -- Each coordinate's opposite sums differ by at most `2 * A` (resp. `2 * B`), AND -- the largest two sums in each coordinate are EQUAL! have hU := real_four_sums p.1 q.1 r.1 s.1 have hV := real_four_sums p.2 q.2 r.2 s.2 have hU_bd : ∀ x y : ℝ, 0 ≤ x ∧ x ≤ A → 0 ≤ y ∧ y ≤ A → |x - y| ≤ A := fun x y hx hy => by rw [abs_le]; constructor <;> linarith have hV_bd : ∀ x y : ℝ, 0 ≤ x ∧ x ≤ B → 0 ≤ y ∧ y ≤ B → |x - y| ≤ B := fun x y hx hy => by rw [abs_le]; constructor <;> linarith have hUgap : ∀ u v, (u = |p.1 - q.1| + |r.1 - s.1| ∨ u = |p.1 - r.1| + |q.1 - s.1| ∨ u = |p.1 - s.1| + |q.1 - r.1|) → (v = |p.1 - q.1| + |r.1 - s.1| ∨ v = |p.1 - r.1| + |q.1 - s.1| ∨ v = |p.1 - s.1| + |q.1 - r.1|) → u - v ≤ 2 * A := by intro u v hu hv have : u ≤ 2 * A := by rcases hu with rfl | rfl | rfl <;> linarith [hU_bd p.1 q.1 hp1 hq1, hU_bd r.1 s.1 hr1 hs1, hU_bd p.1 r.1 hp1 hr1, hU_bd q.1 s.1 hq1 hs1, hU_bd p.1 s.1 hp1 hs1, hU_bd q.1 r.1 hq1 hr1] have : 0 ≤ v := by rcases hv with rfl | rfl | rfl <;> positivity linarith have hVgap : ∀ u v, (u = |p.2 - q.2| + |r.2 - s.2| ∨ u = |p.2 - r.2| + |q.2 - s.2| ∨ u = |p.2 - s.2| + |q.2 - r.2|) → (v = |p.2 - q.2| + |r.2 - s.2| ∨ v = |p.2 - r.2| + |q.2 - s.2| ∨ v = |p.2 - s.2| + |q.2 - r.2|) → u - v ≤ 2 * B := by intro u v hu hv have : u ≤ 2 * B := by rcases hu with rfl | rfl | rfl <;> linarith [hV_bd p.2 q.2 hp2 hq2, hV_bd r.2 s.2 hr2 hs2, hV_bd p.2 r.2 hp2 hr2, hV_bd q.2 s.2 hq2 hs2, hV_bd p.2 s.2 hp2 hs2, hV_bd q.2 r.2 hq2 hr2] have : 0 ≤ v := by rcases hv with rfl | rfl | rfl <;> positivity linarith unfold l1Dist2 set U1 := |p.1 - q.1| + |r.1 - s.1| set U2 := |p.1 - r.1| + |q.1 - s.1| set U3 := |p.1 - s.1| + |q.1 - r.1| set V1 := |p.2 - q.2| + |r.2 - s.2| set V2 := |p.2 - r.2| + |q.2 - s.2| set V3 := |p.2 - s.2| + |q.2 - r.2| have hU12 := hUgap U1 U2 (Or.inl rfl) (Or.inr (Or.inl rfl)) have hU13 := hUgap U1 U3 (Or.inl rfl) (Or.inr (Or.inr rfl)) have hV12 := hVgap V1 V2 (Or.inl rfl) (Or.inr (Or.inl rfl)) have hV13 := hVgap V1 V3 (Or.inl rfl) (Or.inr (Or.inr rfl)) -- 9 combinations of `(hU, hV)`: in EVERY case `U1 + V1 ≤ max (U2 + V2) (U3 + V3) + 2 * min A B`! have hgoal : U1 + V1 ≤ max (U2 + V2) (U3 + V3) + 2 * min A B := by rcases hU with ⟨hU1, hU2⟩ | ⟨hU1, hU2⟩ | ⟨hU1, hU2⟩ <;> rcases hV with ⟨hV1, hV2⟩ | ⟨hV1, hV2⟩ | ⟨hV1, hV2⟩ · linarith [le_min hA hB, le_max_left (U2 + V2) (U3 + V3)] · rcases le_total A B with hAB | hBA · rw [min_eq_left hAB]; linarith [le_max_right (U2 + V2) (U3 + V3)] · rw [min_eq_right hBA]; linarith [le_max_left (U2 + V2) (U3 + V3)] · linarith [le_min hA hB, le_max_left (U2 + V2) (U3 + V3)] · rcases le_total A B with hAB | hBA · rw [min_eq_left hAB]; linarith [le_max_left (U2 + V2) (U3 + V3)] · rw [min_eq_right hBA]; linarith [le_max_right (U2 + V2) (U3 + V3)] · linarith [le_min hA hB, le_max_right (U2 + V2) (U3 + V3)] · linarith [le_min hA hB, le_max_right (U2 + V2) (U3 + V3)] · linarith [le_min hA hB, le_max_left (U2 + V2) (U3 + V3)] · linarith [le_min hA hB, le_max_right (U2 + V2) (U3 + V3)] · linarith [le_min hA hB, le_max_left (U2 + V2) (U3 + V3)] have heq : (|p.1 - q.1| + |p.2 - q.2|) + (|r.1 - s.1| + |r.2 - s.2|) = U1 + V1 := by ring have heq2 : (|p.1 - r.1| + |p.2 - r.2|) + (|q.1 - s.1| + |q.2 - s.2|) = U2 + V2 := by ring have heq3 : (|p.1 - s.1| + |p.2 - s.2|) + (|q.1 - r.1| + |q.2 - r.2|) = U3 + V3 := by ring rw [heq, heq2, heq3]; exact hgoal · intro δ hδ -- Witness: the 4 corners `(0, 0), (min A B, min A B), (min A B, 0), (0, min A B)`! set M := min A B have hM0 : 0 ≤ M := le_min hA hB have hMA : M ≤ A := min_le_left A B have hMB : M ≤ B := min_le_right A B have h4 := hδ (0, 0) (M, M) (M, 0) (0, M) ⟨le_rfl, hA⟩ ⟨hM0, hMA⟩ ⟨hM0, hMA⟩ ⟨le_rfl, hA⟩ ⟨le_rfl, hB⟩ ⟨hM0, hMB⟩ ⟨le_rfl, hB⟩ ⟨hM0, hMB⟩ simp only [l1Dist2, sub_zero, zero_sub, abs_neg, abs_zero, sub_self, abs_of_nonneg hM0, add_zero, zero_add] at h4 rw [max_self] at h4 linarith /-- Shortest-path metric on the 2D grid graph `P_m □ P_k` (`Fin m × Fin k`). -/ def gridDist (m k : ℕ) (p q : Fin m × Fin k) : ℝ := l1Dist2 ((p.1.1 : ℝ), (p.2.1 : ℝ)) ((q.1.1 : ℝ), (q.2.1 : ℝ)) /-- **THEOREM (Exact Gromov 4-Point Hyperbolicity of ALL 2D Grids `P_m □ P_k`)**: For every `m, k ≥ 1`, `δ_4(P_m □ P_k) = min(m, k) - 1` EXACTLY! -/ theorem grid_delta4_exact {m k : ℕ} (hm : 1 ≤ m) (hk : 1 ≤ k) : IsFourPointHyperbolic (gridDist m k) (((min m k : ℕ) : ℝ) - 1) ∧ ∀ δ, IsFourPointHyperbolic (gridDist m k) δ → (((min m k : ℕ) : ℝ) - 1) ≤ δ := by have hA : (0 : ℝ) ≤ (m : ℝ) - 1 := by have : (1 : ℝ) ≤ (m : ℝ) := by exact_mod_cast hm linarith have hB : (0 : ℝ) ≤ (k : ℝ) - 1 := by have : (1 : ℝ) ≤ (k : ℝ) := by exact_mod_cast hk linarith have hmin : min ((m : ℝ) - 1) ((k : ℝ) - 1) = ((min m k : ℕ) : ℝ) - 1 := by rcases le_total m k with h | h · rw [min_eq_left h, min_eq_left (by have : (m : ℝ) ≤ (k : ℝ) := Nat.cast_le.mpr h; linarith)] · rw [min_eq_right h, min_eq_right (by have : (k : ℝ) ≤ (m : ℝ) := Nat.cast_le.mpr h; linarith)] constructor · intro p q r s have hbd := (l1_rect_delta4_exact hA hB).1 ((p.1.1 : ℝ), (p.2.1 : ℝ)) ((q.1.1 : ℝ), (q.2.1 : ℝ)) ((r.1.1 : ℝ), (r.2.1 : ℝ)) ((s.1.1 : ℝ), (s.2.1 : ℝ)) rw [hmin] at hbd have hcoord : ∀ (N : ℕ) (x : Fin N), 0 ≤ (x.1 : ℝ) ∧ (x.1 : ℝ) ≤ (N : ℝ) - 1 := fun N x => by refine ⟨Nat.cast_nonneg _, ?_⟩ have : (x.1 : ℝ) + 1 ≤ (N : ℝ) := by exact_mod_cast x.2 linarith exact hbd (hcoord m p.1) (hcoord m q.1) (hcoord m r.1) (hcoord m s.1) (hcoord k p.2) (hcoord k q.2) (hcoord k r.2) (hcoord k s.2) · intro δ hδ set M := min m k - 1 have hMm : M < m := by omega have hMk : M < k := by omega have h4 := hδ (⟨0, hm⟩, ⟨0, hk⟩) (⟨M, hMm⟩, ⟨M, hMk⟩) (⟨M, hMm⟩, ⟨0, hk⟩) (⟨0, hm⟩, ⟨M, hMk⟩) unfold gridDist l1Dist2 at h4 simp only [Nat.cast_zero, sub_zero, zero_sub, abs_neg, abs_zero, sub_self, abs_of_nonneg (Nat.cast_nonneg (α := ℝ) M), add_zero, zero_add] at h4 rw [max_self] at h4 have hcast : (M : ℝ) = ((min m k : ℕ) : ℝ) - 1 := by have : 1 ≤ min m k := le_min hm hk rw [Nat.cast_sub this]; norm_num linarith /-- Shortest-path `ℓ₁` metric on the 3D grid `P_{a+1}^3`. -/ def grid3Dist (a : ℕ) (p q : Fin (a + 1) × Fin (a + 1) × Fin (a + 1)) : ℝ := |(p.1.1 : ℝ) - (q.1.1 : ℝ)| + |(p.2.1.1 : ℝ) - (q.2.1.1 : ℝ)| + |(p.2.2.1 : ℝ) - (q.2.2.1 : ℝ)| /-- **THEOREM (Petrie-Hexagon Tree-Approximation Lower Bound on 3D Grids `P_{a+1}^3`)**: Every `δ'`-hyperbolic approximation of `P_{a+1}^3` within `L_∞` error `ε` satisfies `ε + δ' ≥ a`! For `0`-hyperbolic trees (`δ' = 0`), this gives `ε ≥ a`, STRICTLY BEATING the 4-point lower bound `3a / 4` by a factor of `4/3`! -/ theorem grid3_petrie_hexagon_tree_lower_bound (a : ℕ) {δ' ε : ℝ} {d' : (Fin (a + 1) × Fin (a + 1) × Fin (a + 1)) → (Fin (a + 1) × Fin (a + 1) × Fin (a + 1)) → ℝ} (hd' : IsPseudoMetricFn d') (h' : IsFourPointHyperbolic d' δ') (happrox : ∀ p q, |grid3Dist a p q - d' p q| ≤ ε) : (a : ℝ) ≤ ε + δ' := by let z : Fin (a + 1) := ⟨0, Nat.zero_lt_succ a⟩ let u : Fin (a + 1) := ⟨a, Nat.lt_succ_self a⟩ -- Petrie hexagon of the 3-cube `[0, a]^3`: isometric copy of `a · C_6`! let p₀ := (z, z, z) let p₁ := (u, z, z) let p₂ := (u, u, z) let p₃ := (u, u, u) let p₄ := (z, u, u) let p₅ := (z, z, u) have hhex := hexagon_hyperbolic_ineq hd' h' p₀ p₁ p₂ p₃ p₄ p₅ have ha0 : (0 : ℝ) ≤ (a : ℝ) := Nat.cast_nonneg a have hd03 : grid3Dist a p₀ p₃ = 3 * (a : ℝ) := by simp [grid3Dist, p₀, p₃, z, u, abs_of_nonneg ha0]; ring have hd14 : grid3Dist a p₁ p₄ = 3 * (a : ℝ) := by simp [grid3Dist, p₁, p₄, z, u, abs_of_nonneg ha0]; ring have hd25 : grid3Dist a p₂ p₅ = 3 * (a : ℝ) := by simp [grid3Dist, p₂, p₅, z, u, abs_of_nonneg ha0]; ring have hd01 : grid3Dist a p₀ p₁ = (a : ℝ) := by simp [grid3Dist, p₀, p₁, z, u, abs_of_nonneg ha0] have hd12 : grid3Dist a p₁ p₂ = (a : ℝ) := by simp [grid3Dist, p₁, p₂, z, u, abs_of_nonneg ha0] have hd23 : grid3Dist a p₂ p₃ = (a : ℝ) := by simp [grid3Dist, p₂, p₃, z, u, abs_of_nonneg ha0] have hd34 : grid3Dist a p₃ p₄ = (a : ℝ) := by simp [grid3Dist, p₃, p₄, z, u, abs_of_nonneg ha0] have hd45 : grid3Dist a p₄ p₅ = (a : ℝ) := by simp [grid3Dist, p₄, p₅, z, u, abs_of_nonneg ha0] have hd50 : grid3Dist a p₅ p₀ = (a : ℝ) := by simp [grid3Dist, p₅, p₀, z, u, abs_of_nonneg ha0] have hlo : 3 * (a : ℝ) - ε ≤ min (d' p₀ p₃) (min (d' p₁ p₄) (d' p₂ p₅)) := by refine le_min ?_ (le_min ?_ ?_) · linarith [(abs_le.mp (happrox p₀ p₃)).2, hd03] · linarith [(abs_le.mp (happrox p₁ p₄)).2, hd14] · linarith [(abs_le.mp (happrox p₂ p₅)).2, hd25] have hhi : max (max (d' p₀ p₁) (d' p₁ p₂)) (max (max (d' p₂ p₃) (d' p₃ p₄)) (max (d' p₄ p₅) (d' p₅ p₀))) ≤ (a : ℝ) + ε := by refine max_le (max_le ?_ ?_) (max_le (max_le ?_ ?_) (max_le ?_ ?_)) · linarith [(abs_le.mp (happrox p₀ p₁)).1, hd01] · linarith [(abs_le.mp (happrox p₁ p₂)).1, hd12] · linarith [(abs_le.mp (happrox p₂ p₃)).1, hd23] · linarith [(abs_le.mp (happrox p₃ p₄)).1, hd34] · linarith [(abs_le.mp (happrox p₄ p₅)).1, hd45] · linarith [(abs_le.mp (happrox p₅ p₀)).1, hd50] linarith end GromovTreeApproximation #print axioms GromovTreeApproximation.fourPointHyperbolic_iff_gromovProdHyperbolic #print axioms GromovTreeApproximation.shiftOffDiag_zeroHyperbolic #print axioms GromovTreeApproximation.gpStep_le_gromovProd_add #print axioms GromovTreeApproximation.gpStep_stabilizes #print axioms GromovTreeApproximation.gromovTreeDist_isPseudoMetricFn #print axioms GromovTreeApproximation.gromovTreeDist_root #print axioms GromovTreeApproximation.gromovTreeDist_zeroHyperbolic #print axioms GromovTreeApproximation.gromov_tree_approx_sharp_upper #print axioms GromovTreeApproximation.gromov_tree_approx_centered #print axioms GromovTreeApproximation.ptolemyLogDist_isPseudoMetricFn #print axioms GromovTreeApproximation.ptolemyLogDist_hyperbolic #print axioms GromovTreeApproximation.ptolemyLog_tree_distortion_exact #print axioms GromovTreeApproximation.gromov_tree_approx_exact_dyadic #print axioms GromovTreeApproximation.fourPoint_approx_lower_bound #print axioms GromovTreeApproximation.hexagon_hyperbolic_ineq #print axioms GromovTreeApproximation.circle_hyperbolic_approx_lower_bound #print axioms GromovTreeApproximation.circle_fold_tripod_exact_upper #print axioms GromovTreeApproximation.circle_minimax_tree_distortion_exact #print axioms GromovTreeApproximation.cycle6m_minimax_tree_distortion_exact #print axioms GromovTreeApproximation.cycle_delta4_exact #print axioms GromovTreeApproximation.l1_rect_delta4_exact #print axioms GromovTreeApproximation.grid_delta4_exact #print axioms GromovTreeApproximation.grid3_petrie_hexagon_tree_lower_bound