l3lab/ntp-mathlib huggingface dataset:
@[ext]
theorem ComponentCompl.supp_injective :
    Function.Injective (ComponentCompl.supp : G.ComponentCompl K → Set V) := by
  refine' ConnectedComponent.ind₂ _
  rintro ⟨v, hv⟩ ⟨w, hw⟩ h
  simp only [Set.ext_iff, ConnectedComponent.eq, Set.mem_setOf_eq, ComponentCompl.supp] at h ⊢
  

Proof state:
case mk.mk
V : Type u
G : SimpleGraph V
K L L' M : Set V
v : V
hv : v ∈ Kᶜ
w : V
hw : w ∈ Kᶜ
h :
  ∀ (x : V),
    (∃ (h : x ∉ K), Reachable (induce Kᶜ G) { val := x, property := (_ : x ∉ K) } { val := v, property := hv }) ↔
      ∃ (h : x ∉ K), Reachable (induce Kᶜ G) { val := x, property := (_ : x ∉ K) } { val := w, property := hw }
⊢ Reachable (induce Kᶜ G) { val := v, property := hv } { val := w, property := hw }

Next tactic:
exact ((h v).mp ⟨hv, Reachable.refl _⟩).choose_spec
theorem componentComplMk_eq_of_adj (G : SimpleGraph V) {v w : V} (vK : v ∉ K) (wK : w ∉ K)
    (a : G.Adj v w) : G.componentComplMk vK = G.componentComplMk wK := by
  

Proof state:
V : Type u
G✝ : SimpleGraph V
K L L' M : Set V
G : SimpleGraph V
v w : V
vK : v ∉ K
wK : w ∉ K
a : Adj G v w
⊢ componentComplMk G vK = componentComplMk G wK

Next tactic:
rw [ConnectedComponent.eq]
theorem componentComplMk_eq_of_adj (G : SimpleGraph V) {v w : V} (vK : v ∉ K) (wK : w ∉ K)
    (a : G.Adj v w) : G.componentComplMk vK = G.componentComplMk wK := by
  rw [ConnectedComponent.eq]
  

Proof state:
V : Type u
G✝ : SimpleGraph V
K L L' M : Set V
G : SimpleGraph V
v w : V
vK : v ∉ K
wK : w ∉ K
a : Adj G v w
⊢ Reachable (induce Kᶜ G) { val := v, property := vK } { val := w, property := wK }

Next tactic:
apply Adj.reachable
theorem componentComplMk_eq_of_adj (G : SimpleGraph V) {v w : V} (vK : v ∉ K) (wK : w ∉ K)
    (a : G.Adj v w) : G.componentComplMk vK = G.componentComplMk wK := by
  rw [ConnectedComponent.eq]
  apply Adj.reachable
  

Proof state:
case h
V : Type u
G✝ : SimpleGraph V
K L L' M : Set V
G : SimpleGraph V
v w : V
vK : v ∉ K
wK : w ∉ K
a : Adj G v w
⊢ Adj (induce Kᶜ G) { val := v, property := vK } { val := w, property := wK }

Next tactic:
exact a
/-- A `ComponentCompl` specialization of `Quot.lift`, where soundness has to be proved only
for adjacent vertices.
-/
protected def lift {β : Sort*} (f : ∀ ⦃v⦄ (_ : v ∉ K), β)
    (h : ∀ ⦃v w⦄ (hv : v ∉ K) (hw : w ∉ K), G.Adj v w → f hv = f hw) : G.ComponentCompl K → β :=
  ConnectedComponent.lift (fun vv => f vv.prop) fun v w p => by
    

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
β : Sort u_1
f : ⦃v : V⦄ → v ∉ K → β
h : ∀ ⦃v w : V⦄ (hv : v ∉ K) (hw : w ∉ K), Adj G v w → f hv = f hw
v w : ↑Kᶜ
p : Walk (induce Kᶜ G) v w
⊢ Walk.IsPath p → (fun vv => f (_ : ↑vv ∈ Kᶜ)) v = (fun vv => f (_ : ↑vv ∈ Kᶜ)) w

Next tactic:
induction' p with _ u v w a q ih
/-- A `ComponentCompl` specialization of `Quot.lift`, where soundness has to be proved only
for adjacent vertices.
-/
protected def lift {β : Sort*} (f : ∀ ⦃v⦄ (_ : v ∉ K), β)
    (h : ∀ ⦃v w⦄ (hv : v ∉ K) (hw : w ∉ K), G.Adj v w → f hv = f hw) : G.ComponentCompl K → β :=
  ConnectedComponent.lift (fun vv => f vv.prop) fun v w p => by
    induction' p with _ u v w a q ih
    · 

