-
Notifications
You must be signed in to change notification settings - Fork 397
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: apply_rfl tactic: handle Eq, HEq, better error messages #3714
Conversation
this implements the first half of #3302: It improves the extensible `rfl` tactic (the one that looks at `refl` attributes) to * Check itself that the lhs and rhs are defEq, and give a nice consistent error message when they don't (instead of just passing on the less helpful error message from `apply Foo.refl`) * Also handle `Eq` and `HEq` (built in) and `Iff` (using the attribute) Care ist taken that, as before, the transparency setting affects comparing the lhs and rhs, but not the reduction of the relation A test file checks the various failure modes and error messages. I believe this `apply_rfl` can serve as the only implementation of `rfl`, which would then complete #3302, but that seems to require a non-trivial bootstrapping dance, so maybe better done separately.
leanprover-community-mathlib4-bot
commented
Mar 19, 2024
•
edited by leanprover-community-bot
Loading
edited by leanprover-community-bot
Mathlib CI status (docs):
|
throwError MessageData.tagged `Tactic.unsolvedGoals <| m!"unsolved goals\n{ | ||
goalsToMessageData gs}" |
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 seems like it should be a function somewhere
Ah, interesting: The So I should adjust this code to do these things as well (reduce with |
This is a bit unfortunate: since a given goal can look quite different under Given prominence of (The alternative of using either |
the `rfl` was a bit of a defeq abuse: The goal was `StateEqRs a b` for definitely different terms `a` and `b`, but it was still using `StateEqRs.refl a`, because then after unfolding `StateEqRs` and doing a bit of computation the proof held. This would break once leanprover/lean4#3714 lands, and is a bit fishy in any case so let's just let `simp` handle it.
This reverts commit c972bcb.
This implements the first half of #3302: It improves the extensible
apply_rfl
tactic (the one that looks atrefl
attributes, part ofthe
rfl
macro) toCheck itself and ahead of time that the lhs and rhs are defEq, and give
a nice consistent error message when they don't (instead of just passing on
the less helpful error message from
apply Foo.refl
), and using themachinery that
apply
uses to elaborate expressions to highlight diffsin implicit arguments.
Also handle
Eq
andHEq
(built in) andIff
(using the attribute)Care is taken that, as before, the current transparency setting affects
comparing the lhs and rhs, but not the reduction of the relation
So before we had
and with this PR the messages we get are
resp.
A test file checks the various failure modes and error messages.
I believe this
apply_rfl
can serve as the only implementation ofrfl
, which would then complete #3302, and actually expose these improvederror messages to the user. But as that seems to require a
non-trivial bootstrapping dance, it’ll be separate.