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
|
|
|
|
|
2023-07-21 11:57:47 -04:00
|
|
|
|
def if-dep : 0.(P : Bool → ★) → (b : Bool) → ω.(P 'true) → ω.(P 'false) → P b =
|
|
|
|
|
λ P b t f ⇒ case b return b' ⇒ P b' of { 'true ⇒ t; 'false ⇒ f };
|
|
|
|
|
|
|
|
|
|
def if : 0.(A : ★) → (b : Bool) → ω.A → ω.A → A =
|
|
|
|
|
λ A ⇒ if-dep (λ _ ⇒ A);
|
2023-04-18 18:42:40 -04:00
|
|
|
|
|
2023-07-21 11:57:47 -04:00
|
|
|
|
def0 if-same : (A : ★) → (b : Bool) → (x : A) → if A b x x ≡ x : A =
|
|
|
|
|
λ A b x ⇒ if-dep (λ b' ⇒ if A b' x x ≡ x : A) b (δ _ ⇒ x) (δ _ ⇒ x);
|
2023-04-18 18:42:40 -04:00
|
|
|
|
|
2023-07-21 11:57:47 -04:00
|
|
|
|
def if2 : 0.(A B : ★) → (b : Bool) → ω.A → ω.B → if¹ ★ b A B =
|
|
|
|
|
λ A B ⇒ if-dep (λ b ⇒ if-dep¹ (λ _ ⇒ ★) b A B);
|
2023-04-18 18:42:40 -04:00
|
|
|
|
|
2023-07-21 11:57:47 -04:00
|
|
|
|
def0 T : Bool → ★ = λ b ⇒ if¹ ★ b True False;
|
|
|
|
|
|
|
|
|
|
def boolω : Bool → [ω.Bool] =
|
|
|
|
|
λ b ⇒ if [ω.Bool] b ['true] ['false];
|
2023-04-18 18:42:40 -04:00
|
|
|
|
|
|
|
|
|
def true-not-false : Not ('true ≡ 'false : Bool) =
|
2023-07-21 11:57:47 -04:00
|
|
|
|
λ eq ⇒ coe (𝑖 ⇒ T (eq @𝑖)) 'true;
|
2023-04-18 18:42:40 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- [todo] infix
|
2023-07-18 17:12:04 -04:00
|
|
|
|
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;
|