Proof state:
case nil
V : Type u
G : SimpleGraph V
K L L' M : Set V
β : Sort u_1
f : ⦃v : V⦄ → v ∉ K → β
h : ∀ ⦃v w : V⦄ (hv : v ∉ K) (hw : w ∉ K), Adj G v w → f hv = f hw
v w u✝ : ↑Kᶜ
⊢ Walk.IsPath Walk.nil → (fun vv => f (_ : ↑vv ∈ Kᶜ)) u✝ = (fun vv => f (_ : ↑vv ∈ Kᶜ)) u✝

Next tactic:
rintro _
/-- A `ComponentCompl` specialization of `Quot.lift`, where soundness has to be proved only
for adjacent vertices.
-/
protected def lift {β : Sort*} (f : ∀ ⦃v⦄ (_ : v ∉ K), β)
    (h : ∀ ⦃v w⦄ (hv : v ∉ K) (hw : w ∉ K), G.Adj v w → f hv = f hw) : G.ComponentCompl K → β :=
  ConnectedComponent.lift (fun vv => f vv.prop) fun v w p => by
    induction' p with _ u v w a q ih
    · rintro _
      

Proof state:
case nil
V : Type u
G : SimpleGraph V
K L L' M : Set V
β : Sort u_1
f : ⦃v : V⦄ → v ∉ K → β
h : ∀ ⦃v w : V⦄ (hv : v ∉ K) (hw : w ∉ K), Adj G v w → f hv = f hw
v w u✝ : ↑Kᶜ
a✝ : Walk.IsPath Walk.nil
⊢ (fun vv => f (_ : ↑vv ∈ Kᶜ)) u✝ = (fun vv => f (_ : ↑vv ∈ Kᶜ)) u✝

Next tactic:
rfl
/-- A `ComponentCompl` specialization of `Quot.lift`, where soundness has to be proved only
for adjacent vertices.
-/
protected def lift {β : Sort*} (f : ∀ ⦃v⦄ (_ : v ∉ K), β)
    (h : ∀ ⦃v w⦄ (hv : v ∉ K) (hw : w ∉ K), G.Adj v w → f hv = f hw) : G.ComponentCompl K → β :=
  ConnectedComponent.lift (fun vv => f vv.prop) fun v w p => by
    induction' p with _ u v w a q ih
    · rintro _
      rfl
    · 

Proof state:
case cons
V : Type u
G : SimpleGraph V
K L L' M : Set V
β : Sort u_1
f : ⦃v : V⦄ → v ∉ K → β
h : ∀ ⦃v w : V⦄ (hv : v ∉ K) (hw : w ∉ K), Adj G v w → f hv = f hw
v✝ w✝ u v w : ↑Kᶜ
a : Adj (induce Kᶜ G) u v
q : Walk (induce Kᶜ G) v w
ih : Walk.IsPath q → (fun vv => f (_ : ↑vv ∈ Kᶜ)) v = (fun vv => f (_ : ↑vv ∈ Kᶜ)) w
⊢ Walk.IsPath (Walk.cons a q) → (fun vv => f (_ : ↑vv ∈ Kᶜ)) u = (fun vv => f (_ : ↑vv ∈ Kᶜ)) w

Next tactic:
rintro h'
/-- A `ComponentCompl` specialization of `Quot.lift`, where soundness has to be proved only
for adjacent vertices.
-/
protected def lift {β : Sort*} (f : ∀ ⦃v⦄ (_ : v ∉ K), β)
    (h : ∀ ⦃v w⦄ (hv : v ∉ K) (hw : w ∉ K), G.Adj v w → f hv = f hw) : G.ComponentCompl K → β :=
  ConnectedComponent.lift (fun vv => f vv.prop) fun v w p => by
    induction' p with _ u v w a q ih
    · rintro _
      rfl
    · rintro h'
      

Proof state:
case cons
V : Type u
G : SimpleGraph V
K L L' M : Set V
β : Sort u_1
f : ⦃v : V⦄ → v ∉ K → β
h : ∀ ⦃v w : V⦄ (hv : v ∉ K) (hw : w ∉ K), Adj G v w → f hv = f hw
v✝ w✝ u v w : ↑Kᶜ
a : Adj (induce Kᶜ G) u v
q : Walk (induce Kᶜ G) v w
ih : Walk.IsPath q → (fun vv => f (_ : ↑vv ∈ Kᶜ)) v = (fun vv => f (_ : ↑vv ∈ Kᶜ)) w
h' : Walk.IsPath (Walk.cons a q)
⊢ (fun vv => f (_ : ↑vv ∈ Kᶜ)) u = (fun vv => f (_ : ↑vv ∈ Kᶜ)) w

