Skip to content

Commit 3305399

Browse files
author
twwar
committed
maximal acyclic subgraph
1 parent ef80520 commit 3305399

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

LatticePath/SpanningTree.lean

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ theorem sSup_acyclic_of_directed_of_acyclic (Hs : Set <| SimpleGraph V) (H₀ :
4747
rw [ne_eq, ←Walk.nil_iff_eq_nil, Walk.nil_iff_support_eq] at hp ⊢
4848
grind
4949

50+
theorem exists_maximal_acyclic_extension {H : SimpleGraph V} (hHG : H ≤ G) (hH : H.IsAcyclic) :
51+
∃ H' : SimpleGraph V, H ≤ H' ∧ Maximal (fun H => H ≤ G ∧ H.IsAcyclic) H' := by
52+
let s : Set (SimpleGraph V) := {H : SimpleGraph V | H ≤ G ∧ H.IsAcyclic}
53+
apply zorn_le_nonempty₀ s
54+
· intro c hcs hc y hy
55+
refine ⟨sSup c, ⟨?_, ?_⟩, CompleteLattice.le_sSup c⟩
56+
· simp only [sSup_le_iff]
57+
grind
58+
· exact sSup_acyclic_of_directed_of_acyclic c ⟨y, hy⟩ (by grind) hc.directedOn
59+
· grind
60+
5061
theorem add_edge_acyclic [DecidableEq V] {G : SimpleGraph V} (hG : IsAcyclic G) (x y : V)
5162
(hxy : ¬ Reachable G x y) : IsAcyclic <| G ⊔ fromEdgeSet {s(x,y)} := by
5263
have x_neq_y : x ≠ y := fun c => (c ▸ hxy) (Reachable.refl y)
@@ -112,20 +123,10 @@ theorem Connected.connected_of_maximal_acyclic [Inhabited V] (T : SimpleGraph V)
112123
simp_rw [s, SetLike.coe, ConnectedComponent.supp_inj, ←ConnectedComponent.mem_supp_iff]
113124
grind
114125

115-
theorem Connected.has_spanning_tree [Inhabited V] (hG : G.Connected) : ∃ T ≤ G, T.IsTree := by
116-
let s : Set (SimpleGraph V) := {H : SimpleGraph V | H ≤ G ∧ H.IsAcyclic}
117-
suffices ∃ T : (SimpleGraph V), Maximal (fun H => H ∈ s) T by
118-
obtain ⟨T, hT⟩ := this
119-
exact ⟨T, hT.1.1, hG.connected_of_maximal_acyclic T hT, hT.1.2
120-
apply zorn_le₀ s
121-
intro c hcs hc
122-
obtain rfl | ⟨H₀, hH₀⟩ := c.eq_empty_or_nonempty
123-
· use ⊥
124-
simp [s]
125-
· have : ∀ H ∈ c, H.IsAcyclic := by grind
126-
have :_ := sSup_acyclic_of_directed_of_acyclic c ⟨H₀, hH₀⟩ this hc.directedOn
127-
refine ⟨sSup c, ?_, CompleteLattice.le_sSup c⟩
128-
simp_rw [s, Set.mem_setOf_eq, sSup_le_iff]
129-
grind
126+
theorem Connected.has_spanning_tree [Inhabited V] (hG : G.Connected) {H : SimpleGraph V}
127+
(hHG : H ≤ G) (hH : H.IsAcyclic) : ∃ T ≤ G, H ≤ T ∧ T.IsTree := by
128+
obtain ⟨T, hHT, hT⟩ := exists_maximal_acyclic_extension hHG hH
129+
exact ⟨T, hT.1.1, hHT, hG.connected_of_maximal_acyclic T hT, hT.1.2
130+
130131

131132
end SimpleGraph

0 commit comments

Comments
 (0)