feat(Combinatorics/SimpleGraph/Acyclic): define star graphs#38027
feat(Combinatorics/SimpleGraph/Acyclic): define star graphs#380278e7 wants to merge 8 commits intoleanprover-community:masterfrom
Conversation
Welcome new contributor!Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests. We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR. Thank you again for joining our community. |
PR summary 2ff88851d5Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
Please mark the review comments 'resolved' once you've addressed them so the next reviewer doesn't think they're still open. |
Co-authored-by: Vlad Tsyrklevich <vlad902@gmail.com>
IvanRenison
left a comment
There was a problem hiding this comment.
I like the idea!
Maybe we should have StarGraph in a separate graph
| lemma starGraph_adj {r x y : V} : (starGraph r).Adj x y ↔ x ≠ y ∧ (x = r ∨ y = r) := by | ||
| unfold starGraph | ||
| simp [SimpleGraph.fromRel] |
There was a problem hiding this comment.
| lemma starGraph_adj {r x y : V} : (starGraph r).Adj x y ↔ x ≠ y ∧ (x = r ∨ y = r) := by | |
| unfold starGraph | |
| simp [SimpleGraph.fromRel] | |
| lemma starGraph_adj {r x y : V} : (starGraph r).Adj x y ↔ x ≠ y ∧ (x = r ∨ y = r) := by | |
| simp [starGraph, fromRel] |
| simp [SimpleGraph.fromRel] | ||
|
|
||
| /-- If v ≠ r, then v is adjacent to r. -/ | ||
| lemma starGraph_center_adj {r v : V} (h : r ≠ v) : (starGraph r).Adj r v := |
There was a problem hiding this comment.
Can you also add (starGraph r).Adj v r?
| lemma starGraph_not_center_imp_degree_one [Fintype V] [DecidableEq V] {r v : V} (h : v ≠ r) : | ||
| (starGraph r).degree v = 1 := |
There was a problem hiding this comment.
| lemma starGraph_not_center_imp_degree_one [Fintype V] [DecidableEq V] {r v : V} (h : v ≠ r) : | |
| (starGraph r).degree v = 1 := | |
| lemma degree_starGraph_of_ne_center [Fintype V] [DecidableEq V] {r v : V} (h : v ≠ r) : | |
| (starGraph r).degree v = 1 := |
| lemma starGraph_center_degree [Fintype V] [DecidableEq V] {r : V} : | ||
| (starGraph r).degree r = Fintype.card V - 1 := by |
There was a problem hiding this comment.
| lemma starGraph_center_degree [Fintype V] [DecidableEq V] {r : V} : | |
| (starGraph r).degree r = Fintype.card V - 1 := by | |
| lemma degree_starGraph_center [Fintype V] [DecidableEq V] {r : V} : | |
| (starGraph r).degree r = Fintype.card V - 1 := by |
|
|
||
| /-- 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) |
There was a problem hiding this comment.
| SimpleGraph.fromRel (fun x _ => x = r) | |
| .fromRel fun v _ ↦ v = r |
| · refine isAcyclic_iff_forall_adj_isBridge.mpr fun _ _ hadj ↦ ?_ | ||
| exact isBridge_iff_adj_and_not_isEdgeConnected_two.mpr ⟨hadj, h hadj.ne⟩ | ||
|
|
||
| section Star |
There was a problem hiding this comment.
How about moving this to a new file that imports Acyclic.lean?
There was a problem hiding this comment.
I suggested the same. I think it is a good idea to have it in a new file
| instance [DecidableEq V] (r : V) : DecidableRel (starGraph r).Adj := by | ||
| unfold starGraph; infer_instance |
There was a problem hiding this comment.
Hey @JovanGerb, should this be inferInstanceAs?
(I'm not sure what the rules are)
There was a problem hiding this comment.
Yes! We shouldn't use tactics like unfold or dsimp to create instances.
(with Decidable instances we typically don't run into diamonds, so it would probably not have been a problem in this case. But it's better to consistently apply these rules)
Add a new definition
starGraphand several key lemmas. Star graphs are a trivial class of tree, often used in constructive proofs regarding trees.All lemmas are hand written first, then golfed with the help of Claude Code.