l3lab/ntp-mathlib huggingface dataset:
/-- Given a set of vertex pairs, remove all of the corresponding edges from the
graph's edge set, if present.

See also: `SimpleGraph.Subgraph.deleteEdges`. -/
def deleteEdges (s : Set (Sym2 V)) : SimpleGraph V
    where
  Adj := G.Adj \ Sym2.ToRel s
  symm a b := by simp [adj_comm, Sym2.eq_swap]
  loopless a := by 

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a✝ b c u v w : V
e : Sym2 V
s : Set (Sym2 V)
a : V
⊢ ¬(G.Adj \ Sym2.ToRel s) a a

Next tactic:
simp [SDiff.sdiff]
theorem sdiff_eq_deleteEdges (G G' : SimpleGraph V) : G \ G' = G.deleteEdges G'.edgeSet := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G✝ : SimpleGraph V
G'✝ : SimpleGraph W
a b c u v w : V
e : Sym2 V
G G' : SimpleGraph V
⊢ G \ G' = deleteEdges G (edgeSet G')

Next tactic:
ext
theorem sdiff_eq_deleteEdges (G G' : SimpleGraph V) : G \ G' = G.deleteEdges G'.edgeSet := by
  ext
  

Proof state:
case Adj.h.h.a
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G✝ : SimpleGraph V
G'✝ : SimpleGraph W
a b c u v w : V
e : Sym2 V
G G' : SimpleGraph V
x✝¹ x✝ : V
⊢ Adj (G \ G') x✝¹ x✝ ↔ Adj (deleteEdges G (edgeSet G')) x✝¹ x✝

Next tactic:
simp
theorem deleteEdges_eq_sdiff_fromEdgeSet (s : Set (Sym2 V)) :
    G.deleteEdges s = G \ fromEdgeSet s := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
s : Set (Sym2 V)
⊢ deleteEdges G s = G \ fromEdgeSet s

Next tactic:
ext
theorem deleteEdges_eq_sdiff_fromEdgeSet (s : Set (Sym2 V)) :
    G.deleteEdges s = G \ fromEdgeSet s := by
  ext
  

Proof state:
case Adj.h.h.a
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
s : Set (Sym2 V)
x✝¹ x✝ : V
⊢ Adj (deleteEdges G s) x✝¹ x✝ ↔ Adj (G \ fromEdgeSet s) x✝¹ x✝

Next tactic:
exact ⟨fun h => ⟨h.1, not_and_of_not_left _ h.2⟩, fun h => ⟨h.1, not_and'.mp h.2 h.ne⟩⟩
@[simp]
lemma deleteEdges_eq_self {s : Set (Sym2 V)} : G.deleteEdges s = G ↔ Disjoint G.edgeSet s := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
s : Set (Sym2 V)
⊢ deleteEdges G s = G ↔ Disjoint (edgeSet G) s

Next tactic:
rw [deleteEdges_eq_sdiff_fromEdgeSet, sdiff_eq_left, disjoint_fromEdgeSet]
theorem compl_eq_deleteEdges : Gᶜ = (⊤ : SimpleGraph V).deleteEdges G.edgeSet := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
⊢ Gᶜ = deleteEdges ⊤ (edgeSet G)

Next tactic:
ext
theorem compl_eq_deleteEdges : Gᶜ = (⊤ : SimpleGraph V).deleteEdges G.edgeSet := by
  ext
  

Proof state:
case Adj.h.h.a
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
x✝¹ x✝ : V
⊢ Adj Gᶜ x✝¹ x✝ ↔ Adj (deleteEdges ⊤ (edgeSet G)) x✝¹ x✝

Next tactic:
simp
@[simp]
theorem deleteEdges_deleteEdges (s s' : Set (Sym2 V)) :
    (G.deleteEdges s).deleteEdges s' = G.deleteEdges (s ∪ s') := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
s s' : Set (Sym2 V)
⊢ deleteEdges (deleteEdges G s) s' = deleteEdges G (s ∪ s')

