What abstraction looks like
Category theory allows one to talk about things in a sort of “universal” language, by which I mean one which is not specific about what you are talking about. This seems weird - how could we talk about a car without knowing that it’s something that has four wheels? Or talk about justice and government without making reference to what a human is?
Although the stuff you care about certainly does have its own internal structure and properties, category theory tries to get away with saying as much as it can despite treating your rich, intricate object as a mere dot (i.e. a point without internal structure). Remember, a category is a mathematical construction that only has objects and morphisms (informally called arrows) between those objects, as well as a notion of composing morphisms together.
Let’s stress this point with some examples:
- A configuration of a Rubik’s cube has a lot of data: there are six faces each with a 3x3 grid of colors. One way of relating these is by the possible moves you can make by rotating one of the faces:
- The category-theoretic picture of the above faces looks like the below, which makes us feel like we’ve lost information.
- Graphs are another example of something that has a potentially complicated internal structure. In mathematics, a graph has vertices (also called nodes) as well as edges connecting them. We’ll draw graphs as having grey vertices and black edges, in order to keep them visually distinct from “mile-high” view diagrams in some category, such as the square one drawn above. Here are three graphs.
- The connections between the graphs (given by the grey dashed lines) above are called graph homomorphisms.1
- Now the category theory perspective of the above might look like this:
One way applied category theory is useful
One of the value propositions of applied category theory is that it’s possible for you to take your concrete domain of expertise (be it Rubik’s cube solving, delivery routes, psychology, etc.) and massage it into the language of a category. Once you do this, you are viewing it from the mile-high view, where everything is just dots and arrows.
The general story of the usefulness of abstracting your subject matter into these dots and arrows is that category theorists have spent decades thinking about categories and special configurations of dots and arrows that have special importance and deserve special names. This lets you inherit a large menu of tools for doing operations/constructions at that level of abstraction.
For example, the following configuration highlighted in red is called a coproduct. The diagram is saying that, for any dot (call it ), if you have arrows and then there exists a unique arrow (for which the path is the same as and likewise for ).
The symbol is evocative of what this abstract definition cashes out to when we instantiate this pattern in various categories. For example, it can correspond to adding numbers together, or taking the union of a Venn diagram, or getting the most recent common ancestor from a geneology chart, or, in the case of graphs, obtaining the graph that places graphs and side-by-side.2
Beyond things to do within a single category, the category theorists think a lot about how different categories relate to each other, meaning you can relate things in your domain of expertise to other domains (or other perspectives on your own domain) if the other ones are likewise able to be viewed as dots and arrows.
Critical to this value proposition is that you then can take these high-level insights back to the ground level, i.e. specialize them in your domain of interest.
How to go back in the other direction
There is nothing magic about category theory,3 but there seems at first like some magic is needed to take ideas from the mile-high view, where we seemed to have had thrown away so much information, and concretize them on the ground level. The resolution to this riddle is that there wasn’t actually information loss when we moved to the mile-high view.4
Let’s consider a concrete example from graphs. Let’s say we wanted to locate the following graph, , from the mile-high view.
It turns out that this graph has a very special quirk. We want to know “How many graph homomorphisms are there from some arbitrary graph into ?” It turns out, no matter how many vertices and edges has, and no matter how those edges are connected, there is exactly one graph homomorphism , because all of the vertices are mapped onto the single vertex and all of the edges are mapped onto the single edge. This means we can actually pick out which dot is actually from the mile-high view, a subset of which is visualized below. Can you find it?
In category theory lingo, this is called a universal property. Likewise, the coproduct pattern described by the diagram in the previous section was also a universal property. Category theory tries to talk about things (e.g. being , being the “sum” of two other things) purely based on these properties, which is why it can do powerful reasoning in a subject-matter-agnostic way.
One way of thinking of a graph homomorphism from a graph into a graph is that it answers the question “where can I find a copy of hiding within ?” You’d need to find a corresponding set of vertices and edges in that have the same connectivity as the ones in . ↩
With Catlab.jl,one can write programs at this level of abstraction, which has many practical advantages, such as being able to reuse the same code in radically different contexts as well as not needing to change one’s code even when the underlying data model changes. ↩
This is true “up to isomorphism”. The moment we turn our set of objects into a category by picking what it means to be a morphism, we are choosing what information we are going to lose when going to the mile-high view: objects which are indistinguishable by their morphisms, i.e. how they relate to other objects, will appear identical from the mile-high view. ↩