Categorical systems theory
Categorical systems theory is the study of the design and analysis of systems using category theory. Category theory is a hopelessly abstract branch of pure mathematics, so abstract that even the other mathematicians refer to it as “abstract nonsense”. Why would anyone want to study such complex and concrete situations as general systems with a branch of mathematics so divorced from reality? In this blog post, I hope to answer that question. I want to say what the point of doing systems theory categorically is; what the main take-away lesson is, beyond the technicalities. I also want to show that category theory isn’t divorced from reality at all; it’s just general purpose.
Categorical systems theory is the study of the design and analysis of systems using category theory. Category theory is a hopelessly abstract branch of pure mathematics, so abstract that even the other mathematicians refer to it as “abstract nonsense”. Why would anyone want to study such complex and concrete situations as general systems with a branch of mathematics so divorced from reality?
In this blog post, I hope to answer that question. I want to say what the point of doing systems theory categorically is; what the main take-away lesson is, beyond the technicalities. I also want to show that category theory isn’t divorced from reality at all; it’s just general purpose.
I don’t want to waste your time, so here is the main idea of categorical systems theory: when designing or analyzing systems, we should keep a clean separation between the internals of a system and its interface with its environment. Here are the basic principles:
- Generally, systems don’t exist in isolation. A system can always interact with its environment. However, when we model systems, we should be precise about exactly how a system can interact with its environment. We call this precise way that the system can interact with its environment the interface of the system.
- Systems should only interact with each other through their interfaces. Otherwise, it becomes very difficult to reason about how combined systems will behave.
- Therefore, from outside the system, all we need to know is what is going on at the interface. We can then give guarantees on system behavior that only mention the interfaces. So long as we know how the interfaces can interact, we can understand the possible ways that systems can interact.
Now, these ideas weren’t invented by category theorists. In fact, the idea that we should cleanly separate the things a system does inside from the way it interacts with its environment through an interface is common practice in computing (both in hardware and in software). This clean separation allows for modularity — systems can be designed component by component, and then the components can be put together to get more complex systems.
But note that I didn’t say what I meant by system here. By “system” I could have meant a circuit, whose interface consists of the ports that are left exposed to the environment. Or I could have meant a software library whose interface is an API. Or I could have meant a system of differential equations, whose interface is composed of its free parameters and some of its variables to be used to set other parameters down the line. Or I could have meant a Markov decision process, whose interface is the menu of actions an agent can take. Or I could have meant a Petri net, whose interface is a set of species which can be involved in interactions with other Petri nets down the line. Or I could have meant an epidemiological model, whose interface involves the flow of people between locations. Or I could have meant an ecosystem, whose interface involves the flow of animals and energy through its boundary. Or I could have meant…
Everyone has their own notion of “system”, depending on what they are studying or designing at the moment. The reason we use a general mathematical framework like category theory is because systems theory is general. The lessons of categorical systems theory apply to any sort of system, no matter what it is. And category theory tells us how to formulate properties of combined systems in terms of how they interact through their interfaces. This is because, at its heart, category theory is the algebra of composing things.
1 A bit of history: Ordinary categories
Category theory was not invented to put systems theory on solid mathematical grounds. It was invented — in the early 1940’s — in order to make sense of calculations in homological algebra. Really, it was invented to describe when two constructions in homological algebra were “naturally equivalent”, and therefore could be replaced by each other in long calculations with many moving parts.
In order to organize these big calculations, Eilenberg and Mac Lane introduced the notion of a category. A category is an abstract algebra of functions, just like a vector space is an abstract algebra of vectors. The “vectors” in a vector space can be anything; what matters is that you can add them and scale them. Similarly, the “functions” in a category can be anything; what matters is that you can compose them. But while you can add any two vectors, you can’t compose any two functions; you need the domain of the second to equal the codomain of the first.
If you’ve taken a few calculus classes, you know that functions can often be expressed by formulas, like Functions can be composed by plugging in. If we have another function then the composite function is This may seem like all there is to composition, but there’s a hidden difficulty here. What if we have the constant function ? Then the composite doesn’t make any sense! This is because is not in the domain of — it doesn’t make sense to plug it in for .
In calculus class, you might have been asked to “find the domain” of a function; this was just an exercise in figuring out when a composite could possibly make sense. You might have been asked to find the domain of a composite if you know the domain of each component. But this gets complicated fast, and you really have to know the specifics of how your functions work to figure this out. If you mess up, you get gibberish.
Category theory takes a different approach: we say that part of what it means to be a function is that it has a well defined domain and codomain. We could write to say that the domain of is the set of real numbers except and , and that the codomain of is all of . This gives us a guarantee on the use of : whenever is any function whatsoever with codomain the domain of , the composite is well-defined, and it has the domain of and the codomain of . We do the work up front when we define our function , and then get guarantees on all future behavior no matter what we compose in (or out).
This idea of requiring that functions have well defined domains and codomains was a conceptual innovation of category theory, way back in the 40’s. It cleanly separated a function from its interface with other functions.
This idea of giving an interface to functions is very much the same idea that leads us to use data types while programming. By keeping track of the types of inputs to a method and the return type, we can catch errors at compile time that would have resulted in gibberish at runtime. This is why category theory has been so useful in the study of programming languages.
2 What do functions have to do with systems
The “functions” in a category are abstract things — all that is necessary is that they have domains and codomains (which could themselves be any sorts of things), and that you can compose them (satisfying some axioms). This means that could, in principle, be something entirely un-function-like — so long as you could compose things like this.
We can even take to be a system whose input interface is and whose output interface is ! Then if we have another system whose input interface is and whose output interface is , we can compose them to get a system whose input interface is and whose output interface is .
For example, could be a circuit diagram with three dangling wires on the left, and two dangling wires on the right:
And could be a circuit diagram with 2 dangling wires on the left, and no dangling wires on the right:
By plugging the output wires of into the input wires of , we get the composite system :
But we didn’t have to plug into , we could have plugged it into :
Then we’d get :
Of course, I could have told this story with Markov processes instead of circuit diagrams. Or labelled transition systems. Or even systems of differential equations. Category theory is a precise and flexible mathematics for describing how to compose any sort of systems.
3 Composing behaviors: Functors
Circuit diagrams are one model of an electrical circuit which foregrounds the way that they are composed out of basic components. But to predict what a circuit will do, we need a model which foregrounds the quantities we might measure about a circuit. This situation is repeated across systems science — we often have presentations of systems which are easy to describe and read, and then models of those same systems which are more difficult to build and understand, but match the world more closely.
However, we can save ourself some trouble. If we agree to only measure our circuits at their terminals — only looking at how our systems behave on their interfaces — then we need to track a lot less information. We can, following John Baez and Brendan Fong, consider the Lagrangian relation between the input and output terminals of our circuits (which encodes the total power dissipated by the circuit). Then there is a way to black box a circuit into this relation between potentials and currents at the terminals. It doesn’t matter what a Lagrangian relation is precisely, just that it describes the physics of the circuit.
What this means is that if we have a circuit with input terminals and output terminals in the category of circuits, then we get a Lagrangian relation which relates the potentials (in ) and currents (in the dual ) at the input and output terminals. So lives in a different category, the category of Lagrangian relations, and its domain and codomain in that category were calculated from the domain and codomain of — the terminals of the circuit .
The crucial property of this black boxing operation is that it preserves composition. That is, if we plug the circuit into the circuit to get the circuit , then we could calculate the Lagrangian relation of this combined circuit as a compose of the Lagrangian relations associated to each component .
An operation like this which goes between categories is called a functor, and the formula gives us a way of expressing constraints on the behavior of combined systems () in terms of their parts ( and ).
4 What do categorical systems theorists do?
Hopefully I have given you a sense of how category theory can be useful in studying complex systems: we keep track of how the systems are interacting with other systems through their interfaces, build up more complicated systems by composing them along their interfaces, then study their behaviors in terms of the behaviors of their (simpler) components.
But what do categorical systems theorists actually do? There are two main thrusts of research in categorical systems theory which I might broadly characterize as “breadth focused” and “depth focused”.
The breadth focused research is about bringing more systems theories into the categorical fold. The generality of category theory means it can apply to any systems theory in which systems can interact through well defined interfaces. But though the idea of cleanly separated interfaces from internal behavior is well understood in the computing sciences, it is not widespread throughout science. So effort has to go into understanding what sorts of interface are appropriate for a particular sort of model of systems — what sort of category is appropriate for that theory of systems. Then mathematical work has to go into finding the functors which package up the behaviors and give guarantees of behaviors of composites in terms of guarantees on their components.
The depth focused research is about extending the main ideas of category theory to more faithfully model what an interface to a system can be and how they interact. This means going beyond basic categories to other related mathematical structures from category theory: symmetric monoidal categories, operads, double categories. Sometimes, new categorical structures have to be invented just for this purpose. The upside of this research is that the kinds of guarantees offered by the appropriate analogues of functors can more finely respect the ways systems can be put together.
Finally, and perhaps most importantly, a number of mathematicians and programmers are implementing categorical systems theory into software, so that these methods can be used to design and study complex systems built out of existing numerical and computer models. This is the work being done by the AlgebraicJulia group, supported in part by the Topos Institute.