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: custom eliminators for induction and cases tactics, and beautiful eliminators for Nat #3629

Merged
merged 3 commits into from
Mar 9, 2024

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Mar 7, 2024

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

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.

kmill added 3 commits March 6, 2024 22:06
Defines `@[induction_eliminator]` and `@[cases_eliminator]` for defining custom eliminators for the `induction` and `cases` tactics, respectively.

Also adds `Nat.recAux` and `Nat.casesAuxOn`, which are eliminators that are defeq to `Nat.rec` and `Nat.casesOn` but use `0` and `n + 1`.
These will be given the above attributes in a followup commit after updating stage0.
Adds the `@[induction_eliminator]` and `@[cases_eliminator]` attributes to these custom `Nat` eliminators so that `induction` and `cases` put everything in terms of `0` and `n + 1` rather than `Nat.zero` and `Nat.succ n`.

Also does fixes to account for the change from `@[eliminator]` to these two new attributes.
@kmill kmill requested review from leodemoura and kim-em as code owners March 7, 2024 06:20
@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 7, 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 611b1746896bbadf459c00cc218fa31cf51b4e08 --onto ae492265fec103aa834d897bf9f68c94d10f0785. (2024-03-07 06:38:33)

@leodemoura leodemoura added this pull request to the merge queue Mar 9, 2024
Merged via the queue into leanprover:master with commit 45fccc5 Mar 9, 2024
12 checks passed
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.

3 participants