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

feat: better support for reducing Nat.rec #3616

Merged
merged 1 commit into from
Mar 6, 2024
Merged

feat: better support for reducing Nat.rec #3616

merged 1 commit into from
Mar 6, 2024

Conversation

leodemoura
Copy link
Member

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).

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)`.
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 6, 2024 03:55 Inactive
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Mar 6, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Std/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 794228a982aa55cd320d5e289c80b8839f8418b0 --onto ae492265fec103aa834d897bf9f68c94d10f0785. (2024-03-06 04:00:07)

@leodemoura leodemoura added this pull request to the merge queue Mar 6, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 6, 2024
@leodemoura leodemoura added this pull request to the merge queue Mar 6, 2024
Merged via the queue into master with commit 09bc477 Mar 6, 2024
11 checks passed
@@ -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?`
Copy link
Contributor

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nat.add n 0 expressions appear when unfolding with simp (but not with rw)
3 participants