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
[Merged by Bors] - feat(algebra/category/*): get rid of the local reducible hack #3354
Conversation
Looks good to me. This is definitely the way to go. Why is the PR closed? |
I ran into trouble in |
It used to be that the line Now, however we get the sick The problem is surely connected to where we use |
Okay, that's awesome, @gebner, thank you! I was beginning to suspect that it was |
No, you made exactly the right change to the derive handler. Before: @[instance]
protected noncomputable def ennreal.complete_linear_order : complete_linear_order ennreal :=
id with_top.complete_linear_order After: @[instance]
protected noncomputable def ennreal.complete_linear_order : complete_linear_order ennreal :=
with_top.complete_linear_order Notice the missing The built-in |
src/tactic/fix_by_cases.lean
Outdated
dec_e ← mk_app ``decidable [e] <|> fail "by_cases tactic failed, type is not a proposition", | ||
inst ← mk_instance dec_e <|> pure `(classical.prop_decidable %%e), | ||
let inst := `(id %%inst : decidable %%e), | ||
cases inst [h, h], |
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.
Does anybody use by_cases
in term-mode and expect the result to be a dite
?
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.
Apparently @b-mehta's fintype_hom
instance did, so I've changed it (back) to produce a dite
term.
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.
Is this something I can fix? Was it one of the things in wide_pullbacks
?
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.
No, I've already changed by_cases
so that it produces a dite
. I don't have a strong opinion one way or another. The cases
tactic (which produces decidable.rec
) was just easier to use than to construct a dite
term by hand.
And yes, it was wide_pullbacks
.
The only thing missing on this PR now are the linting errors (inhabited instances & docstrings).
It is surprisingly hard to write a robust |
- It only works if the proposition is decidable. | ||
- It sometimes unfolds the proposition. | ||
|
||
We override the `by_cases` tactic with a correct implementation here. |
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.
Why not fix this in core?
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.
I'll move it to core once it works in mathlib. But seeing the problems (and unforeseen issues) that I encountered while "improving" the tactic, it is absolutely necessary to test this on mathlib first.
Oh hah just the other day I saw this local reducible trick and thought it was clever and copied you! Now I know :) |
bors r+ |
I thought I did this back in April, but apparently never made the PR. We currently use a strange hack when setting up concrete categories, making them locally reducible. There's a library note about this, which ends: ``` TODO: Probably @[derive] should be able to create instances of the required form (without `id`), and then we could use that instead of this obscure `local attribute [reducible]` method. ``` This PR makes the small change required to `delta_instance` to make this happen, and then stops using the hack in setting up concrete categories (and deletes the library note explaining this hack). Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Gabriel Ebner <gebner@gebner.org>
Pull request successfully merged into master. Build succeeded: |
`by_cases` was changed to use classical reasoning (#3354, leanprover-community/lean#409), but the documentation hasn't been updated yet. I leave `by_contra` alone as it still uses `decidable`.
`by_cases` was changed to use classical reasoning (#3354, leanprover-community/lean#409), but the documentation hasn't been updated yet. I leave `by_contra` alone as it still uses `decidable`.
…over-community#3354) I thought I did this back in April, but apparently never made the PR. We currently use a strange hack when setting up concrete categories, making them locally reducible. There's a library note about this, which ends: ``` TODO: Probably @[derive] should be able to create instances of the required form (without `id`), and then we could use that instead of this obscure `local attribute [reducible]` method. ``` This PR makes the small change required to `delta_instance` to make this happen, and then stops using the hack in setting up concrete categories (and deletes the library note explaining this hack). Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Gabriel Ebner <gebner@gebner.org>
I thought I did this back in April, but apparently never made the PR.
We currently use a strange hack when setting up concrete categories, making them locally reducible. There's a library note about this, which ends:
This PR makes the small change required to
delta_instance
to make this happen, and then stops using the hack in setting up concrete categories (and deletes the library note explaining this hack).