-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(Combinatorics/SimpleGraph/Acyclic): define star graphs #38027
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
34ca34e
e672972
9f9e7c7
cfa0439
d1a36c9
eebb8e1
d3c0233
3a1e62f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -667,4 +667,62 @@ lemma isAcyclic_iff_pairwise_not_isEdgeReachable_two : | |||||||||||
| · refine isAcyclic_iff_forall_adj_isBridge.mpr fun _ _ hadj ↦ ?_ | ||||||||||||
| exact isBridge_iff_adj_and_not_isEdgeConnected_two.mpr ⟨hadj, h hadj.ne⟩ | ||||||||||||
|
|
||||||||||||
| section Star | ||||||||||||
|
|
||||||||||||
| /-- The star graph on `V` centered at `r`: every non-center vertex is adjacent to `r`. -/ | ||||||||||||
| def starGraph (r : V) : SimpleGraph V := | ||||||||||||
| SimpleGraph.fromRel (fun x _ => x = r) | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
|
||||||||||||
| instance [DecidableEq V] (r : V) : DecidableRel (starGraph r).Adj := by | ||||||||||||
| unfold starGraph; infer_instance | ||||||||||||
|
Comment on lines
+676
to
+677
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @JovanGerb, should this be (I'm not sure what the rules are) |
||||||||||||
|
|
||||||||||||
| @[simp] | ||||||||||||
| lemma starGraph_adj {r x y : V} : (starGraph r).Adj x y ↔ x ≠ y ∧ (x = r ∨ y = r) := by | ||||||||||||
| unfold starGraph | ||||||||||||
| simp [SimpleGraph.fromRel] | ||||||||||||
|
Comment on lines
+680
to
+682
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
|
||||||||||||
| /-- If v ≠ r, then v is adjacent to r. -/ | ||||||||||||
| lemma starGraph_center_adj {r v : V} (h : r ≠ v) : (starGraph r).Adj r v := | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add |
||||||||||||
| starGraph_adj.mpr ⟨h, Or.inl rfl⟩ | ||||||||||||
|
|
||||||||||||
| lemma starGraph_isConnected (r : V) : (starGraph r).Connected := by | ||||||||||||
8e7 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||
| have : ∀ v, (starGraph r).Reachable r v := by | ||||||||||||
| intro v | ||||||||||||
8e7 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||
| by_cases! h : r = v | ||||||||||||
| · exact h ▸ Reachable.rfl | ||||||||||||
| · exact (starGraph_center_adj h).reachable | ||||||||||||
| exact connected_iff _ |>.mpr ⟨fun u v => (this u).symm.trans (this v), ⟨r⟩⟩ | ||||||||||||
|
|
||||||||||||
| lemma starGraph_isAcyclic (r : V) : (starGraph r).IsAcyclic := by | ||||||||||||
| refine isAcyclic_iff_forall_adj_isBridge.mpr fun v w hadj ↦ isBridge_iff.mpr ⟨hadj, ?_⟩ | ||||||||||||
| rw [starGraph_adj] at hadj | ||||||||||||
| wlog! h : v = r | ||||||||||||
| · have hw : w = r := hadj.2.resolve_left h | ||||||||||||
| replace hadj : w ≠ v ∧ (w = r ∨ v = r) := ⟨hadj.1.symm, hadj.2.symm⟩ | ||||||||||||
| rw [reachable_comm, Sym2.eq_swap] | ||||||||||||
| exact this r w v hadj hw | ||||||||||||
| · subst h | ||||||||||||
| apply not_reachable_of_neighborSet_right_eq_empty hadj.1 | ||||||||||||
| ext x; aesop | ||||||||||||
|
|
||||||||||||
| /-- A star graph is a tree. -/ | ||||||||||||
| lemma starGraph_isTree (r : V) : (starGraph r).IsTree := by | ||||||||||||
| refine ⟨starGraph_isConnected r, starGraph_isAcyclic r⟩ | ||||||||||||
|
|
||||||||||||
| /-- Every non-center vertex of a starGraph has degree one. -/ | ||||||||||||
| lemma starGraph_not_center_imp_degree_one [Fintype V] [DecidableEq V] {r v : V} (h : v ≠ r) : | ||||||||||||
| (starGraph r).degree v = 1 := | ||||||||||||
|
Comment on lines
+712
to
+713
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| degree_eq_one_iff_existsUnique_adj.mpr ⟨r, by simp [h], by grind [starGraph_adj]⟩ | ||||||||||||
|
|
||||||||||||
| /-- The center vertex of a starGraph has degree (card V) - 1. -/ | ||||||||||||
| lemma starGraph_center_degree [Fintype V] [DecidableEq V] {r : V} : | ||||||||||||
| (starGraph r).degree r = Fintype.card V - 1 := by | ||||||||||||
|
Comment on lines
+717
to
+718
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| rw [degree, neighborFinset_eq_filter (starGraph r)] | ||||||||||||
| simp only [starGraph_adj, ne_eq, true_or, and_true] | ||||||||||||
| have : ({w | ¬r = w} : Finset V) = Finset.univ.erase r := by | ||||||||||||
| ext v; simp [eq_comm] | ||||||||||||
| rw [this, Finset.card_erase_of_mem (Finset.mem_univ r), Finset.card_univ] | ||||||||||||
|
|
||||||||||||
| end Star | ||||||||||||
|
|
||||||||||||
| end SimpleGraph | ||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
How about moving this to a new file that imports
Acyclic.lean?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 suggested the same. I think it is a good idea to have it in a new file