Zulip Chat Archive
Stream: mathlib4
Topic: global notation linter
Patrick Massot (Jun 04 2024 at 20:09):
Should we have a linter against global notation? Of course it could be deactivated when needed. I just found #10043 that introduced an extremely generic notation (the infix operator ^*
) to use it exactly twice in Mathlib if I’m not mistaken. Clearly this is a failure of the reviewing process but linters should be here to help reviewers.
Patrick Massot (Jun 04 2024 at 20:12):
We’ll see in #13518 whether CI agrees this notation was not used elsewhere.
Yaël Dillies (Jun 04 2024 at 20:50):
I mean surely global notation is usually fine?
Patrick Massot (Jun 04 2024 at 20:52):
Maybe there would be too many nolints. I’m really not sure what to do. Maybe we need some GitHub bot to detect that word notation and post a message reminding reviewers to check whether the notation is global and reasonable.
Patrick Massot (Jun 04 2024 at 21:01):
In the mean time CI confirmed that global ^*
was used exactly twice in Mathlib. I would appreciate a quick merge of #13518 so that I can finish updating GlimpseOfLean.
Richard Osborn (Jun 05 2024 at 00:12):
I do think in general it would be nice for CI to post a summary of a PR. A list of theorems added and/or deleted, notations added, change in the import graph, etc... Basically, anything that would make it easier for reviewers to spot suspicious changes.
Patrick Massot (Jun 05 2024 at 01:47):
@Alex J. Best had a nice prototype in January.
Damiano Testa (Jun 05 2024 at 05:11):
Richard Osborn said:
I do think in general it would be nice for CI to post a summary of a PR. A list of theorems added and/or deleted, notations added, change in the import graph, etc... Basically, anything that would make it easier for reviewers to spot suspicious changes.
Each PR has a CI step called summarize-declarations
that does a part of that.
A more verbose output, such as this and a more compact one that you can get by adding the label move-decls
(the same PR as an example).
Alex J. Best (Jun 05 2024 at 09:35):
Patrick Massot said:
Alex J. Best had a nice prototype in January.
I would even say that it was progressing beyond the prototype stage. But I no longer have time to work on it. If anyone, or the community wants to adopt github.com/alexjbest/leaff that would make me very happy
Yaël Dillies (Jun 06 2024 at 16:00):
Speaking of PRs introducing global notation... #11142
Patrick Massot (Jun 06 2024 at 16:24):
Thanks for noticing. All those notations should definitely be scoped.
Patrick Massot (Jan 07 2025 at 08:54):
Once again, I suffering because of crazy global notations introduced in super low-level files. Today it’s https://github.com/leanprover-community/mathlib4/blob/d4a7b67c52e526f04082b832d2f3d298b17bd29e/Mathlib/Logic/Function/Defs.lean#L46-L47. @Kyle Miller is there anything I can do to deactivate this notation in a downstream project? Or should I stick to Lean 4.15.0 because of this?
Yaël Dillies (Jan 07 2025 at 09:20):
I don't understand why 4.15.0 vs 4.16.0-rc1 would change anything. This notation has been around forever (and is quite useless, I agree)
Kyle Miller (Jan 07 2025 at 10:02):
My understanding is that you can't disable syntaxes.
I don't understand why 4.15->4.16 would change anything either.
Given that this is a mathlib notation, could we scope it (or delete it?)
Yaël Dillies (Jan 07 2025 at 10:04):
Happy to see it go to :wastebasket:
Eric Wieser (Jan 07 2025 at 10:19):
I think it's used fairly heavily with Disjoint (f on tuple)
and Pairwise (Disjoint on tuple)
; but maybe f.on tuple
would be fine instead
Patrick Massot (Jan 07 2025 at 10:20):
Yaël, the reason why 4.15.0 vs 4.16.0-rc1 changes everything has been discussed at length already, it’s lean4#6012.
Yaël Dillies (Jan 07 2025 at 10:21):
Ah! not because the mathlib on
notation but because your on
notation changed.
Patrick Massot (Jan 07 2025 at 10:21):
This major change in parsing makes it much harder to avoid hitting this on
notation bug.
Eric Wieser (Jan 07 2025 at 10:28):
What prevents you using the same token?
Eric Wieser (Jan 07 2025 at 10:30):
(we have many notations in mathlib that use a ]
token, for instance)
Patrick Massot (Jan 07 2025 at 10:32):
I guess it creates a grammar ambiguity.
Patrick Massot (Jan 07 2025 at 10:33):
By the way, I wrote the wrong number. This issue prevents bumping from 4.14.0 to 4.15.0, it has nothing to do with 4.16
Patrick Massot (Jan 07 2025 at 10:38):
If anyone wants to play with this, it’s at https://github.com/PatrickMassot/verbose-lean4/tree/bump
Patrick Massot (Jan 07 2025 at 10:39):
https://github.com/PatrickMassot/verbose-lean4/blob/bump/Verbose/French/By.lean#L8 does not work because of Mathlib’s on
notation.
Patrick Massot (Jan 07 2025 at 10:40):
It creates tons of unexpected token 'obtient'; expected term
.
Kim Morrison (Jan 08 2025 at 00:51):
@Patrick Massot, I'm preparing a PR to scope on
. Will scoping be enough for your purposes? The Function
namespace gets opened pretty frequently.
I'm also happy to require people to write f.on tuple
as Eric suggested above.
Kim Morrison (Jan 08 2025 at 01:24):
chore: scope 'on' notation to Function #20562
Last updated: May 02 2025 at 03:31 UTC