Next tactic:
exact (h u.prop v.prop a).trans (ih h'.of_cons)
@[elab_as_elim] -- Porting note: added
protected theorem ind {β : G.ComponentCompl K → Prop}
    (f : ∀ ⦃v⦄ (hv : v ∉ K), β (G.componentComplMk hv)) : ∀ C : G.ComponentCompl K, β C := by
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
β : ComponentCompl G K → Prop
f : ∀ ⦃v : V⦄ (hv : v ∉ K), β (componentComplMk G hv)
⊢ ∀ (C : ComponentCompl G K), β C

Next tactic:
apply ConnectedComponent.ind
@[elab_as_elim] -- Porting note: added
protected theorem ind {β : G.ComponentCompl K → Prop}
    (f : ∀ ⦃v⦄ (hv : v ∉ K), β (G.componentComplMk hv)) : ∀ C : G.ComponentCompl K, β C := by
  apply ConnectedComponent.ind
  

Proof state:
case h
V : Type u
G : SimpleGraph V
K L L' M : Set V
β : ComponentCompl G K → Prop
f : ∀ ⦃v : V⦄ (hv : v ∉ K), β (componentComplMk G hv)
⊢ ∀ (v : ↑Kᶜ), β (connectedComponentMk (induce Kᶜ G) v)

Next tactic:
exact fun ⟨v, vnK⟩ => f vnK
protected theorem disjoint_right (C : G.ComponentCompl K) : Disjoint K C := by
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
C : ComponentCompl G K
⊢ Disjoint K ↑C

Next tactic:
rw [Set.disjoint_iff]
protected theorem disjoint_right (C : G.ComponentCompl K) : Disjoint K C := by
  rw [Set.disjoint_iff]
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
C : ComponentCompl G K
⊢ K ∩ ↑C ⊆ ∅

Next tactic:
exact fun v ⟨vK, vC⟩ => vC.choose vK
protected theorem pairwise_disjoint :
    Pairwise fun C D : G.ComponentCompl K => Disjoint (C : Set V) (D : Set V) := by
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
⊢ Pairwise fun C D => Disjoint ↑C ↑D

Next tactic:
rintro C D ne
protected theorem pairwise_disjoint :
    Pairwise fun C D : G.ComponentCompl K => Disjoint (C : Set V) (D : Set V) := by
  rintro C D ne
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
C D : ComponentCompl G K
ne : C ≠ D
⊢ Disjoint ↑C ↑D

Next tactic:
rw [Set.disjoint_iff]
protected theorem pairwise_disjoint :
    Pairwise fun C D : G.ComponentCompl K => Disjoint (C : Set V) (D : Set V) := by
  rintro C D ne
  rw [Set.disjoint_iff]
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
C D : ComponentCompl G K
ne : C ≠ D
⊢ ↑C ∩ ↑D ⊆ ∅

Next tactic:
exact fun u ⟨uC, uD⟩ => ne (uC.choose_spec.symm.trans uD.choose_spec)
/-- Any vertex adjacent to a vertex of `C` and not lying in `K` must lie in `C`.
-/
theorem mem_of_adj : ∀ {C : G.ComponentCompl K} (c d : V), c ∈ C → d ∉ K → G.Adj c d → d ∈ C :=
  fun {C} c d ⟨cnK, h⟩ dnK cd =>
  ⟨dnK, by
    

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
C : ComponentCompl G K
c d : V
x✝ : c ∈ C
dnK : d ∉ K
cd : Adj G c d
cnK : c ∉ K
h : componentComplMk G cnK = C
⊢ componentComplMk G dnK = C

Next tactic:
rw [← h, ConnectedComponent.eq]
/-- Any vertex adjacent to a vertex of `C` and not lying in `K` must lie in `C`.
-/
theorem mem_of_adj : ∀ {C : G.ComponentCompl K} (c d : V), c ∈ C → d ∉ K → G.Adj c d → d ∈ C :=
  fun {C} c d ⟨cnK, h⟩ dnK cd =>
  ⟨dnK, by
    rw [← h, ConnectedComponent.eq]
    

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
C : ComponentCompl G K
c d : V
x✝ : c ∈ C
dnK : d ∉ K
cd : Adj G c d
cnK : c ∉ K
h : componentComplMk G cnK = C
⊢ Reachable (induce Kᶜ G) { val := d, property := dnK } { val := c, property := cnK }

Next tactic:
exact Adj.reachable cd.symm
/--
Assuming `G` is preconnected and `K` not empty, given any connected component `C` outside of `K`,
there exists a vertex `k ∈ K` adjacent to a vertex `v ∈ C`.
-/
theorem exists_adj_boundary_pair (Gc : G.Preconnected) (hK : K.Nonempty) :
    ∀ C : G.ComponentCompl K, ∃ ck : V × V, ck.1 ∈ C ∧ ck.2 ∈ K ∧ G.Adj ck.1 ck.2 := by
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
Gc : Preconnected G
hK : Set.Nonempty K
⊢ ∀ (C : ComponentCompl G K), ∃ ck, ck.1 ∈ C ∧ ck.2 ∈ K ∧ Adj G ck.1 ck.2

Next tactic:
refine' ComponentCompl.ind fun v vnK => _
/--
Assuming `G` is preconnected and `K` not empty, given any connected component `C` outside of `K`,
there exists a vertex `k ∈ K` adjacent to a vertex `v ∈ C`.
-/
theorem exists_adj_boundary_pair (Gc : G.Preconnected) (hK : K.Nonempty) :
    ∀ C : G.ComponentCompl K, ∃ ck : V × V, ck.1 ∈ C ∧ ck.2 ∈ K ∧ G.Adj ck.1 ck.2 := by
  refine' ComponentCompl.ind fun v vnK => _
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
Gc : Preconnected G
hK : Set.Nonempty K
v : V
vnK : v ∉ K
⊢ ∃ ck, ck.1 ∈ componentComplMk G vnK ∧ ck.2 ∈ K ∧ Adj G ck.1 ck.2

Next tactic:
let C : G.ComponentCompl K := G.componentComplMk vnK
/--
Assuming `G` is preconnected and `K` not empty, given any connected component `C` outside of `K`,
there exists a vertex `k ∈ K` adjacent to a vertex `v ∈ C`.
-/
theorem exists_adj_boundary_pair (Gc : G.Preconnected) (hK : K.Nonempty) :
    ∀ C : G.ComponentCompl K, ∃ ck : V × V, ck.1 ∈ C ∧ ck.2 ∈ K ∧ G.Adj ck.1 ck.2 := by
  refine' ComponentCompl.ind fun v vnK => _
  let C : G.ComponentCompl K := G.componentComplMk vnK
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
Gc : Preconnected G
hK : Set.Nonempty K
v : V
vnK : v ∉ K
C : ComponentCompl G K := componentComplMk G vnK
⊢ ∃ ck, ck.1 ∈ componentComplMk G vnK ∧ ck.2 ∈ K ∧ Adj G ck.1 ck.2

Next tactic:
let dis := Set.disjoint_iff.mp C.disjoint_right
/--
Assuming `G` is preconnected and `K` not empty, given any connected component `C` outside of `K`,
there exists a vertex `k ∈ K` adjacent to a vertex `v ∈ C`.
-/
theorem exists_adj_boundary_pair (Gc : G.Preconnected) (hK : K.Nonempty) :
    ∀ C : G.ComponentCompl K, ∃ ck : V × V, ck.1 ∈ C ∧ ck.2 ∈ K ∧ G.Adj ck.1 ck.2 := by
  refine' ComponentCompl.ind fun v vnK => _
  let C : G.ComponentCompl K := G.componentComplMk vnK
  let dis := Set.disjoint_iff.mp C.disjoint_right
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
Gc : Preconnected G
hK : Set.Nonempty K
v : V
vnK : v ∉ K
C : ComponentCompl G K := componentComplMk G vnK
dis : K ∩ ↑C ⊆ ∅ := Set.disjoint_iff.mp (ComponentCompl.disjoint_right C)
⊢ ∃ ck, ck.1 ∈ componentComplMk G vnK ∧ ck.2 ∈ K ∧ Adj G ck.1 ck.2

Next tactic:
by_contra! h
/--
Assuming `G` is preconnected and `K` not empty, given any connected component `C` outside of `K`,
there exists a vertex `k ∈ K` adjacent to a vertex `v ∈ C`.
-/
theorem exists_adj_boundary_pair (Gc : G.Preconnected) (hK : K.Nonempty) :
    ∀ C : G.ComponentCompl K, ∃ ck : V × V, ck.1 ∈ C ∧ ck.2 ∈ K ∧ G.Adj ck.1 ck.2 := by
  refine' ComponentCompl.ind fun v vnK => _
  let C : G.ComponentCompl K := G.componentComplMk vnK
  let dis := Set.disjoint_iff.mp C.disjoint_right
  by_contra! h
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
Gc : Preconnected G
hK : Set.Nonempty K
v : V
vnK : v ∉ K
C : ComponentCompl G K := componentComplMk G vnK
dis : K ∩ ↑C ⊆ ∅ := Set.disjoint_iff.mp (ComponentCompl.disjoint_right C)
h : ∀ (ck : V × V), ck.1 ∈ componentComplMk G vnK → ck.2 ∈ K → ¬Adj G ck.1 ck.2
⊢ False

Next tactic:
suffices Set.univ = (C : Set V) by exact dis ⟨hK.choose_spec, this ▸ Set.mem_univ hK.some⟩
/--
Assuming `G` is preconnected and `K` not empty, given any connected component `C` outside of `K`,
there exists a vertex `k ∈ K` adjacent to a vertex `v ∈ C`.
-/
theorem exists_adj_boundary_pair (Gc : G.Preconnected) (hK : K.Nonempty) :
    ∀ C : G.ComponentCompl K, ∃ ck : V × V, ck.1 ∈ C ∧ ck.2 ∈ K ∧ G.Adj ck.1 ck.2 := by
  refine' ComponentCompl.ind fun v vnK => _
  let C : G.ComponentCompl K := G.componentComplMk vnK
  let dis := Set.disjoint_iff.mp C.disjoint_right
  by_contra! h
  suffices Set.univ = (C : Set V) by 

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
Gc : Preconnected G
hK : Set.Nonempty K
v : V
vnK : v ∉ K
C : ComponentCompl G K := componentComplMk G vnK
dis : K ∩ ↑C ⊆ ∅ := Set.disjoint_iff.mp (ComponentCompl.disjoint_right C)
h : ∀ (ck : V × V), ck.1 ∈ componentComplMk G vnK → ck.2 ∈ K → ¬Adj G ck.1 ck.2
this : Set.univ = ↑C
⊢ False

Next tactic:
exact dis ⟨hK.choose_spec, this ▸ Set.mem_univ hK.some⟩
/--
Assuming `G` is preconnected and `K` not empty, given any connected component `C` outside of `K`,
there exists a vertex `k ∈ K` adjacent to a vertex `v ∈ C`.
-/
theorem exists_adj_boundary_pair (Gc : G.Preconnected) (hK : K.Nonempty) :
    ∀ C : G.ComponentCompl K, ∃ ck : V × V, ck.1 ∈ C ∧ ck.2 ∈ K ∧ G.Adj ck.1 ck.2 := by
  refine' ComponentCompl.ind fun v vnK => _
  let C : G.ComponentCompl K := G.componentComplMk vnK
  let dis := Set.disjoint_iff.mp C.disjoint_right
  by_contra! h
  suffices Set.univ = (C : Set V) by exact dis ⟨hK.choose_spec, this ▸ Set.mem_univ hK.some⟩
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
Gc : Preconnected G
hK : Set.Nonempty K
v : V
vnK : v ∉ K
C : ComponentCompl G K := componentComplMk G vnK
dis : K ∩ ↑C ⊆ ∅ := Set.disjoint_iff.mp (ComponentCompl.disjoint_right C)
h : ∀ (ck : V × V), ck.1 ∈ componentComplMk G vnK → ck.2 ∈ K → ¬Adj G ck.1 ck.2
⊢ Set.univ = ↑C

Next tactic:
symm
/--
Assuming `G` is preconnected and `K` not empty, given any connected component `C` outside of `K`,
there exists a vertex `k ∈ K` adjacent to a vertex `v ∈ C`.
-/
theorem exists_adj_boundary_pair (Gc : G.Preconnected) (hK : K.Nonempty) :
    ∀ C : G.ComponentCompl K, ∃ ck : V × V, ck.1 ∈ C ∧ ck.2 ∈ K ∧ G.Adj ck.1 ck.2 := by
  refine' ComponentCompl.ind fun v vnK => _
  let C : G.ComponentCompl K := G.componentComplMk vnK
  let dis := Set.disjoint_iff.mp C.disjoint_right
  by_contra! h
  suffices Set.univ = (C : Set V) by exact dis ⟨hK.choose_spec, this ▸ Set.mem_univ hK.some⟩
  symm
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
Gc : Preconnected G
hK : Set.Nonempty K
v : V
vnK : v ∉ K
C : ComponentCompl G K := componentComplMk G vnK
dis : K ∩ ↑C ⊆ ∅ := Set.disjoint_iff.mp (ComponentCompl.disjoint_right C)
h : ∀ (ck : V × V), ck.1 ∈ componentComplMk G vnK → ck.2 ∈ K → ¬Adj G ck.1 ck.2
⊢ ↑C = Set.univ

Next tactic:
rw [Set.eq_univ_iff_forall]
/--
Assuming `G` is preconnected and `K` not empty, given any connected component `C` outside of `K`,
there exists a vertex `k ∈ K` adjacent to a vertex `v ∈ C`.
-/
theorem exists_adj_boundary_pair (Gc : G.Preconnected) (hK : K.Nonempty) :
    ∀ C : G.ComponentCompl K, ∃ ck : V × V, ck.1 ∈ C ∧ ck.2 ∈ K ∧ G.Adj ck.1 ck.2 := by
  refine' ComponentCompl.ind fun v vnK => _
  let C : G.ComponentCompl K := G.componentComplMk vnK
  let dis := Set.disjoint_iff.mp C.disjoint_right
  by_contra! h
  suffices Set.univ = (C : Set V) by exact dis ⟨hK.choose_spec, this ▸ Set.mem_univ hK.some⟩
  symm
  rw [Set.eq_univ_iff_forall]
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
Gc : Preconnected G
hK : Set.Nonempty K
v : V
vnK : v ∉ K
C : ComponentCompl G K := componentComplMk G vnK
dis : K ∩ ↑C ⊆ ∅ := Set.disjoint_iff.mp (ComponentCompl.disjoint_right C)
h : ∀ (ck : V × V), ck.1 ∈ componentComplMk G vnK → ck.2 ∈ K → ¬Adj G ck.1 ck.2
⊢ ∀ (x : V), x ∈ ↑C

Next tactic:
rintro u
/--
Assuming `G` is preconnected and `K` not empty, given any connected component `C` outside of `K`,
there exists a vertex `k ∈ K` adjacent to a vertex `v ∈ C`.
-/
theorem exists_adj_boundary_pair (Gc : G.Preconnected) (hK : K.Nonempty) :
    ∀ C : G.ComponentCompl K, ∃ ck : V × V, ck.1 ∈ C ∧ ck.2 ∈ K ∧ G.Adj ck.1 ck.2 := by
  refine' ComponentCompl.ind fun v vnK => _
  let C : G.ComponentCompl K := G.componentComplMk vnK
  let dis := Set.disjoint_iff.mp C.disjoint_right
  by_contra! h
  suffices Set.univ = (C : Set V) by exact dis ⟨hK.choose_spec, this ▸ Set.mem_univ hK.some⟩
  symm
  rw [Set.eq_univ_iff_forall]
  rintro u
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
Gc : Preconnected G
hK : Set.Nonempty K
v : V
vnK : v ∉ K
C : ComponentCompl G K := componentComplMk G vnK
dis : K ∩ ↑C ⊆ ∅ := Set.disjoint_iff.mp (ComponentCompl.disjoint_right C)
h : ∀ (ck : V × V), ck.1 ∈ componentComplMk G vnK → ck.2 ∈ K → ¬Adj G ck.1 ck.2
u : V
⊢ u ∈ ↑C

Next tactic:
by_contra unC
/--
Assuming `G` is preconnected and `K` not empty, given any connected component `C` outside of `K`,
there exists a vertex `k ∈ K` adjacent to a vertex `v ∈ C`.
-/
theorem exists_adj_boundary_pair (Gc : G.Preconnected) (hK : K.Nonempty) :
    ∀ C : G.ComponentCompl K, ∃ ck : V × V, ck.1 ∈ C ∧ ck.2 ∈ K ∧ G.Adj ck.1 ck.2 := by
  refine' ComponentCompl.ind fun v vnK => _
  let C : G.ComponentCompl K := G.componentComplMk vnK
  let dis := Set.disjoint_iff.mp C.disjoint_right
  by_contra! h
  suffices Set.univ = (C : Set V) by exact dis ⟨hK.choose_spec, this ▸ Set.mem_univ hK.some⟩
  symm
  rw [Set.eq_univ_iff_forall]
  rintro u
  by_contra unC
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
Gc : Preconnected G
hK : Set.Nonempty K
v : V
vnK : v ∉ K
C : ComponentCompl G K := componentComplMk G vnK
dis : K ∩ ↑C ⊆ ∅ := Set.disjoint_iff.mp (ComponentCompl.disjoint_right C)
h : ∀ (ck : V × V), ck.1 ∈ componentComplMk G vnK → ck.2 ∈ K → ¬Adj G ck.1 ck.2
u : V
unC : u ∉ ↑C
⊢ False

Next tactic:
obtain ⟨p⟩ := Gc v u
/--
Assuming `G` is preconnected and `K` not empty, given any connected component `C` outside of `K`,
there exists a vertex `k ∈ K` adjacent to a vertex `v ∈ C`.
-/
theorem exists_adj_boundary_pair (Gc : G.Preconnected) (hK : K.Nonempty) :
    ∀ C : G.ComponentCompl K, ∃ ck : V × V, ck.1 ∈ C ∧ ck.2 ∈ K ∧ G.Adj ck.1 ck.2 := by
  refine' ComponentCompl.ind fun v vnK => _
  let C : G.ComponentCompl K := G.componentComplMk vnK
  let dis := Set.disjoint_iff.mp C.disjoint_right
  by_contra! h
  suffices Set.univ = (C : Set V) by exact dis ⟨hK.choose_spec, this ▸ Set.mem_univ hK.some⟩
  symm
  rw [Set.eq_univ_iff_forall]
  rintro u
  by_contra unC
  obtain ⟨p⟩ := Gc v u
  

Proof state:
case intro
V : Type u
G : SimpleGraph V
K L L' M : Set V
Gc : Preconnected G
hK : Set.Nonempty K
v : V
vnK : v ∉ K
C : ComponentCompl G K := componentComplMk G vnK
dis : K ∩ ↑C ⊆ ∅ := Set.disjoint_iff.mp (ComponentCompl.disjoint_right C)
h : ∀ (ck : V × V), ck.1 ∈ componentComplMk G vnK → ck.2 ∈ K → ¬Adj G ck.1 ck.2
u : V
unC : u ∉ ↑C
p : Walk G v u
⊢ False

Next tactic:
obtain ⟨⟨⟨x, y⟩, xy⟩, -, xC, ynC⟩ :=
    p.exists_boundary_dart (C : Set V) (G.componentComplMk_mem vnK) unC
/--
Assuming `G` is preconnected and `K` not empty, given any connected component `C` outside of `K`,
there exists a vertex `k ∈ K` adjacent to a vertex `v ∈ C`.
-/
theorem exists_adj_boundary_pair (Gc : G.Preconnected) (hK : K.Nonempty) :
    ∀ C : G.ComponentCompl K, ∃ ck : V × V, ck.1 ∈ C ∧ ck.2 ∈ K ∧ G.Adj ck.1 ck.2 := by
  refine' ComponentCompl.ind fun v vnK => _
  let C : G.ComponentCompl K := G.componentComplMk vnK
  let dis := Set.disjoint_iff.mp C.disjoint_right
  by_contra! h
  suffices Set.univ = (C : Set V) by exact dis ⟨hK.choose_spec, this ▸ Set.mem_univ hK.some⟩
  symm
  rw [Set.eq_univ_iff_forall]
  rintro u
  by_contra unC
  obtain ⟨p⟩ := Gc v u
  obtain ⟨⟨⟨x, y⟩, xy⟩, -, xC, ynC⟩ :=
    p.exists_boundary_dart (C : Set V) (G.componentComplMk_mem vnK) unC
  

Proof state:
case intro.intro.mk.mk.intro.intro
V : Type u
G : SimpleGraph V
K L L' M : Set V
Gc : Preconnected G
hK : Set.Nonempty K
v : V
vnK : v ∉ K
C : ComponentCompl G K := componentComplMk G vnK
dis : K ∩ ↑C ⊆ ∅ := Set.disjoint_iff.mp (ComponentCompl.disjoint_right C)
h : ∀ (ck : V × V), ck.1 ∈ componentComplMk G vnK → ck.2 ∈ K → ¬Adj G ck.1 ck.2
u : V
unC : u ∉ ↑C
p : Walk G v u
x y : V
xy : Adj G (x, y).1 (x, y).2
xC : { toProd := (x, y), is_adj := xy }.toProd.1 ∈ ↑C
ynC : { toProd := (x, y), is_adj := xy }.toProd.2 ∉ ↑C
⊢ False

Next tactic:
exact ynC (mem_of_adj x y xC (fun yK : y ∈ K => h ⟨x, y⟩ xC yK xy) xy)
theorem subset_hom (C : G.ComponentCompl L) (h : K ⊆ L) : (C : Set V) ⊆ (C.hom h : Set V) := by
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
C : ComponentCompl G L
h : K ⊆ L
⊢ ↑C ⊆ ↑(hom h C)

Next tactic:
rintro c ⟨cL, rfl⟩
theorem subset_hom (C : G.ComponentCompl L) (h : K ⊆ L) : (C : Set V) ⊆ (C.hom h : Set V) := by
  rintro c ⟨cL, rfl⟩
  

Proof state:
case intro
V : Type u
G : SimpleGraph V
K L L' M : Set V
h : K ⊆ L
c : V
cL : c ∉ L
⊢ c ∈ ↑(hom h (componentComplMk G cL))

Next tactic:
exact ⟨fun h' => cL (h h'), rfl⟩
theorem hom_eq_iff_not_disjoint (C : G.ComponentCompl L) (h : K ⊆ L) (D : G.ComponentCompl K) :
    C.hom h = D ↔ ¬Disjoint (C : Set V) (D : Set V) := by
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
C : ComponentCompl G L
h : K ⊆ L
D : ComponentCompl G K
⊢ hom h C = D ↔ ¬Disjoint ↑C ↑D

