Idris2/tests/idris2/total/total023/Abel2002.idr

20 lines
428 B
Idris
Raw Normal View History

-- adapted from:
-- Andreas Abel, Thorsten Altenkirch
-- A predicative analysis of structural recursion
-- https://doi.org/10.1017/S0956796801004191
data Ord : Type where
O : Ord
S : Ord -> Ord
Lim : (Nat -> Ord) -> Ord
total
addord : Ord -> Ord -> Ord
addord_lim : (Nat -> Ord) -> Ord -> Ord
addord O y = y
addord (S x) y = S (addord x y)
addord (Lim f) y = addord_lim f y
addord_lim f y = Lim (\z => addord (f z) y)