natural deduction metalanguage, practical foundations
type theory (dependent, intensional, observational type theory, homotopy type theory)
computational trinitarianism =
propositions as types +programs as proofs +relation type theory/category theory
In type theory a sum type of two types $A$ and $B$ (really: coproduct) is the type whose terms are either terms $a\colon A$ or terms $b\colon B$.
In a model of the type theory in categorical semantics this is a distributive coproduct. In set theory, it is a disjoint union.
Like all type constructors in type theory, to characterize sum types we must specify how to build them, how to construct elements of them, how to use such elements, and the computation rules.
The way to build sum types is easy:
Sum types are most naturally presented as positive types, so that the constructor rules are primary. These say that we can obtain an element of $A+B$ from an element of $A$, or from an element of $B$.
The eliminator is derived from these: it says that in order to use an element of $A+B$, it suffices to specify what should be done for the two ways in which that element could have been constructed.
The terms $c_A$ and $c_B$ can have free variables $x$ and $y$ respectively, but those variables become bound in the $match$ expression. In dependent type theory, we must generalize the eliminator to allow $C$ to depend on $A+B$.
The beta reduction rules for a constructor followed by an eliminator:
The eta reduction rule for the opposite composite says that for any term $c\colon C$ in the context of $p\colon A+B$,
This says that if we unpack a term of type $A+B$, but only use the resulting term of type $A$ or $B$ by way of packing them back into $A+B$, then we might as well not have unpacked them to begin with. Note that choosing $C\coloneqq A+B$ and $c \coloneqq z$, we obtain a simpler form of $\eta$-conversion:
The positive presentation of sum types can be regarded as a particular sort of inductive type. In Coq syntax:
Inductive sum (A B:Type) : Type :=
| inl : A -> sum A B
| inr : B -> sum A B.
Coq implements the beta reduction rule, but not the eta (although eta equivalence is provable for the inductively defined identity types, using the dependent eliminator mentioned above).
It is possible to present sum types as negative types as well, but only if we allow sequents with multiple conclusions. This is common in sequent calculus presentations of classical logic, but not as common in type theory and almost unheard of in dependent type theory.
The two definitions are provably equivalent, but only using the contraction rule and the weakening rule. Thus, in linear logic they become distinct; the positive sum type is “plus” $A\oplus B$ and the negative one is “par” $A \parr B$.
Assuming that identification types, function types and dependent product types exist in the type theory, the sum type of types $A$ and $B$ is the inductive type generated by a function from $A$ to $A + B$ and a function from $B$ to $A + B$:
Formation rules for sum types:
Introduction rules for sum types:
Elimination rules for sum types:
Computation rules for sum types:
Uniqueness rules for sum types:
The elimination, computation, and uniqueness rules for the sum type of $A$ and $B$ state that the sum type of $A$ and $B$ satisfy the dependent universal property of the sum type of $A$ and $B$. If the dependent type theory also has dependent sum types and product types, allowing one to define the uniqueness quantifier, the dependent universal property of the sum type of of $A$ and $B$ could be simplified to the following rule:
The sum type can be defined in terms of the boolean domain and the dependent sum type. Given types $A$ and $B$, the sum type $A + B$ is defined as
The descent for the sum type $A + B$ states that given any type families $x:A \vdash C(x)$ and $y:B \vdash D(y)$ one can construct a type family $z:A + B \vdash \mathrm{descFam}_{A + B}^{C, D}(z)$ with families of equivalences of types
Large elimination for sum types strengthens the equivalences of types in descent to judgmental equality of types
A textbook account in the context of programming languages is in section 12 of
For sum types in homotopy type theory, see:
Homotopy Type Theory: Univalent Foundations of Mathematics, The Univalent Foundations Project, Institute for Advanced Study, 2013. (web, pdf)
Egbert Rijke, Introduction to Homotopy Type Theory, Cambridge Studies in Advanced Mathematics, Cambridge University Press (arXiv:2212.11082)
Last revised on February 27, 2024 at 21:37:37. See the history of this page for a list of all contributions to it.