Next tactic:
rw [Set.not_disjoint_iff]
theorem hom_eq_iff_not_disjoint (C : G.ComponentCompl L) (h : K ⊆ L) (D : G.ComponentCompl K) :
    C.hom h = D ↔ ¬Disjoint (C : Set V) (D : Set V) := by
  rw [Set.not_disjoint_iff]
  

Proof state:
V : Type u
G : SimpleGraph V
K L L' M : Set V
C : ComponentCompl G L
h : K ⊆ L
D : ComponentCompl G K
⊢ hom h C = D ↔ ∃ x ∈ ↑C, x ∈ ↑D

Next tactic:
constructor
theorem hom_eq_iff_not_disjoint (C : G.ComponentCompl L) (h : K ⊆ L) (D : G.ComponentCompl K) :
    C.hom h = D ↔ ¬Disjoint (C : Set V) (D : Set V) := by
  rw [Set.not_disjoint_iff]
  constructor
  · 

Proof state:
case mp
V : Type u
G : SimpleGraph V
K L L' M : Set V
C : ComponentCompl G L
h : K ⊆ L
D : ComponentCompl G K
⊢ hom h C = D → ∃ x ∈ ↑C, x ∈ ↑D

Next tactic:
rintro rfl
theorem hom_eq_iff_not_disjoint (C : G.ComponentCompl L) (h : K ⊆ L) (D : G.ComponentCompl K) :
    C.hom h = D ↔ ¬Disjoint (C : Set V) (D : Set V) := by
  rw [Set.not_disjoint_iff]
  constructor
  · rintro rfl
    

