quox/examples/bool.quox

29 lines
748 B
Plaintext

load "misc.quox";
namespace bool {
def0 Bool : ★ = {true, false};
def boolω : Bool → [ω.Bool] =
λ b ⇒ case b return [ω.Bool] of { 'true ⇒ ['true]; 'false ⇒ ['false] };
def if : 0.(A : ★) → Bool → ω.A → ω.A → A =
λ A b t f ⇒ case b return A of { 'true ⇒ t; 'false ⇒ f };
def0 If : Bool → ★ → ★ → ★ =
λ b T F ⇒ case b return ★ of { 'true ⇒ T; 'false ⇒ F };
def0 T : Bool → ★ = λ b ⇒ If b True False;
def true-not-false : Not ('true ≡ 'false : Bool) =
λ eq ⇒ coe (i ⇒ T (eq @i)) 'true;
-- [todo] infix
def and : Bool → ω.Bool → Bool = λ a b ⇒ if Bool a b 'false;
def or : Bool → ω.Bool → Bool = λ a b ⇒ if Bool a 'true b;
}
def0 Bool = bool.Bool;