Properties of the disjoint sum _+_ of types.
\begin{code}
{-# OPTIONS --safe --without-K #-}
module MLTT.Plus-Properties where
open import MLTT.Plus
open import MLTT.Negation
open import MLTT.Id
open import MLTT.Empty
open import MLTT.Unit
open import MLTT.Unit-Properties
+-commutative : {A : π€ Μ } {B : π₯ Μ } β A + B β B + A
+-commutative = cases inr inl
+disjoint : {X : π€ Μ } {Y : π₯ Μ } {x : X} {y : Y} β Β¬ (inl x οΌ inr y)
+disjoint {π€} {π₯} {X} {Y} p = π-is-not-π q
where
f : X + Y β π€β Μ
f (inl x) = π
f (inr y) = π
q : π οΌ π
q = ap f p
+disjoint' : {X : π€ Μ } {Y : π₯ Μ } {x : X} {y : Y} β Β¬ (inr y οΌ inl x)
+disjoint' p = +disjoint (p β»ΒΉ)
inl-lc : {X : π€ Μ } {Y : π₯ Μ } {x x' : X} β inl {π€} {π₯} {X} {Y} x οΌ inl x' β x οΌ x'
inl-lc refl = refl
inr-lc : {X : π€ Μ } {Y : π₯ Μ } {y y' : Y} β inr {π€} {π₯} {X} {Y} y οΌ inr y' β y οΌ y'
inr-lc refl = refl
equality-cases : {X : π€ Μ } {Y : π₯ Μ } {A : π¦ Μ } (z : X + Y)
β ((x : X) β z οΌ inl x β A) β ((y : Y) β z οΌ inr y β A) β A
equality-cases (inl x) f g = f x refl
equality-cases (inr y) f g = g y refl
Cases-equality-l : {X : π€ Μ } {Y : π₯ Μ } {A : π¦ Μ } (f : X β A) (g : Y β A)
β (z : X + Y) (x : X) β z οΌ inl x β Cases z f g οΌ f x
Cases-equality-l f g .(inl x) x refl = refl
Cases-equality-r : {X : π€ Μ } {Y : π₯ Μ } {A : π¦ Μ } (f : X β A) (g : Y β A)
β (z : X + Y) (y : Y) β z οΌ inr y β Cases z f g οΌ g y
Cases-equality-r f g .(inr y) y refl = refl
Left-fails-gives-right-holds : {P : π€ Μ } {Q : π₯ Μ } β P + Q β Β¬ P β Q
Left-fails-gives-right-holds (inl p) u = π-elim (u p)
Left-fails-gives-right-holds (inr q) u = q
Right-fails-gives-left-holds : {P : π€ Μ } {Q : π₯ Μ } β P + Q β Β¬ Q β P
Right-fails-gives-left-holds (inl p) u = p
Right-fails-gives-left-holds (inr q) u = π-elim (u q)
open import MLTT.Sigma
open import Notation.General
inl-preservation : {X : π€ Μ } {Y : π₯ Μ } (f : X + π {π¦} β Y + π {π£})
β f (inr β) οΌ inr β
β left-cancellable f
β (x : X) β Ξ£ y κ Y , f (inl x) οΌ inl y
inl-preservation {π€} {π₯} {π¦} {π£} {X} {Y} f p l x = Ξ³ x (f (inl x)) refl
where
Ξ³ : (x : X) (z : Y + π) β f (inl x) οΌ z β Ξ£ y κ Y , z οΌ inl y
Ξ³ x (inl y) q = y , refl
Ξ³ x (inr β) q = π-elim (+disjoint (l r))
where
r : f (inl x) οΌ f (inr β)
r = q β p β»ΒΉ
+functor : {X : π€ Μ } {Y : π₯ Μ } {A : π¦ Μ } {B : π£ Μ }
β (X β A) β (Y β B) β X + Y β A + B
+functor f g (inl x) = inl (f x)
+functor f g (inr y) = inr (g y)
+functorβ : {X : π€ Μ } {Y : π₯ Μ } {Z : π¦ Μ } {X' : π€' Μ } {Y' : π₯' Μ } {Z' : π¦' Μ }
β (X β X') β (Y β Y') β (Z β Z') β X + Y + Z β X' + Y' + Z'
+functorβ f g h = +functor f (+functor g h)
\end{code}