Theorem: SimpleGraph.isTree_iff_existsUnique_path
File: Mathlib/Combinatorics/SimpleGraph/Acyclic.lean

tactic: rw [IsTree_iff, isAcyclic_iff_path_unique]
state_before: V : Type u
G : SimpleGraph V
⊢ IsTree G ↔ Nonempty V ∧ ∀ (v w : V), ∃! p, Walk.IsPath p

tactic: constructor
state_before: V : Type u
G : SimpleGraph V
⊢ (Connected G ∧ ∀ ⦃v w : V⦄ (p q : Path G v w), p = q) ↔ Nonempty V ∧ ∀ (v w : V), ∃! p, Walk.IsPath p

tactic: rintro ⟨hc, hu⟩
state_before: case mp
V : Type u
G : SimpleGraph V
⊢ (Connected G ∧ ∀ ⦃v w : V⦄ (p q : Path G v w), p = q) → Nonempty V ∧ ∀ (v w : V), ∃! p, Walk.IsPath p

tactic: refine ⟨hc.nonempty, ?_⟩
state_before: case mp.intro
V : Type u
G : SimpleGraph V
hc : Connected G
hu : ∀ ⦃v w : V⦄ (p q : Path G v w), p = q
⊢ Nonempty V ∧ ∀ (v w : V), ∃! p, Walk.IsPath p

tactic: intro v w
state_before: case mp.intro
V : Type u
G : SimpleGraph V
hc : Connected G
hu : ∀ ⦃v w : V⦄ (p q : Path G v w), p = q
⊢ ∀ (v w : V), ∃! p, Walk.IsPath p

tactic: let q := (hc v w).some.toPath
state_before: case mp.intro
V : Type u
G : SimpleGraph V
hc : Connected G
hu : ∀ ⦃v w : V⦄ (p q : Path G v w), p = q
v w : V
⊢ ∃! p, Walk.IsPath p

tactic: use q
state_before: case mp.intro
V : Type u
G : SimpleGraph V
hc : Connected G
hu : ∀ ⦃v w : V⦄ (p q : Path G v w), p = q
v w : V
q : Path G v w := Walk.toPath (Nonempty.some (_ : Reachable G v w))
⊢ ∃! p, Walk.IsPath p

tactic: simp only [true_and_iff, Path.isPath]
state_before: case mp.intro
V : Type u
G : SimpleGraph V
hc : Connected G
hu : ∀ ⦃v w : V⦄ (p q : Path G v w), p = q
v w : V
q : Path G v w := Walk.toPath (Nonempty.some (_ : Reachable G v w))
⊢ (fun p => Walk.IsPath p) ↑q ∧ ∀ (y : Walk G v w), (fun p => Walk.IsPath p) y → y = ↑q

tactic: intro p hp
state_before: case mp.intro
V : Type u
G : SimpleGraph V
hc : Connected G
hu : ∀ ⦃v w : V⦄ (p q : Path G v w), p = q
v w : V
q : Path G v w := Walk.toPath (Nonempty.some (_ : Reachable G v w))
⊢ ∀ (y : Walk G v w), Walk.IsPath y → y = ↑(Walk.toPath (Nonempty.some (_ : Reachable G v w)))

tactic: specialize hu ⟨p, hp⟩ q
state_before: case mp.intro
V : Type u
G : SimpleGraph V
hc : Connected G
hu : ∀ ⦃v w : V⦄ (p q : Path G v w), p = q
v w : V
q : Path G v w := Walk.toPath (Nonempty.some (_ : Reachable G v w))
p : Walk G v w
hp : Walk.IsPath p
⊢ p = ↑(Walk.toPath (Nonempty.some (_ : Reachable G v w)))

tactic: exact Subtype.ext_iff.mp hu
state_before: case mp.intro
V : Type u
G : SimpleGraph V
hc : Connected G
v w : V
q : Path G v w := Walk.toPath (Nonempty.some (_ : Reachable G v w))
p : Walk G v w
hp : Walk.IsPath p
hu : { val := p, property := hp } = q
⊢ p = ↑(Walk.toPath (Nonempty.some (_ : Reachable G v w)))

tactic: rintro ⟨hV, h⟩
state_before: case mpr
V : Type u
G : SimpleGraph V
⊢ (Nonempty V ∧ ∀ (v w : V), ∃! p, Walk.IsPath p) → Connected G ∧ ∀ ⦃v w : V⦄ (p q : Path G v w), p = q

tactic: refine ⟨Connected.mk ?_, ?_⟩
state_before: case mpr.intro
V : Type u
G : SimpleGraph V
hV : Nonempty V
h : ∀ (v w : V), ∃! p, Walk.IsPath p
⊢ Connected G ∧ ∀ ⦃v w : V⦄ (p q : Path G v w), p = q

tactic: intro v w
state_before: case mpr.intro.refine_1
V : Type u
G : SimpleGraph V
hV : Nonempty V
h : ∀ (v w : V), ∃! p, Walk.IsPath p
⊢ Preconnected G

tactic: obtain ⟨p, _⟩ := h v w
state_before: case mpr.intro.refine_1
V : Type u
G : SimpleGraph V
hV : Nonempty V
h : ∀ (v w : V), ∃! p, Walk.IsPath p
v w : V
⊢ Reachable G v w

tactic: exact p.reachable
state_before: case mpr.intro.refine_1.intro
V : Type u
G : SimpleGraph V
hV : Nonempty V
h : ∀ (v w : V), ∃! p, Walk.IsPath p
v w : V
p : Walk G v w
h✝ : (fun p => Walk.IsPath p) p ∧ ∀ (y : Walk G v w), (fun p => Walk.IsPath p) y → y = p
⊢ Reachable G v w

tactic: rintro v w ⟨p, hp⟩ ⟨q, hq⟩
state_before: case mpr.intro.refine_2
V : Type u
G : SimpleGraph V
hV : Nonempty V
h : ∀ (v w : V), ∃! p, Walk.IsPath p
⊢ ∀ ⦃v w : V⦄ (p q : Path G v w), p = q

tactic: simp only [ExistsUnique.unique (h v w) hp hq]
state_before: case mpr.intro.refine_2.mk.mk
V : Type u
G : SimpleGraph V
hV : Nonempty V
h : ∀ (v w : V), ∃! p, Walk.IsPath p
v w : V
p : Walk G v w
hp : Walk.IsPath p
q : Walk G v w
hq : Walk.IsPath q
⊢ { val := p, property := hp } = { val := q, property := hq }