-
Notifications
You must be signed in to change notification settings - Fork 465
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: better support for reducing Nat.rec
#3616
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
closes #3022 With this commit, given the declaration ``` def foo : Nat → Nat | 0 => 2 | n + 1 => foo n ``` when we unfold `foo (n+1)`, we now obtain `foo n` instead of `foo (Nat.add n 0)`.
Mathlib CI status (docs):
|
eric-wieser
reviewed
Mar 7, 2024
@@ -64,9 +65,17 @@ def constructorApp? (e : Expr) : MetaM (Option (ConstructorVal × Array Expr)) : | |||
|
|||
/-- | |||
Similar to `constructorApp?`, but on failure it puts `e` in WHNF and tries again. | |||
It also `isOffset?` |
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 assume this sentence is incomplete?
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 9, 2024
…utiful eliminators for `Nat` (#3629) Replaces `@[eliminator]` with two attributes `@[induction_eliminator]` and `@[cases_eliminator]` for defining custom eliminators for the `induction` and `cases` tactics, respectively. Adds `Nat.recAux` and `Nat.casesAuxOn`, which are eliminators that are defeq to `Nat.rec` and `Nat.casesOn`, but these use `0` and `n + 1` rather than `Nat.zero` and `Nat.succ n`. For example, using `induction` to prove that the factorial function is positive now has the following goal states (thanks also to #3616 for the goal state after unfolding). ```lean example : 0 < fact x := by induction x with | zero => decide | succ x ih => /- x : Nat ih : 0 < fact x ⊢ 0 < fact (x + 1) -/ unfold fact /- ... ⊢ 0 < (x + 1) * fact x -/ simpa using ih ``` Thanks to @adamtopaz for initial work on splitting the `@[eliminator]` attribute.
tydeu
pushed a commit
to tydeu/lean4
that referenced
this pull request
Mar 11, 2024
closes leanprover#3022 With this commit, given the declaration ``` def foo : Nat → Nat | 0 => 2 | n + 1 => foo n ``` when we unfold `foo (n+1)`, we now obtain `foo n` instead of `foo (Nat.add n 0)`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
toolchain-available
A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #3022
With this commit, given the declaration
when we unfold
foo (n+1)
, we now obtainfoo n
instead offoo (Nat.add n 0)
.