-- Mathlib/Topology/Connected/PathConnected.lean
theorem IsPathConnected.exists_path_through_family {n : ℕ}
    {s : Set X} (h : IsPathConnected s) (p : Fin (n + 1) → X) (hp : ∀ i, p i ∈ s) :
    ∃ γ : Path (p 0) (p n), range γ ⊆ s ∧ ∀ i, p i ∈ range γ

Proof state:
case neg
X : Type u_1
inst✝ : TopologicalSpace X
s : Set X
h : IsPathConnected s
p' : ℕ → X
n : ℕ
hn : (∀ i ≤ n, p' i ∈ s) → ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s
hp' : ∀ i ≤ n + 1, p' i ∈ s
γ₀ : Path (p' 0) (p' n)
hγ₀ : (∀ i ≤ n, p' i ∈ range ⇑γ₀) ∧ range ⇑γ₀ ⊆ s
γ₁ : Path (p' n) (p' (n + 1))
hγ₁ : ∀ (t : ↑I), γ₁ t ∈ s
γ : Path (p' 0) (p' (n + 1)) := γ₀.trans γ₁
range_eq : range ⇑γ = range ⇑γ₀ ∪ range ⇑γ₁
i : ℕ
hi : i ≤ n + 1
hi' : n.succ ≤ i
⊢ p' i ∈ range ⇑γ

Tactic:
have : i = n.succ := le_antisymm hi hi'

Result:
case neg
X : Type u_1
inst✝ : TopologicalSpace X
s : Set X
h : IsPathConnected s
p' : ℕ → X
n : ℕ
hn : (∀ i ≤ n, p' i ∈ s) → ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s
hp' : ∀ i ≤ n + 1, p' i ∈ s
γ₀ : Path (p' 0) (p' n)
hγ₀ : (∀ i ≤ n, p' i ∈ range ⇑γ₀) ∧ range ⇑γ₀ ⊆ s
γ₁ : Path (p' n) (p' (n + 1))
hγ₁ : ∀ (t : ↑I), γ₁ t ∈ s
γ : Path (p' 0) (p' (n + 1)) := γ₀.trans γ₁
range_eq : range ⇑γ = range ⇑γ₀ ∪ range ⇑γ₁
i : ℕ
hi : i ≤ n + 1
hi' : n.succ ≤ i
this : i = n.succ
⊢ p' i ∈ range ⇑γ

Proof state:
case h
X : Type u_1
inst✝ : TopologicalSpace X
s : Set X
h : IsPathConnected s
p' : ℕ → X
n : ℕ
hn : (∀ i ≤ n, p' i ∈ s) → ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s
hp' : ∀ i ≤ n + 1, p' i ∈ s
γ₀ : Path (p' 0) (p' n)
hγ₀ : (∀ i ≤ n, p' i ∈ range ⇑γ₀) ∧ range ⇑γ₀ ⊆ s
γ₁ : Path (p' n) (p' (n + 1))
hγ₁ : ∀ (t : ↑I), γ₁ t ∈ s
γ : Path (p' 0) (p' (n + 1)) := γ₀.trans γ₁
range_eq : range ⇑γ = range ⇑γ₀ ∪ range ⇑γ₁
⊢ (∀ i ≤ n + 1, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s

Tactic:
constructor

Result:
case h.left
X : Type u_1
inst✝ : TopologicalSpace X
s : Set X
h : IsPathConnected s
p' : ℕ → X
n : ℕ
hn : (∀ i ≤ n, p' i ∈ s) → ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s
hp' : ∀ i ≤ n + 1, p' i ∈ s
γ₀ : Path (p' 0) (p' n)
hγ₀ : (∀ i ≤ n, p' i ∈ range ⇑γ₀) ∧ range ⇑γ₀ ⊆ s
γ₁ : Path (p' n) (p' (n + 1))
hγ₁ : ∀ (t : ↑I), γ₁ t ∈ s
γ : Path (p' 0) (p' (n + 1)) := γ₀.trans γ₁
range_eq : range ⇑γ = range ⇑γ₀ ∪ range ⇑γ₁
⊢ ∀ i ≤ n + 1, p' i ∈ range ⇑γ

case h.right
X : Type u_1
inst✝ : TopologicalSpace X
s : Set X
h : IsPathConnected s
p' : ℕ → X
n : ℕ
hn : (∀ i ≤ n, p' i ∈ s) → ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s
hp' : ∀ i ≤ n + 1, p' i ∈ s
γ₀ : Path (p' 0) (p' n)
hγ₀ : (∀ i ≤ n, p' i ∈ range ⇑γ₀) ∧ range ⇑γ₀ ⊆ s
γ₁ : Path (p' n) (p' (n + 1))
hγ₁ : ∀ (t : ↑I), γ₁ t ∈ s
γ : Path (p' 0) (p' (n + 1)) := γ₀.trans γ₁
range_eq : range ⇑γ = range ⇑γ₀ ∪ range ⇑γ₁
⊢ range ⇑γ ⊆ s

Proof state:
X : Type u_1
inst✝ : TopologicalSpace X
n : ℕ
s : Set X
h : IsPathConnected s
p : Fin (n + 1) → X
hp : ∀ (i : Fin (n + 1)), p i ∈ s
p' : ℕ → X
hp' : ∀ i ≤ n, p' i ∈ s
⊢ ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s

Tactic:
clear hp p

Result:
X : Type u_1
inst✝ : TopologicalSpace X
n : ℕ
s : Set X
h : IsPathConnected s
p' : ℕ → X
hp' : ∀ i ≤ n, p' i ∈ s
⊢ ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s

Proof state:
case h.right
X : Type u_1
inst✝ : TopologicalSpace X
s : Set X
h : IsPathConnected s
p' : ℕ → X
hp' : ∀ i ≤ 0, p' i ∈ s
⊢ ∀ (y : ↑I), (Path.refl (p' 0)) y ∈ s

Tactic:
rintro _x

Result:
case h.right
X : Type u_1
inst✝ : TopologicalSpace X
s : Set X
h : IsPathConnected s
p' : ℕ → X
hp' : ∀ i ≤ 0, p' i ∈ s
_x : ↑I
⊢ (Path.refl (p' 0)) _x ∈ s

Proof state:
case h
X : Type u_1
inst✝ : TopologicalSpace X
n : ℕ
s : Set X
h : IsPathConnected s
p : Fin (n + 1) → X
hp : ∀ (i : Fin (n + 1)), p i ∈ s
p' : ℕ → X := fun k => if h : k < n + 1 then p ⟨k, h⟩ else p ⟨0, ⋯⟩
γ : Path (p' 0) (p' n)
hγ : (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s
hpp' : ∀ k < n + 1, p ↑k = p' k
⊢ range ⇑(γ.cast ⋯ ⋯) ⊆ s ∧ ∀ (i : Fin (n + 1)), p i ∈ range ⇑(γ.cast ⋯ ⋯)

Tactic:
simp only [γ.cast_coe]

Result:
case h
X : Type u_1
inst✝ : TopologicalSpace X
n : ℕ
s : Set X
h : IsPathConnected s
p : Fin (n + 1) → X
hp : ∀ (i : Fin (n + 1)), p i ∈ s
p' : ℕ → X := fun k => if h : k < n + 1 then p ⟨k, h⟩ else p ⟨0, ⋯⟩
γ : Path (p' 0) (p' n)
hγ : (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s
hpp' : ∀ k < n + 1, p ↑k = p' k
⊢ range ⇑γ ⊆ s ∧ ∀ (i : Fin (n + 1)), p i ∈ range ⇑γ

Proof state:
X : Type u_1
inst✝ : TopologicalSpace X
n : ℕ
s : Set X
h : IsPathConnected s
p : Fin (n + 1) → X
hp : ∀ (i : Fin (n + 1)), p i ∈ s
p' : ℕ → X := fun k => if h : k < n + 1 then p ⟨k, h⟩ else p ⟨0, ⋯⟩
hp' : ∀ i ≤ n, p' i ∈ s
⊢ ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s

Tactic:
clear_value p'

Result:
X : Type u_1
inst✝ : TopologicalSpace X
n : ℕ
s : Set X
h : IsPathConnected s
p : Fin (n + 1) → X
hp : ∀ (i : Fin (n + 1)), p i ∈ s
p' : ℕ → X
hp' : ∀ i ≤ n, p' i ∈ s
⊢ ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s

Proof state:
case h.left
X : Type u_1
inst✝ : TopologicalSpace X
s : Set X
h : IsPathConnected s
p' : ℕ → X
n : ℕ
hn : (∀ i ≤ n, p' i ∈ s) → ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s
hp' : ∀ i ≤ n + 1, p' i ∈ s
γ₀ : Path (p' 0) (p' n)
hγ₀ : (∀ i ≤ n, p' i ∈ range ⇑γ₀) ∧ range ⇑γ₀ ⊆ s
γ₁ : Path (p' n) (p' (n + 1))
hγ₁ : ∀ (t : ↑I), γ₁ t ∈ s
γ : Path (p' 0) (p' (n + 1)) := γ₀.trans γ₁
range_eq : range ⇑γ = range ⇑γ₀ ∪ range ⇑γ₁
i : ℕ
hi : i ≤ n + 1
⊢ p' i ∈ range ⇑γ

Tactic:
by_cases hi' : i ≤ n

Result:
case pos
X : Type u_1
inst✝ : TopologicalSpace X
s : Set X
h : IsPathConnected s
p' : ℕ → X
n : ℕ
hn : (∀ i ≤ n, p' i ∈ s) → ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s
hp' : ∀ i ≤ n + 1, p' i ∈ s
γ₀ : Path (p' 0) (p' n)
hγ₀ : (∀ i ≤ n, p' i ∈ range ⇑γ₀) ∧ range ⇑γ₀ ⊆ s
γ₁ : Path (p' n) (p' (n + 1))
hγ₁ : ∀ (t : ↑I), γ₁ t ∈ s
γ : Path (p' 0) (p' (n + 1)) := γ₀.trans γ₁
range_eq : range ⇑γ = range ⇑γ₀ ∪ range ⇑γ₁
i : ℕ
hi : i ≤ n + 1
hi' : i ≤ n
⊢ p' i ∈ range ⇑γ

case neg
X : Type u_1
inst✝ : TopologicalSpace X
s : Set X
h : IsPathConnected s
p' : ℕ → X
n : ℕ
hn : (∀ i ≤ n, p' i ∈ s) → ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s
hp' : ∀ i ≤ n + 1, p' i ∈ s
γ₀ : Path (p' 0) (p' n)
hγ₀ : (∀ i ≤ n, p' i ∈ range ⇑γ₀) ∧ range ⇑γ₀ ⊆ s
γ₁ : Path (p' n) (p' (n + 1))
hγ₁ : ∀ (t : ↑I), γ₁ t ∈ s
γ : Path (p' 0) (p' (n + 1)) := γ₀.trans γ₁
range_eq : range ⇑γ = range ⇑γ₀ ∪ range ⇑γ₁
i : ℕ
hi : i ≤ n + 1
hi' : ¬i ≤ n
⊢ p' i ∈ range ⇑γ

Proof state:
case neg
X : Type u_1
inst✝ : TopologicalSpace X
s : Set X
h : IsPathConnected s
p' : ℕ → X
n : ℕ
hn : (∀ i ≤ n, p' i ∈ s) → ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s
hp' : ∀ i ≤ n + 1, p' i ∈ s
γ₀ : Path (p' 0) (p' n)
hγ₀ : (∀ i ≤ n, p' i ∈ range ⇑γ₀) ∧ range ⇑γ₀ ⊆ s
γ₁ : Path (p' n) (p' (n + 1))
hγ₁ : ∀ (t : ↑I), γ₁ t ∈ s
γ : Path (p' 0) (p' (n + 1)) := γ₀.trans γ₁
range_eq : range ⇑γ = range ⇑γ₀ ∪ range ⇑γ₁
i : ℕ
hi : i ≤ n + 1
hi' : n.succ ≤ i
this : i = n.succ
⊢ p' n.succ ∈ range ⇑γ

Tactic:
use 1

Result:
case h
X : Type u_1
inst✝ : TopologicalSpace X
s : Set X
h : IsPathConnected s
p' : ℕ → X
n : ℕ
hn : (∀ i ≤ n, p' i ∈ s) → ∃ γ, (∀ i ≤ n, p' i ∈ range ⇑γ) ∧ range ⇑γ ⊆ s
hp' : ∀ i ≤ n + 1, p' i ∈ s
γ₀ : Path (p' 0) (p' n)
hγ₀ : (∀ i ≤ n, p' i ∈ range ⇑γ₀) ∧ range ⇑γ₀ ⊆ s
γ₁ : Path (p' n) (p' (n + 1))
hγ₁ : ∀ (t : ↑I), γ₁ t ∈ s
γ : Path (p' 0) (p' (n + 1)) := γ₀.trans γ₁
range_eq : range ⇑γ = range ⇑γ₀ ∪ range ⇑γ₁
i : ℕ
hi : i ≤ n + 1
hi' : n.succ ≤ i
this : i = n.succ
⊢ γ 1 = p' n.succ