Skip to content

Commit 6a86aa7

Browse files
chore: address review comments and sync with master
1 parent 3cb74a0 commit 6a86aa7

1 file changed

Lines changed: 61 additions & 47 deletions

File tree

Mathlib/Combinatorics/SimpleGraph/Connectivity/VertexConnectivity.lean

Lines changed: 61 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This file defines k-vertex connectivity for simple graphs.
1717
* `SimpleGraph.IsVertexReachable`: Two vertices are `k`-vertex-reachable if they remain reachable
1818
after removing strictly fewer than `k` other vertices.
1919
* `SimpleGraph.IsVertexConnected`: A graph is `k`-vertex-connected if it has more than `k`
20-
vertices and any two distinct vertices are `k`-vertex-reachable.
20+
vertices and any two vertices are `k`-vertex-reachable.
2121
-/
2222

2323
@[expose] public section
@@ -26,28 +26,28 @@ namespace SimpleGraph
2626

2727
variable {V : Type*} {G H : SimpleGraph V} {k l : ℕ∞} {u v : V}
2828

29-
/-- `G.deleteVerts s` is the graph where all vertices in `s` are isolated. -/
30-
def deleteVerts (G : SimpleGraph V) (s : Set V) : SimpleGraph V where
29+
/-- `G.isolateVerts s` is the graph where all vertices in `s` are isolated. -/
30+
def isolateVerts (G : SimpleGraph V) (s : Set V) : SimpleGraph V where
3131
Adj u v := u ∉ s ∧ v ∉ s ∧ G.Adj u v
3232
symm _ _ h := ⟨h.2.1, h.1, h.2.2.symm⟩
3333

3434
@[simp]
35-
lemma deleteVerts_empty : G.deleteVerts ∅ = G := by
36-
ext; simp [deleteVerts]
35+
lemma isolateVerts_empty : G.isolateVerts ∅ = G := by
36+
ext; simp [isolateVerts]
3737

3838
@[simp]
39-
lemma deleteVerts_bot (s : Set V) : (⊥ : SimpleGraph V).deleteVerts s = ⊥ := by
40-
ext; simp [deleteVerts]
39+
lemma isolateVerts_bot (s : Set V) : (⊥ : SimpleGraph V).isolateVerts s = ⊥ := by
40+
ext; simp [isolateVerts]
4141

4242
@[simp]
43-
lemma deleteVerts_le (s : Set V) : G.deleteVerts s ≤ G :=
43+
lemma isolateVerts_le (s : Set V) : G.isolateVerts s ≤ G :=
4444
fun _ _ h ↦ h.2.2
4545

4646
variable (G k u v) in
4747
/-- Two vertices are `k`-vertex-reachable if they remain reachable after removing
4848
strictly fewer than `k` other vertices. -/
4949
def IsVertexReachable : Prop :=
50-
∀ ⦃s : Set V⦄, s.encard < k → u ∉ s → v ∉ s → (G.deleteVerts s).Reachable u v
50+
∀ ⦃s : Set V⦄, s.encard < k → u ∉ s → v ∉ s → (G.isolateVerts s).Reachable u v
5151

5252
@[simp]
5353
lemma IsVertexReachable.refl (u : V) : G.IsVertexReachable k u u :=
@@ -71,71 +71,85 @@ lemma IsVertexReachable.anti (hkl : k ≤ l) (h : G.IsVertexReachable l u v) :
7171
fun _ hs ↦ h (hs.trans_le hkl)
7272

7373
@[simp]
74-
protected lemma IsVertexReachable.zero : G.IsVertexReachable 0 u v :=
75-
fun _ hs ↦ absurd hs (not_lt_of_ge (zero_le _))
74+
lemma IsVertexReachable.zero : G.IsVertexReachable 0 u v :=
75+
fun _ hs ↦ absurd hs not_lt_zero
7676

7777
lemma IsVertexReachable.of_adj (h : G.Adj u v) (k : ℕ∞) : G.IsVertexReachable k u v :=
7878
fun _ _ hu hv ↦ (Adj.reachable ⟨hu, hv, h⟩)
7979

80+
alias _root_.SimpleGraph.Adj.isVertexReachable := IsVertexReachable.of_adj
81+
8082
/-- A vertex pair is reachable if it is `k`-vertex-reachable for `k ≠ 0`. -/
81-
lemma IsVertexReachable.reachable {hk : k ≠ 0} (h : G.IsVertexReachable k u v) :
83+
lemma IsVertexReachable.reachable (hk : k ≠ 0) (h : G.IsVertexReachable k u v) :
8284
G.Reachable u v := by
83-
have := pos_iff_ne_zero.mpr hk
84-
specialize h (s := ∅) (by simpa) (by simp) (by simp)
85-
rwa [deleteVerts_empty] at h
85+
rw [← G.isolateVerts_empty]
86+
apply h <;> simp [pos_of_ne_zero hk]
8687

87-
variable (G k) in
88+
variable (G) (k : ℕ∞) in
8889
/-- A graph is `k`-vertex-connected if it has more than `k` vertices
89-
and any two distinct vertices are `k`-vertex-reachable. -/
90-
def IsVertexConnected [Fintype V] (k : ℕ) : Prop :=
91-
k < Fintype.card V ∧ ∀ u v : V, u ≠ v → G.IsVertexReachable k u v
90+
and any two vertices are `k`-vertex-reachable. -/
91+
def IsVertexConnected : Prop :=
92+
k + 1 ≤ ENat.card V ∧ ∀ u v : V, G.IsVertexReachable k u v
9293

