-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(combinatorics/simple_graph/connectivity): number of connected components when deleting edges #17654
base: master
Are you sure you want to change the base?
Conversation
Add definition for number of connected components and then prove that this number either goes up by 1 or is unchanged when an edge is removed, depending on if its in a cycle or not.
Could you fix the style errors? |
Should be fixed now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left some comments for the first half. Once you've addressed them, I'll keep going through the rest.
Thanks for your work on the relationship between delete_edges
and the number of connected components!
@@ -697,6 +705,8 @@ lemma edge_finset_delete_edges [fintype V] [decidable_eq V] [decidable_rel G.adj | |||
(G.delete_edges s).edge_finset = G.edge_finset \ s := | |||
by { ext e, simp [edge_set_delete_edges] } | |||
|
|||
lemma delete_non_edge {e: sym2 V} (he: e ∉ G.edge_set) : G.delete_edges {e} = G := by {ext,finish} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that finish
has now been banned in mathlib3 since it's not going to be ported to Lean 4.
There are some more general results we should add here, in place of delete_non_edge
.
lemma delete_edges_eq_self_iff_disjoint {s : set (sym2 V)} :
G.delete_edges s = G ↔ disjoint G.edge_set s :=
begin
rw [set.disjoint_left, simple_graph.ext_iff],
simp only [function.funext_iff, delete_edges_adj, eq_iff_iff, and_iff_left_iff_imp],
split,
{ intro h,
refine sym2.ind (λ v w, _),
exact h v w, },
{ intros h v w hvw,
rw ← mem_edge_set at hvw,
exact h hvw, }
end
lemma delete_edges_singleton_eq_self_iff_not_mem :
G.delete_edges {e} = G ↔ e ∉ G.edge_set :=
by rw [delete_edges_eq_self_iff_disjoint, set.disjoint_singleton_right]
I should mention that mathlib3 style is that type ascription colons should have a space on both sides, so {e : sym2 V}
rather than {e: sym2 V}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make both of those lemmas simp.
lemma darts_nodup_of_edges_nodup {u v : V} {p : G.walk u v} (h : p.edges.nodup) : p.darts.nodup | ||
:=list.nodup.of_map dart.edge h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mathlib3 style:
lemma darts_nodup_of_edges_nodup {u v : V} {p : G.walk u v} (h : p.edges.nodup) : p.darts.nodup | |
:=list.nodup.of_map dart.edge h | |
lemma darts_nodup_of_edges_nodup {u v : V} {p : G.walk u v} (h : p.edges.nodup) : p.darts.nodup := | |
list.nodup.of_map dart.edge h |
Co-authored-by: Kyle Miller <kmill31415@gmail.com>
…unity/mathlib into graphs_num_comps Merging suggested edit with local edits
Thanks for your various comments! Sorry for the delay, but I think I've now fixed everything you mentioned (as well as similar issues later in the code). Let me know what you think |
This PR is on my radar, and while it missed the mathlib3 cutoff, I'm hoping to (eventually) get it ported to mathlib4! |
Add definition for number of connected components and then prove that this number either goes up by 1 or is unchanged when an edge is removed, depending on if its in a cycle or not.