More on categories
September 09, 2020 • category theory
Tl;dr — We look at some important concepts and examples of categories that will come up over and over again.
As a quick review, a category is a collection of objects with morphisms between them that can be composed together. Check out my previous post introducing categories if you need a refresher.
Preorders
Preorders are categories in which there is at most one morphism between any two objects. In our pictures of categories, this means there is at most one arrow from one object to another (there might be one going from to and one from to though).
Another way to think about preorders is that all parallel paths are equal. By a path we mean any sequence of arrows where the target of one arrow is the source of the next (so they can be composed together). By parallel paths we mean all the paths have the same initial sources and the same final targets. By all parallel paths are equal we specifically mean that the compositions of all the morphisms in each path are equal to each other.
For preorders, we often denote that there is a morphism from an object to an object by writing .
The definition of a category implies that for any object we have , and for any three objects , if and , then .
I like to think of preorders as generalized hierarchies, as the examples below hopefully illustrate.
Examples of preorders
Bool
One of the simplest preorders is the booleans Bool = {false, true}. We get a preorder by setting false true.
Natural numbers
The natural numbers = {0, 1, 2… } form a preorder with the usual ordering (e.g. 5 ≤ 9).
Resource theories
At a basic level, a resource theory is simply a collection of objects, or resources, a way to combine resources together as a single resource1, and a way to convert resources to other resources, which corresponds to morphisms between resources.
We can think of resource theories as preorders if we set if there is at least one morphism from to .
An example is the set of all collections of atoms and molecules Mat (for materials). In Mat we denote combining materials by +, and a preorder structure is given by setting if there is a chemical reaction that converts to , which we usually write as (note is used instead of ≤ in this context).
Here’s a concrete example in Mat if the above doesn’t quite make sense:
This describes the chemical reaction creating water from hydrogen and oxygen.
Power sets
Given a set , we can consider its power set which is the set of all subsets of . For example, if then
where is the empty set.
We can turn into a preorder as follows: if and are subsets of (and thus elements of ) we say if is a subset of , which following standard mathematical notation we write as .
Partial orders
Power sets are also examples of partially ordered sets, often abbreviated as posets. A poset is a preorder that has the additional property that if and , then . In other words, you can’t have arrows that form loops like the following diagram:
In terms of sets, if a set is a subset of , and is a subset of , then they must have exactly the same elements, and thus are the same set.
Posets are partially ordered in the sense that you don’t need to be able to compare every pair of objects. For example, say = {a, b, c}. Then {a} and {b} are subsets of , but neither is a subset of the other, which is to say neither {a} {b} nor {b} {a}.
Total orders
Bool and are also partial orders, and in fact they are also total orders. A total order is a poset for which every two objects are comparable, so either ≤ or ≤ is true (and if both are true then ).
Pictorially the objects of a total order can be placed in a line with all the arrows pointing in the same direction, as in our pictures of Bool and above.
The category of sets
This is probably the most important category in mathematics, since sets come up all the time in mathematics. We denote this category by Set. The objects of Set are, as you might expect, all sets. The morphisms between them are functions between sets.
If you don’t remember, a function between sets and is a relation that takes each element in to an element in , where we usually denote this mapping explicitly by writing for . Note that maps each to an in , but for each there may or may not be an that maps to (in fact more than one could map to the same ).
Identity morphisms are given by the identity function: for any set define by for all in .
Composition is also straightforward: for any two morphisms define their composite to be by for all in .
Monoids
Preorders are categories whose morphisms are simple: only one is allowed from one object to another. Monoids are like the reverse of preorders: there’s only one object, but there might be infinitely many morphisms.
Monoids might be more familiar in terms of sets: a monoid is defined to be a set with a binary operation that takes a pair of elements of and maps it to another element of . We write . Note that in general .
There must also be an identity element in that satisfies for all in . The operation must also satisfy an associativity property:
From this description in terms of sets, do you see how to reconcile this with the category-theoretic definition of a monoid as a one-object category?
Here’s the answer: each element of corresponds to a morphism in the category, and in particular the identity element corresponds to the identity morphism . The binary operation corresponds to composition of morphisms.
A common example of a monoid is strings in most programming languages: the empty string ""
is the identity morphism, and string
concatenation is composition.
We’ll talk about another important class of monoids after we introduce the idea of isomorphisms.
Isomorphisms
We often come across the idea that two objects and are not quite equal, but instead equivalent or interchangeable. They are equivalent in the sense that there exist morphisms and such that
We say that and are inverses of each other and write and to denote this. We also say that and are isomorphic, writing , and that a morphism is an isomorphism if an inverse exists.
The intuition is that you can go from to through and then back to through (and similarly from to and back to through and then ), without losing any information.
As an example of losing information in Set, suppose and . Defining by setting , we see there is no way to define an inverse function that satisfies and (that is, ). Going from to we lose information about where we started from.
In a preorder, objects and are isomorphic if and , and we can turn any preorder into a partial order by setting and equal to each other if .
In the string monoid example above, the only isomorphism is the empty string with itself, since only "" + "" = "".
However, isomorphisms may not be unique. That is to say, there may be more than one isomorphism between a given pair of objects. For example, in Set, let = {a, b, c} and = {1, 2, 3}. We can define an isomorphism by defining by and by You can check that = and = .
But we can define another isomorphism by defining and by Again you can check that = and = .
In fact there are a few more isomorphisms between and . How many are there?
Groups
Going back to our discussion of monoids, if every morphism of is an isomorphism, then is called a group.
Groups are super important, especially in physics. This is because groups generally have to do with symmetries, and symmetries are incredibly important.2 Examples of symmetries include concrete ones like rotational symmetry and more abstract ones like the Lorentz symmetry of special relativity.
For each symmetry, there is a group associated with it. The morphisms of the group (viewed as a one-object category) correspond to the transformations that preserve the symmetry.
For example, rotating a square about its center by leaves it unchanged. In fact, there are seven more symmetry transformations of the square. Can you think of what they are? This group of symmetry transformations is known as the dihedral group of the square, usually denoted .
I think it’s intuitive that groups are one-object categories, because each symmetry transformation only acts on a single object, and each transformation corresponds to a morphism from the (abstract) object in the category to itself. It’s basically an abstract picture of what’s happening.
The fact that each morphism is an isomorphism reflects the fact that the symmetry transformations are invertible: if I rotate by nintey degrees one way, I can undo it by rotating ninety degrees the other way.
Opposite categories
Our last example of categories is that of opposite categories — given a category , we get another one for free! We denote it by and call it the opposite category of . It’s opposite in the sense that the objects of are the same as the objects of , but the morphisms are reversed: if is a morphism from to in , then in is considered a morphism from to instead.
Composition remains the same, so that if and , then in the opposite category becomes a morphism from to .
For preorders, this is literally reversing all the arrows.
- The way of combining resources corresponds to a monoidal product, which we haven’t discussed before, but the details aren’t important here. More precisely, a resource theory corresponds to a symmetric monoidal category, which we haven’t defined either. Check out the paper A mathematical theory of resources for more details.↩
- As an example of the importance of symmetries, Noether’s theorem says that if a physical system has a (continuous) symmetry, like a rotational symmetry by arbitrary degree, then that system has a conserved quantity. Examples of this include conservation of energy and momentum.↩