mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-24 20:23:11 +03:00
20 lines
428 B
Idris
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)
|