# Category Theory and Compositionality

"All abstractions are leaky!" — a nice explanation of what mathematical Category Theory focuses on, by "eli_gottlieb" = Eli Sennesh in a recent Hacker News thread:

Every branch of mathematics formalizes and studies some underlying phenomena. For example, in calculus, it's rates of change: their division into instantaneous changes (derivatives) and their accumulation into changes over time or space (integrals). In topology, it's properties like continuity and connectedness.

Of course, all mathematics is abstraction, and all abstractions are leaky. Calculus just chooses not to study non-differentiable and non-integrable functions. Topology chooses not to study discontinuous transformations, and abstracts away the spatial metric.

In category theory, the property under study is compositionality: the property that given a path from A->B, and another from B->C, you have a path A->C. Of course, anyone who's ever written a computer program knows that this is not as guaranteed as it sounds. All abstractions are leaky, and if your "paths" are functions, in the programming sense, then the second one could throw an exception, leaving you high and dry with the intuitive transitive property being straight-up wrong. Likewise, if your "paths" are mathematical functions, composition can preserve continuity (f . g for continuous f and g is continuous), but if either one is discontinuous, the result will fail to be continuous.

So category theory abstracts away the "exceptions" and "discontinuities" by ruling them illegal: in a category of topological spaces and continuous functions, everything, by construction, preserves continuity. We thus have an entire field of mathematics devoted to asking and answering the question: "what sorts of properties are preserved under transitive composition in what sorts of settings?"

(cf Greatest Inventions (2011-06-09), Cakes, Custard, and Category Theory (2016-02-14), Put the Vast Storehouse in Order (2017-10-04), ...) - ^z - 2020-05-06