-- Mathlib/Analysis/Normed/Module/FiniteDimension.lean
theorem IsCompact.exists_mem_frontier_infDist_compl_eq_dist {E : Type*}
    [NormedAddCommGroup E] [NormedSpace ℝ E] [Nontrivial E] {x : E} {K : Set E} (hK : IsCompact K)
    (hx : x ∈ K) :
    ∃ y ∈ frontier K, Metric.infDist x Kᶜ = dist x y

Proof state:
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
⊢ ∃ y ∈ frontier K, infDist x Kᶜ = dist x y

Tactic:
obtain hx' | hx' : x ∈ interior K ∪ frontier K := by
  rw [← closure_eq_interior_union_frontier]
  exact subset_closure hx

Result:
case inl
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
hx' : x ∈ interior K
⊢ ∃ y ∈ frontier K, infDist x Kᶜ = dist x y

case inr
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
hx' : x ∈ frontier K
⊢ ∃ y ∈ frontier K, infDist x Kᶜ = dist x y

Proof state:
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
⊢ x ∈ closure K

Tactic:
exact subset_closure hx

Result:
no goals

Proof state:
case inl.intro.intro
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
r : ℝ
hr₀ : 0 < r
hrK : closedBall x r ⊆ K
⊢ ∃ y ∈ frontier K, infDist x Kᶜ = dist x y

Tactic:
have : FiniteDimensional ℝ E :=
  .of_isCompact_closedBall ℝ hr₀
    (hK.of_isClosed_subset Metric.isClosed_closedBall hrK)

Result:
case inl.intro.intro
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
r : ℝ
hr₀ : 0 < r
hrK : closedBall x r ⊆ K
this : FiniteDimensional ℝ E
⊢ ∃ y ∈ frontier K, infDist x Kᶜ = dist x y

Proof state:
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
⊢ x ∈ interior K ∪ frontier K

Tactic:
rw [← closure_eq_interior_union_frontier]

Result:
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
⊢ x ∈ closure K

Proof state:
case inl
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
hx' : x ∈ interior K
⊢ ∃ y ∈ frontier K, infDist x Kᶜ = dist x y

Tactic:
rw [mem_interior_iff_mem_nhds, Metric.nhds_basis_closedBall.mem_iff] at hx'

Result:
case inl
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
hx' : ∃ i, 0 < i ∧ closedBall x i ⊆ K
⊢ ∃ y ∈ frontier K, infDist x Kᶜ = dist x y

Proof state:
case inl.intro.intro
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
r : ℝ
hr₀ : 0 < r
hrK : closedBall x r ⊆ K
this : FiniteDimensional ℝ E
⊢ ∃ y ∈ frontier K, infDist x Kᶜ = dist x y

Tactic:
exact exists_mem_frontier_infDist_compl_eq_dist hx hK.ne_univ

Result:
no goals

Proof state:
case inl
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
hx' : ∃ i, 0 < i ∧ closedBall x i ⊆ K
⊢ ∃ y ∈ frontier K, infDist x Kᶜ = dist x y

Tactic:
rcases hx' with ⟨r, hr₀, hrK⟩

Result:
case inl.intro.intro
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
r : ℝ
hr₀ : 0 < r
hrK : closedBall x r ⊆ K
⊢ ∃ y ∈ frontier K, infDist x Kᶜ = dist x y

Proof state:
case inr
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
hx' : x ∈ closure K ∩ closure Kᶜ
⊢ infDist x Kᶜ = dist x x

Tactic:
rw [Metric.infDist_zero_of_mem_closure hx'.2, dist_self]

Result:
no goals

Proof state:
case inr
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
hx' : x ∈ frontier K
⊢ infDist x Kᶜ = dist x x

Tactic:
rw [frontier_eq_closure_inter_closure] at hx'

Result:
case inr
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
hx' : x ∈ closure K ∩ closure Kᶜ
⊢ infDist x Kᶜ = dist x x

Proof state:
case inr
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
hx' : x ∈ frontier K
⊢ ∃ y ∈ frontier K, infDist x Kᶜ = dist x y

Tactic:
refine ⟨x, hx', ?_⟩

Result:
case inr
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : Nontrivial E
x : E
K : Set E
hK : IsCompact K
hx : x ∈ K
hx' : x ∈ frontier K
⊢ infDist x Kᶜ = dist x x