lean4-htt/tests/lean/run/matchEqs.lean
Leonardo de Moura 173b956961
feat: reserved names (#3675)
- Add support for reserved declaration names. We use them for theorems
generated on demand.
- Equation theorems are not private declarations anymore.
- Generate equation theorems on demand when resolving symbols.
- Prevent users from creating declarations using reserved names. Users
can bypass it using meta-programming.

See next test for examples.
2024-03-15 00:33:22 +00:00

28 lines
626 B
Text

import Lean
syntax (name := test) "test%" ident : command
open Lean.Elab
open Lean.Elab.Command
@[command_elab test] def elabTest : CommandElab := fun stx => do
let id ← liftCoreM <| realizeGlobalConstNoOverloadWithInfo stx[1]
liftTermElabM do
IO.println (repr (← Lean.Meta.Match.getEquationsFor id))
return ()
def f (x : List Nat) : Nat :=
match x with
| [] => 1
| [a] => 2
| _ => 3
test% f.match_1
#check @f.match_1
#check @f.match_1.splitter
theorem ex (x : List Nat) : f x > 0 := by
simp [f]
split <;> decide
test% Lean.RBNode.balance1.match_1
#check @Lean.RBNode.balance1.match_1.splitter