Proof state:
case mp
V : Type u
G : SimpleGraph V
K L L' M : Set V
C : ComponentCompl G L
h : K ⊆ L
⊢ ∃ x ∈ ↑C, x ∈ ↑(hom h C)

Next tactic:
refine C.ind fun x xnL => ?_
theorem hom_eq_iff_not_disjoint (C : G.ComponentCompl L) (h : K ⊆ L) (D : G.ComponentCompl K) :
    C.hom h = D ↔ ¬Disjoint (C : Set V) (D : Set V) := by
  rw [Set.not_disjoint_iff]
  constructor
  · rintro rfl
    refine C.ind fun x xnL => ?_
    

Proof state:
case mp
V : Type u
G : SimpleGraph V
K L L' M : Set V
C : ComponentCompl G L
h : K ⊆ L
x : V
xnL : x ∉ L
⊢ ∃ x_1 ∈ ↑(componentComplMk G xnL), x_1 ∈ ↑(hom h (componentComplMk G xnL))

Next tactic:
exact ⟨x, ⟨xnL, rfl⟩, ⟨fun xK => xnL (h xK), rfl⟩⟩
theorem hom_eq_iff_not_disjoint (C : G.ComponentCompl L) (h : K ⊆ L) (D : G.ComponentCompl K) :
    C.hom h = D ↔ ¬Disjoint (C : Set V) (D : Set V) := by
  rw [Set.not_disjoint_iff]
  constructor
  · rintro rfl
    refine C.ind fun x xnL => ?_
    exact ⟨x, ⟨xnL, rfl⟩, ⟨fun xK => xnL (h xK), rfl⟩⟩
  · 

Proof state:
case mpr
V : Type u
G : SimpleGraph V
K L L' M : Set V
C : ComponentCompl G L
h : K ⊆ L
D : ComponentCompl G K
⊢ (∃ x ∈ ↑C, x ∈ ↑D) → hom h C = D

Next tactic:
refine C.ind fun x xnL => ?_