Skip to content

Commit 74ee8fd

Browse files
refactor(Combinatorics/SimpleGraph): use IsVertexPreconnected and Nontrivial typeclass
1 parent 2759029 commit 74ee8fd

1 file changed

Lines changed: 25 additions & 19 deletions

File tree

Mathlib/Combinatorics/SimpleGraph/Connectivity/VertexConnectivity.lean

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@ Authors: Youheng Luo
55
-/
66
module
77
public import Mathlib.Combinatorics.SimpleGraph.Connectivity.Connected
8-
public import Mathlib.Data.Set.Card
98
public import Mathlib.Combinatorics.SimpleGraph.IsolateVerts
9+
public import Mathlib.Data.Set.Card
10+
public import Mathlib.Tactic.GRewrite
11+
1012
/-!
1113
# Vertex Connectivity
1214
13-
This file defines k-vertex connectivity for simple graphs.
15+
This file defines `k`-vertex connectivity for simple graphs.
1416
1517
## Main definitions
1618
1719
* `SimpleGraph.IsVertexReachable`: Two vertices are `k`-vertex-reachable if they remain reachable
1820
after removing strictly fewer than `k` other vertices.
1921
* `SimpleGraph.IsVertexPreconnected`: A graph is `k`-vertex-preconnected if any two vertices
2022
are `k`-vertex-reachable.
21-
* `SimpleGraph.IsVertexConnected`: A graph is `k`-vertex-connected if its order is at least
22-
`k + 1` and any two vertices are `k`-vertex-reachable.
23+
* `SimpleGraph.IsVertexConnected`: A graph is `k`-vertex-connected if it is `k`-vertex-preconnected
24+
and it has more than `k` vertices.
2325
-/
2426

2527
@[expose] public section
@@ -93,8 +95,7 @@ lemma isVertexPreconnected_one : G.IsVertexPreconnected 1 ↔ G.Preconnected :=
9395
simp [IsVertexPreconnected, isVertexReachable_one_iff, Preconnected]
9496

9597
/-- A preconnected graph is 1-vertex-preconnected. -/
96-
lemma Preconnected.isVertexPreconnected_one (h : G.Preconnected) : G.IsVertexPreconnected 1 :=
97-
SimpleGraph.isVertexPreconnected_one.mpr h
98+
alias ⟨_, Preconnected.isVertexPreconnected_one⟩ := isVertexPreconnected_one
9899

99100
/-- Vertex preconnectivity is antitonic in `k`. -/
100101
@[gcongr]
@@ -116,34 +117,39 @@ lemma isVertexPreconnected_top [Fintype V] :
116117
exacts [h ▸ .refl _, .of_adj _ h]
117118

118119
variable (G k) in
119-
/-- A graph is `k`-vertex-connected if its order is at least `k + 1` and any two vertices
120-
are `k`-vertex-reachable. -/
120+
/-- A graph is `k`-vertex-connected if it is `k`-vertex-preconnected and it has more than `k`
121+
vertices. -/
121122
def IsVertexConnected : Prop :=
122123
k + 1 ≤ ENat.card V ∧ G.IsVertexPreconnected k
123124

124-
/-- A 0-vertex-connected graph is just a nonempty graph. -/
125+
/-- A graph is 0-vertex-connected iff it is nonempty. -/
125126
@[simp]
126127
lemma isVertexConnected_zero : G.IsVertexConnected 0 ↔ Nonempty V := by
127128
simp [IsVertexConnected, ENat.one_le_card_iff_nonempty]
128129

129-
/-- 1-vertex-connectivity is equivalent to preconnectedness and having at least two vertices. -/
130+
lemma IsVertexConnected.zero [Nonempty V] : G.IsVertexConnected 0 :=
131+
isVertexConnected_zero.mpr ‹_›
132+
133+
/-- 1-vertex-connectivity is equivalent to preconnectedness and `V` being nontrivial. -/
130134
@[simp]
131-
lemma isVertexConnected_one : G.IsVertexConnected 12 ≤ ENat.card V ∧ G.Preconnected := by
132-
rw [IsVertexConnected, isVertexPreconnected_one, show (1 : ℕ∞) + 1 = 2 from rfl]
135+
lemma isVertexConnected_one : G.IsVertexConnected 1 ↔ Nontrivial V ∧ G.Preconnected := by
136+
rw [IsVertexConnected, isVertexPreconnected_one, ← ENat.one_lt_card_iff_nontrivial]
137+
exact and_congr_left' <| ENat.add_one_le_iff ENat.one_ne_top
138+
139+
lemma Preconnected.isVertexConnected_one [Nontrivial V] (h : G.Preconnected) :
140+
G.IsVertexConnected 1 :=
141+
SimpleGraph.isVertexConnected_one.mpr ⟨‹_›, h⟩
133142

134143
/-- Vertex connectivity is antitonic in `k`. -/
135144
@[gcongr]
136145
lemma IsVertexConnected.anti (hkl : l ≤ k) (hc : G.IsVertexConnected k) :
137146
G.IsVertexConnected l := by
138-
constructor
139-
· rw [add_comm]
140-
exact (add_le_add_right hkl 1).trans (by rw [add_comm]; exact hc.1)
141-
· exact hc.2.anti hkl
147+
constructor <;> grw [hkl]
148+
exacts [hc.left, hc.right]
142149

143150
/-- Vertex connectivity is monotonic in the graph. -/
144151
@[gcongr]
145-
lemma IsVertexConnected.mono (hGH : G ≤ H) (hc : G.IsVertexConnected k) :
146-
H.IsVertexConnected k :=
147-
⟨hc.1, hc.2.mono hGH⟩
152+
lemma IsVertexConnected.mono (hGH : G ≤ H) (hc : G.IsVertexConnected k) : H.IsVertexConnected k :=
153+
⟨hc.left, hc.right.mono hGH⟩
148154

149155
end SimpleGraph

0 commit comments

Comments
 (0)