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: generalize elab_as_elim to allow arbitrary motive applications #5510

Merged
merged 1 commit into from
Sep 28, 2024

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Sep 28, 2024

Now the elab-as-elim procedure allows eliminators whose result is an arbitrary application of the motive. For example, the following is now accepted. It will generalize Int.natAbs _ from the expected type.

@[elab_as_elim]
theorem natAbs_elim {motive : Nat → Prop} (i : Int)
  (hpos : ∀ (n : Nat), i = n → motive n)
  (hneg : ∀ (n : Nat), i = -↑n → motive n) :
  motive (Int.natAbs i) := by sorry

This change simplifies the elaborator, since it no longer needs to keep track of discriminants (which can easily be read off from the return type of the eliminator) or the difference between "targets" and "extra arguments" (which are now both "major arguments" that should be eagerly elaborated).

Closes #4086

Simplifies the elab-as-elim procedure, and as a consequence now eliminators can include arbitrary expressions.

For example, the following is now accepted. It will generalize `Int.natAbs _` from the expected type.
```lean
@[elab_as_elim]
theorem natAbs_elim {motive : Nat → Prop} (i : Int)
  (hpos : ∀ (n : Nat), i = n → motive n)
  (hneg : ∀ (n : Nat), i = -↑n → motive n) :
  motive (Int.natAbs i) := by sorry
  ```

Closes leanprover#4086
@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 Sep 28, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Sep 28, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Sep 28, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@leanprover-community-bot leanprover-community-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Sep 28, 2024
@kmill kmill added this pull request to the merge queue Sep 28, 2024
Merged via the queue into leanprover:master with commit 130b465 Sep 28, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR 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.

elab_as_elim does not support function application in resulting motive arguments
2 participants