quox/examples/bool.quox

29 lines
748 B
Plaintext
Raw Normal View History

2023-04-18 18:42:40 -04:00
load "misc.quox";
namespace bool {
2023-05-21 14:33:42 -04:00
def0 Bool : ★ = {true, false};
2023-04-18 18:42:40 -04:00
def boolω : Bool → [ω.Bool] =
λ b ⇒ case b return [ω.Bool] of { 'true ⇒ ['true]; 'false ⇒ ['false] };
2023-04-18 18:42:40 -04:00
def if : 0.(A : ★) → Bool → ω.A → ω.A → A =
λ A b t f ⇒ case b return A of { 'true ⇒ t; 'false ⇒ f };
2023-04-18 18:42:40 -04:00
def0 If : Bool → ★ → ★ → ★ =
λ b T F ⇒ case b return ★ of { 'true ⇒ T; 'false ⇒ F };
2023-04-18 18:42:40 -04:00
def0 T : Bool → ★ = λ b ⇒ If b True False;
2023-04-18 18:42:40 -04:00
def true-not-false : Not ('true ≡ 'false : Bool) =
λ eq ⇒ coe (i ⇒ T (eq @i)) 'true;
2023-04-18 18:42:40 -04:00
-- [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;
2023-04-18 18:42:40 -04:00
}
def0 Bool = bool.Bool;