\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 𝔸 }