quox/examples/nat.quox
2023-04-17 21:44:16 +02:00

38 lines
901 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;
def0 succ-inj : 0.(m : ) → 0.(n : ) →
0.(succ m ≡ succ n : ) → m ≡ n : =
λ m n eq ⇒ δ i ⇒ pred (eq @i);