Initial and final object
The initial and final object(s) take up the extreme positions in a category.
An initial object, if it exists, is an object of a category , with the property that there exists a unique morphism from to , for all in the category:
And the final (or terminal) object is an object of a category , with the property that there exists a unique morphism from to , for all in the category:
That is the initial object is the object that has a single morphism going from itself to all other objects in the category (including itself). The final object is the object that has a single morphism coming to it from every other object in the category (including itself). The uniqueness of the morphism is the crucial part.
Again, as an example, we use the category of sets and total functions. Let:
be a singleton set. For each set A there is a unique morphism:
which is the function (in Set) that sends everything to . Thus is the final object of the category . That is, everything in the category ends up as the final object when composed to the extremes.
Then consider the empty set, , which for each set there exists the unique morphism (which exists as from nothing anything can be constructed):
This is an initial object of the category .
corresponds to the type in Haskell and the unique polymorphic function from :
means that is the initial object in .
Similarly, corresponds to the type (unit) in Haskell and again the unique polymorphic function to :
means that is the final (or terminal) object in .
A category can have both an initial and final object or none, it can have only one, and it can even have more than one initial and/or final objects. More than one initial (or final) objects in a category are isomorphic. This means, that by the definition of inital/final object there can only be one morphism to/from any other object in the category. So take, for example, two initial objects and two unique morphisms between them:
The composition of and which means that and are isomorphic. A similar argument applies for the terminal objects.
A category in which the initial and final object are the same is said to be a zero object.
Furthermore, an initial/final object in a category is the final/initial object in the opposite category . The opposite category is the category in which all the morphisms are reversed.
And as we learned before, there is a morphism that simply selects a value from the type in the category . This morphism allows us to select elements of the set without actually having any notion of elements of a set as in category theory we only deal with objects (think points) and all morphisms between those objects.