lean4-htt/tests/lean/run/eliminatorImplicitTargets.lean
Kyle Miller 45fccc5906
feat: custom eliminators for induction and cases tactics, and beautiful 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.
2024-03-09 15:31:51 +00:00

13 lines
504 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

inductive Equality {α : Type u} : αα → Type u
| refl {a : α} : Equality a a
open Equality
@[induction_eliminator]
def ind {α : Type u} (motive : ∀ (a b : α) (p : Equality a b), Sort v)
{a : α} (πrefl : motive a a refl) {b : α} (p : Equality a b) : motive a b p :=
@Equality.casesOn α a (λ b p => motive a a refl → motive a b p) b p
(λ (ε : motive a a refl) => ε) πrefl
def symm {α : Type u} {a b : α} (p : Equality a b) : Equality b a :=
by { induction p; apply refl }