Next tactic:
ext
@[simp]
theorem deleteEdges_deleteEdges (s s' : Set (Sym2 V)) :
    (G.deleteEdges s).deleteEdges s' = G.deleteEdges (s ∪ s') := by
  ext
  

Proof state:
case Adj.h.h.a
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
s s' : Set (Sym2 V)
x✝¹ x✝ : V
⊢ Adj (deleteEdges (deleteEdges G s) s') x✝¹ x✝ ↔ Adj (deleteEdges G (s ∪ s')) x✝¹ x✝

Next tactic:
simp [and_assoc, not_or]
@[simp]
theorem deleteEdges_empty_eq : G.deleteEdges ∅ = G := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
⊢ deleteEdges G ∅ = G

Next tactic:
ext
@[simp]
theorem deleteEdges_empty_eq : G.deleteEdges ∅ = G := by
  ext
  

Proof state:
case Adj.h.h.a
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
x✝¹ x✝ : V
⊢ Adj (deleteEdges G ∅) x✝¹ x✝ ↔ Adj G x✝¹ x✝

Next tactic:
simp
@[simp]
theorem deleteEdges_univ_eq : G.deleteEdges Set.univ = ⊥ := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
⊢ deleteEdges G Set.univ = ⊥

Next tactic:
ext
@[simp]
theorem deleteEdges_univ_eq : G.deleteEdges Set.univ = ⊥ := by
  ext
  

Proof state:
case Adj.h.h.a
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
x✝¹ x✝ : V
⊢ Adj (deleteEdges G Set.univ) x✝¹ x✝ ↔ Adj ⊥ x✝¹ x✝

Next tactic:
simp
theorem deleteEdges_le (s : Set (Sym2 V)) : G.deleteEdges s ≤ G := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
s : Set (Sym2 V)
⊢ deleteEdges G s ≤ G

Next tactic:
intro
theorem deleteEdges_le (s : Set (Sym2 V)) : G.deleteEdges s ≤ G := by
  intro
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
s : Set (Sym2 V)
v✝ : V
⊢ ∀ ⦃w : V⦄, Adj (deleteEdges G s) v✝ w → Adj G v✝ w

Next tactic:
simp (config := { contextual := true })
theorem deleteEdges_le_of_le {s s' : Set (Sym2 V)} (h : s ⊆ s') :
    G.deleteEdges s' ≤ G.deleteEdges s := fun v w => by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v✝ w✝ : V
