Categories
Birds and frogs
If you are like me and you don’t have a lot of stability in your life, you will be familiar with the experience of moving to a new home once in a while. Moving is sometimes a relief, new place, new roomates, but it is almost universally a pain in the ass. Packing everything in labeled boxes that will stay in a corner for the next five months. Trying to fit everything in one car, while that friend who agreed to help you moving only because when you asked them they were drunk, seats in silence in the driving seat.
The best part comes when you finally moved every single coin, every lamp, every shoe (once I lost a pair of shoes that way), and every pan and pot that make your daily life as it is: chaotic. Everything is secluded in a cartboard box, some with a name on it, some with the wrong name from the previous moving, and the great majority without any whatsover hint or suggestions about their content.
After spending the entire day with a frustrated friend, friend who you won’t see for the next few months, in a car surrounded by all your belongings, the chaos formed in the new place by the numerous boxes doesn’t bother you anymore. There’s only one thing at that stage. Finding that bottle of wine you opened a week ago and drink a well-deserved glass, with your favourite wine glass you keep bringing with you to every new house.
But how to find them? Trusting the labels on the boxes is something so näive that you only do once in your life. You learn very soon that any written clue is not going to help you in your finding. It feels almost like the labels got swapped for being too close in the car.
Another näive solution would be to open the first box in front of you, but after two boxes you realize that the chances to get what you want are lower than winning the lottery. The only remaining strategy is to guess the content of a box from its weight, size, and most importantly sound produced when shaken.
Like a true explorer you adventure yourself in that jungle of cartboard and tape and you start delicately shaking every vaguely rectangular object you encounter, hoping for the best. Too tired to think clearly, in the attempt to graciously balance your steps ending in resembling a gorilla in a french ballet outfit, if you are like me and you have done this process too many times, you might start thinking that are not the boxes to contain the things, but instead the things being themselves because they belong to that box.
Your foot just hit a large box called “lamps” (why do I have so many lamps? And why it’s so heavy?). Are the lamps in the box being lamps because they are lamps or because they belong to the “lamp” box. At the end of the day, you know they are lamps not from the label, but from the tickling sound the box made when you hit it.
The next unlucky box to smell your foot is the “memories” box. Is that a memory something that went in that box, or is the box that makes them memories? These thoughts that are common in time of despair and in adventures in dangerous territories like that one, might not be so absurd as they sound.
One time my supervisor told me that there are two types of mathematicians: the frogs, who live in a pond and spend their lives studying the roots and the petals of the lily pads, and birds, who fly high in the sky and don’t care about the iridecence of the flowers, but instead they see the whole forest at once. The frogs care about the details of every single lilly pad and they ignore the laws of the ecosystem they live in. The birds don’t care about all the small species that live on the ground, because their focus is on the structure of the forest: where to land, and where to stay away from.
The frogs prefer to think of an object as something that is there, because their interest is on those objects. They don’t care about the context. For a bird, that lily pad or another one are essentially the same. Instead a bird focuses on the environments. If they see a river, they know it might be a good spot for refreshing and finding some shadow from the sun. If they see a large field, it might be good for landing or to catch a prey. When they see forest, they know they might find a good spot for nesting.
The jungle of boxes in front of you makes you feel like a bird, trying to get meaninful information from the emergence of patterns and structures. In my life, I decided to be a bird. I want to make it clear: birds and frogs are both noble creatures. We need frogs who can understand the intimate nature of mathematics and we need birds to find patterns and structures.
I realized I wanted to be a bird when I learned about vectors. When you study linear algebra, you encounter the definition of a vector only after you discover the notion of a vector space. This is because, a vector, by definition, is an element of a vector space. It sounds like a strange definition at first. However, there are similar notions. Being a Newyorker is not something that comes from you, but it’s a contextual property. It’s a property enjoyed by the people of New York. When you heard the first time the word “New York” and you asked what it meant, whoever explained to you that New York is a city in the United States of America, they definitely didn’t tell you that New York is where the Newyorkers live, because being a Newyorker can only be established if you already know what New York is.
What if every concept is entirely contextual? What if, being a lamp is being in the box of lamps, instead of being the other way around?
Category theory is the science of boxes. It’s the idea of defining a mathematical concept as being an object in a special type of box. Being a lamp, for a category theorist, is not an intrinsic property of an object, but it’s entirely contextual: being a lamp is being an object is a suitable type of category, equipped with this and that structure and enjoy this and that property.
Let me make an actual example. If you have two collections of objects and (I say collection, I mean set), you might want to draw a table with all the pairs formed by an object and an object . The collection of those pairs is denoted by and is kwown in the lab as the Cartesian product of and . This is the intrinsic definition of the Cartesian product.
Categorically, the Cartesian product between two collections and is defined as the collection together with two special maps
called projections, subject to the following condition. For any other collection that comes with two maps and there must be exactly one map
such that, composed with and gives and , respectively. Here’s a diagram that helps:
What a bird definition! A frog would never agree to define the Cartesian product that way! This is because, in order to establish if a collection is or is not the Cartesian product of and , with this definition, you are doomed to check for every other collection and pair of maps and , if you can construct the unique map . Only a bird could come with such a definition!
Not just that, but in fact, there are infinite possible choices of what is the Cartesian product of and . A bird like me would answer to the petulant frog that those choices are all substatially the same. Birds would say something like, “it’s unique up to a unique isomorphism”.
The frustration of the frog is justified if we only care about the pond of sets, but as soon as you live that comfortable pond, it might come in handy having a solid definition that works in every other context. If you are an adventurous frog and you want to check what’s going on after that rock other there, you would feel very comfortable in finding that some flowers in the new pond you just found closely resembles the lilly pads you know very well and that you trust.
This is what category theory is good for. Extract the definitions of a concept and finding the correct context in which that definition makes sense and works as usual. For a bird perspective, a pond is always a pond. There will be water, there will be flowers, where will be frogs to argue with.
The definition of a category
After all these words, let me at least give you the definition of a category. A category consists of the following things:
[C.1] A collection of objects, that we write as ;
[C.2] For some pairs of object and , a collection of morphisms, which should be regarded as arrows and are denoted as ;
[C.3] For every object there exists a distinguished morphism, called identity of and denoted by .
In a category, the domain of a morphism is the object and the codomain of is . Two morphisms and are said to be composable when the codomain is equal to the domain of .
[C.4] For every pair of composable morphisms and , there is a distinguished morphism , called the composition of followed by .
Moreover, the following conditions are satisfied:
The objects of a category should be interpreted as generic objects that have no intrinsic property, points, or internal structure. The morphisms of a category should be regarded as the transformations between those objects. In particular, the identities should be regarded as the transformations that do nothing and the composition of a transformation with a transformation should be thought as performing the transformation after .
The key idea of category theory is that we can understand objects by looking at how they transform.
Let’s make an example of a category. Imagine to collect every possible -dimensional image. An image can be transformed in another image by sending each pixel of in a pixel . For example, the image of a cat can be rotated to obtain a rotated image of a cat. Some images are also contained in other images. For example, you might have the picture of a cat dancing the samba in a spaceship. This collection of images together these transformations form a category.
Some useful references
There are many great books about category theory. If you are interested in learning more about it, I personally enjoyed Steve Awodey’s book:
- Awodey, S. (2010). Category Theory (Vol. 52). OUP Oxford.
I’ve never read it, but I’ve heard that Emily Riehl’s book is also very nice:
- Riehl, E. (2017). Category theory in context. Courier Dover Publications.