EITHER

DISJOINT UNION

The disjoint union (sum type) is the type of values that are either from (tagged left) or from (tagged right). It is the coproduct in the category of types.

Formation

def + (A B: U) : U := Ξ£ (x : 𝟐), indβ‚‚ (Ξ» (_ : 𝟐), U) A B x

Constructors

def inl (A B : U) (a : A) : + A B := (0β‚‚, a) def inr (A B : U) (b : B) : + A B := (>1β‚‚, b)

Eliminators

The induction principle -ind allows case analysis on a value of the sum type.

def +-ind (A B : U) (C : + A B β†’ U) (f : Ξ  (x : A), C (inl A B x)) (g : Ξ  (y : B), C (inr A B y)) (w : + A B) : C w := indβ‚‚ (Ξ» (x : 𝟐), Ξ  (u : indβ‚‚ (Ξ» (_ : 𝟐), U) A B x), C (x, u)) f g w.1 w.2

Non-dependent recursion:

def +-rec (A B C : U) (f : A β†’ C) (g : B β†’ C) : (+ A B) β†’ C := +-ind A B (Ξ» (_ : + A B), C) f g

Computation Rules

The -rules for the disjoint union state how the eliminator computes on the constructors.

def +-β₁ (A B : U) (C : + A B β†’ U) (a: A) (f : Ξ  (x : A), C (inl A B x)) (g : Ξ  (y : B), C (inr A B y)) : PathP (<_>C (inl A B a)) (f a) (+-ind A B C f g (inl A B a)) := <_> f a def +-Ξ²β‚‚ (A B : U) (C : + A B β†’ U) (b: B) (f : Ξ  (x : A), C (inl A B x)) (g : Ξ  (y : B), C (inr A B y)) : PathP (<_>C (inr A B b)) (g b) (+-ind A B C f g (inr A B b)) := <_> g b

Uniqueness

def +-Ξ· (A B : U) (c : + A B) : + (Ξ£ (x : A), PathP (<_> + A B) c (inl A B x)) (Ξ£ (y : B), PathP (<_> + A B) c (inr A B y)) := +-ind A B (Ξ» (c : + A B), + (Ξ£ (x : A), PathP (<_> + A B) c (inl A B x)) (Ξ£ (y : B), PathP (<_> + A B) c (inr A B y))) (Ξ» (x : A), (0β‚‚, (x, <_> (0β‚‚, x)))) (Ξ» (y : B), (>1β‚‚, (y, <_> (>1β‚‚, y)))) c

Finite Coproducts

Using , we can define small finite sum types such as , , , etc., with their corresponding eliminators.

def πŸ‘ : U := + 𝟏 𝟐 def 0₃ : πŸ‘ := inl 𝟏 𝟐 β˜… def 1₃ : πŸ‘ := inr 𝟏 𝟐 0β‚‚ def 2₃ : πŸ‘ := inr 𝟏 𝟐 1β‚‚ def ind₃ (C : πŸ‘ β†’ U) (cβ‚€ : C 0₃) (c₁ : C 1₃) (cβ‚‚ : C 2₃) : Ξ  (x : πŸ‘), C x := +-ind 𝟏 𝟐 C (ind₁ (Ξ» (_ : 𝟏), C 0₃) cβ‚€) (indβ‚‚ (Ξ» (_ : 𝟐), C (>1β‚‚, _)) c₁ cβ‚‚)

Similar definitions exist for $πŸ’$, $πŸ“$, $πŸ”$, $πŸ•$ (see source module for full list).

Theorems

The disjoint union satisfies standard properties expected from a coproduct in type theory.