prop
def truth : Prf ∥𝟙∥ ≔ ⋆
def eqSquash : (a : ℕ) → Prf (a ≡ a ∈ ℕ) ≔ λa. ⋆
def irrel : (p : Ω) (x : Prf p) (y : Prf p) → x ≡ y ∈ Prf p ≔ λp. λx. λy. ⋆
def propext : ∥𝟙∥ ≡ (Z ≡ Z ∈ ℕ) ∈ Ω ≔ ⋆
def reflectSquash : (A : 𝕌) (a : El A) (b : El A) (h : Prf (a ≡ b ∈ _)) → Prf (a ≡ b ∈ _) ≔
λA. λa. λb. λh. ⋆
def quotIff : (A : 𝕌) (v : El A / (n m. ∥𝟙∥)) → El A / (n m. (Z ≡ Z ∈ _)) ≔ λA. λv. v
def ⊥ : Ω ≔ ∥𝟘∥
def ⊤ : Ω ≔ ∥𝟙∥
infixr 5 ∧
def ∧ : Ω → Ω → Ω ≔ λp. λq. ∥Prf p ⨯ Prf q∥
infixr 3 ⊃
def ⊃ : Ω → Ω → Ω ≔ λp. λq. ∥Prf p → Prf q∥
def ¬ : Ω → Ω ≔ λp. p ⊃ ⊥
infixr 4 ∨
def ∨ : Ω → Ω → Ω ≔ λp. λq. ∥(r : Ω) → (Prf p → Prf r) → (Prf q → Prf r) → Prf r∥
def andIntro : (p : Ω) (q : Ω) → Prf p → Prf q → Prf (p ∧ q) ≔
λp. λq. λx. λy. ⋆ (x , y)
def andFst : (p : Ω) (q : Ω) → Prf (p ∧ q) → Prf p ≔
λp. λq. λh. squash-elim h (u. u .π₁)
def andSnd : (p : Ω) (q : Ω) → Prf (p ∧ q) → Prf q ≔
λp. λq. λh. squash-elim h (u. u .π₂)
def andElim : (p : Ω) (q : Ω) (x : Ω) → Prf (p ∧ q) → (Prf p → Prf q → Prf x) → Prf x ≔
λp. λq. λx. λi. λf. squash-elim i (u. f (u .π₁) (u .π₂))
def impIntro : (p : Ω) (q : Ω) → (Prf p → Prf q) → Prf (p ⊃ q) ≔
λp. λq. λf. ⋆ f
def impApply : (p : Ω) (q : Ω) → Prf (p ⊃ q) → Prf p → Prf q ≔
λp. λq. λh. λx. squash-elim h (f. f x)
def orInl : (p : Ω) (q : Ω) → Prf p → Prf (p ∨ q) ≔
λp. λq. λx. ⋆ (λr. λf. λg. f x)
def orInr : (p : Ω) (q : Ω) → Prf q → Prf (p ∨ q) ≔
λp. λq. λy. ⋆ (λr. λf. λg. g y)
def orElim : (p : Ω) (q : Ω) (c : Ω) → Prf (p ∨ q) → (Prf p → Prf c) → (Prf q → Prf c) → Prf c ≔
λp. λq. λc. λh. λf. λg. squash-elim h (u. u _ f g)
infixr 2 ↔
def ↔ : Ω → Ω → Ω ≔ λp. λq. (p ⊃ q) ∧ (q ⊃ p)
def iffIntro : (p : Ω) (q : Ω) → (Prf p → Prf q) → (Prf q → Prf p) → Prf (p ↔ q) ≔
λp. λq. λf. λg. andIntro _ _ (impIntro _ _ f) (impIntro _ _ g)
def iffLeft : (p : Ω) (q : Ω) → Prf (p ↔ q) → Prf p → Prf q ≔
λp. λq. λh. impApply _ _ (andFst _ _ h)
def iffRight : (p : Ω) (q : Ω) → Prf (p ↔ q) → Prf q → Prf p ≔
λp. λq. λh. impApply _ _ (andSnd _ _ h)
def curry : (p : Ω) (q : Ω) (c : Ω) → Prf ((p ∧ q) ⊃ c) → Prf (p ⊃ q ⊃ c) ≔
λp. λq. λc. λh. impIntro _ _ (λx. impIntro _ _ (λy. impApply _ _ h (andIntro _ _ x y)))
def uncurry : (p : Ω) (q : Ω) (c : Ω) → Prf (p ⊃ q ⊃ c) → Prf ((p ∧ q) ⊃ c) ≔
λp. λq. λc. λh. impIntro _ _ (λpq. impApply _ _ (impApply _ _ h (andFst _ _ pq)) (andSnd _ _ pq))
def notNotLem : (p : Ω) → Prf (¬ (¬ (p ∨ ¬ p))) ≔
λp. impIntro _ _ (λk.
impApply _ _ k
(orInr _ _ (impIntro _ _ (λhp.
impApply _ _ k (orInl _ _ hp)))))
def rClosure : (A : 𝕌) → (El A → El A → Ω) → El A → El A → Ω ≔
λA. λr. λa. λb. ∥ (R : El A → El A → Ω)
→ ((x : El A) (y : El A) → Prf (r x y) → Prf (R x y))
→ ((x : El A) → Prf (R x x))
→ ((x : El A) (y : El A) (z : El A) → Prf (R x y) → Prf (R y z) → Prf (R x z))
→ ((x : El A) (y : El A) → Prf (R x y) → Prf (R y x))
→ Prf (R a b) ∥
def rClosureContains : (A : 𝕌) (r : El A → El A → Ω) (a : El A) (b : El A) →
Prf (r a b) → Prf (rClosure _ r a b) ≔
λA. λr. λa. λb. λh. ⋆ (λR. λcont. λrefl. λtrans. λsymm. cont _ _ h)
def rClosureRefl : (A : 𝕌) (r : El A → El A → Ω) (a : El A) → Prf (rClosure _ r a a) ≔
λA. λr. λa. ⋆ (λR. λcont. λrefl. λtrans. λsymm. refl _)
def rClosureSymm : (A : 𝕌) (r : El A → El A → Ω) (a : El A) (b : El A) →
Prf (rClosure _ r a b) → Prf (rClosure _ r b a) ≔
λA. λr. λa. λb. λh.
squash-elim h (u. ⋆ (λR. λcont. λrefl. λtrans. λsymm. symm a b (u _ cont refl trans symm)))
def rClosureTrans : (A : 𝕌) (r : El A → El A → Ω) (a : El A) (b : El A) (c : El A) →
Prf (rClosure _ r a b) → Prf (rClosure _ r b c) → Prf (rClosure _ r a c) ≔
λA. λr. λa. λb. λc. λhab. λhbc.
squash-elim hab (uab.
squash-elim hbc (ubc.
⋆ (λR. λcont. λrefl. λtrans. λsymm.
trans _ _ _ (uab _ cont refl trans symm) (ubc _ cont refl trans symm))))
def rClosureLeast : (A : 𝕌) (r : El A → El A → Ω) (Q : El A → El A → Ω)
→ ((x : El A) (y : El A) → Prf (r x y) → Prf (Q x y))
→ ((x : El A) → Prf (Q x x))
→ ((x : El A) (y : El A) (z : El A) → Prf (Q x y) → Prf (Q y z) → Prf (Q x z))
→ ((x : El A) (y : El A) → Prf (Q x y) → Prf (Q y x))
→ (a : El A) (b : El A) → Prf (rClosure _ r a b) → Prf (Q a b) ≔
λA. λr. λQ. λcontQ. λreflQ. λtransQ. λsymmQ. λa. λb. λh.
squash-elim h (u. u _ contQ reflQ transQ symmQ)