Skip to content
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

use does not work with the goal type #5072

Closed
Ruben-VandeVelde opened this issue Jun 15, 2023 · 2 comments
Closed

use does not work with the goal type #5072

Ruben-VandeVelde opened this issue Jun 15, 2023 · 2 comments
Labels
lean4-change-in-behaviour Describes a known change in behaviour. No implication that it "needs fixing". t-meta Tactics, attributes or user commands

Comments

@Ruben-VandeVelde
Copy link
Collaborator

This fails:

example (n : Nat) : Nat := by
  use n

though it worked in mathlib3.

@Ruben-VandeVelde Ruben-VandeVelde added the lean4-change-in-behaviour Describes a known change in behaviour. No implication that it "needs fixing". label Jun 15, 2023
@semorrison
Copy link
Contributor

This link searches for references to this issue in the source code.

@kmill
Copy link
Contributor

kmill commented Jun 21, 2023

I've made a PR to make use support this, and I've added a use! that is almost the same as the original mathlib3 use. #5350

@urkud urkud added the t-meta Tactics, attributes or user commands label Jul 16, 2023
bors bot pushed a commit that referenced this issue Jul 27, 2023
…like flattening `use!` (#5350)

Changes:
* `use` now by default discharges with `try with_reducible use_discharger` with a custom discharger tactic rather than `try with_reducible rfl`, which makes it be closer to `exists` and the `use` in mathlib3. It doesn't go so far as to do `try with_reducible trivial` since that involves the `contradiction` tactic.
* this discharger is configurable with `use (discharger := tacticSeq...)`
* the `use` evaluation loop will try refining after constructor failure, so it can be used to fill in all arguments rather than all but the last, like in mathlib3 (closes #5072) but with the caveat that it only works so long as the last argument is not an inductive type (like `Eq`).
* adds `use!`, which is nearly the same as the mathlib3 `use` and fills in constructor arguments along the nodes *and* leaves of the nested constructor expressions. This version tries refining before applying constructors, so it can be used like `exact` for the last argument.

The difference between mathlib3 `use` and this `use!` is that (1) `use!` uses a different tactic to discharge goals (mathlib3 used `trivial'`, which did reducible refl, but also `contradiction`, which we don't emulate) (2) it does not rewrite using `exists_prop`. Regarding 2, this feature seems to be less useful now that bounded existentials encode the bound using a conjunction rather than with nested existentials. We do have `exists_prop` as part of `use_discharger` however.



Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>
@bors bors bot closed this as completed in c841722 Jul 28, 2023
adomani pushed a commit that referenced this issue Jul 28, 2023
…like flattening `use!` (#5350)

Changes:
* `use` now by default discharges with `try with_reducible use_discharger` with a custom discharger tactic rather than `try with_reducible rfl`, which makes it be closer to `exists` and the `use` in mathlib3. It doesn't go so far as to do `try with_reducible trivial` since that involves the `contradiction` tactic.
* this discharger is configurable with `use (discharger := tacticSeq...)`
* the `use` evaluation loop will try refining after constructor failure, so it can be used to fill in all arguments rather than all but the last, like in mathlib3 (closes #5072) but with the caveat that it only works so long as the last argument is not an inductive type (like `Eq`).
* adds `use!`, which is nearly the same as the mathlib3 `use` and fills in constructor arguments along the nodes *and* leaves of the nested constructor expressions. This version tries refining before applying constructors, so it can be used like `exact` for the last argument.

The difference between mathlib3 `use` and this `use!` is that (1) `use!` uses a different tactic to discharge goals (mathlib3 used `trivial'`, which did reducible refl, but also `contradiction`, which we don't emulate) (2) it does not rewrite using `exists_prop`. Regarding 2, this feature seems to be less useful now that bounded existentials encode the bound using a conjunction rather than with nested existentials. We do have `exists_prop` as part of `use_discharger` however.



Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>
semorrison pushed a commit that referenced this issue Aug 2, 2023
…like flattening `use!` (#5350)

Changes:
* `use` now by default discharges with `try with_reducible use_discharger` with a custom discharger tactic rather than `try with_reducible rfl`, which makes it be closer to `exists` and the `use` in mathlib3. It doesn't go so far as to do `try with_reducible trivial` since that involves the `contradiction` tactic.
* this discharger is configurable with `use (discharger := tacticSeq...)`
* the `use` evaluation loop will try refining after constructor failure, so it can be used to fill in all arguments rather than all but the last, like in mathlib3 (closes #5072) but with the caveat that it only works so long as the last argument is not an inductive type (like `Eq`).
* adds `use!`, which is nearly the same as the mathlib3 `use` and fills in constructor arguments along the nodes *and* leaves of the nested constructor expressions. This version tries refining before applying constructors, so it can be used like `exact` for the last argument.

The difference between mathlib3 `use` and this `use!` is that (1) `use!` uses a different tactic to discharge goals (mathlib3 used `trivial'`, which did reducible refl, but also `contradiction`, which we don't emulate) (2) it does not rewrite using `exists_prop`. Regarding 2, this feature seems to be less useful now that bounded existentials encode the bound using a conjunction rather than with nested existentials. We do have `exists_prop` as part of `use_discharger` however.



Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>
semorrison pushed a commit that referenced this issue Aug 14, 2023
…like flattening `use!` (#5350)

Changes:
* `use` now by default discharges with `try with_reducible use_discharger` with a custom discharger tactic rather than `try with_reducible rfl`, which makes it be closer to `exists` and the `use` in mathlib3. It doesn't go so far as to do `try with_reducible trivial` since that involves the `contradiction` tactic.
* this discharger is configurable with `use (discharger := tacticSeq...)`
* the `use` evaluation loop will try refining after constructor failure, so it can be used to fill in all arguments rather than all but the last, like in mathlib3 (closes #5072) but with the caveat that it only works so long as the last argument is not an inductive type (like `Eq`).
* adds `use!`, which is nearly the same as the mathlib3 `use` and fills in constructor arguments along the nodes *and* leaves of the nested constructor expressions. This version tries refining before applying constructors, so it can be used like `exact` for the last argument.

The difference between mathlib3 `use` and this `use!` is that (1) `use!` uses a different tactic to discharge goals (mathlib3 used `trivial'`, which did reducible refl, but also `contradiction`, which we don't emulate) (2) it does not rewrite using `exists_prop`. Regarding 2, this feature seems to be less useful now that bounded existentials encode the bound using a conjunction rather than with nested existentials. We do have `exists_prop` as part of `use_discharger` however.



Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lean4-change-in-behaviour Describes a known change in behaviour. No implication that it "needs fixing". t-meta Tactics, attributes or user commands
Projects
None yet
4 participants