9394
@[simp]
94-
lemma isVertexConnected_zero [Fintype V] : G.IsVertexConnected 0 ↔ Nonempty V := by
95-
simp [IsVertexConnected, Fintype.card_pos_iff]
95+
lemma isVertexConnected_zero : G.IsVertexConnected 0 ↔ Nonempty V := by
96+
rw [IsVertexConnected]
97+
have h0 : (0 : ℕ∞) + 1 = 1 := rfl
98+
rw [h0]
99+
simp [ENat.one_le_card_iff_nonempty]
96100

97101
/-- 1-vertex-connectivity is equivalent to being a connected graph with at least 2 vertices. -/
98-
@[simp]
99-
protected lemma isVertexConnected_one [Fintype V] :
100-
G.IsVertexConnected 11 < Fintype.card V ∧ G.Connected := by
101-
classical
102+
lemma isVertexConnected_one :
103+
G.IsVertexConnected 12 ≤ ENat.card V ∧ G.Connected := by
104+
rw [IsVertexConnected]
105+
have h1 : (1 : ℕ∞) + 1 = 2 := rfl
106+
rw [h1]
102107
constructor
103108
· rintro ⟨h_card, h_reach⟩
104109
refine ⟨h_card, ?_⟩
105110
rw [connected_iff_exists_forall_reachable]
106-
have := Fintype.card_pos_iff.1 (zero_lt_one.trans h_card)
107-
rcases this with ⟨x⟩
108-
refine ⟨x, fun y ↦ ?_⟩
109-
by_cases hxy : x = y
110-
· subst hxy; exact .refl _
111-
· specialize h_reach x y hxy
112-
simpa using h_reach (s := ∅) (by simp)
111+
have h_ne : Nonempty V := by
112+
rw [← ENat.one_le_card_iff_nonempty]
113+
exact (self_le_add_right (1 : ℕ∞) 1).trans h_card
114+
rcases h_ne with ⟨x⟩
115+
refine ⟨x, fun y ↦ (h_reach x y).reachable (by simp)⟩
113116
· rintro ⟨h_card, h_conn⟩
114-
refine ⟨h_card, fun u v huv ↦ ?_⟩
115-
intro s hs hu hv
117+
refine ⟨h_card, fun u v s hs _ _ ↦ ?_⟩
116118
have : s = ∅ := by
117119
rw [← Set.encard_eq_zero, ← ENat.lt_one_iff_eq_zero]
118-
exact_mod_cast hs
120+
exact hs
119121
subst this
120-
rw [deleteVerts_empty]
122+
rw [isolateVerts_empty]
121123
exact h_conn.preconnected u v
122124

123125
/-- Vertex connectivity is antitonic in `k`. -/
124-
@[gcongr]
125-
lemma IsVertexConnected.anti [Fintype V] {k l : ℕ} (hkl : l ≤ k) (hc : G.IsVertexConnected k) :
126-
G.IsVertexConnected l :=
127-
⟨hkl.trans_lt hc.1, fun u v huv ↦ (hc.2 u v huv).anti (Nat.cast_le.mpr hkl)⟩
126+
lemma IsVertexConnected.anti {k l : ℕ∞} (hkl : l ≤ k) (hc : G.IsVertexConnected k) :
127+
G.IsVertexConnected l := by
128+
constructor
129+
· let h_le := add_le_add_right hkl 1
130+
let h_card := hc.1
131+
have h1 : l + 1 = 1 + l := add_comm ..
132+
have h2 : k + 1 = 1 + k := add_comm ..
133+
rw [h1]
134+
rw [h2] at h_card
135+
exact h_le.trans h_card
136+
· exact fun u v ↦ (hc.2 u v).anti hkl
128137

129138
/-- Vertex connectivity is monotonic in the graph. -/
130-
@[gcongr]
131-
lemma IsVertexConnected.mono [Fintype V] {k : ℕ} (hGH : G ≤ H) (hc : G.IsVertexConnected k) :
139+
lemma IsVertexConnected.mono {k : ℕ∞} (hGH : G ≤ H) (hc : G.IsVertexConnected k) :
132140
H.IsVertexConnected k :=
133-
⟨hc.1, fun u v huv ↦ (hc.2 u v huv).mono hGH⟩
141+
⟨hc.1, fun u v ↦ (hc.2 u v).mono hGH⟩
134142

135143
/-- The complete graph on `n` vertices is `(n-1)`-vertex-connected. -/
136-
lemma isVertexConnected_completeGraph [Fintype V] [Nonempty V] :
137-
(⊤ : SimpleGraph V).IsVertexConnected (Fintype.card V - 1) :=
138-
⟨Nat.sub_lt Fintype.card_pos Nat.zero_lt_one,
139-
fun u v huv ↦ IsVertexReachable.of_adj (by simp [huv]) _⟩
144+
lemma isVertexConnected_top [Fintype V] [Nonempty V] :
145+
(⊤ : SimpleGraph V).IsVertexConnected (Fintype.card V - 1) := by
146+
constructor
147+
· rw [ENat.card_eq_coe_fintype_card]
148+
norm_cast
149+
exact Nat.sub_add_cancel Fintype.card_pos |>.le
150+
· intro u v
151+
by_cases h : u = v
152+
· subst h; exact .refl _
153+
· exact IsVertexReachable.of_adj h _
140154

141155
end SimpleGraph

0 commit comments

Comments
 (0)