@@ -328,8 +328,7 @@ lemma IsPath.getVert_eq_start_iff {i : ℕ} {p : G.Walk u w} (hp : p.IsPath) (hi
328
328
lemma IsPath.getVert_eq_end_iff {i : ℕ} {p : G.Walk u w} (hp : p.IsPath) (hi : i ≤ p.length) :
329
329
p.getVert i = w ↔ i = p.length := by
330
330
have := hp.reverse.getVert_eq_start_iff (by omega : p.reverse.length - i ≤ p.reverse.length)
331
- simp only [length_reverse, getVert_reverse,
332
- show p.length - (p.length - i) = i from by omega] at this
331
+ simp only [length_reverse, getVert_reverse, show p.length - (p.length - i) = i by omega] at this
333
332
rw [this]
334
333
omega
335
334
@@ -893,7 +892,6 @@ lemma Reachable.mem_subgraphVerts {u v} {H : G.Subgraph} (hr : G.Reachable u v)
893
892
exact aux (H.edge_vert (h _ hv' _ (Walk.adj_snd hnp)).symm) p.tail
894
893
termination_by p.length
895
894
decreasing_by {
896
- simp_wf
897
895
rw [← Walk.length_tail_add_one hnp]
898
896
omega
899
897
}
@@ -1132,15 +1130,12 @@ theorem map_mk (φ : G →g G') (v : V) :
1132
1130
rfl
1133
1131
1134
1132
@[simp]
1135
- theorem map_id (C : ConnectedComponent G) : C.map Hom.id = C := by
1136
- refine C.ind ?_
1137
- exact fun _ => rfl
1133
+ theorem map_id (C : ConnectedComponent G) : C.map Hom.id = C := C.ind (fun _ => rfl)
1138
1134
1139
1135
@[simp]
1140
1136
theorem map_comp (C : G.ConnectedComponent) (φ : G →g G') (ψ : G' →g G'') :
1141
- (C.map φ).map ψ = C.map (ψ.comp φ) := by
1142
- refine C.ind ?_
1143
- exact fun _ => rfl
1137
+ (C.map φ).map ψ = C.map (ψ.comp φ) :=
1138
+ C.ind (fun _ => rfl)
1144
1139
1145
1140
variable {φ : G ≃g G'} {v : V} {v' : V'}
1146
1141
@@ -1167,10 +1162,8 @@ namespace Iso
1167
1162
def connectedComponentEquiv (φ : G ≃g G') : G.ConnectedComponent ≃ G'.ConnectedComponent where
1168
1163
toFun := ConnectedComponent.map φ
1169
1164
invFun := ConnectedComponent.map φ.symm
1170
- left_inv C := ConnectedComponent.ind
1171
- (fun v => congr_arg G.connectedComponentMk (Equiv.left_inv φ.toEquiv v)) C
1172
- right_inv C := ConnectedComponent.ind
1173
- (fun v => congr_arg G'.connectedComponentMk (Equiv.right_inv φ.toEquiv v)) C
1165
+ left_inv C := C.ind (fun v => congr_arg G.connectedComponentMk (Equiv.left_inv φ.toEquiv v))
1166
+ right_inv C := C.ind (fun v => congr_arg G'.connectedComponentMk (Equiv.right_inv φ.toEquiv v))
1174
1167
1175
1168
@[simp]
1176
1169
theorem connectedComponentEquiv_refl :
@@ -1203,9 +1196,8 @@ def supp (C : G.ConnectedComponent) :=
1203
1196
theorem supp_injective :
1204
1197
Function.Injective (ConnectedComponent.supp : G.ConnectedComponent → Set V) := by
1205
1198
refine ConnectedComponent.ind₂ ?_
1206
- intro v w
1207
1199
simp only [ConnectedComponent.supp, Set.ext_iff, ConnectedComponent.eq, Set.mem_setOf_eq]
1208
- intro h
1200
+ intro v w h
1209
1201
rw [reachable_comm, h]
1210
1202
1211
1203
@[simp]
@@ -1228,15 +1220,6 @@ lemma mem_supp_congr_adj {v w : V} (c : G.ConnectedComponent) (hadj : G.Adj v w)
1228
1220
· exact hadj.symm
1229
1221
· exact hadj
1230
1222
1231
- lemma adj_spanningCoe_induce_supp {v w : V} (c : G.ConnectedComponent) :
1232
- (G.induce c.supp).spanningCoe.Adj v w ↔ v ∈ c.supp ∧ G.Adj v w := by
1233
- by_cases h : v ∈ c.supp
1234
- · refine ⟨by aesop, ?_⟩
1235
- intro h'
1236
- have : w ∈ c.supp := by rwa [c.mem_supp_congr_adj h'.2 ] at h
1237
- aesop
1238
- · aesop
1239
-
1240
1223
theorem connectedComponentMk_mem {v : V} : v ∈ G.connectedComponentMk v :=
1241
1224
rfl
1242
1225
@@ -1263,8 +1246,7 @@ lemma mem_coe_supp_of_adj {v w : V} {H : Subgraph G} {c : ConnectedComponent H.c
1263
1246
lemma eq_of_common_vertex {v : V} {c c' : ConnectedComponent G} (hc : v ∈ c.supp)
1264
1247
(hc' : v ∈ c'.supp) : c = c' := by
1265
1248
simp only [mem_supp_iff] at *
1266
- subst hc hc'
1267
- rfl
1249
+ rw [← hc, ← hc']
1268
1250
1269
1251
lemma connectedComponentMk_supp_subset_supp {G'} {v : V} (h : G ≤ G') (c' : G'.ConnectedComponent)
1270
1252
(hc' : v ∈ c'.supp) : (G.connectedComponentMk v).supp ⊆ c'.supp := by
@@ -1288,28 +1270,84 @@ lemma top_supp_eq_univ (c : ConnectedComponent (⊤ : SimpleGraph V)) :
1288
1270
have ⟨w, hw⟩ := c.exists_rep
1289
1271
ext v
1290
1272
simp only [Set.mem_univ, iff_true, mem_supp_iff, ← hw]
1291
- apply SimpleGraph.ConnectedComponent.sound
1292
- exact (@SimpleGraph.top_connected V (Nonempty.intro v)).preconnected v w
1273
+ apply ConnectedComponent.sound
1274
+ exact (@top_connected V (Nonempty.intro v)).preconnected v w
1275
+
1276
+ lemma reachable_of_mem_supp {G : SimpleGraph V} (C : G.ConnectedComponent) {u v : V}
1277
+ (hu : u ∈ C.supp) (hv : v ∈ C.supp) : G.Reachable u v := by
1278
+ rw [mem_supp_iff] at hu hv
1279
+ exact ConnectedComponent.exact (hv ▸ hu)
1280
+
1281
+ lemma mem_supp_of_adj_mem_supp {G : SimpleGraph V} (C : G.ConnectedComponent) {u v : V}
1282
+ (hu : u ∈ C.supp) (hadj : G.Adj u v) : v ∈ C.supp := by
1283
+ have hC : G.connectedComponentMk u = G.connectedComponentMk v :=
1284
+ connectedComponentMk_eq_of_adj hadj
1285
+ rw [hu] at hC
1286
+ exact hC.symm
1287
+
1288
+ /--
1289
+ Given a connected component `C` of a simple graph `G`, produce the induced graph on `C`.
1290
+ The declaration `connected_toSimpleGraph` shows it is connected, and `toSimpleGraph_hom`
1291
+ provides the homomorphism back to `G`.
1292
+ -/
1293
+ def toSimpleGraph {G : SimpleGraph V} (C : G.ConnectedComponent) : SimpleGraph C := G.induce C.supp
1293
1294
1294
- lemma reachable_induce_supp {v w} {c : ConnectedComponent G} (hv : v ∈ c.supp) (hw : w ∈ c.supp)
1295
- (p : G.Walk v w) : (G.induce c.supp).Reachable ⟨v, hv⟩ ⟨w, hw⟩ := by
1296
- induction p with
1297
- | nil => rfl
1298
- | @cons u v w h p ih =>
1299
- have : v ∈ c.supp := (c.mem_supp_congr_adj h).mp hv
1300
- obtain ⟨q⟩ := ih this hw
1301
- have hadj : (G.induce c.supp).Adj ⟨u, hv⟩ ⟨v, this⟩ := h
1302
- use q.cons hadj
1303
-
1304
- lemma connected_induce_supp (c : ConnectedComponent G) : (G.induce c.supp).Connected := by
1305
- rw [connected_iff_exists_forall_reachable]
1306
- use ⟨c.out, c.out_eq⟩
1307
- intro w
1308
- have hwc := (c.mem_supp_iff w).mp (Subtype.coe_prop w)
1309
- obtain ⟨p⟩ := ConnectedComponent.exact
1310
- (show G.connectedComponentMk c.out = G.connectedComponentMk w by
1311
- simp [← hwc, connectedComponentMk])
1312
- exact c.reachable_induce_supp c.out_eq hwc p
1295
+ /-- Homomorphism from a connected component graph to the original graph. -/
1296
+ def toSimpleGraph_hom {G : SimpleGraph V} (C : G.ConnectedComponent) : C.toSimpleGraph →g G where
1297
+ toFun u := u.val
1298
+ map_rel' := id
1299
+
1300
+ lemma toSimpleGraph_hom_apply {G : SimpleGraph V} (C : G.ConnectedComponent) (u : C) :
1301
+ C.toSimpleGraph_hom u = u.val := rfl
1302
+
1303
+ lemma toSimpleGraph_adj {G : SimpleGraph V} (C : G.ConnectedComponent) {u v : V} (hu : u ∈ C)
1304
+ (hv : v ∈ C) : C.toSimpleGraph.Adj ⟨u, hu⟩ ⟨v, hv⟩ ↔ G.Adj u v := by
1305
+ simp [toSimpleGraph]
1306
+
1307
+ lemma adj_spanningCoe_toSimpleGraph {v w : V} (C : G.ConnectedComponent) :
1308
+ C.toSimpleGraph.spanningCoe.Adj v w ↔ v ∈ C.supp ∧ G.Adj v w := by
1309
+ apply Iff.intro
1310
+ · intro h
1311
+ simp_all only [map_adj, SetLike.coe_sort_coe, Subtype.exists, mem_supp_iff]
1312
+ obtain ⟨_, a, _, _, h₁, h₂, h₃⟩ := h
1313
+ subst h₂ h₃
1314
+ exact ⟨a, h₁⟩
1315
+ · simp only [toSimpleGraph, map_adj, comap_adj, Embedding.subtype_apply, Subtype.exists,
1316
+ exists_and_left, and_imp]
1317
+ intro h hadj
1318
+ exact ⟨v, h, w, hadj, rfl, (C.mem_supp_congr_adj hadj).mp h, rfl⟩
1319
+
1320
+ @[deprecated (since := "2025-05-08")]
1321
+ alias adj_spanningCoe_induce_supp := adj_spanningCoe_toSimpleGraph
1322
+
1323
+ /-- Get the walk between two vertices in a connected component from a walk in the original graph. -/
1324
+ private def walk_toSimpleGraph' {G : SimpleGraph V} (C : G.ConnectedComponent) {u v : V}
1325
+ (hu : u ∈ C) (hv : v ∈ C) (p : G.Walk u v) : C.toSimpleGraph.Walk ⟨u, hu⟩ ⟨v, hv⟩ := by
1326
+ cases p with
1327
+ | nil => exact Walk.nil
1328
+ | @cons v w u h p =>
1329
+ have hw : w ∈ C := C.mem_supp_of_adj_mem_supp hu h
1330
+ have h' : C.toSimpleGraph.Adj ⟨u, hu⟩ ⟨w, hw⟩ := h
1331
+ exact Walk.cons h' (C.walk_toSimpleGraph' hw hv p)
1332
+
1333
+ @[deprecated (since := "2025-05-08")] alias reachable_induce_supp := walk_toSimpleGraph'
1334
+
1335
+ /-- There is a walk between every pair of vertices in a connected component. -/
1336
+ noncomputable def walk_toSimpleGraph {G : SimpleGraph V} (C : G.ConnectedComponent) {u v : V}
1337
+ (hu : u ∈ C) (hv : v ∈ C) : C.toSimpleGraph.Walk ⟨u, hu⟩ ⟨v, hv⟩ :=
1338
+ C.walk_toSimpleGraph' hu hv (C.reachable_of_mem_supp hu hv).some
1339
+
1340
+ lemma reachable_toSimpleGraph {G : SimpleGraph V} (C : G.ConnectedComponent) {u v : V}
1341
+ (hu : u ∈ C) (hv : v ∈ C) : C.toSimpleGraph.Reachable ⟨u, hu⟩ ⟨v, hv⟩ :=
1342
+ Walk.reachable (C.walk_toSimpleGraph hu hv)
1343
+
1344
+ lemma connected_toSimpleGraph (C : ConnectedComponent G) : (C.toSimpleGraph).Connected where
1345
+ preconnected := by
1346
+ intro ⟨u, hu⟩ ⟨v, hv⟩
1347
+ exact C.reachable_toSimpleGraph hu hv
1348
+ nonempty := ⟨C.out, C.out_eq⟩
1349
+
1350
+ @[deprecated (since := "2025-05-08")] alias connected_induce_supp := connected_toSimpleGraph
1313
1351
1314
1352
end ConnectedComponent
1315
1353
@@ -1327,7 +1365,7 @@ lemma iUnion_connectedComponentSupp (G : SimpleGraph V) :
1327
1365
⋃ c : G.ConnectedComponent, c.supp = Set.univ := by
1328
1366
refine Set.eq_univ_of_forall fun v ↦ ⟨G.connectedComponentMk v, ?_⟩
1329
1367
simp only [Set.mem_range, SetLike.mem_coe]
1330
- exact ⟨by use G.connectedComponentMk v; exact rfl, rfl⟩
1368
+ exact ⟨⟨ G.connectedComponentMk v, rfl⟩ , rfl⟩
1331
1369
1332
1370
theorem Preconnected.set_univ_walk_nonempty (hconn : G.Preconnected) (u v : V) :
1333
1371
(Set.univ : Set (G.Walk u v)).Nonempty := by
@@ -1361,8 +1399,7 @@ theorem reachable_delete_edges_iff_exists_walk {v w v' w' : V} :
1361
1399
simpa using p.edges_subset_edgeSet h
1362
1400
· rintro ⟨p, h⟩
1363
1401
refine ⟨p.transfer _ fun e ep => ?_⟩
1364
- simp only [edgeSet_sdiff, edgeSet_fromEdgeSet, edgeSet_sdiff_sdiff_isDiag, Set.mem_diff,
1365
- Set.mem_singleton_iff]
1402
+ simp only [edgeSet_sdiff, edgeSet_fromEdgeSet, edgeSet_sdiff_sdiff_isDiag]
1366
1403
exact ⟨p.edges_subset_edgeSet ep, fun h' => h (h' ▸ ep)⟩
1367
1404
1368
1405
theorem isBridge_iff_adj_and_forall_walk_mem_edges {v w : V} :
0 commit comments