|logic||category theory||type theory|
|true||terminal object/(-2)-truncated object||h-level 0-type/unit type|
|false||initial object||empty type|
|proposition||(-1)-truncated object||h-proposition, mere proposition|
|cut elimination for implication||counit for hom-tensor adjunction||beta reduction|
|introduction rule for implication||unit for hom-tensor adjunction||eta conversion|
|disjunction||coproduct ((-1)-truncation of)||sum type (bracket type of)|
|implication||internal hom||function type|
|negation||internal hom into initial object||function type into empty type|
|universal quantification||dependent product||dependent product type|
|existential quantification||dependent sum ((-1)-truncation of)||dependent sum type (bracket type of)|
|equivalence||path space object||identity type|
|equivalence class||quotient||quotient type|
|induction||colimit||inductive type, W-type, M-type|
|higher induction||higher colimit||higher inductive type|
|completely presented set||discrete object/0-truncated object||h-level 2-type/preset/h-set|
|set||internal 0-groupoid||Bishop set/setoid|
|universe||object classifier||type of types|
|modality||closure operator monad||modal type theory, monad (in computer science)|
|linear logic||(symmetric, closed) monoidal category||linear type theory/quantum computation|
|proof net||string diagram||quantum circuit|
|(absence of) contraction rule||(absence of) diagonal||no-cloning theorem|
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 from an element of , or from an element of .
The eliminator is derived from these: it says that in order to use an element of , it suffices to specify what should be done for the two ways in which that element could have been constructed.
The beta reduction rules for a constructor followed by an eliminator:
The eta reduction rule for the opposite composite says that for any term in the context of ,
This says that if we unpack a term of type , but only use the resulting term of type or by way of packing them back into , then we might as well not have unpacked them to begin with. Note that choosing and , we obtain a simpler form of -conversion:
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” and the negative one is “par” .
A textbook account in the context of programming languages is in section 12 of