-- Mathlib/Topology/MetricSpace/GromovHausdorffRealized.lean
theorem hausdorffDist_optimal_le_HD {f} (h : f ∈ candidatesB X Y) :
    hausdorffDist (range (optimalGHInjl X Y)) (range (optimalGHInjr X Y)) ≤ HD f

Proof state:
case refine_2.intro.intro.intro.intro
X : Type u
Y : Type v
inst✝⁵ : MetricSpace X
inst✝⁴ : CompactSpace X
inst✝³ : Nonempty X
inst✝² : MetricSpace Y
inst✝¹ : CompactSpace Y
inst✝ : Nonempty Y
f : GromovHausdorff.Cb X Y
h : f ∈ GromovHausdorff.candidatesB X Y
r : ℝ
hr : HD (GromovHausdorff.optimalGHDist X Y) < r
A : ∀ x ∈ range (optimalGHInjl X Y), ∃ y ∈ range (optimalGHInjr X Y), dist x y ≤ r
z : Y
I1 : ⨆ y, ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y) < r
I2 :
  ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr z) ≤ ⨆ y, ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y)
I : ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr z) < r
z' : X
hr' : (fun x => (GromovHausdorff.optimalGHDist X Y) (inl x, inr z)) z' < r
⊢ ∃ y ∈ range (optimalGHInjl X Y), dist (optimalGHInjr X Y z) y ≤ r

Tactic:
refine ⟨optimalGHInjl X Y z', mem_range_self _, le_of_lt ?_⟩

Result:
case refine_2.intro.intro.intro.intro
X : Type u
Y : Type v
inst✝⁵ : MetricSpace X
inst✝⁴ : CompactSpace X
inst✝³ : Nonempty X
inst✝² : MetricSpace Y
inst✝¹ : CompactSpace Y
inst✝ : Nonempty Y
f : GromovHausdorff.Cb X Y
h : f ∈ GromovHausdorff.candidatesB X Y
r : ℝ
hr : HD (GromovHausdorff.optimalGHDist X Y) < r
A : ∀ x ∈ range (optimalGHInjl X Y), ∃ y ∈ range (optimalGHInjr X Y), dist x y ≤ r
z : Y
I1 : ⨆ y, ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y) < r
I2 :
  ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr z) ≤ ⨆ y, ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y)
I : ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr z) < r
z' : X
hr' : (fun x => (GromovHausdorff.optimalGHDist X Y) (inl x, inr z)) z' < r
⊢ dist (optimalGHInjr X Y z) (optimalGHInjl X Y z') < r

Proof state:
case intro
X : Type u
Y : Type v
inst✝⁵ : MetricSpace X
inst✝⁴ : CompactSpace X
inst✝³ : Nonempty X
inst✝² : MetricSpace Y
inst✝¹ : CompactSpace Y
inst✝ : Nonempty Y
f : GromovHausdorff.Cb X Y
h : f ∈ GromovHausdorff.candidatesB X Y
r : ℝ
hr : HD (GromovHausdorff.optimalGHDist X Y) < r
z : X
I1 : ⨆ x, ⨅ y, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y) < r
⊢ ∃ y ∈ range (optimalGHInjr X Y), dist (optimalGHInjl X Y z) y ≤ r

Tactic:
have I2 :
    ⨅ y, optimalGHDist X Y (inl z, inr y) ≤ ⨆ x, ⨅ y, optimalGHDist X Y (inl x, inr y) :=
  le_csSup (by simpa using HD_bound_aux1 _ 0) (mem_range_self _)

Result:
case intro
X : Type u
Y : Type v
inst✝⁵ : MetricSpace X
inst✝⁴ : CompactSpace X
inst✝³ : Nonempty X
inst✝² : MetricSpace Y
inst✝¹ : CompactSpace Y
inst✝ : Nonempty Y
f : GromovHausdorff.Cb X Y
h : f ∈ GromovHausdorff.candidatesB X Y
r : ℝ
hr : HD (GromovHausdorff.optimalGHDist X Y) < r
z : X
I1 : ⨆ x, ⨅ y, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y) < r
I2 :
  ⨅ y, (GromovHausdorff.optimalGHDist X Y) (inl z, inr y) ≤ ⨆ x, ⨅ y, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y)
⊢ ∃ y ∈ range (optimalGHInjr X Y), dist (optimalGHInjl X Y z) y ≤ r

Proof state:
case intro
X : Type u
Y : Type v
inst✝⁵ : MetricSpace X
inst✝⁴ : CompactSpace X
inst✝³ : Nonempty X
inst✝² : MetricSpace Y
inst✝¹ : CompactSpace Y
inst✝ : Nonempty Y
f : GromovHausdorff.Cb X Y
h : f ∈ GromovHausdorff.candidatesB X Y
r : ℝ
hr : HD (GromovHausdorff.optimalGHDist X Y) < r
z : X
I1 : ⨆ x, ⨅ y, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y) < r
I2 :
  ⨅ y, (GromovHausdorff.optimalGHDist X Y) (inl z, inr y) ≤ ⨆ x, ⨅ y, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y)
⊢ ∃ y ∈ range (optimalGHInjr X Y), dist (optimalGHInjl X Y z) y ≤ r

Tactic:
have I : ⨅ y, optimalGHDist X Y (inl z, inr y) < r := lt_of_le_of_lt I2 I1

Result:
case intro
X : Type u
Y : Type v
inst✝⁵ : MetricSpace X
inst✝⁴ : CompactSpace X
inst✝³ : Nonempty X
inst✝² : MetricSpace Y
inst✝¹ : CompactSpace Y
inst✝ : Nonempty Y
f : GromovHausdorff.Cb X Y
h : f ∈ GromovHausdorff.candidatesB X Y
r : ℝ
hr : HD (GromovHausdorff.optimalGHDist X Y) < r
z : X
I1 : ⨆ x, ⨅ y, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y) < r
I2 :
  ⨅ y, (GromovHausdorff.optimalGHDist X Y) (inl z, inr y) ≤ ⨆ x, ⨅ y, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y)
