Given a definition `foo`, they were previously called `foo._unfold` until 4.7.0. We tried to rename them to `foo.def`, but it created too many issues in the Mathlib repo. We decided to rename it again to `foo.eq_def`. The new name is also consistent with the `eq_<idx>` theorems generated for different "cases". That is, `foo.eq_def` is the equality theorem for the whole definition, and `foo.eq_<idx>` is the equality theorem for case `<idx>`. cc @semorrison
48 lines
854 B
Text
48 lines
854 B
Text
import Lean
|
||
|
||
open Lean
|
||
open Lean.Meta
|
||
def tst (declName : Name) : MetaM Unit := do
|
||
IO.println (← getUnfoldEqnFor? declName)
|
||
|
||
mutual
|
||
def f : Nat → α → α → α
|
||
| 0, a, b => a
|
||
| n, a, b => g a n b |>.1
|
||
termination_by n _ _ => (n, 2)
|
||
decreasing_by
|
||
simp_wf
|
||
apply Prod.Lex.right
|
||
decide
|
||
|
||
def g : α → Nat → α → (α × α)
|
||
| a, 0, b => (a, b)
|
||
| a, n, b => (h a b n, a)
|
||
termination_by _ n _ => (n, 1)
|
||
decreasing_by
|
||
simp_wf
|
||
apply Prod.Lex.right
|
||
decide
|
||
|
||
def h : α → α → Nat → α
|
||
| a, b, 0 => b
|
||
| a, b, n+1 => f n a b
|
||
termination_by _ _ n => (n, 0)
|
||
decreasing_by
|
||
simp_wf
|
||
apply Prod.Lex.left
|
||
apply Nat.lt_succ_self
|
||
end
|
||
|
||
#eval f 5 'a' 'b'
|
||
|
||
#eval tst ``f
|
||
#check @f.eq_1
|
||
#check @f.eq_2
|
||
#check @f.eq_def
|
||
|
||
|
||
#eval tst ``h
|
||
#check @h.eq_1
|
||
#check @h.eq_2
|
||
#check @h.eq_def
|