More Category Theory: Getting into Functors

Let’s talk a bit about functors. Functors are fun!

What’s a functor? I already gave the short definition: a structure-preserving mapping between categories. Let’s be a bit more formal. What does the structure-preserving property mean?

A functor F from category C to category D is a mapping from C to D that:

  • Maps each member m in Obj(C) to an object F(m) in Obj(D).
  • Maps each arrow a : x rightarrow y  in Mor(C) to an arrow F(a) : F(x) rightarrow F(y), where:
    • forall o in Obj(C): F(1_o) = 1_{F(o)}. (Identity is preserved by the functor mapping of morphisms.)
    • forall m,n in Mor(C):  F(n circ o) = F(o) circ F(n). (Associativity is preserved by the Functor mapping of morphisms.)

That’s the standard textbook gunk for defining a functor. But if you look back at the original definition of a category, you should notice that this looks familiar. In fact, it’s almost identical to the definition of the necessary properties of arrows!

We can make functors much easier to understand by talking about them in the language of categories themselves. Functors are arrows between a category of categories.

There’s a kind of category, called a small category. (I happen to dislike the term “small” category; I’d prefer something like “well-behaved”.) A small category is a category C where Obj(C) and Mor(C) are sets, not proper classes. Alas, more definitions; in set theory, a class is a collection of sets that can be defined by a non-paradoxical property that all of its members share. Some classes are sets of sets; some classes are not sets; they lack some of the required properties of sets – but still, the class is a collection with a well-defined, non-paradoxical, unambiguous property. If a class isn’t a set of sets, but just a collection that isn’t a set, then it’s called a proper class.

Any category whose collections of objects and arrows are sets, not proper classes, are called small categories. Small categories are, basically, categories that are well-behaved – meaning that their collections of objects and arrows don’t have any of the obnoxious properties that would prevent them from being sets.

The small categories are, quite beautifully, the objects of a category called Cat. (For some reason, category theorists like three-letter labels.) The arrows of Cat are the functors: Functors are morphisms between small categories. Once you wrap you head around that, then the meaning of a functor, and the meaning of a structure-preserving transformation become extremely easy to understand.

Functors come up over and over again, all over mathematics. They’re an amazingly useful notion. I was looking for a list of examples of things that you can describe using functors, and found a really wonderful list on wikipedia.. I highly recommend following that link and taking a look at the list. I’ll just mention one particularly interesting example: groups and group actions.

If you’ve been reading GM/BM long enough, you’ll remember my posts on group theory, and how long it took for me to work up to the point where I could really define what symmetry meant, and how every symmetric transformation was actually a group action. Category theory makes that much easier.

Every group can be represented as a category with a single object. A functor from the category of a group to the category of Sets is a group action on the set that is the target of the functor. Poof! Symmetry. (This paragraph was modified to correct some ambiguous wording; the ambiguity was pointed out by commenter “Cat lover”.)

Since symmetry means structure-preserving transformation; and a functor is a structure preserving transformation – well, they’re almost the same thing. The functor is an even more general abstraction of that concept: group symmetry is just one particular case of a functor transformation. Once you get functors, understanding symmetry is easy. And so are lots of other things.

And of course, you can always carry these things further. There is a category of functors themselves; and notions which can be most easily understood in terms of functors operating on the category of functors!

By now, it should be sort of clear why category theory is affectionately known as abstract nonsense. Category theory operates at a level of abstraction where almost anything can be wrapped up in it; and once you’ve wrapped something up in a category, almost anything you can do with it can itself be wrapped up asa category – levels upon levels, categories of categories, categories of functors on categories of functors on categories, ad infinitum. And yet, it makes sense. It captures a useful, comprehensible notion. All that abstraction, to the point where it seems like nothing could possibly come out of it. And then out pops a piece of beautiful crystal.

0 thoughts on “More Category Theory: Getting into Functors

  1. Corkscrew

    Small categories are, basically, categories that are well-behaved – meaning that their collections of objects and arrows don’t have any of the obnoxious properties that would prevent them from being sets.
    Just to clarify (I flunked set theory :P) are we talking about stuff like the infamous “set of all sets that don’t contain themselves” that break naive set theory?

    Reply
  2. Mark C. Chu-Carroll

    Corkscrew:
    Yeah, exactly. You can construct set theory in ways that make it harder to create funky paradoxical things. In small categories, you’re working with the non-paradoxical set types.

    Reply
  3. Cat lover

    “A group is a category with a single object. A functor from the category of a group to the category of Sets is a group action on the set that is the target of the functor. Poof! Symmetry.”
    A minor correction: in general, a category with a single object is merely a monoid; to get a group you must additionally require that all arrows are invertible.
    Sorry to nitpick, just wanted to set the record straight 🙂

    Reply
  4. Mark C. Chu-Carroll

    Cat lover:
    Poor wording on my part; I did not mean to say that any category with a single object is a group; rather, I meant to say that any group can be represented as a category with a single element. I’ll correct the wording there to clarify it.

    Reply
  5. cleek

    interesting. while i understood basically none of it, i recognized enough of the words to be able to recall that C++ (and most object-oriented programming languages) allow something called a “function object” – often called a “functor”.
    in programming terms, this is an object that can be used as a function. so, you can give this object ‘state’ (set some attributes, etc) and then, when you invoke it as a function call, that state is available to the function call. it’s very handy in things like sorting. it’s also a type of
    i suppose it’s mostly a case of two fields confusingly using the same set of names to describe different things. as the Wiki notes about function objects: “A functor used in this manner in computing bears little relation to the term functor as used in the mathematical field of category theory.”

    Reply
  6. Stephen

    ‘Functors are arrows between a category of categories.’
    Oh, fancy footwork!
    ‘I happen to dislike the term “small” category; I’d prefer something like “well-behaved”.’
    I don’t know – I mean, the collection of categories who’s Homs and Obs are all classes. And this is just as well-behaved : ) Anyway, all I’m saying is that I’d keep that term nonmathematical so that I can apply it (in appropriate contexts) to categories of whatever sizes I want.
    In terms of generally how one should think of functors, I think that in a lot of cases, it is really,really useful to think functors as giving properties of objects in a certain category, or giving constructions that one can perform on objects of one category. Because that’s what they usually do represent.
    “And then out pops a piece of beautiful crystal.”
    The piece of imagery does bring to mind a less wholesome mental picture of a rather excretorial nature. (probably not with crystals though…well..depending on how much pain you have to go through to get out your results in full categoricality I guess then maybe : ) )

    Reply
  7. llewelly

    I suppose it’s mostly a case of two fields confusingly using the same set of names to describe different things.

    It’s worse than that, cleek. Each programming language community has subtly but substantially different meanings for words like ‘functor’, ‘iterator’, ‘category’, etc.

    Reply
  8. Pingback: Topoi Prerequisites: an Intro to Pre-Sheafs | Good Math, Bad Math

Leave a Reply