Zulip Chat Archive
Stream: mathlib4
Topic: Renaming SimpleGraph.{edgeSet,vertexSet}
Peter Nelson (May 07 2025 at 23:32):
To reduce noise, I'll bring up the second issue in this thread as well. (I'm happy to have it moved to a new thread if a moderator thinks that would be better).
For G : SimpleGraph V, the vertex set is the type V, and the edge set is a Set, referred to as G.edgeSet.
For multigraph G : Graph a b, both the vertex set and edge sets are Sets. I have called them G.V and G.E, and was thinking a good convention would be to call them edgeSet and vertexSet in lemma names.
I think the compact notation is important, mostly because the design of multigraphs will require the vertex and edge sets to be explicitly referred to a lot in hypotheses; the comparison is something like
(hx : x ∈ G.V) (hy : y ∈ G.V) (he : e ∈ G.E) vs (hx : x ∈ G.vertexSet) (hy : y ∈ G.vertexSet) (he : e ∈ G.edgeSet) in countless places.
If H is a subgraph of G, then I believe H.V ⊆ G.V looks much cleaner than H.vertexSet ⊆ G.vertexSet and I don't think any clarity is lost. I have used the same convention for mathlib's matroids (where M.E is the ground set of a matroid M, and this is called ground in lemma names) and I think it's working well.
But Eric brought up that this would cause an inconsistency between Graph and SimpleGraph, where Graph.E corresponds to SimpleGraph.edgeSet. Fixing this would involve either changing what exists for SimpleGraph, or using the long names for multigraphs.
I have a much stronger point of view on this issue than the last one - I believe the longer names will cause the multigraph API to be considerably uglier. But consistency is also good, so here's a poll anyway!
Peter Nelson (May 07 2025 at 23:34):
/poll How should the edge/vertex sets of SimpleGraph and Graph be denoted?
SimpleGraph.E and Graph.V/Graph.E, with vertexSet and edgeSet in lemma names
[Simple]Graph.vertexSet and [Simple]Graph.edgeSet,
Graph.V and [Simple]Graph.edgeSet, with vertexSet for Graph.V in lemma names
Peter Nelson (May 07 2025 at 23:43):
(To be clear, the first option would involve a commitment to eventually rename SimpleGraph.edgeSet to SimpleGraph.E, without changing existing lemma names.)
Bhavik Mehta (May 07 2025 at 23:44):
My opinion is that we should also move towards refactoring SimpleGraph to either mimic Graph or be defined in terms of it, ie eventually go even further than just renaming to match
Notification Bot (May 08 2025 at 00:14):
4 messages were moved here from #mathlib4 > Multigraph notation - naming poll by Eric Wieser.
Eric Wieser (May 08 2025 at 00:15):
Peter Nelson said:
I'm happy to have it moved to a new thread if a moderator thinks that would be better).
(I did this, I think we want visibility in the title of the rename being proposed, to make it easier to spot)
Eric Wieser (May 08 2025 at 00:17):
The proposal to use vertexSet in theorems names but V in the definition seems quite strange to me; this goes against our default symbol-reading rule (though the new preferred spelling machinery does at least give us a way to document it). I would have expected V in both places or neither, like Polynomial.X (which I guess could have been Polynomial.var instead)
Bhavik Mehta (May 08 2025 at 00:29):
I agree it goes against the default; my vote above is assuming that it's documented using recommended_spelling, in the module doc, and on the definition itself, together with the justification (as in the original post here) for the decision. Provided it is, I think the justification above makes sense
Pim Otte (May 08 2025 at 06:16):
I might be missing some context from somewhere else, but what is the case against using V/E in names too?
I'm not strongly opposed to introducing a split, but in mirroring Matroid, we might also consider verts/vertices/edges as names.
Peter Nelson (May 08 2025 at 10:53):
Single capital letters look strange with the capitalization convention in lemma names, I find. It also feels right for lemma names to correspond somewhat to how things are said, rather than written.
verts/edges isn’t bad, though. One disadvantage maybe is that these objects will also be packaged in Finset and List forms in other places, so Set disambiguates these.
Eric Wieser (May 08 2025 at 11:29):
Peter Nelson said:
Single capital letters look strange with the capitalization convention in lemma names, I find
But we do use them extensively in Polynomial
Andrew Yang (May 08 2025 at 11:36):
My two cents as a passerby:
I think it is very strange if the name of the definition doesn't match the name in lemmas. Maybe one could consider naming the field vertexSet but introduce a scoped notation V(G) for that?
Peter Nelson (May 08 2025 at 11:51):
That hadn’t occurred to me, but that is exactly how it is written, and would be perfect. If there are no technical problems with that, it would be a great compromise-free solution.
Peter Nelson (May 08 2025 at 14:59):
I've now played around with V(G)/E(G) notation, and it has caused no problems, even when the same notation is used for multiple related objects, eg V(P) for the vertex set of a path in a graph G, with statements like V(P) = V(G). See this proof in my repo for an example of the notation in action.
Peter Nelson (May 08 2025 at 15:04):
I think this is really the ideal solution - it will mean that no actual definitions or lemma names in SimpleGraph need to be deprecated or refactored; we just define new notation E(G) for SimpleGraph.edgeSet G and change lemma statements to use it.
The E(_) and V(_) notation could also become standard for paths, walks, cycles, subgraphs, etc in both simple and non-simple graphs.
We could also introduce a similar notation like E₀(G) for G.edgeFinset.
Peter Nelson (May 08 2025 at 15:12):
I've added a new poll option, and changed my vote in that direction.
Eric Wieser (May 08 2025 at 15:27):
Are you suggesting vxSet as the name, or did the poll force you to truncate?
Peter Nelson (May 08 2025 at 15:43):
Yes, I am. vertexSet is a bit long. SimpleGraph.subgraph uses verts, but I think it is less obvious from the name what type that should have.
Peter Nelson (May 08 2025 at 15:44):
vx is the normal 'teaching on the board' abbreviation for 'vertex'.
Sébastien Gouëzel (May 08 2025 at 17:18):
If you have a notation available, isn't it reasonable for the full name to be as understandable as possible, i.e., vertexSet? (I have never encountered vx)
Peter Nelson (May 09 2025 at 15:40):
It was a late addition to the poll, but reactions seems to suggest we are on board with the V(G)/E(G) notation, with vertexSet/edgeSet in definitions. Is this correct?
Eric Wieser (May 09 2025 at 16:07):
Should we pick a notation for the finset ones at the same time?
Peter Nelson (May 10 2025 at 02:51):
E₀(G) and V₀(G) are what come to mind - are there any other suggestions? (Note that this really only applies to SimpleGraph.edgeFinset at the moment - there is nothing planned immediately for finsets and Graph)
Eric Wieser (May 10 2025 at 12:20):
I don't know if there's any precedent in mathlib for using _0 in that way
Andrew Yang (May 10 2025 at 12:22):
I'm guessing the idea comes from →₀, but that notation is probably because Finsupp is a function that is mostly zero, not that ₀ has anything inherent to do with finiteness.
Peter Nelson (May 10 2025 at 12:35):
Maybe a subscript f, similar to finsum?
Eric Wieser (May 10 2025 at 12:51):
I thought finsum was superscript?
Peter Nelson (May 10 2025 at 13:23):
It is. Either would work
Last updated: Dec 20 2025 at 21:32 UTC