\title{coproduct}
\author{dannypsnl}
\{\{#{\triangle} Helpers}
\agda{
module coproduct where
open import foundation
variable
l : Level
π : UU
π = unit
β
: UU
β
= empty
}
}
\p{We can prove that a type plus empty type is equiv to itself, so \code{πΈ + β
β πΈ}.}
\agda{
module πΈ+β
(πΈ : UU l) where
f : πΈ + β
β πΈ
f (inl a) = a
f (inr ())
add-nothing : πΈ + β
β πΈ
pr1 add-nothing = f
pr1 (pr2 add-nothing) = (Ξ» a β inl a) , Ξ» _ β refl
pr2 (pr2 add-nothing) = (Ξ» a β inl a) , lem
where
lem : (a+β
: πΈ + β
) β inl (f a+β
) οΌ a+β
lem (inl a) = refl
lem (inr ())
}
\p{We can also see that the \code{+} is symmetric, which means \code{πΈ + πΉ β πΉ + πΈ}.}
\agda{
module Symm (πΈ πΉ : UU l) where
g : πΈ + πΉ β πΉ + πΈ
g (inl a) = inr a
g (inr b) = inl b
g' : πΉ + πΈ β πΈ + πΉ
g' (inl b) = inr b
g' (inr a) = inl a
lemβ : (x : πΉ + πΈ) β (g β g') x οΌ x
lemβ (inl a) = refl
lemβ (inr b) = refl
lemβ : (x : πΈ + πΉ) β (g' β g) x οΌ x
lemβ (inl a) = refl
lemβ (inr b) = refl
+-symm : πΈ + πΉ β πΉ + πΈ
pr1 +-symm = g
pr1 (pr2 +-symm) = g' , Ξ» x β lemβ x
pr2 (pr2 +-symm) = g' , Ξ» x β lemβ x
}
\agda{
module _ (πΈ : UU) where
lemma : β
+ πΈ β πΈ + β
lemma = Symm.+-symm β
πΈ
lemmaβ : β
+ πΈ β πΈ
lemmaβ = equivalence-reasoning
β
+ πΈ
β πΈ + β
by lemma
β πΈ
by πΈ+β
.add-nothing πΈ
}