Idris2/tests/idris2/total/total023/Abel2002.idr
2023-11-06 20:10:21 +00:00

20 lines
428 B
Idris

-- 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)