Learning Category Theory without a Formal Mathematics Background (pt. 1)


Introduction

About a year ago, I decided I wanted to learn a new programming language. I had heard quite a bit about Haskell and its purely functional approach, and with C++ adopting more and more features from functional programming languages, I thought Haskell would be a good choice. My journey to learn Haskell is a story perhaps for another series of blog posts, but during my reading, I came across the term "category theory." I decided to do a little bit of reading on the topic to round out my education, but little did I know how deep that rabbit hole led...

Motivation

To give a brief introduction to the unaware, category theory is the study of underlying mathematical structure. That sounds abstract, and intentionally so, because it is this abstractness that allows it to be so applicable to a wide variety of fields. For example, category theory can be applied to programming language design, natural language processing, analysis of chemical reactions, as well as all sorts of other branches of mathematics. This list goes on and on... it's really quite incredible. If you're approaching from a programming perspective as well, I would highly recommend Philip Wadler's talk Category Theory for the Working Hacker as an introduction. Here's a quick sketch to give you a taste:

Category theory is all about studying the relationships between "objects". Again, "objects" here is an intentionally vague word, but here an object is the set of elements of a given type. So, in the diagram above, we are considering a few relationships between the set of lists of integers, the set of integers, and the set of booleans. The arrows that connect two objects then represent functions that take an input of one type and return an output of another type. For example, the reduce with addition function takes a list of integers, and adds them all up to produce a single integer. The >0 function returns true if the integer is greater than zero, and false otherwise. One key aspect of category theory is composition of arrows. We can compose the arrows labeled reduce+ and >0 to obtain a new arrow that goes from the List of integer object to the Bool object. This represents the function that takes an input list and returns true if the sum of its elements is greater than 0, and false otherwise. In this way, the diagram can also represent composition of functions, which is obviously prevalent in any programming language.

If, on the other hand, you're approaching from non-programming perspective, you might enjoy Eugenia Cheng's talk Category Theory in Life.

The Struggle

In any case, I've always liked math, but having done my university degrees in electrical and computer engineering, my formal mathematics background was limited to calculus and more practical applications thereof, with minimal exposure to the more abstract branches of math. As a result, when I started checking out books to learn, I was quickly shocked by the advanced background demanded of the reader by essentially any text that I picked up. Was I really that out of touch with the world of math? Or is this branch of math really that inaccessible to people without graduate degrees in mathematics? (For reference, the first two books I tried to read were, of course, Saunders Mac Lane's Categories for the Working Mathematician and Steve Awodey's Category Theory.)

It was somewhat discouraging at first, but I set out to find a truly introductory text, and I wanted to share what I found here.

Conceptual Mathematics: A First Introduction to Categories

After some searching on the internet, I decided to give Lawvere and Schanuel's Conceptual Mathematics: A First Introduction to Categories (2nd ed.) a try, and found it to be exactly what I needed. This text takes a unique approach in that it presents itself as a transcription of an interactive classroom session. It's a little strange at first, but once it reaches the more advanced concepts, I really appreciated how it makes the text easier to read, and offers a way for the authors to provide plenty of examples and alternative perspectives. Personally, I find that alternative perspectives are extremely valuable for a field as abstract as category theory... it seems that often the concepts are quite simple, albeit difficult to describe, so you never know when you'll stumble upon that perspective that makes things click.

As for topics, Conceptual Mathematics does a fantastic job of introducing the notion of a category, as well as the notions of

  • isomorphisms and one-to-one correspondences
  • monoids
  • products and sums
  • map objects

If you have indeed watched Philip Wadler's talk mentioned above and want to learn more, this book is perfect in scope.

The one weakness of the book in my opinion is the pacing at the end. The basics, as well as product/sums and map objects are wonderfully explained, but the final concepts (including the notion of adjoint functors, which is apparently very important) are presented in significantly less detail. Admittedly, the preface acknowledges that the final sections were written in the spirit of additional information for the interested reader. Hopefully a future edition expands on these concepts more.

Actually, I do have one more complaint in that answers to the exercises are not provided. In a book that is clearly geared towards the self-learner (as opposed to being an accompanying text to a lecture), why not provide answers as well? This was a minor point of frustration, especially in the later chapters.

Conclusion

All in all, thanks to the jump start provided by Conceptual Mathematics, I've found the journey to learn category theory to be incredibly rewarding thus far, and I would highly recommend that anyone with even a remote interest in mathematics give it a shot. In the meantime, I'm moving on to Category Theory for Computing Science by Barr and Wells, which seems thus far to be more advanced and concise, but still manageable at my current level. I'll share more thoughts when I'm done.

EDIT(04-28-2022): Here's pt. 2 and pt. 3.