# What is a Category? Definition and Examples

/As promised, here is the first in our triad of posts on basic category theory definitions: categories, functors, and natural transformations. If you're just now tuning in and are wondering *what is category theory, anyway? *be sure to* *follow the link to find out!

Category theory takes a bird's eye view of mathematics. From high in the sky, details become invisible, but we can spot patters that were impossible to detect from ground level.

- Tom Leinster

## What is a category?

**category**$\mathsf{C}$ consists of some data that satisfy certain properties:

### The Data

- a class of
**objects**, $x,y,z,\ldots$ - a set* of
**morphisms**between pairs of objects; $x\overset{f}{\longrightarrow} y$ means "$f$ is a morphism from $x$ to $y$," and the set of all such morphisms is denoted $\text{hom}_{\mathsf{C}}(x,y)$ - a
**composition rule:**whenever the codomain of one morphism matches the domain of another, there is a morphism that is their composition, i.e. given $x\overset{f}{\longrightarrow} y$ and $y\overset{g}{\longrightarrow} z$ there is a morphism $x\overset{g\:\circ f}{\longrightarrow} z$.

### The Properties

- Each object $x$ has an
**identity morphism**$x\overset{\text{id}_x}{\longrightarrow} x$ which satisfies $\text{id}_y\circ f=f=f\circ\text{id}_x$ for any $x\overset{f}{\longrightarrow} y$. - The composition is
**associative**: $(h\circ g)\circ f = h\circ(g\circ f)$ whenever $$x\overset{f}{\longrightarrow}y\overset{g}{\longrightarrow}z\overset{h}{\longrightarrow}w.$$

Here's a picture of a category with four objects--depicted as bold dots instead of letters--and some morphisms between them. The gray arrow at each object indicates its identity morphism.

Last time I listed a few examples of categories but never provided the proofs. To make sure you're comfortable with the definition, try proving a few of them. For example, to form the category of groups, we declare the objects to be groups and the morphisms to be group homomorphisms. But we should check: is the composition of two group homomorphisms another group homomorphism? (Or is it merely a function?) Is this composition associative? And is the identity function from a group to itself a group homomorphism? (Or, again, is it merely a function?)

I also mentioned briefly that every poset (a set with a binary relation that is reflexive, transitive, and antisymmetric) is a category. This turns out to be a useful example, so let's be explicit.

## Example #1: a poset

## Example #2: a group

## Example #3: new categories from old ones

*How can I construct new objects from given ones?***In particular one could ask,

*How can I make a new category from old ones?*There are several ways to go about this. Given two categories $\mathsf{C}$ and $\mathsf{D}$, you might try defining their

*product*$\mathsf{C}\times\mathsf{D}$. (This paves the way for monoidal categories.) What do you think the objects in $\mathsf{C}\times\mathsf{D}$ should be? The morphisms?

Additionally, every category $\mathsf{C}$ has an **oppposite category** $\mathsf{C}^{op}$. The only difference between a category and its opposite is the direction in which the arrows/morphisms point. That is, the objects in $\mathsf{C}^{op}$ are exactly the same as objects in $\mathsf{C}$, but there is a morphism $x\to y$ in $\mathsf{C}^{op}$ whenever there is morphism $y\to x$ in $\mathsf{C}$. (Check that $\mathsf{C}^{op}$ really does satisfy the definition of a category.) In other words,
$$
\text{hom}_{\mathsf{C}^{op}}(x,y)=\text{hom}_{\mathsf{C}}(y,x).
$$

*functors*, between categories.

You can also construct a new category $\mathsf{D}^\mathsf{C}$ from given categories $\mathsf{C}$ and $\mathsf{D}$ by declaring the objects to be functors $F:\mathsf{C}\to\mathsf{D}$. (The notation $\mathsf{D}^\mathsf{C}$ is quite suggestive.) Here a morphism between two functors $F:\mathsf{C}\to\mathsf{D}$ and $G:\mathsf{C}\to\mathsf{D}$ is a natural transformation, often denoted by a double arrow $F\Longrightarrow G$. In the special case when $\mathsf{D}=\mathsf{Set}$, the objects of $\mathsf{Set}^{\mathsf{C}^{op}}$ are given the name

**presheaves**. Again, I'm jumping the gun here, but I expect these examples to resurface later on the blog, so now is a good time to mention them.

We'll chat about functors next week and natural transformations the following week. I encourage you to revisit Example #3 once you're familiar with these notions.

Until next week!

*set*is called a

**locally small category.**In other words, a category is locally small if there aren't two many morphisms between the objects. Most of the categories you're familiar with--$\mathsf{Set},\mathsf{Top},\mathsf{Group}$, etc.--are locally small. In future posts, let's always assume our categories have this property, unless otherwise stated.

**For instance, the intersection of sets is another set, the direct product of groups is another group, the tensor product of vector spaces is another vector space, the product of compact topological spaces is another compact topological space, and so on.

***For size considerations, the categories in $\mathsf{Cat}$ are assumed to be small. A category $\mathsf{C}$ is called **small** if it doesn't contain too many objects and if there aren't too many morphisms between those objects, i.e. if both $\text{ob}(\mathsf{C})$ (all the objects in $\mathsf{C}$) and $\text{hom}_{\mathsf{C}}(x,y)$ are honest-to-goodness sets.