e : Sym2 V
s s' : Set (Sym2 V)
h : s ⊆ s'
v w : V
⊢ Adj (deleteEdges G s') v w → Adj (deleteEdges G s) v w

Next tactic:
simp (config := { contextual := true }) only [deleteEdges_adj, and_imp, true_and_iff]
theorem deleteEdges_le_of_le {s s' : Set (Sym2 V)} (h : s ⊆ s') :
    G.deleteEdges s' ≤ G.deleteEdges s := fun v w => by
  simp (config := { contextual := true }) only [deleteEdges_adj, and_imp, true_and_iff]
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v✝ w✝ : V
e : Sym2 V
s s' : Set (Sym2 V)
h : s ⊆ s'
v w : V
⊢ Adj G v w → ⟦(v, w)⟧ ∉ s' → ⟦(v, w)⟧ ∉ s

Next tactic:
exact fun _ hn hs => hn (h hs)
theorem deleteEdges_eq_inter_edgeSet (s : Set (Sym2 V)) :
    G.deleteEdges s = G.deleteEdges (s ∩ G.edgeSet) := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
s : Set (Sym2 V)
⊢ deleteEdges G s = deleteEdges G (s ∩ edgeSet G)

Next tactic:
ext
theorem deleteEdges_eq_inter_edgeSet (s : Set (Sym2 V)) :
    G.deleteEdges s = G.deleteEdges (s ∩ G.edgeSet) := by
  ext
  

Proof state:
case Adj.h.h.a
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
s : Set (Sym2 V)
x✝¹ x✝ : V
⊢ Adj (deleteEdges G s) x✝¹ x✝ ↔ Adj (deleteEdges G (s ∩ edgeSet G)) x✝¹ x✝

Next tactic:
simp (config := { contextual := true }) [imp_false]
theorem deleteEdges_sdiff_eq_of_le {H : SimpleGraph V} (h : H ≤ G) :
    G.deleteEdges (G.edgeSet \ H.edgeSet) = H := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
H : SimpleGraph V
h : H ≤ G
⊢ deleteEdges G (edgeSet G \ edgeSet H) = H

Next tactic:
ext v w
theorem deleteEdges_sdiff_eq_of_le {H : SimpleGraph V} (h : H ≤ G) :
    G.deleteEdges (G.edgeSet \ H.edgeSet) = H := by
  ext v w
  

Proof state:
case Adj.h.h.a
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v✝ w✝ : V
e : Sym2 V
H : SimpleGraph V
h : H ≤ G
v w : V
⊢ Adj (deleteEdges G (edgeSet G \ edgeSet H)) v w ↔ Adj H v w

Next tactic:
constructor
theorem deleteEdges_sdiff_eq_of_le {H : SimpleGraph V} (h : H ≤ G) :
    G.deleteEdges (G.edgeSet \ H.edgeSet) = H := by
  ext v w
  constructor <;> 

Proof state:
case Adj.h.h.a.mp
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v✝ w✝ : V
e : Sym2 V
H : SimpleGraph V
h : H ≤ G
v w : V
⊢ Adj (deleteEdges G (edgeSet G \ edgeSet H)) v w → Adj H v w

Next tactic:
simp (config := { contextual := true }) [@h v w]
theorem deleteEdges_sdiff_eq_of_le {H : SimpleGraph V} (h : H ≤ G) :
    G.deleteEdges (G.edgeSet \ H.edgeSet) = H := by
  ext v w
  constructor <;> 

Proof state:
case Adj.h.h.a.mpr
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v✝ w✝ : V
e : Sym2 V
H : SimpleGraph V
h : H ≤ G
v w : V
⊢ Adj H v w → Adj (deleteEdges G (edgeSet G \ edgeSet H)) v w

Next tactic:
simp (config := { contextual := true }) [@h v w]
theorem edgeSet_deleteEdges (s : Set (Sym2 V)) : (G.deleteEdges s).edgeSet = G.edgeSet \ s := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
s : Set (Sym2 V)
⊢ edgeSet (deleteEdges G s) = edgeSet G \ s

Next tactic:
ext e
theorem edgeSet_deleteEdges (s : Set (Sym2 V)) : (G.deleteEdges s).edgeSet = G.edgeSet \ s := by
  ext e
  

Proof state:
case h
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e✝ : Sym2 V
s : Set (Sym2 V)
e : Sym2 V
⊢ e ∈ edgeSet (deleteEdges G s) ↔ e ∈ edgeSet G \ s

Next tactic:
refine' Sym2.ind _ e
theorem edgeSet_deleteEdges (s : Set (Sym2 V)) : (G.deleteEdges s).edgeSet = G.edgeSet \ s := by
  ext e
  refine' Sym2.ind _ e
  

Proof state:
case h
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e✝ : Sym2 V
s : Set (Sym2 V)
e : Sym2 V
⊢ ∀ (x y : V), ⟦(x, y)⟧ ∈ edgeSet (deleteEdges G s) ↔ ⟦(x, y)⟧ ∈ edgeSet G \ s

Next tactic:
simp
theorem edgeFinset_deleteEdges [Fintype (Sym2 V)] [DecidableEq V] [DecidableRel G.Adj]
    (s : Finset (Sym2 V)) [DecidableRel (G.deleteEdges s).Adj] :
    (G.deleteEdges s).edgeFinset = G.edgeFinset \ s := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝³ : Fintype (Sym2 V)
inst✝² : DecidableEq V
inst✝¹ : DecidableRel G.Adj
s : Finset (Sym2 V)
inst✝ : DecidableRel (deleteEdges G ↑s).Adj
⊢ edgeFinset (deleteEdges G ↑s) = edgeFinset G \ s

Next tactic:
ext e
theorem edgeFinset_deleteEdges [Fintype (Sym2 V)] [DecidableEq V] [DecidableRel G.Adj]
    (s : Finset (Sym2 V)) [DecidableRel (G.deleteEdges s).Adj] :
    (G.deleteEdges s).edgeFinset = G.edgeFinset \ s := by
  ext e
  

Proof state:
case a
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e✝ : Sym2 V
inst✝³ : Fintype (Sym2 V)
inst✝² : DecidableEq V
inst✝¹ : DecidableRel G.Adj
s : Finset (Sym2 V)
inst✝ : DecidableRel (deleteEdges G ↑s).Adj
e : Sym2 V
⊢ e ∈ edgeFinset (deleteEdges G ↑s) ↔ e ∈ edgeFinset G \ s

Next tactic:
simp [edgeSet_deleteEdges]
theorem deleteFar_iff :
    G.DeleteFar p r ↔ ∀ ⦃H : SimpleGraph _⦄ [DecidableRel H.Adj],
      H ≤ G → p H → r ≤ G.edgeFinset.card - H.edgeFinset.card := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝⁴ : OrderedRing 𝕜
inst✝³ : Fintype V
inst✝² : Fintype (Sym2 V)
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
p : SimpleGraph V → Prop
r r₁ r₂ : 𝕜
⊢ DeleteFar G p r ↔
    ∀ ⦃H : SimpleGraph V⦄ [inst : DecidableRel H.Adj], H ≤ G → p H → r ≤ ↑(card (edgeFinset G)) - ↑(card (edgeFinset H))

Next tactic:
refine ⟨fun h H _ hHG hH ↦ ?_, fun h s hs hG ↦ ?_⟩
theorem deleteFar_iff :
    G.DeleteFar p r ↔ ∀ ⦃H : SimpleGraph _⦄ [DecidableRel H.Adj],
      H ≤ G → p H → r ≤ G.edgeFinset.card - H.edgeFinset.card := by
  refine ⟨fun h H _ hHG hH ↦ ?_, fun h s hs hG ↦ ?_⟩
  · 

Proof state:
case refine_1
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝⁴ : OrderedRing 𝕜
inst✝³ : Fintype V
inst✝² : Fintype (Sym2 V)
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
p : SimpleGraph V → Prop
r r₁ r₂ : 𝕜
h : DeleteFar G p r
H : SimpleGraph V
x✝ : DecidableRel H.Adj
hHG : H ≤ G
hH : p H
⊢ r ≤ ↑(card (edgeFinset G)) - ↑(card (edgeFinset H))

Next tactic:
have := h (sdiff_subset G.edgeFinset H.edgeFinset)
theorem deleteFar_iff :
    G.DeleteFar p r ↔ ∀ ⦃H : SimpleGraph _⦄ [DecidableRel H.Adj],
      H ≤ G → p H → r ≤ G.edgeFinset.card - H.edgeFinset.card := by
  refine ⟨fun h H _ hHG hH ↦ ?_, fun h s hs hG ↦ ?_⟩
  · have := h (sdiff_subset G.edgeFinset H.edgeFinset)
    

Proof state:
case refine_1
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝⁴ : OrderedRing 𝕜
inst✝³ : Fintype V
inst✝² : Fintype (Sym2 V)
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
p : SimpleGraph V → Prop
r r₁ r₂ : 𝕜
h : DeleteFar G p r
H : SimpleGraph V
x✝ : DecidableRel H.Adj
hHG : H ≤ G
hH : p H
this : p (deleteEdges G ↑(edgeFinset G \ edgeFinset H)) → r ≤ ↑(card (edgeFinset G \ edgeFinset H))
⊢ r ≤ ↑(card (edgeFinset G)) - ↑(card (edgeFinset H))

Next tactic:
simp only [deleteEdges_sdiff_eq_of_le _ hHG, edgeFinset_mono hHG, card_sdiff,
      card_le_of_subset, coe_sdiff, coe_edgeFinset, Nat.cast_sub] at this
theorem deleteFar_iff :
    G.DeleteFar p r ↔ ∀ ⦃H : SimpleGraph _⦄ [DecidableRel H.Adj],
      H ≤ G → p H → r ≤ G.edgeFinset.card - H.edgeFinset.card := by
  refine ⟨fun h H _ hHG hH ↦ ?_, fun h s hs hG ↦ ?_⟩
  · have := h (sdiff_subset G.edgeFinset H.edgeFinset)
    simp only [deleteEdges_sdiff_eq_of_le _ hHG, edgeFinset_mono hHG, card_sdiff,
      card_le_of_subset, coe_sdiff, coe_edgeFinset, Nat.cast_sub] at this
    

Proof state:
case refine_1
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝⁴ : OrderedRing 𝕜
inst✝³ : Fintype V
inst✝² : Fintype (Sym2 V)
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
p : SimpleGraph V → Prop
r r₁ r₂ : 𝕜
h : DeleteFar G p r
H : SimpleGraph V
x✝ : DecidableRel H.Adj
hHG : H ≤ G
hH : p H
this : p H → r ≤ ↑(card (edgeFinset G)) - ↑(card (edgeFinset H))
⊢ r ≤ ↑(card (edgeFinset G)) - ↑(card (edgeFinset H))

Next tactic:
exact this hH
theorem deleteFar_iff :
    G.DeleteFar p r ↔ ∀ ⦃H : SimpleGraph _⦄ [DecidableRel H.Adj],
      H ≤ G → p H → r ≤ G.edgeFinset.card - H.edgeFinset.card := by
  refine ⟨fun h H _ hHG hH ↦ ?_, fun h s hs hG ↦ ?_⟩
  · have := h (sdiff_subset G.edgeFinset H.edgeFinset)
    simp only [deleteEdges_sdiff_eq_of_le _ hHG, edgeFinset_mono hHG, card_sdiff,
      card_le_of_subset, coe_sdiff, coe_edgeFinset, Nat.cast_sub] at this
    exact this hH
  · 

Proof state:
case refine_2
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝⁴ : OrderedRing 𝕜
inst✝³ : Fintype V
inst✝² : Fintype (Sym2 V)
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
p : SimpleGraph V → Prop
r r₁ r₂ : 𝕜
h : ∀ ⦃H : SimpleGraph V⦄ [inst : DecidableRel H.Adj], H ≤ G → p H → r ≤ ↑(card (edgeFinset G)) - ↑(card (edgeFinset H))
s : Finset (Sym2 V)
hs : s ⊆ edgeFinset G
hG : p (deleteEdges G ↑s)
⊢ r ≤ ↑(card s)

Next tactic:
classical
    simpa [card_sdiff hs, edgeFinset_deleteEdges, -Set.toFinset_card, Nat.cast_sub,
      card_le_of_subset hs] using h (G.deleteEdges_le s) hG
theorem deleteFar_iff :
    G.DeleteFar p r ↔ ∀ ⦃H : SimpleGraph _⦄ [DecidableRel H.Adj],
      H ≤ G → p H → r ≤ G.edgeFinset.card - H.edgeFinset.card := by
  refine ⟨fun h H _ hHG hH ↦ ?_, fun h s hs hG ↦ ?_⟩
  · have := h (sdiff_subset G.edgeFinset H.edgeFinset)
    simp only [deleteEdges_sdiff_eq_of_le _ hHG, edgeFinset_mono hHG, card_sdiff,
      card_le_of_subset, coe_sdiff, coe_edgeFinset, Nat.cast_sub] at this
    exact this hH
  · classical
    

Proof state:
case refine_2
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝⁴ : OrderedRing 𝕜
inst✝³ : Fintype V
inst✝² : Fintype (Sym2 V)
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
p : SimpleGraph V → Prop
r r₁ r₂ : 𝕜
h : ∀ ⦃H : SimpleGraph V⦄ [inst : DecidableRel H.Adj], H ≤ G → p H → r ≤ ↑(card (edgeFinset G)) - ↑(card (edgeFinset H))
s : Finset (Sym2 V)
hs : s ⊆ edgeFinset G
hG : p (deleteEdges G ↑s)
⊢ r ≤ ↑(card s)

Next tactic:
simpa [card_sdiff hs, edgeFinset_deleteEdges, -Set.toFinset_card, Nat.cast_sub,
      card_le_of_subset hs] using h (G.deleteEdges_le s) hG
/-- The graph formed by forgetting `t`'s neighbours and instead giving it those of `s`. The `s-t`
edge is removed if present. -/
abbrev replaceVertex : SimpleGraph V where
  Adj v w := if v = t then if w = t then False else G.Adj s w
                      else if w = t then G.Adj v s else G.Adj v w
  symm v w := by 

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v✝ w✝ : V
e : Sym2 V
inst✝ : DecidableEq V
s t v w : V
⊢ (fun v w => if v = t then if w = t then False else Adj G s w else if w = t then Adj G v s else Adj G v w) v w →
    (fun v w => if v = t then if w = t then False else Adj G s w else if w = t then Adj G v s else Adj G v w) w v

Next tactic:
dsimp only
/-- The graph formed by forgetting `t`'s neighbours and instead giving it those of `s`. The `s-t`
edge is removed if present. -/
abbrev replaceVertex : SimpleGraph V where
  Adj v w := if v = t then if w = t then False else G.Adj s w
                      else if w = t then G.Adj v s else G.Adj v w
  symm v w := by dsimp only; 

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v✝ w✝ : V
e : Sym2 V
inst✝ : DecidableEq V
s t v w : V
⊢ (if v = t then if w = t then False else Adj G s w else if w = t then Adj G v s else Adj G v w) →
    if w = t then if v = t then False else Adj G s v else if v = t then Adj G w s else Adj G w v

Next tactic:
split_ifs
/-- The graph formed by forgetting `t`'s neighbours and instead giving it those of `s`. The `s-t`
edge is removed if present. -/
abbrev replaceVertex : SimpleGraph V where
  Adj v w := if v = t then if w = t then False else G.Adj s w
                      else if w = t then G.Adj v s else G.Adj v w
  symm v w := by dsimp only; split_ifs <;> 

Proof state:
case pos
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v✝ w✝ : V
e : Sym2 V
inst✝ : DecidableEq V
s t v w : V
h✝¹ : v = t
h✝ : w = t
⊢ False → False

Next tactic:
simp [adj_comm]
/-- The graph formed by forgetting `t`'s neighbours and instead giving it those of `s`. The `s-t`
edge is removed if present. -/
abbrev replaceVertex : SimpleGraph V where
  Adj v w := if v = t then if w = t then False else G.Adj s w
                      else if w = t then G.Adj v s else G.Adj v w
  symm v w := by dsimp only; split_ifs <;> 

Proof state:
case neg
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v✝ w✝ : V
e : Sym2 V
inst✝ : DecidableEq V
s t v w : V
h✝¹ : v = t
h✝ : ¬w = t
⊢ Adj G s w → Adj G w s

Next tactic:
simp [adj_comm]
/-- The graph formed by forgetting `t`'s neighbours and instead giving it those of `s`. The `s-t`
edge is removed if present. -/
abbrev replaceVertex : SimpleGraph V where
  Adj v w := if v = t then if w = t then False else G.Adj s w
                      else if w = t then G.Adj v s else G.Adj v w
  symm v w := by dsimp only; split_ifs <;> 

Proof state:
case pos
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v✝ w✝ : V
e : Sym2 V
inst✝ : DecidableEq V
s t v w : V
h✝¹ : ¬v = t
h✝ : w = t
⊢ Adj G v s → Adj G s v

Next tactic:
simp [adj_comm]
/-- The graph formed by forgetting `t`'s neighbours and instead giving it those of `s`. The `s-t`
edge is removed if present. -/
abbrev replaceVertex : SimpleGraph V where
  Adj v w := if v = t then if w = t then False else G.Adj s w
                      else if w = t then G.Adj v s else G.Adj v w
  symm v w := by dsimp only; split_ifs <;> 

Proof state:
case neg
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v✝ w✝ : V
e : Sym2 V
inst✝ : DecidableEq V
s t v w : V
h✝¹ : ¬v = t
h✝ : ¬w = t
⊢ Adj G v w → Adj G w v

Next tactic:
simp [adj_comm]
/-- There is never an `s-t` edge in `G.replaceVertex s t`. -/
theorem not_adj_replaceVertex_same : ¬(G.replaceVertex s t).Adj s t := by 

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝ : DecidableEq V
s t : V
⊢ ¬Adj (replaceVertex G s t) s t

Next tactic:
simp
@[simp]
theorem replaceVertex_self : G.replaceVertex s s = G := by
  

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝ : DecidableEq V
s t : V
⊢ replaceVertex G s s = G

Next tactic:
ext
@[simp]
theorem replaceVertex_self : G.replaceVertex s s = G := by
  ext; 

Proof state:
case Adj.h.h.a
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝ : DecidableEq V
s t x✝¹ x✝ : V
⊢ Adj (replaceVertex G s s) x✝¹ x✝ ↔ Adj G x✝¹ x✝

Next tactic:
dsimp only
@[simp]
theorem replaceVertex_self : G.replaceVertex s s = G := by
  ext; dsimp only; 

Proof state:
case Adj.h.h.a
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝ : DecidableEq V
s t x✝¹ x✝ : V
⊢ (if x✝¹ = s then if x✝ = s then False else Adj G s x✝ else if x✝ = s then Adj G x✝¹ s else Adj G x✝¹ x✝) ↔
    Adj G x✝¹ x✝

Next tactic:
split_ifs
@[simp]
theorem replaceVertex_self : G.replaceVertex s s = G := by
  ext; dsimp only; split_ifs <;> 

Proof state:
case pos
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝ : DecidableEq V
s t x✝¹ x✝ : V
h✝¹ : x✝¹ = s
h✝ : x✝ = s
⊢ False ↔ Adj G x✝¹ x✝

Next tactic:
simp_all [adj_comm]
@[simp]
theorem replaceVertex_self : G.replaceVertex s s = G := by
  ext; dsimp only; split_ifs <;> 

Proof state:
case neg
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝ : DecidableEq V
s t x✝¹ x✝ : V
h✝¹ : x✝¹ = s
h✝ : ¬x✝ = s
⊢ Adj G s x✝ ↔ Adj G x✝¹ x✝

Next tactic:
simp_all [adj_comm]
@[simp]
theorem replaceVertex_self : G.replaceVertex s s = G := by
  ext; dsimp only; split_ifs <;> 

Proof state:
case pos
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝ : DecidableEq V
s t x✝¹ x✝ : V
h✝¹ : ¬x✝¹ = s
h✝ : x✝ = s
⊢ Adj G x✝¹ s ↔ Adj G x✝¹ x✝

Next tactic:
simp_all [adj_comm]
@[simp]
theorem replaceVertex_self : G.replaceVertex s s = G := by
  ext; dsimp only; split_ifs <;> 

Proof state:
case neg
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w : V
e : Sym2 V
inst✝ : DecidableEq V
s t x✝¹ x✝ : V
h✝¹ : ¬x✝¹ = s
h✝ : ¬x✝ = s
⊢ Adj G x✝¹ x✝ ↔ Adj G x✝¹ x✝

Next tactic:
simp_all [adj_comm]
/-- Except possibly for `t`, the neighbours of `s` in `G.replaceVertex s t` are its neighbours in
`G`. -/
lemma adj_replaceVertex_iff_of_ne_left {w : V} (hw : w ≠ t) :
    (G.replaceVertex s t).Adj s w ↔ G.Adj s w := by 

Proof state:
ι : Sort u_1
𝕜 : Type u_2
V : Type u
W : Type v
X : Type w
G : SimpleGraph V
G' : SimpleGraph W
a b c u v w✝ : V
e : Sym2 V
inst✝ : DecidableEq V
s t w : V
hw : w ≠ t
⊢ Adj (replaceVertex G s t) s w ↔ Adj G s w

Next tactic:
simp [hw]