I : ⨅ y, (GromovHausdorff.optimalGHDist X Y) (inl z, inr y) < r
⊢ ∃ y ∈ range (optimalGHInjr X Y), dist (optimalGHInjl X Y z) y ≤ r

Proof state:
X : Type u
Y : Type v
inst✝⁵ : MetricSpace X
inst✝⁴ : CompactSpace X
inst✝³ : Nonempty X
inst✝² : MetricSpace Y
inst✝¹ : CompactSpace Y
inst✝ : Nonempty Y
f : GromovHausdorff.Cb X Y
h : f ∈ GromovHausdorff.candidatesB X Y
r : ℝ
hr : HD (GromovHausdorff.optimalGHDist X Y) < r
⊢ hausdorffDist (range (optimalGHInjl X Y)) (range (optimalGHInjr X Y)) ≤ r

Tactic:
have A : ∀ x ∈ range (optimalGHInjl X Y), ∃ y ∈ range (optimalGHInjr X Y), dist x y ≤ r := by
  rintro _ ⟨z, rfl⟩
  have I1 : (⨆ x, ⨅ y, optimalGHDist X Y (inl x, inr y)) < r :=
    lt_of_le_of_lt (le_max_left _ _) hr
  have I2 :
      ⨅ y, optimalGHDist X Y (inl z, inr y) ≤ ⨆ x, ⨅ y, optimalGHDist X Y (inl x, inr y) :=
    le_csSup (by simpa using HD_bound_aux1 _ 0) (mem_range_self _)
  have I : ⨅ y, optimalGHDist X Y (inl z, inr y) < r := lt_of_le_of_lt I2 I1
  rcases exists_lt_of_csInf_lt (range_nonempty _) I with ⟨r', ⟨z', rfl⟩, hr'⟩
  exact ⟨optimalGHInjr X Y z', mem_range_self _, le_of_lt hr'⟩

Result:
X : Type u
Y : Type v
inst✝⁵ : MetricSpace X
inst✝⁴ : CompactSpace X
inst✝³ : Nonempty X
inst✝² : MetricSpace Y
inst✝¹ : CompactSpace Y
inst✝ : Nonempty Y
f : GromovHausdorff.Cb X Y
h : f ∈ GromovHausdorff.candidatesB X Y
r : ℝ
hr : HD (GromovHausdorff.optimalGHDist X Y) < r
A : ∀ x ∈ range (optimalGHInjl X Y), ∃ y ∈ range (optimalGHInjr X Y), dist x y ≤ r
⊢ hausdorffDist (range (optimalGHInjl X Y)) (range (optimalGHInjr X Y)) ≤ r

Proof state:
case refine_2.intro
X : Type u
Y : Type v
inst✝⁵ : MetricSpace X
inst✝⁴ : CompactSpace X
inst✝³ : Nonempty X
inst✝² : MetricSpace Y
inst✝¹ : CompactSpace Y
inst✝ : Nonempty Y
f : GromovHausdorff.Cb X Y
h : f ∈ GromovHausdorff.candidatesB X Y
r : ℝ
hr : HD (GromovHausdorff.optimalGHDist X Y) < r
A : ∀ x ∈ range (optimalGHInjl X Y), ∃ y ∈ range (optimalGHInjr X Y), dist x y ≤ r
z : Y
I1 : ⨆ y, ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y) < r
I2 :
  ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr z) ≤ ⨆ y, ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y)
⊢ ∃ y ∈ range (optimalGHInjl X Y), dist (optimalGHInjr X Y z) y ≤ r

Tactic:
have I : ⨅ x, optimalGHDist X Y (inl x, inr z) < r := lt_of_le_of_lt I2 I1

Result:
case refine_2.intro
X : Type u
Y : Type v
inst✝⁵ : MetricSpace X
inst✝⁴ : CompactSpace X
inst✝³ : Nonempty X
inst✝² : MetricSpace Y
inst✝¹ : CompactSpace Y
inst✝ : Nonempty Y
f : GromovHausdorff.Cb X Y
h : f ∈ GromovHausdorff.candidatesB X Y
r : ℝ
hr : HD (GromovHausdorff.optimalGHDist X Y) < r
A : ∀ x ∈ range (optimalGHInjl X Y), ∃ y ∈ range (optimalGHInjr X Y), dist x y ≤ r
z : Y
I1 : ⨆ y, ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y) < r
I2 :
  ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr z) ≤ ⨆ y, ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y)
I : ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr z) < r
⊢ ∃ y ∈ range (optimalGHInjl X Y), dist (optimalGHInjr X Y z) y ≤ r

Proof state:
X : Type u
Y : Type v
inst✝⁵ : MetricSpace X
inst✝⁴ : CompactSpace X
inst✝³ : Nonempty X
inst✝² : MetricSpace Y
inst✝¹ : CompactSpace Y
inst✝ : Nonempty Y
f : GromovHausdorff.Cb X Y
h : f ∈ GromovHausdorff.candidatesB X Y
r : ℝ
hr : HD (GromovHausdorff.optimalGHDist X Y) < r
A : ∀ x ∈ range (optimalGHInjl X Y), ∃ y ∈ range (optimalGHInjr X Y), dist x y ≤ r
z : Y
I1 : ⨆ y, ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y) < r
⊢ BddAbove (range fun y => ⨅ x, (GromovHausdorff.optimalGHDist X Y) (inl x, inr y))

Tactic:
simpa using HD_bound_aux2 _ 0

Result:
no goals