feat(Combinatorics/GraphLike): introduce GraphLike typeclass#36743
feat(Combinatorics/GraphLike): introduce GraphLike typeclass#36743Jun2M wants to merge 34 commits intoleanprover-community:masterfrom
GraphLike typeclass#36743Conversation
PR summary e960b84129Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
lauramonk
left a comment
There was a problem hiding this comment.
Thank you! This seems great to me, maybe a few names to pick carefully. Notably I agree with the idea of calling the notion GraphLike. I am not certain about prodDart and in particular I do not fully understand the point of having the two different objects (but this is my own ignorance).
|
@IvanRenison, I have moved the instance of |
|
Okay |
|
|
Hi Ivan, the problem with Graph is that Darts have not yet been added for them. I have a repo with a notion of Dart of Graph, with the inversion and basic results, here. I need to adapt it to Jun2M's set-up to prove the instance for Graph; it should be fairly straightforward but I have not yet managed to (as I am a beginner). |
|
@IvanRenison, For For |
|
@Jun2M Please feel free to work on Dart for Graph, as you are a lot faster. I clearly cannot do it until next week. If our work on https://github.com/lauramonk/mathlib4/tree/GraphDart is of any use please also feel free to take it from there. I feel it would make sense to define Dart for Graph before GraphLike. |
|
I can also PR Dart for Graph without the instance and let you write the instance. |
|
Ah, I didn't thought that there are still no Darts in Graph. I think adding temporary instances here is a good idea. And later they could be moved, but also they can simply be extended |
|
@IvanRenison, by adding temporary instances, do you mean |
|
I would add |
|
@lauramonk, I am realising I should have coordinated things much better. Perhaps there should be a separate Zulip thread to discuss the I did say I like your I thought I would finish making PR for moving SimpleGraph stuff to be based on |
|
This pull request has conflicts, please merge |
| rfl | ||
|
|
||
| /-- Convert a step to a dart. -/ | ||
| def step.todart (h : step G u v) : darts G := ⟨h.val, h.prop.1⟩ |
There was a problem hiding this comment.
Maybe we want this to return β? I don't know, but it is is worth asking I think
There was a problem hiding this comment.
This was initially defined as that but so many of the theorems in SimpleGraph expected the darts to be a type so it was changed. I think there is an argument to have whether there should be a function that returns β along with this function but, unless we want ⟨step.todart h, step.todart_mem h⟩ everywhere in SimpleGraph, I think we should have a function that returns darts G.
| lemma adj_of_mem_darts (hd : d ∈ darts G) : Adj G (fst d) (snd d) := | ||
| exists_darts_iff_adj.mp ⟨d, hd, rfl, rfl⟩ |
There was a problem hiding this comment.
Could you make this an iff?
There was a problem hiding this comment.
The other direction is not true as there can be d that does not belong in darts G yet shares fst and snd with a dart that is in darts G.
| @[inherit_doc verts] | ||
| scoped notation "V(" G ")" => verts G | ||
|
|
||
| variable {α β Gr : Type*} {G : Gr} {u u' v v' w : α} {d : β} |
There was a problem hiding this comment.
| variable {α β Gr : Type*} {G : Gr} {u u' v v' w : α} {d : β} | |
| variable {V β Gr : Type*} {G : Gr} {u u' v v' w : V} {d : β} |
From to the style guidelines:
Types with a mathematical content are expressed with the usual mathematical notation, often with an upper case letter (
Gfor a group,Rfor a ring,Kor𝕜for a field, E for a vector space, ...). This convention is not followed in older files, where greek letters are used for all types. Pull requests renaming type variables in these files are welcome.
In SimpleGraph the use is mixed, sometimes with α, β, etc. and some times with U, V, etc. but maybe for new things we should use U, V, etc.
Per discussion at (#graph theory > HasAdj), This PR introduces the
GraphLiketypeclass to capture the notions likedartandwalkacross various graph objects, such asSimpleGraph,Graph, andDigraph.The goal is that by abstracting these core components into a typeclass, we can prove these results once for all graph-like structures rather than duplicating them across different graph types.
This PR generalises #35776 to also unify
Graph.Main definitions
GraphLike α β Gr: A typeclass parameterized by a vertex typeα, dart typeβand a graph typeGr(withαas anoutParam).GraphLike.verts : Set α: The set of vertices of the graph.GraphLike.darts : Set β: The set of darts of the graph.GraphLike.Adj : α → α → Prop: The adjacency relation, defined by default asNonempty (darts G u v).