dualitydisjoint union The types 0 and 1
are called dualsdual of each other in a category theory.
Here is what this means. The object 1 is called
terminalterminal (or finalfinal) because for every
type A, there is a unique map in
1, i.e. a map
terminating in 1, namely
.
The object
0 is initialinitial since for every type A, there
is a unique map initiating in 0, i.e. 0
,
namely
.30
The dualitydual concept is that the arrows of the types are reversed in the definition.
1 is final iff for all A there is a unique element in
![]() |
---|
0 is initial iff for all A there is a unique element in
![]() |
The type
can be characterized in terms of functions. In
category theory this is done with a diagramproduct type
C | ||
f ![]() |
![]() |
![]() |
A
![]() |
![]() |
![]() |
![]() |
![]() |
In category theory there is a construction that is dual to the product, called co-productco-product type. Duals are created by reversing the arrows in the diagram, so for a dual we claim this.
C | ||
f ![]() |
![]() |
![]() |
A
![]() |
A + B |
![]() |
Given A, B with maps
,
and maps
,
there is a
unique map
such that
In type theory we take inl(a), inr(b) to be canonical values with evaluation
For A and B types, A+B is a new type called the disjoint uniondisjoint union of A and B. But the typing rules present a difficulty. If we simply write
We could solve this problem by including a new judgment,
,
into the theory. The rules would be quite clear for the types
already built, namely:
![]() |
![]() |
![]() |
![]() |
![]() |
We can then use the rules
We will see in section 3.4 how to avoid adding this
new judgment
.
The map [f, g] is built from a new form called decide(d; u.f(u); v.g(v)) whose evaluation rules are
[f, g](inl(a))=f(a) and |
[f, g](inr(b))=g(b). |