crude but effective stratification

This commit is contained in:
rhiannon morris 2023-05-21 20:09:34 +02:00
parent e4a20cc632
commit 42aa07c9c8
31 changed files with 817 additions and 582 deletions

View file

@ -3,22 +3,22 @@ load "bool.quox";
namespace either {
def0 Tag : ★ = {left, right};
def0 Tag : ★ = {left, right};
def0 Payload : 0.★₀ → 0.★₀ → 1.Tag → ★₀ =
λ A B tag ⇒ case1 tag return ★ of { 'left ⇒ A; 'right ⇒ B };
def0 Payload : 0.★⁰ → 0.★⁰ → 1.Tag → ★⁰ =
λ A B tag ⇒ case1 tag return ★ of { 'left ⇒ A; 'right ⇒ B };
def0 Either : 0.★₀ → 0.★₀ → ★₀ =
def0 Either : 0.★⁰ → 0.★⁰ → ★⁰ =
λ A B ⇒ (tag : Tag) × Payload A B tag;
def Left : 0.(A B : ★) → 1.A → Either A B =
def Left : 0.(A B : ★) → 1.A → Either A B =
λ A B x ⇒ ('left, x);
def Right : 0.(A B : ★) → 1.B → Either A B =
def Right : 0.(A B : ★) → 1.B → Either A B =
λ A B x ⇒ ('right, x);
def elim' :
0.(A B : ★₀) → 0.(P : 0.(Either A B) → ★₀) →
0.(A B : ★⁰) → 0.(P : 0.(Either A B) → ★⁰) →
ω.(1.(x : A) → P (Left A B x)) →
ω.(1.(x : B) → P (Right A B x)) →
1.(t : Tag) → 1.(a : Payload A B t) → P (t, a) =
@ -28,7 +28,7 @@ def elim' :
of { 'left ⇒ f; 'right ⇒ g };
def elim :
0.(A B : ★₀) → 0.(P : 0.(Either A B) → ★₀) →
0.(A B : ★⁰) → 0.(P : 0.(Either A B) → ★⁰) →
ω.(1.(x : A) → P (Left A B x)) →
ω.(1.(x : B) → P (Right A B x)) →
1.(x : Either A B) → P x =
@ -45,16 +45,16 @@ def Right = either.Right;
namespace dec {
def0 Dec : 0.★₀ → ★₀ = λ A ⇒ Either [0.A] [0.Not A];
def0 Dec : 0.★⁰ → ★⁰ = λ A ⇒ Either [0.A] [0.Not A];
def Yes : 0.(A : ★) → 0.A → Dec A = λ A y ⇒ Left [0.A] [0.Not A] [y];
def No : 0.(A : ★) → 0.(Not A) → Dec A = λ A n ⇒ Right [0.A] [0.Not A] [n];
def Yes : 0.(A : ★) → 0.A → Dec A = λ A y ⇒ Left [0.A] [0.Not A] [y];
def No : 0.(A : ★) → 0.(Not A) → Dec A = λ A n ⇒ Right [0.A] [0.Not A] [n];
def0 DecEq : 0.★₀ → ★₀ =
def0 DecEq : 0.★⁰ → ★⁰ =
λ A ⇒ ω.(x : A) → ω.(y : A) → Dec (x ≡ y : A);
def elim :
0.(A : ★₀) → 0.(P : 0.(Dec A) → ★₀) →
0.(A : ★⁰) → 0.(P : 0.(Dec A) → ★⁰) →
ω.(0.(y : A) → P (Yes A y)) →
ω.(0.(n : Not A) → P (No A n)) →
1.(x : Dec A) → P x =
@ -63,7 +63,7 @@ def elim :
(λ y ⇒ case0 y return y' ⇒ P (Left [0.A] [0.Not A] y') of {[y'] ⇒ f y'})
(λ n ⇒ case0 n return n' ⇒ P (Right [0.A] [0.Not A] n') of {[n'] ⇒ g n'});
def bool : 0.(A : ★) → 1.(Dec A) → Bool =
def bool : 0.(A : ★) → 1.(Dec A) → Bool =
λ A ⇒ elim A (λ _ ⇒ Bool) (λ _ ⇒ 'true) (λ _ ⇒ 'false);
}