quox/examples/nat.quox
2023-04-01 19:16:30 +02:00

34 lines
759 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

defω dup- : 1. → [ω.] =
λ n ⇒
case1 n return [ω.] of {
zero ⇒ [zero];
succ _, 1.d ⇒
case1 d return [ω.] of { [d] ⇒ [succ d] }
};
defω plus : 1. → 1. =
λ m n ⇒
case1 m return of {
zero ⇒ n;
succ _, 1.p ⇒ succ p
};
defω times-ω : 1. → ω. =
λ m n ⇒
case1 m return of {
zero ⇒ zero;
succ _, 1.t ⇒ plus n t
};
defω times : 1. → 1. =
λ m n ⇒
case1 dup- n return of {
[n] ⇒ times-ω m n
};
defω pred : 1. =
λ n ⇒
case1 n return of { zero ⇒ zero; succ n ⇒ n };
def0 pred-succ : ω.(n : ) → pred (succ n) ≡ n : =
λ n ⇒ δ i ⇒ n;