This post is a continuation of a previous post and part of a mini-series on category theory. As before, knowing the background of every single example is not necessary (nor sufficient) to grasp the general concept.
Introduction
Previously, we have defined and discussed categories. However, studying categories as isolated objects with no relation to other categories would be a fruitless toil. It would also not be in the spirit of category theory, which studies everything through its relationship to other things. Yet the necessity to bring together distinct instances of the objects one is studying is not specific to category theory: For example, it’s hard to imagine studying group theory without studying group homomorphisms.
It should by now be clear that we are in dire need of a notion allowing us to connect different categories and to express relationships between them. It seems natural to let the definition of a category guide us to the definition of things that relate them. This plan comes to fruition in the conception of functors. These should be thought of as (homo)morphisms of categories, mappings preserving the structure categories have, i.e. identities and composition, just like a monoid homomorphism preserves the neutral element and the monoid operation.
The ubiquity with which functors arise is remarkable, and after some experience in thinking categorically it will become second nature to ask whether a construction behaves “functorially”.
Functors
Definition C2.1 Let and be categories, then a (covariant) functor consists of the following data:
- A map
- For any pair of objects a map
such that the following conditions hold:
- For every object we have
- For any three objects and morphisms we have .
Let us ponder for a moment how this definition generalizes familiar concepts.
Example C2.2 Let and be sets, then we can consider them as discrete categories (cf. C1.4), so that the elements of each set are the objects of the associated discrete category and the only morphisms are the identity morphisms. Then any map uniquely determines a functor between the associated discrete categories restricting to on the objects, as the only morphisms are identities and the definition of a functor requires sending identity morphisms to the corresponding identity morphisms in the target category. To summarize, functors between discrete categories correspond to maps between the underlying sets.
Example C2.3 Let and be monoids, considered as one-object categories. Then a functor has to send the unique object of to the unique object of . The action on morphisms is more interesting: from the definition of a functor, we see that a map of the underlying sets determines a functor if and only if it preserves the monoid operation and the identity, i.e. if and only if it is a monoid homomorphisms. Thus for monoids (and hence for groups), we can regard homomorphisms as functors.
Example C2.4 Let be a group, considered as a one-object category and let us consider functors to the category of sets (cf. C1.2), . Since has one proxy object , the value of corresponds to a choice of a particular set . As for the morphisms, we have for each a map such that and . These are precisely the axioms for a group action on , such that functors correspond to sets with a (left) -action, i.e. -Sets.
Example C2.5 By reasoning as in the last example, one can show that if is a field and we consider the category of vector spaces over with linear maps as morphisms, then functors correspond to representations of on vector spaces over .
Now we shall look into examples of particular functors.
Example C2.6 There are a plethora of so-called “forgetful” functors. These arise when you “forget” part of the structure of an object. In this case, the target category consists of objects with less structure than the source category.
For example, we can forget about the multiplication in a ring and are left with an abelian group, this gives rise to a forgetful functor from the category of rings to the category of abelian groups. We can then proceed on our path to oblivion and forget that an abelian group is abelian, yielding a forgetful functor from abelian groups to groups. Finally, every group is a set, giving rise to yet another forgetful functor. It should be noted that it is important to consider also the morphisms for these forgetful functors to work: every ring homomorphism is a homomorphism of abelian groups on the additive groups, every homomorphism of abelian groups is a group homomorphism and every group homomorphism is a map of sets. Another chain of forgetful functors goes from smooth complex varieties to complex manifolds, from complex manifolds to smooth manifolds, from smooth manifolds to topological manifolds, from topological manifolds to topological spaces and from topological spaces to sets, ending another journey of obliviousness in the same destination.
Forgetful functors are often implicitly applied, especially if one is not doing category theory. And indeed, it should deserve no particular mention that for instance, any group is a set. It can be quite helpful, however, to explicitly state when you apply them, for example to clarify in which category two objects are isomorphic or if you want to apply concepts or theorems on functors to a forgetful functor.
Example C2.7 One could say that the first example of functoriality is encountered in an introductory calculus class, although that would be a bit of a stretch.
Let be the category of pointed smooth manifolds, i.e. objects are pairs where is a smooth manifold and and morphisms are smooth maps such that . Then there’s the tangent space functor to the category of -vector spaces with linear maps that sends a pair to the tanget space of at and a morphism to the differential . The fact that this behaves functorially is an abstract version of the chain rule: , justifying the assertion on functoriality in calculus above.
Example C2.8 Let be the category of rings with ring homomorphisms as morphisms, then for any ring , the units form a group and ring homomorphisms preserve units so that a ring homomorphism restricts to a group homomorphism . We obtain a functor from to , the category of groups with group homomorphisms as morphisms.
Example C2.9 Let be an abelian group and , then there’s a functor from the category of topological spaces to the category of abelian groups that sends a space to the singular homology group . The fact that this is a functor is even part of the Eilenberg-Steenrod axioms for homology theories.
Example C2.10 Let be the category of topological spaces with continuous maps and let be the category of measurable spaces with measurable maps as morphisms. There’s a functor that equips a topological space with its Borel -algebra, turning it into a measurable space. Every continuous map is measurable with respect to the corresponding Borel -algebras, ensuring that this construction yields a functor.
Example C2.11 Not every constructions that seems in some sense “natural” can be turned into a functor. For example, we can associate to each group its center which is an abelian group. One could hope that this can be made into a functor. The problem is that central elements don’t necessarily get sent to central elements under a group homomorphism. Indeed, it is impossible to define any action on morphisms such that the assignment on objects becomes a functor, for the identity on the cyclic group on two elements factors through the inclusion of to as a transposition and the sign homomorphism . We have . However, the center of is itself, whereas the center of is trivial. If there was any functor that restricts to on objects, then we would get implying that the identity on factors over the trivial group, which is impossible.
Example C2.12 Let be a category and let , then for any object , we have a set and for a morphism , we can postcompose with , yielding a map . By associativity of composition and the definition of the identity elements, this construction yields a functor . These functors – affectionally called Hom-functors – are of paramount importance, as we shall see in future posts.
Example C2.13 We have said that functors can be thought of as morphisms between categories. This can be taken quite literally. To avoid Russel’s paradox and to ensure that our sets of morphisms will actually be sets, let’s restrict our attention to categories whose class of objects is actually a set, so-called “small” categories. There’s a (non-small!) category , in which the objects are small categories and morphisms are functors between small categories. Note that we have implicitly said that one can compose functors and that there’s an identity functor for each category.
Contravariance
All the previous examples of functors had one thing in common: they didn’t reverse the orientation of the arrows. Even so, there are other instances of functoriality. The following construction allows us to subsume those instances under the previous definition:
Definition C2.15 Let be a category, then the opposite category has the same objects. For , we set composition is defined like the composition in except in the opposite order.
Intuitively, we just reverse all the arrows.
Definition C2.16 Let and be categories, then a contravariant functor is a covariant functor .
For clarification, regular functors (as in definition C2.1) are called covariant, but if “functor” is used without specification, they are always covariant by default.
From this definition, it follows that a contravariant functor reverses the direction of morphisms when it is applied. (Hence the picture in the beginning of this section)
Example C2.16 Consider the category of sets . The assignment on objects can be made into a functor in two different ways, a covariant one and a contravariant one. For the covariant one, let be any map. Then we can define a map via , giving rise to the covariant powerset functor. For the contravariant one, we can define for a map a map via . In both cases the verification of the functorial properties is easy.
Example C2.17 Let be a field. Consider the category of finite separable extensions of with -linear field homomorphisms as morphisms. We can define a contravariant functor from to , the category of groups with group homomorphisms as morphisms, in the following manner: For an object , set and for a (necessarily injective) morphism , define to be the field norm . The transitivity formula for norms in towers translates into functoriality of this construction: For a tower of extensions we have .
A similar construction works for the field trace.
Example C2.18 Consider the category of compact Hausdorff spaces with continuous maps as morphisms. For any compact Hausdorff space , the continuous functions form a C*-algebra with pointwise operations (i.e. addition, multiplication, scalar multiplication and conjugation), denoted by . If and are compact Hausdorff spaces and is a continuous map, then we can define a homomorphism of C*-algebras by pulling back continuous functions along : for a continuous function , is a continuous function . We obtain a contravariant functor from the category of compact Hausdorff spaces to the category of commutative unital C*-algebras.
Example C2.19 As in the examples C2.4 and C2.5, if is a group, considered as a one-object category and we let be the category of sets or the category of -vector spaces for a field , then contravariant functors correspond to right -sets or right representations on vector spaces over , respectively.
Example C2.20 The construction from C2.12 has a contravariant sibling. Let be any category and . Then we have for any object in , a set and for a morphism , we get a map . This construction is a functor, called the contravariant Hom functor.