Why Category Theory?

Keith A. Lewis

January 26, 2025

I came across Category Theory when I was a fledgling assistant professor at Brown. One requirement of getting a PhD in mathematics is to take a course in Set Theory. If you held a gun to my head and told me to write down all the axioms of Zermelo-Frankel set theory, I would be a dead man. The simplicity of Category Theory was a revelation. I made the mistake of telling one of my colleagues about my interest and was shocked by his angry reply, “Category Theory doesn’t do anything. Stop wasting your time on it!”

Many people think math is abstract nonsence. Most mathematicians seem to regard Category Theory as generalized abstract nonsense. It is definitely something that is difficult to appreciate until you’ve learned a lot of mathematics. Samuel Eilenberg and Saunders Mac Lane invented it to unify common themes shared by many mathematical objects.

Category Theory involves objects and arrows from one object to another. The discipline of defining mathematical concepts using them clarifies classical definitions. One surprising result is that set membership cannot be defined using only objects and arrows.

I’m sure Sammy and Saunders had no idea that Category Theory would become the basis for modern functional programming languages. Classical logic casually uses \forall and \exists to quantify over propositions that are either true of false. It turns out it is sometimes not possilbe to write a computer program to determine this.

A truely astounding result is the Curry-Howard correspondence. Proofs using the axioms of Hilbert stye deduction for intuitional logic are the “same” as a the computational model of lambda calculus.

Math true false statemts caveats. !!!

“equal” is a problem

“equivaltent” is better

HOTT

Set

Everything in classical mathematics is a set. Logicians are wont to say “the language of Set Theory is epsilon.” By that they mean the only additional symbol required in first-order logic to define the axioms for set membership is ϵ\epsilon

The first attempt at defining modern Set Theory is due to Frege. He defined a set by giving a rule for membership. Bertrand Russell showed that entailed a contradiction. Let SS be the set of all sets xx where it is not the case xxx\in x, S={xxx}S = \{x\mid x\notin x\}.

Exercise. Show SSS\in S implies SSS\notin S and SSS\notin S implies SSS\in S.

It was not easy to fix up Frege’s theory. This led to various schemes to axiomatize what a set is, e.g., Zermelo-Fraenkel, von Neumann. Their axioms are not the first thing you might think of.

A simple solution to this is to only define subsets of an existing set that satisfy a rule. For any set SS and a predicate PP on SS we can stay out of trouble by defining {xSP(x)}\{x\in S\mid P(x)\}. A predicate is a function from elements of a set that returns either true or false.

A set is just a bag of things (elements) with no structure. Two sets are equal if they contain the same elements. Using epsilon and first order logic this is written A=BA = B if and only if (aA aB)(bB bA). (\forall a\in A\ a\in B)\wedge(\forall b\in B\ b\in A).

If A=BA = B then they have the same number of elements. A weaker notion is two sets have the same cardinality if they have the same number of elements. If AA and BB are infinite this becomes a bit tricky to define. The sets A={1,2,3,}A = \{1, 2, 3,\ldots\} and B={2,4,6,}B = \{2, 4, 6, \ldots\} are both infinite and clearly BAB\subset A but BAB\not=A. They have the same cardinality because we can associate nAn\in A with 2nB2n\in B. The function f ⁣:ABf\colon A\to B defined by f(n)=2nf(n) = 2n is one-to-on and onto.

If AA and BB are sets, their cartesian product is the set of all pairs A×B={(a,b)aA,bB}A\times B = \{(a,b)\mid a\in A, b\in B\}. A relation is a subset RA×BR\subseteq A\times B. We write aRbaRb for (a,b)R(a,b)\in R. The left coset of bBb\in B is Rb={aAaRb}Rb = \{a\in A\mid aRb\}. The right coset of aAa\in A is aR={bBaRb}aR = \{b\in B\mid aRb\}.

A relation is a function if for every aAa\in A there exists a unique bBb\in B with (a,b)R(a,b)\in R. We can write R(a)=bR(a) = b instead of aRbaRb since bb is unique.

Exercise. A relation RA×BR\subseteq A\times B is a function if and only if the the right coset aRaR contains exactly one element of BB.

If ff is relation on A×BA\times B that is a function we write f ⁣:ABf\colon A\to B. A function is one-to-one if f(a)=f(b)f(a) = f(b) implies a=ba = b. A function is onto if for every bBb\in B there exists aAa\in A with f(a)=bf(a) = b. An isomorphism is a function that is one-to-one and onto.

Two sets have the same cardinality if there is an isomorphism f ⁣:ABf\colon A\to B and we write #A=#B\#A = \#B.

Exercise. Show #A=#A\#A = \#A for every set AA.

Hint: Define f ⁣:AAf\colon A\to A by f(a)=af(a) = a, the identity function.

Exercise. If a function f ⁣:ABf\colon A\to B is an isomorphism show there exists a function g ⁣:BAg\colon B\to A that is also an isomorphism.

Hint: Define g ⁣:BAg\colon B\to A by g(b)=ag(b) = a if and only if f(a)=bf(a) = b, the inverse function of ff.

