-
Notifications
You must be signed in to change notification settings - Fork 108
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
feat: more lemmas and perf update #329
Conversation
* fixed `le`, `lt`, `min`, `max` to be more efficient * fixed lemma names and added some aliases
@eric-wieser Would you mind checking this out to see if I missed anything? I'll work on the Mathlib patch tomorrow. |
@joehendrix I tagged this one WIP just because I want to check-in with @eric-wieser. It's also ready for review by others. Feel free to change the label as you find most appropriate. |
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.
This looks good, thanks! Its not clear to me what the purpose of these aliases is; arguably having lots of ways to spell the same thing makes it harder for people to spot the patterns in the naming. If you do really want to keep them, I think it would be appropriate to add a /-!
comment before the first batch of aliases explaining the motivation.
I'm fine with the name change and without the aliases. They seem to be for backward compatibility, as they are the pre-renamed names. I think we could start a policy of using |
I added brief comments as @eric-wieser suggested. @digama0 I'm not sure what you're recommending but my personal philosophy is to try to accommodate everyone, when possible. People who think of |
Well, this is what we have a naming convention for. We should make a rule for how to name these things and stick to it, we should not make versions for multiple naming conventions unless the convention itself is ambiguous about how to name them. I would argue that in this case we can have a clear rule - binary functions are named in infix - and stick to it, at least for the basic functions one would find in Std.Logic. |
Let's make some rules then! Even though I'd personally prefer no rules, having any rules at all would be progress! |
I think Mario just did. :-) |
I agree that we should pick one naming scheme. Having multiple aliases for the same definition has its own costs. For simplification rules, I personally prefer prefix naming using the root symbol of the left-hand side independent of whether the operator is infix or prefix. e.g, I would naively expect I am open to the other options though. Hopefully better search and automation can make knowing individual lemma names like that less important. |
Our naming convention is ambiguous with regard to parenthesis positioning. This is okay, names don't need to be unique with respect to all theorems that could possibly exist, only the ones that do exist, and in the few cases where this arises we just use
This decision also affects mathlib, which is using the same naming convention. (This isn't just me making up a rule on the spot, it's the rule that already exists in mathlib.) If we want to make a change here we should make sure everyone is on the same page. |
Ok, let's make sure are on the same page for the naming convention. Obviously we've all written enough simp rules that these conventions aren't being made up on the spot. It sounds like the Mathlib naming convention is to name simp theorems like this based roughly on the left-to-right order of the left-hand side as typically rendered, and the proposal is to do the same here. I'm ok with that. Is that captured anywhere else? |
No, it does not use rendering order, because this depends on how the author decided to write the expression and lean is pretty freeform regarding textual order. In particular dot-notation functions are named in prefix (i.e. |
Ok, let me try to specify this again: If the lemma is a binary operator (see below), then we typically use a left-op-right ordering. Otherwise, we use a preorder naming scheme with the operator name followed by arguments. A binary operator is either:
I think the goal here is to reduce the need to specify left/right. I still personally prefer the preorder approach (mostly so I can use the top operator in IDE completion), but I think as long as there is a clear intention I am ok with adopting the Mathlib scheme. |
My concern regarding prefix-everything is that we clearly can't follow this rule for (I think your specification is fine, it covers all the cases I can think of.) |
I'm okay with @joehendrix's spec. (More importantly the existence of a spec!) For clarity: Should the prefix alternatives be deprecated or just marginalized in some way? Note that using |
I think it's good to have |
This sounds like a pretty misleading example to me; IIRC, |
These are questionable but Mathlib breaks without them.
I've cleaned up this PR according to the naming conventions. (Let me know if I missed something!) CI is currently working on testing the Mathlib patch. I just deleted the prefix aliases and did not deprecate them. The reason is that if some (perhaps imaginary) Std user is attached to the prefix convention in some circumstances, deprecation would basically prevent them from updating Std and adding their preferred aliases until the deprecation window is done. That seems like a bad idea to me especially if such deprecation windows compound, which may lead users to give up on Std altogether. |
That's an excellent point. We should have some mechanism for users to be able to at least remove upstream deprecation marks if they either disagree with the deprecation or want to globally allow usage of that particular deprecated function in their project without silencing all warnings. |
The ideal solution might be for deprecation to have a more complex mechanism where it doesn't actually declare the named theorem but does something like what private does and stops issuing warnings once a proper declaration is made. That sounds very complicated though! |
The Mathlib patch has passed CI. I can't think of any major edits to this PR, but I'm always happy to hear nitpicks! @semorrison Do we still have time to make the 4.2.0 release? |
@eric-wieser It is indeed a subtle, even possibly misleading example, since one has to make the equivalence between the two bind functions. I did that intentionally in the "spec" because #334 is currently under review, and I think the notion of "infix" is not literally syntactically equal to infix notation, but a more general semantic notion. |
Sorry, I didn't see this query until too late. Std is now on |
This bumps Std up to leanprover-community/batteries#329. This is a replacement for #8005, which I'll now close. Co-authored-by: François G. Dorais <fgdorais@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
le
,lt
,min
,max
to be more efficient