Category theory is unmatched in its ability to organize and layer abstractions and to find commonalities between structures of all sorts. No longer the exclusive preserve of pure mathematicians, it is now proving itself to be a powerful tool in science, informatics, and industry. By facilitating communication between communities and building rigorous bridges between disparate worlds, applied category theory has the potential to be a major organizing force. This book offers a self-contained tour of applied category theory. Each chapter follows a single thread motivated by a real-world application and discussed with category-theoretic tools. We see data migration as an adjoint functor, electrical circuits in terms of monoidal categories and operads, and collaborative design via enriched profunctors. All the relevant category theory, from simple to sophisticated, is introduced in an accessible way with many examples and exercises, making this an ideal guide even for those without experience of university-level mathematics.
While I really loved this book, I feel I should first give a disclaimer about what you might need to know beforehand to productively get something out of it. You can definitely approach this book as a high school student with pretty much having just done algebra 2. With that said, I think it would vastly help if you approach this book possessing what is commonly known in math pedagogical land as "mathematical maturity". Having a strong working fluency with the language and syntax commonly found in mathematical logic and set theory would vastly improve your reading experience. Additionally, while you don't need fluency in this latter area, having at least some exposure to group-theoretic concepts and maybe a smidgin of abstract algebra would help in feeling comfortable. I myself am a data scientist with an undergrad in neuroscience & philosophy, and am just a recreational math lover :)
I also know there are some programmers who might have heard of category theory potentially being helpful in functional programming languages like Haskell, but I just wanted to say that although this book has the word "Applied" in the title, this is definitely *not* pragmatic-oriented like for instance the O'Reilly series of books with the cute animals on the covers. If you are seeking something more practically helpful, I would probably take a look at Bartosz Milewski's Category Theory for Programmers, his corresponding YouTube course, or even this recent Applied Category Theory 4 Engineers online course, the latter two of which I've just recently completed myself and can recommend.
Having said all that, I would additionally like to *highly recommend* going through this book in parallel with the authors' MIT course posted on YouTube by the Topos Institute. I found it incredibly helpful to have both of the authors talk out their concepts after having just read each chapter (with their lectures pretty much corresponding with their book chapters).
Going back to the book, what I especially appreciated is that it was friendly towards those autodidacts and self-learners among us, with lots of smart color usage, tons of pictures, and more importantly, exercises with(!) solutions in the back. I can't thank the authors more for having gone through the trouble to do this for us, especially since I'm the type of reader who often has a pencil in hand marking up my books (oh the blasphemy!) Additionally, if you happened to plot chapters by page number on the x-axis and level of difficulty on the y-axis, you'd see an almost "saw-tooth"-like graph, which means that you don't necessarily have to understand everything from the previous chapter to move on to begin learning the concepts in the next. Each chapter was relatively self-contained in its topics and provided more conceptually difficult material towards the end of each for a little extra challenge to those of us who want it. The book itself wasn't some ginormous monstrosity either, and was relatively straightforward to work your way through and light enough to stick in your bag if you wanted to go read and study at a park or something.
Chapter Review
Ch. 1 - Generative Effects: Orders and Galois Connections
Although this chapter starts off really basic, discussing high-level conceptual frameworks and what we mean when we "observe" a system, I really enjoyed it for giving a systematic review of the jargon commonly used. The authors discuss something called generative effects which you can think of like the surprises we see when we move from observation to observation of a system and what operations are preserved or not. In essence, we'd like to know if an observation is "operation preserving" or not.
They then discuss how we can draw such systems by drawing a circle around some objects (called a partition) and arranging these various ways of circling these objects into what is called a Hasse Diagram, with arrows from each collection representing the "≤" relation, and where individually circled systems are hierarchically arranged to be less than entirely circled systems of increasing order.
Other important terms we learn are Galois connections which are a special case of what we call adjunctions. I actually think this is one of the most important conceptual ideas found in category theory. You can think of the former as pairs of monotone maps between orders where going to the right we preserve meets and going to the left we preserve joins. In summary, you can think of a relationship notated by F : C ⇆ D : G, where we have the most strict relationship being an equality, the middle relationship a natural isomorphism, and the least strict relationship being an adjunction (where each direction of arrow relationship refers to the left adjoint (preserves joins) or right adjoint (preserves meets) respectively). This idea of adjunctions then allows us to give rise to closure operators which you can think of like the "inheritance of order". I also found neat that we can think of a computer program as a rewriting system as a closure operator, which all innately possess a partial order (which is cool because I just recently started writing a blog series about rewriting systems & lindenmayer grammars).
Other useful terms to know are functors (which are also diagrams) and are maps from one category to another, and natural transformations which are like maps from functors to functors.
Ch. 2 - Resource Theories: Monoidal Preorders and Enrichment
This chapter discusses general ideas regardings resources, costs, possibilities of, or ways from moving one way to another. Category theory allows us to capture very high level ideas like this and is even being used in Quantum Physics by Bob Coecke and his group at Oxford where he has also mentioned that he potentially wants to teach 10 year olds this language of wiring diagrams and have them compete in tests against adults who are used to our current mathematical formalisms (he hypothesizes the kids would out-calculate the older group).
Anyway, it's in this chapter that we get introduced to the (in)famous monoid which is a set consisting of a set M, a function *: M x M → M called the monoidal product, an element e in M called the monoidal unit, and which all satisfy associativity and the unital. To turn this monoid or monoidal set into a monoidal poset, you just require that it satisfies monotonicity (ie - preserves the less than relation). Monoidal preorders help us build up to rigorously define what a "cost" is, which is like saying how we get from a to b.
Ch. 3 - Database: Categories, Functors, and Universal Constructions
Honestly, I found this the most boring chapter and portion of the lecture series 😅, but it seems like much of the work that was done here actually had real-world applied consequences. For the pragmatic-minded people or the coders, you might appreciate this chapter the most. In this chapter we learn about how to represent Database Schemas as categories, a database instance or value as a set-valued functor, and data transformations as universal construction.
Ch. 4 - Collaborative Design: Profunctors, Categorification, and Monoidal Categories
This chapter seemed like it would be best suited for engineers. It basically allows us to capture at a high level language the way we can compose different functionalities of subsystems embedded as black boxes in even bigger systems, etc. It would be useful for "collaborative design" or where there are teams of engineers having to work together on projects where their domains of expertise or background knowledge might not overlap entirely with another to understand the whole scope of the project.
In this chapter we are introduced to the idea of a profunctor which is a generalization of a functor where you don't have to have every point mapped over or you can have the same point mapped to multiple places. An example is multiplication or if we were to generalize, any "grid" of sorts where the grid inherently can be mapped to a single line because it possesses an implicit preorder relation built in it. This allows us to generalize the concept of what a "feasibility" relation might be or the "availability of x given y", which for example would allow us to capture something like a chassis whose resources are torque and speed and whose outputs or functionalities are load and velocity, etc.
Ch. 5 - Signal Flow Graphs: Props, Presentations, and Proofs
Okies dokes, so this was absolutely my favorite chapter out of the whole book and was actually the main reason why I read it. This is where we start assigning a semantics or an interpretation to a string diagram, where that string diagram represents the flow of signals from one area to another. You can think of this like an information processor, a program, an electrical flow, biological signals, etc. What I found cool though, was how these string diagrams are actually representing various matrix manipulations! And since matrices represent systems of equations, we have a nice little rosetta stone here of concepts from a diverse and staggeringly vast amount of different fields of study.
It is here where I would like to also mention two great resources. The first is the incredibly beautiful blog Math3ma of Tai-Danae Bradley. The next resource is a super cool blog called Graphical Linear Algebra by Pawel Sobocinski. I think I consider this one of the single greatest treasures I've come across online. I'm actually using this right now to write my own series of articles translating phenomena like biochemical graphs, conceptualizations of information & entropy, and string rewriting mechanisms representing plant growth.
Anyways, this chapter goes over these wiring diagrams called signal flow graphs which have the property that unlike monoidal preorders and monoidal categories, you don't need to label the wires. This is called a symmetric monoidal category or a prop. Overall this chapter explains how there are fundamental objects or beads on these string diagrams which you can think of as the fundamental operations of adding, copying, zero, amplify, and discard/delete. You can then "slide" these beads across one another and move these strings around to simplify the diagram.
Ch. 6 - Electric Circuits: Hypergraph Categories and Operads
This was my second favorite chapter, and one for the more applied people again, but this time those who are interested in electronics. Although not an electronics or electrical engineer myself, I along with my whole family grew up "enslaved" 😅 and working in my father's electronics company assembling and testing circuit boards from like 5 years old all the way until college, so I am quite used to the familiar sight of circuit diagrams.
It is here where we are introduced to the concept of cospans which conveniently package up the aforementioned concept of colimits from before in terms of composition and monoidal products, and overall allow us to model "interconnection" like the "completing of circuits". We also were introduced to the use of Frobenius monoids and hypergraph categories, where these two concepts combine to form a decorated cospan. In summary, this chapter teaches us how to simplify circuits and break apart the functionalities of different sections.
Ch. 7 - Logic of Behavior: Sheaves, Toposes, and Internal Languages
This chapter deals with how we can "constrain" or design a system of interacting components to ensure that it is safe for instance or if you want it to perform only under a select range of options. It is here where we are introduced to the concept of a topos which is a special kind of category that in our case above can have objects called behavior types, which are sets of elements that can change through time.
We are also introduced to the concept of sheaves which can be thought of as a space of possibilities that varies in a controlled way, or a space of possible behaviors that change in a certain notion of time (which technically makes a sheaf a certain type of functor). In this case, our wires will correspond to different behavior types and our beads will correspond to different behavioral properties or a relation that X maintains between different changing values on its ports (corresponding to a sensor, controller, or motor for example). Another example of a sheaf on a space M can be that of a vector field on M. Overall, a sheaf on a space is basically "a sort of thing that can happen on a space".
One really cool thing that I learned was how we can connect the language of logic to the language of topos and sheaves by viewing predicates as things that when applied to a subject output a truth value. Thus, you can think of this as a logic where truth values can change over time. They further mention a few things regarding a type of "logic-to-sheaf" compiler where we can carry out constructions and formal proofs (further work can be looked up under the terms categorical semantics or Kripke-Joyal semantics). These latter ideas really had me salivating and even though they didn't go too much into depth that I might be able to apply, I'm thankful they mentioned a lot more references for me to check out later.
Summary
Overall, even though there's still a lot more in this that I don't fully understand and will need to re-read more than a few times, I feel like I gained a lot. With that said, my main projects center around attempting to apply category theory to the biological realm and I wish more was mentioned about that or petri nets for example (like on John Baez's blog). Regardless, I'm giving this book a solid five stars and will definitely be reviewing and re-studying it quite a bit over the next few years as I continue on my math journey. Thank you to both Brendan Fong and David Spivak for creating an artifact like this book, changing my perspective, and giving me a new language to use to explore my interests :)
Some people like to joke by saying, "A monad is just a monoid in the category of endofunctors, what's the problem?" and it almost echoes von Neumann's words: "Young man, in mathematics you don't understand things. You just get used to them." Well, the problem is, even "getting used" to things can be difficult, requiring substantial help from people who've spent more time on those things than you did: I really wanted to understand what category theory is all about and its potential connections to other areas of mathematics and engineering. And I didn't want to hear anything about functional programming: this was a deliberate choice on my part.
Did I manage to grok what category theory is all about and how it connects to other areas of mathematics? I must say this book helped a lot! It wasn't a super dense textbook, had a healthy dose of humor, and enough number of exercises to fire my brain cells, forcing me to find examples, counterexamples, and come up with proofs. Most important of all, it helped me build up some intuition, which is pedagogically very challenging: it requires going beyond formal sequence of definitions, axioms, lemmas, proofs; you need to select examples and exercises very carefully. The authors deserve a lot of praise for having achieved such a feat!
The journey that led me to this book can give you some ideas and help you manage your expectations:
- I have an bachelor's degree in math and engineering: I already had courses in algebra, linear algebra, real analysis, topology, etc. - Ten years ago I worked as a software engineer in a European Commission funded project, CUBIST, led by Dr. Frithjof Dau. In that CUBIST project, we tried to applied Formal Concept Analysis (FCA) to space telemetry data, and therefore I had to learn about Hasse diagrams (you can find some papers from that project here). - Five years ago, I've spent some time trying to learn Haskell. Category theory was not required to learn and apply Haskell, but it was also impossible to avoid it 100% because the historical development of the language borrowed a lot of concepts from category theory. I really wanted to have some proper, mathematical introduction to the topic, and was curious about its connection to the abstract algebra that I was introduced to in my undergraduate course because some terms such as morphism, ring, etc. also appeared in abstract algebra. - In 2018, Prof. John C. Baez taught a free, online course based on this book. I enrolled in the course, but couldn't manage to finish it. (The audience had very interesting "students", such as Conal Elliott.) - Finally the book was published, and I read Mundy Reimer's excellent review: it became a tipping point. - I also started to attend to Applied Compositional Thinking for Engineers (ACT4E)lectures.
In this part of my journey, thanks to this excellent book, I'm motivated to learn more about category theory and its applications to other fields. I can't claim to have perfectly understood all of the concepts in the book, some of them I'll have to revisit and maybe approach from different perspectives, using different books and papers, but the book is also helpful in this aspect, because at the end of each chapter, there's a very good overview of the established literature as well as recent papers both related to the fundamental, theoretical parts, as well as applied parts.
If you have a bit of a mathematical maturity, and some patience coupled with a lot of curiosity, I think this book gives a lot of "taste" of category theory and its applications to other areas of math, logic, and engineering. If you're not interested in the math, then don't bother with this book. It's not intended for programmers who're trying to use Haskell to get some records from the database, or interact with some cloud computing API, process some JSON, insert some data into some distributed database, etc.
I should conclude this review by noting a few annoying aspects: sometimes using the index to find the definitions doesn't work very well, I guess this is the price you pay when you focus so much on pedagogy. And a final nitpick: they note down page number where a particular book or article is cited, but those page numbers have some errors, that's probably related to some numbering mix up between the PDF and the printed edition, and should be fixed in a later printing.
Background: I am an engineer masquerading as a computer scientist. My previous math thus amounts to the standard memorize-and-regurgitate style analysis/LA/ODE/etc. sequence. Additionally I have gone through "How to prove it" by Velleman and "Elements of Abstract and Linear Algebra" by Connel. These two books began my attempt to understand the math that I regurgitate so well.
I read seven sketches by: 1) Skim through chapter to get broad ideas 2) Write short summary of what each title/subtitle/image is conveying 3) Add summaries and definitions to Anki 4) Go through flashcards while answering every question and attempting every proof The great diagrams and plain-English explanations made this a relatively pain free process. Some of the concepts (hom-elements, profunctors, sheaves, etc.) took a while to click, but I think this was mostly due to my lack of grounding in abstract math.
My primary motivation for going through seven sketches was the strong applied example focus, and how category theory manages to generalize over huge swathes of mathematics (I figured that by learning CT near the beginning of my math journey I would learn faster overall, fingers crossed this pays off!).
Seven sketches has been written so that each chapter ramps up in difficulty quite fast, but this difficulty is partially reset between chapters. By the end of each chapter I struggled to complete the proofs, but the reset difficulty in the next chapter enabled some forward progress while working out what I'd previously struggled with. This made my overall rate of progress through the book seem slow, but the constant back-referencing made the concepts stick better overall.
There is a wealth of references for modern applied category theory, especially 'Temporal Type Theory" by the same authors. These references are worth a couples of stars by themselves.
I give this 4/5 because I prefer to be given the full definition of a concept up front and then work out what each part means, whereas this book does the opposite.
I feel I should qualify my 3 stars, since they might be largely due to me going into this with wrong expectations, which I at least partially blame on the book's cute, unassuming title. Make no mistake: this is a book by mathematicians, for mathematicians, and as such is drenched in formalism. The "applications" I found act more as vehicles to introduce ever more formalisms, but to what end I didn't understand. I sure thought it's intriguing that category theory can be used to formalize database migrations, but taken out of the context of software development (which is unfortunately the case here) I found the "application" to be awkward, and honestly, quite useless. Truth is: data is messy. No extent of formal proof about your database schemas will ever yield a useful migration in the real world. What could be useful is to translate these ideas into a programming language, and people have done that with libraries like doobie, which uses structures from category theory in the Scala programming language to model database IO in a purely functional way, but such actual applications of these ideas don't even appear in footnotes.
So if you're looking for a gentle introduction to the key ideas and applications of category theory, this book is probably not for you.
An excellent introduction that shows the applicability of category theory to more practical aspects as a way of forming a common compositional structural grammar.
Allowed me to sketch similar models and application for my area.
I would say a must read for any applied mathematician or computer scientist.
I really recommend this book as a different perspective on category theory for anyone that's learning it. Many books will rehash the same ideas in the same order: not Spivak and Fong. I guarantee that this will perfectly complement any other text you get on the subject, and force you to think differently.
I really enjoyed this as my first introduction to category theory. If you're looking for something that's fun and useful to read without taking it very seriously this is a great book to read. You can still get a lot out of just doing the exercises that you think are neat and trying to loosely follow the constructions.
This book made me feel comfortable talking about categories and put me in a good place to start reading other topics. I particularly enjoyed chapter 7 and the introduction to sheaves.
A very enjoyable and accessible way to get into higher level mathematics and category theory. The book contains full proofs and solutions and is written in a very pleasant style. I could follow every chapter more or less together with the online lectures.