This shows #A=#B\#A = \#B implies #B=#A\#B = \#A.

Exercise. _If #A=#B\#A = \#B and #B=#C\#B = \#C then #A=#C\#A = \#C.

Hint: The composition of isomorphisms is an isomorphism.

This shows cardinality is an equivalence relation on sets.

A relation RA×AR\subseteq A\times A is reflexive if aRaaRa for all aAa\in A. The diagonal of AA is the relation ΔA={(a,a)aA}\Delta_A = \{(a,a)\mid a\in A\}.

Exercise. Show RR is reflexive if and only if ΔAR\Delta_A\subseteq R.

Exercise. Show ΔA\Delta_A is the identity function on AA.

If RA×BR\subseteq A\times B then its transpose is R={(b,a)aA,bB}B×AR^* = \{(b, a)\mid a\in A, b\in B\} \subseteq B\times A.

A relation RA×AR\subseteq A\times A is symmetric if and only if R=RR^* = R.

A relation RA×AR\subseteq A\times A is antisymmetric if and only if RR=R^*\cap R = \emptyset.

If RA×BR\subseteq A\times B and SB×CS\subseteq B\times C the composition SRA×CSR\subseteq A\times C is the set of all (a,c)(a,c) for which there exists bBb\in B with aRbaRb and bScbSc.

A relation RA×AR\subseteq A\times A is transitive if and only if RRRRR\subseteq R.

A relation RA×AR\subseteq A\times A is an equivalence relation if and only if it is reflective, symmetric, and transitive.

Exercise. If RR is an equivalence relation then aR=RaaR = Ra for all aAa\in A.

Exercise. If RR is an equivalence relation then either aR=bRaR = bR or aRbR=aR\cap bR = \emptyset for a,bAa,b\in A.

Exercise. Show {aRaA}\{aR\mid a\in A\} is a partition of AA.

Category Theory

Category theory uses objects and arrows instead of membership to express mathematical concepts.

Using Category Theory to define a set turned out to be problematic. It was not possible to recapture the notion of set membership. Topos Theory identified the concept of parameterized membership as a subobject classifier. Sometimes it is more natural to consider the points on a sphere as the unique tangent plane to the point.

Set

The objects in category Set\mathbf{Set} are sets and the arrows are functions from one set to another.

If A={a}A = \{a\} is a set with one element (a singleton) then for every set BB there is a unique function from BB to the singleton set {a}\{a\}. Every bBb\in B is sent to aa.

Exercise. If AA is a set and for every set BB there exists a unique function from BB to AA then AA is a singleton.

We can define a singleton set using only objects and arrows. We cannot define epsilon using objects an arrows.

This is an example of a terminal object.

The cartesian product of sets AA and BB is A×B={(a,b)aA,bB}A\times B = \{(a,b)\mid a\in A, b\in B\}. Selecting the left and right elements correspond to the functions α(a,b)=a\alpha(a,b) = a and β(a,b)=b\beta(a,b) = b.

Note #(A×B)=#A×#B\#(A\times B) = \#A\times \#B.

Exercise. If α ⁣:CA\alpha\colon C\to A and β ⁣:CB\beta\colon C\to B there exists a unique function γ ⁣:CA×B\gamma\colon C\to A\times B with $$

$$

Hint: γc=(αc,βc)\gamma c = (\alpha c, \beta c).

This defines cartesian product using only objects and arrows.

What is the “sum” of two sets? We could define S+T=STS + T = S\cup T to be the union, but putting on our category theory glasses that turns out to be not quite right.

Reversing the arrows of the category definiton of product we are looking for functions l ⁣:SS+Tl\colon S\to S + T and r ⁣:TS+Tr\colon T\to S + T with the following property: if λ ⁣:SU\lambda\colon S\to U and ρ ⁣:TU\rho\colon T\to U then there exists a unique function σ ⁣:S+TU\sigma\colon S + T\to U with σl=λ,σr=ρ. \sigma l = \lambda, \sigma r = \rho.

We can define l ⁣:SSTl\colon S\to S\cup T and r ⁣:TSTr\colon T\to S\cup T by set inclusion. If λ ⁣:UST\lambda\colon U\to S\cup T and ρ ⁣:UST\rho\colon U\to S\cup T how do we define σ ⁣:STU\sigma\colon S\cup T\to U so σl=λ\sigma l = \lambda and σr=ρ\sigma r = \rho?

If sSs\in S we can define σs=λs\sigma s = \lambda s and if tTt\in T we can define σt=ρt\sigma t = \rho t.

Exercise. If sSs\in S and sTs\notin T then σls=λs\sigma l s = \lambda s. If tTt\in T and tSt\notin S then σlt=ρt\sigma l t = \rho t.

The problem is ensuring σl=λ\sigma l = \lambda and σr=ρ\sigma r = \rho on the intersection STS\cap T.

Computer science product and sum types.

Vector space V + W = V x W and V x W = L(V,W).

#A^B = #A^#B

We want #(A+B) = #A + #B