-
Notifications
You must be signed in to change notification settings - Fork 441
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
Rewrite fails to disambiguate when only one option is valid #2849
Comments
NB: This happens with other tactics as well:
Arguably it’s an issue with |
Yes, that's #5873 |
@b-mehta Was this more of a porting gotcha or are you still interested in seeing this issue fixed? |
I'm still interested in seeing this issue fixed, outside of being a regression from Lean 3:
|
(deleting this comment because it was nonsense) |
So would you expect that all tactics to try all possible interpretations of a name, and silently use the first that happens to make progress? Or only some of them? Would |
No, but if there is exactly one interpretation which makes sense, I would expect the tactic to use that one, rather than failing with an error that there are multiple possible interpretations. If there are multiple interpretations which make sense, then an "ambiguous, possible interpretations" error is completely fine. The bug in this issue is specifically that I hope this makes it clearer what the expected behaviour here is! If nothing else, then I hope it is clear that "ambiguous, possible interpretations" is a poor error message given that not all the interpretations are actually possible. |
Thanks for the (heh) elaboration. My personal opinion is that I find the current behavior, with a clear phase separation between name resolution and tactic execution, more predictable and preferable. But I have noticed that I'm leaning towards more explicitness and less magic than seems to be idiomatic in at least mathlib, so I'll just let that stand and let others call this shot. |
And, to add, some more questions that this feature require raises: Assuming that
More generally, if in Actually, we almost already have that feature, in a way, although the syntax is a bit weird:
(And while you can write Anyways, it’s a big design space, and I’d prefer the simplicity of asking the use to be explicit which lemma they want to use. |
I think that this doesn't need to have quite so profound of design consequences @nomeata. The question to me is just "should kabstract be considered to be part of elaboration or not"? We have at least a couple examples of it being within the scope of elaboration (the triangle operator and elabAsElim), so it doesn't seem impossible for the product of a rw theorem elaboration to be the theorem and the motive together. This should naturally handle disambiguation in the way Bhavik would want. Edit: When writing this I forgot that this disambiguation happens too early even in the elaborator to help rw disambiguate. The next paragraph should be OK though. Similarly, for |
We discussed this a bit further, and decided to leave things as they are. The error message is rather explicit and actionable, so I expect the status quote to be less confusing overall. Plus the unclear scope of “exactly one works” in the presence of tactic combinators. (I acknowledge that the existing term-mode disambiguation muddies my argument a bit, but still.) |
I see, so this is viewed as an acceptable regression from Lean 3 behaviour? I don't view the error message as particularly clear in this case: it says there are multiple possible interpretations, not all of them are actually possible. Indeed, in the example in the OP, using The scope of "exactly one works" can be restricted to exactly the tactic which is throwing the error. Indeed, the behaviour here can be inferred from the Lean 3 version! Furthermore, this disambiguation is exactly how the term-mode disambiguation works, and how the
In the future, should I continue to expect inconsistencies like this in elaboration? |
Maybe I am confused by what you mean, but isn’t Would you say that
I understand this message as “possible interpretations of the name”, which is accurate. It does not mean “possible interpretations of the name for which rewriting succeeds”.
This is a concept I have qualms with. Many tactics are implemented by elaboration to other tactics. Do you mean “tactic that the user wrote” or “primitive tactic” (whatever that means). Consider Or similar with
Yes, unfortunately. Note that
also reports “ambiguous, possible interpretations”. It seems that term elaboration can and will use type information to resolve ambiguities, and it’s not always clear how much type information is available in a given context. But it seems that’s consistent with other features, like dot notation. |
@b-mehta I was just reading the Lean 3 source code, and I don't see anything that indicates that Could you please verify that the Lean 3 |
As far as I am aware, lean 3 did not handle this situation any better than lean 4. |
Hmm okay, this is convincing.
Huh, looking at my older non-minimised example, the behaviour which I'd originally complained about seems to actually work fine now (and behaves similarly to Lean 3). ...and investigating further, the difference happened in minimisation! The example with So I'm happy to consider this issue resolved. Thanks all! |
Prerequisites
Description
Rewrite fails to disambiguate when only one option is valid
Context
Zulip discussion: https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/ambiguous.20rewrite.20when.20only.20one.20is.20valid. The equivalent in Lean 3 succeeds. Thanks to @kmill for minimising. This showed up in porting the exponential-ramsey project.
Steps to Reproduce
Code as above.
Expected behavior: The rewrite succeeds and closes the goal.
Actual behavior: The rewrite fails.
Versions
Lean (version 4.3.0-rc1, commit baa4b68, Release)
MacOS
Additional Information
None
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
The text was updated successfully, but these errors were encountered: