lean4-htt/tests/lean/termination_by2.lean
Joachim Breitner 6d23450642
refactor: rewrite TerminationHint elaborators (#2958)
In order to familiarize myself with this code, and so that the next
person has an easier time, I

* added docstrings explaining what I found out these things to
* rewrote the syntax expansion functions using syntax pattern matches,
  to the extend possible
2023-12-02 10:08:07 +00:00

68 lines
1.1 KiB
Text

mutual
def f (n : Nat) :=
if n == 0 then 0 else f (n / 2) + 1
termination_by _ => n
end
mutual
def f (n : Nat) :=
if n == 0 then 0 else f (n / 2) + 1
end
termination_by n => n
def g' (n : Nat) :=
match n with
| 0 => 1
| n+1 => g' n * 3
termination_by
g' n => n
_ n => n
mutual
def isEven : Nat → Bool
| 0 => true
| n+1 => isOdd n
def isOdd : Nat → Bool
| 0 => false
| n+1 => isEven n
end
termination_by
isEven x => x -- Error
mutual
def isEven : Nat → Bool
| 0 => true
| n+1 => isOdd n
def isOdd : Nat → Bool
| 0 => false
| n+1 => isEven n
end
termination_by
isEven x => x
isOd x => x -- Error
mutual
def isEven : Nat → Bool
| 0 => true
| n+1 => isOdd n
def isOdd : Nat → Bool
| 0 => false
| n+1 => isEven n
end
termination_by
isEven x => x
isEven y => y -- Error
mutual
def isEven : Nat → Bool
| 0 => true
| n+1 => isOdd n
def isOdd : Nat → Bool
| 0 => false
| n+1 => isEven n
end
termination_by
isEven x => x
_ x => x
_ x => x + 1 -- Error