"can somebody explain what the fuck a category is?"
originally posted on cohost, lightly edited oct 2024. oh it feels so good to type in latex notation again and not mathml
saw this question on discord and i can never resist the allure of trying to boil down some math into a plain-language story. category theory is, of course, the strongest bait which could have been loaded onto this hook, so can you blame me? long has the bastion of abstraction entreated us to interpret its diagrams.
unfortunately i fear that the answer is no: nobody can explain what the fuck a category is, not really. because the underlying perspective shift of category theory is to stop asking what things are, and start asking how they relate to other things around them. by externalizing the characteristics of objects into the network of relationships around those objects, we blur our object-vision further than before, hoping to contract presbyopia and see the whole forest, not just the trees.
so if you remember nothing else, i beseech you, remember this: regardless of what a category is, category theory is a surprisingly expressive language for discussing mathematical structure. it works much like any other language. it comes with a profusion of vocabulary. ignorance of it can be worked around and translated past by a skilled interpreter. but there is poetry written in it that most authors agree should be appreciated directly in its mother tongue.
to recite the definition of a category is to demand a cigarette break: it is boring for nonparticipants, bitter and addicting for the user, and chronically toxic to everyone present. i suffer from a crippling addiction to abstract nonsense, but i would like to be at least a bit respectful, so let me split the difference and describe it broadly1 as composed of three pieces of data:
- a collection of objects;
- for each pair of objects, some arrows from one to the other;
- for compatible arrows, a composition operation.
you should2 think of the objects as, like, stuff. you know, elements, points, ko, whatever you materially have in your spaces. then the arrows are structure adorning that stuff, and finally the composition is enforcing properties on the structure. importantly, composition is not ontologically giving names to heretofore unnamed arrows (even though that is a common and convenient use in practice) but merely relating triples of arrows that already exist, ensuring the category is arranged into a coherent shape. in particular, it is commonplace that the composites of two distinct pairs of arrows might be equal.
this is the essence of categories: everything important you need comes from the arrows. there are boatloads of arrows (anytime you have an arrow out somewhere, you also have an arrow out to everywhere that object has arrows!) so it's sometimes a tossup whether you can rely on a single arrow to tell you what you want, or you have to introduce some quantifiers and study across lots of arrows. as a result, there are a lot of quantifiers, and so there are a lot of terms devised to try to make intuitive sense of those stacked quantifiers.3
this is, of course, terribly vague and unmotivated. at this level of abstraction, it's hard to motivate mathematicians except with results. and, while gesturing at the increasing fraction of all results of mathematics since the 1930s is maybe humbling, if you have the time to ponder it, it is useless for a learner. so i'm going to have to tell you a couple of stories instead.
the externalization story
abstract algebra already has a strategy for discussing structure. it goes like this: build your thing out of whatever stuff you have, even if it takes multiple kinds of stuff or whatever. and then, just... try to ignore the the stuff... and what will be left is structure4 that you built.
that sounds vague and maybe even flippant, but you can make this idea precise. what you're doing is treating the things up to isomorphism: any invertible reorganization or relabelling of the stuff a thing is made from, should induce some invertible transformation of the thing in turn, in a structure-preserving way.5 so if you "quotient out" by isomorphism, you will gather things into isomorphism classes, and that way you will have described structure, by a kind of brute force totality.
this is how most mathematical structures in an undergraduate education presently function, with sets playing the role of the stuff. vector spaces are a set of vectors, equipped with some operations like addition and scalar multiplication. groups are sets equipped with associative multiplications. rings, modules, algebras, semirings. combinatorics and geometry use this pattern too: graphs are vertex sets equipped with a set system of edges; topological spaces are point sets equipped with a set system of opens. this system is simple and effective and it is plenty servicable.
one way to interpret the contribution of category theory, is as the modest observation that this conception of structure—as things modulo stuff—is not as blind to the stuff as it could be. you can develop theory well enough, by being abstract, but you are still constantly touching stuff and trying to ignore it.
the proscription of category theory, then, is to stop doing that, and externalize your structure instead. describe your structure as happening between the things, so that in a way you are never touching the stuff at all. then the stuff can truly go away6 and let you study the structure. the versatility of category theory, afforded by adherence to this moral principle, cannot be understated: it has enabled so many applications that it revolutionized entire fields of mathematics, and enabled mathematicians to talk to each other across fields in ways they hadn't been able to before.
in category theory, an isomorphism is an arrow with a two-sided inverse. so if you were looking to categorify some notion of structure discussed this way, then according to category theory, you ought to devise some notion of homomorphism—structure-preserving map—such that the isomorphisms are all and only the homomorphisms with two-sided inverses; those homomorphisms will be your arrows. for this reason, many texts about category theory still refer to arrows as morphisms, and the collection of arrows between a fixed pair of objects as a homset, with the notation .
thus, in a way, a category is a way of externalizing structure of objects, in order to better hone in on that structure, and see the forest in the trees.
the naturality story
in 1945, sam eilenberg and saunders mac lane were doing algebraic topology, and they decided to try and pin down what it means for two things to be "naturally isomorphic". they knew what isomorphism was, and they knew that some isomorphisms were a lot nicer than others. but it's not enough to just know, to feel it; you have to mathematize it.
so to define natural isomorphisms, the story goes, they had to devise functors. and to define functors, they had to devise categories. this story is about digging downwards, and it's very complicated when it is told this way. so i will tell this story in reverse, by climbing up from categories to functors to natural transformations (of which natural isomorphisms are just the two-sided invertibles). you are already acquainted with categories.
functors are, put simply, arrows between categories. they are what you get when you try to preserve categorical structure, by following the externalization instinct. more concretely, functors:
- send objects to objects;
- send arrows to arrows, respecting sources and targets;
- respect composition.
functors enable you to pass structure from categories to other categories. one intuitive way i like to think of them is as recipes: the objects in the domain are your materials, and the objects in the codomain are the kinds of thing you created. the arrows in the domain are constraints imposed on your materials, that composition forces you to respect. the arrows in your codomain are something like "structural freedoms" that you have, though in a sort of strange way, where a unique arrow from to is the best situation to be in as you don't need to make any tough choices, but if there are no arrows then you are prevented from sending that pair of objects there to begin with. it's not a perfect analogy.
the other thing that functors enable you do to, is to define a category of categories, where categories are your objects and functors are your arrows. this allows category theory to study itself and do metamathematics on itself, within reason7.
and now, the great and horrible trick that ties category theory together, is to pursue this externalization again: look for arrows between functors, and discover natural transformations.
concretely, a natural transformation from a functor to a parallel functor , having domain category and codomain , consists of:
- a family of -arrows (for each object of )
- which respect -arrows: (for each arrow of )
- this space intentionally left blank (exercise: why?8)
so now we, like benjamin button before us, reach the beginning of our story: an isomorphism is natural in a parameter , if it respects the categorical structure of that parameter (or more accurately, of what it ranges over). it can take some thinking and interpreting, but so far, anything we have honestly dared to call natural (before category theory could skew the data) is natural in this way.
thus, in a way, a category is an ontological necessity for discussing subtle phenomena that didn't have anything to do with categories and we really were just getting by on vibes.
here's a couple tricks you can do with natural transformations. first of all, they permit us to create functor categories, whose objects are parallel functors—having equal sources and equal targets—and whose arrows are natural transformations. you can put one of these on each homset in the category of categories, using a process called "enrichment" to get a "2-category"; the process is a little bit finnicky to do in the correct level of generality, but it is the first step in a long series of perverse generalizations called higher category theory.
second, natural transformations also permit us to state the yoneda lemma, perhaps the most important theorem of category theory. but i'll save that discussion for the sequel. sorry! yoneda is a lot to talk about, because so many things are an application of yoneda that it's nothing short of mind-boggling.
so what the fuck is a category
a category, in practice, is a mechanism for bundling together massive amounts of data in a uniform way. it is a tool that allows you to quickly and formally prove obvious facts, and sometimes even to suggest nonobvious facts that would be helpful if it so happened that you could prove them. it is a lens through which you can organize your studies, and a field guide to the organization of the studies of others.
it's also a great way to burn out, if you try to learn it too early. it's not called "abstract nonsense" for nothing: category theory is large enough to live in, but it amounts to very little if you don't have anything to apply it to. motivation is scarce and abstract, so you have to bring your own intuition.
languages are for talking about things. they can discuss themselves, but there's also a whole world out there that language is well served to talk about. there are no millennium prize problems in category theory.
i'm oversimplifying a little bit, but if you want to find out how i am lying to you, then you will have to go look up the definition of a category in a book. once upon a time i would have recommended awodey, but today the ultimate book about categories is unquestionably category theory in context by riehl. anyway, for reference's sake, the thing that i am hiding is hidden in item 3. ↩
category theorists familiar with stuffβstructureβproperties will admonish me for using these terms wrong. but i don't care about essential -surjectivity or functor factorization so like, sorry not sorry ↩
this is why category theorists can never shut up. they need to tell you the words they use so that you all can handle the quantifiers flying around. here is a first-order, foundational definition from topos theory: a subobject classifier is an arrow from the terminal object such that every monomorphism is uniquely a pullback of . now, here is that same definition, unrolled into all its gory quantifiers, and with horizontal scrolling enabled:
every variable here is an arrow and i have omitted the signatures of the arrows for brevity. the purpose of this exercise is to scare you, not to teach you. go read a topos book if you want to know about this. my advice is don't use goldblatt. ↩
okay, look, i know i used stuff and structure as words just a moment ago, so let me warn you that later on we will see that we have categories whose objects are the things i am talking about now when i say "structure", even though i called the objects the stuff earlier. so i'm sorry if this is confusing. but secretly i'm right. it suffices to pretend that "stuff" and "structure" and "thing" are like, suggestive names for metavariables for now. but (i think) i'm using them very intentionally and correctly. once you get to the end of this chost, you will know about the category of categories, and maybe you'll see what i'm going for here. ↩
what goes unsaid here is, if the relabelling doesn't induce an isomorphism, then something has gone wrong: either you have built it wrong, or you don't really understand what stuff you are free to relabel. in either case, you are committing a violation of the structure. ↩
as it so happens, there is a one-sorted definition of categories, where you can throw out all the objects and just axiomatize the arrows. it is not used very much, but the fact that it exists is pleasing to a certain kind of logician, so let it be known that categories pass this test. and more importantly, it plays quite poetically into my point. ↩
for the same reason that there cannot be a set of all sets, category theory's metamathematics also rests on a precarious reflection principle. on the one hand, mike shulman has a great note about this that can be taken as an expert opinion of the ability of category theory to do metamathematics. on the other hand, he has been transphobic in public since then, so i am accepting suggestions for alternative resources in the comments. editor's note: there are no comments on this platform ↩
harder second part to the exercise for nlab readers: what should go here, and when? ↩