---
title: Categories, Objects, and Arrows
module: Foundations
moduleNumber: 1
lessonNumber: 1
order: 101
summary: >
  A category is objects, arrows between them, a rule for composing arrows, and
  an identity arrow on every object, subject to associativity and the unit laws.
  The axioms mention no elements: arrows need not be functions, and an object is
  known only through the arrows into and out of it. Isomorphism, commutative
  diagrams, duality, and the terminal object are the first consequences.
topics: [Foundations]
sources:
  - book: Leinster
    ref: "Ch. 1 — Categories, functors and natural transformations; §1.1 Categories"
  - book: Simmons
    ref: "Ch. 1 §1.1 Categories defined"
  - book: Barr & Wells
    ref: "Ch. 2 §2.1 Basic definitions; §2.7 Properties of objects and arrows"
draft: false
---

Most of mathematics is organized around what things _are_: a group is a set with
a multiplication, a topological space is a set with a collection of open subsets, a
vector space is a set with addition and scaling. Category theory reorganizes the
subject around what things _do_ — how they map to one another. An object in a
category is opaque; the only thing you may ask about it is which arrows go into it
and which come out. Almost every construction in these notes is phrased in that
language, which requires learning to work with objects you cannot look
inside.

The definition is short. A category is a directed graph — objects as nodes, arrows
as edges — carrying two extra pieces of data: a way to compose a matching pair of
arrows end to end, and a distinguished identity arrow on each object. Three axioms
constrain them.

## The axioms

> **Definition (Category).** A category $\mathcal{A}$ consists of:
> - a collection $\operatorname{ob}(\mathcal{A})$ of **objects**;
> - for each pair of objects $A, B$, a collection $\mathcal{A}(A, B)$ of **arrows**
>   (also called **maps** or **morphisms**) from $A$ to $B$;
> - for each triple $A, B, C$, a **composition** function
>   $\mathcal{A}(B, C) \times \mathcal{A}(A, B) \to \mathcal{A}(A, C)$, written
>   $(g, f) \mapsto g \circ f$;
> - for each object $A$, an **identity** arrow $1_A \in \mathcal{A}(A, A)$;
>
> subject to the axioms:
> - **associativity:** $(h \circ g) \circ f = h \circ (g \circ f)$ whenever the
>   composites are defined;
> - **unit laws:** $f \circ 1_A = f = 1_B \circ f$ for every $f \in \mathcal{A}(A, B)$.

We write $f : A \to B$ or $A \xrightarrow{f} B$ to mean $f \in \mathcal{A}(A, B)$,
and frequently abbreviate $g \circ f$ to $gf$.[^lein-def] The object $A$ is the
**domain** (or source) of $f$ and $B$ its **codomain** (or target); every arrow in
every category has one definite domain and one definite codomain. The collection
$\mathcal{A}(A, B)$ is the **hom-set** from $A$ to $B$, also written
$\operatorname{Hom}_{\mathcal{A}}(A, B)$ — the name recalls _homomorphism_, from
one of the earliest examples.

Two features of the definition matter before any example.

- **Composition is partial.** You may compose $g$ after $f$ only when the codomain
  of $f$ equals the domain of $g$. The types must line up: $A \xrightarrow{f} B
  \xrightarrow{g} C$ gives $gf : A \to C$, but $f$ and a map $D \to E$ with $D \neq B$
  do not compose at all.
- **"Collection," not "set."** For a small category the objects form a set, but for
  $\mathbf{Set}$ or $\mathbf{Grp}$ the objects are too numerous. We use the informal
  word _collection_ (properly, _class_) and defer the distinction to
  [the lesson on size](/category-theory/foundations/size-and-set-theory).

The single most important consequence of the axioms is that any string of
composable arrows has exactly one composite. Given

$$
A_0 \xrightarrow{f_1} A_1 \xrightarrow{f_2} \cdots \xrightarrow{f_n} A_n,
$$

associativity makes every bracketing of $f_n \cdots f_2 f_1$ equal, so it is safe to
drop the parentheses. The case $n = 0$ is not degenerate: the unique composite of
the empty string at $A$ is $1_A$. An identity is a zero-fold composite in the same
sense that $1$ is the product of no numbers.

$$
% caption: Two arrows compose to a third; the triangle commutes because the
% composite $gf$ is by definition the arrow along the top-then-right path.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\node (A) at (0,0) {$A$};
\node (B) at (3,0) {$B$};
\node (C) at (3,-2.4) {$C$};
\draw[->, acc, thick] (A) -- (B) node[midway, above] {$f$};
\draw[->, acc, thick] (B) -- (C) node[midway, right] {$g$};
\draw[->, black, thick] (A) -- (C) node[midway, below left] {$gf$};
\end{tikzpicture}
$$

## Arrows are not functions

In $\mathbf{Set}$ the arrows are functions, which makes it easy to read the axioms
as a restatement of facts about functions. That reading fails: the definition never
mentions elements. An object need not have any; an arrow need not send points to
points. The axioms describe a bookkeeping of composition, nothing more.

Three small categories make the point.

- **The empty category $\mathbf{0}$** has no objects and no arrows. It vacuously
  satisfies every axiom.
- **The terminal category $\mathbf{1}$** has one object and only its identity arrow.
- **The arrow category $\mathbf{2}$** has two objects and a single non-identity
  arrow between them, $A \xrightarrow{f} B$. Composition is forced; there is nothing
  to choose. It is not obvious what an "element" of $A$ would be, and there is no
  sense in which $f$ is a "function."

$$
% caption: Three finite categories drawn in full; identity arrows are present on
% every object but suppressed, as is standard.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
% empty
\node[align=center] at (-0.2,-1.4) {$\mathbf{0}$};
\draw[black, dashed] (-1.1,-0.9) rectangle (0.7,0.9);
\node[black, font=\footnotesize] at (-0.2,0) {no objects};
% terminal
\node[align=center] at (3,-1.4) {$\mathbf{1}$};
\node[circle, fill=acc, inner sep=1.6pt] (t) at (3,0) {};
% arrow category
\node[align=center] at (6.6,-1.4) {$\mathbf{2}$};
\node (a2) at (5.8,0) {$A$};
\node (b2) at (7.4,0) {$B$};
\draw[->, acc, thick] (a2) -- (b2) node[midway, above] {$f$};
\end{tikzpicture}
$$

More structure appears once the category has special shape. A category with one object, all of whose arrows
compose associatively with a two-sided unit, is exactly a **monoid**: the arrows are
its elements, composition is the operation, $1$ is the identity. If in addition
every arrow is invertible, it is a **group**. A category in which there is at most
one arrow between any two objects is exactly a **preordered set**: write $A \le B$
to mean an arrow $A \to B$ exists; reflexivity is $1_A$, transitivity is
composition.[^lein-examples] These are not analogies. A group _is_ a category of a
special shape, and a theorem about categories is automatically a theorem about
groups and about ordered sets at once. These special shapes are catalogued in
[the zoo of categories](/category-theory/foundations/examples-of-categories).

## Commutative diagrams

Because the only data is arrows and their composites, most statements in category
theory are equations between composite arrows, and these are drawn rather than
written. A **diagram** is a graph of objects and arrows in the category. It
**commutes** when any two directed paths sharing a start and an end compose to the
same arrow.

$$
% caption: The square commutes when $g f = j i h$: the two paths from $A$ to $E$
% agree. Reading a commuting diagram means equating parallel paths.
\begin{tikzpicture}[scale=1.1, >=stealth, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\node (A) at (0,1.6) {$A$};
\node (B) at (2.2,1.6) {$B$};
\node (C) at (0,0) {$C$};
\node (D) at (2.2,0) {$D$};
\node (E) at (4.4,0) {$E$};
\draw[->, acc, thick] (A) -- (B) node[midway, above] {$f$};
\draw[->, acc, thick] (A) -- (C) node[midway, left] {$h$};
\draw[->, acc, thick] (C) -- (D) node[midway, below] {$i$};
\draw[->, acc, thick] (D) -- (E) node[midway, below] {$j$};
\draw[->, acc, thick] (B) -- (E) node[midway, right] {$g$};
\end{tikzpicture}
$$

The triangle drawn earlier is the smallest commuting diagram: it says $gf$ is the
composite of $f$ and $g$, which is true by definition, so a triangle with a labelled
diagonal always commutes. A larger diagram carries real information. Saying "the
square commutes" is a compact way to assert an equation that would otherwise take a
line of symbols, and much of a categorical proof is a **diagram chase**: filling in
arrows so that the outer paths of a diagram are forced to agree.

## Associativity and the unit laws, geometrically

The two axioms have clean pictures. Associativity is the statement that in a chain
of three arrows, the two ways of inserting brackets land on the same composite.

$$
% caption: Associativity: bracketing $h(gf)$ or $(hg)f$ traverses the same chain
% and yields one arrow $A \to D$. The composites $gf$ and $hg$ are the diagonals.
\begin{tikzpicture}[scale=1.05, >=stealth, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\node (A) at (0,0) {$A$};
\node (B) at (2.1,1.15) {$B$};
\node (C) at (4.2,1.15) {$C$};
\node (D) at (6.3,0) {$D$};
\draw[->, acc, thick] (A) -- (B) node[midway, above left] {$f$};
\draw[->, acc, thick] (B) -- (C) node[midway, above] {$g$};
\draw[->, acc, thick] (C) -- (D) node[midway, above right] {$h$};
\draw[->, black, thick] (A) -- (C) node[midway, below] {$gf$};
\draw[->, black, thick] (B) -- (D) node[midway, below] {$hg$};
\draw[->, black, thick] (A) to[bend right=18] node[midway, below] {$hgf$} (D);
\end{tikzpicture}
$$

The unit laws say that composing with an identity changes nothing. Every object
carries a loop $1_A$, and pre- or post-composing an arrow with the appropriate
identity returns the same arrow.

$$
% caption: Identities and the unit laws; a self-loop $1_A$ absorbs into any arrow
% touching $A$, so $f \, 1_A = f = 1_B \, f$.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\node (A) at (0,0) {$A$};
\node (B) at (3,0) {$B$};
\draw[->, acc, thick] (A) -- (B) node[midway, above] {$f$};
\draw[->, black, thick] (A) to[out=150, in=210, looseness=6] node[left] {$1_A$} (A);
\draw[->, black, thick] (B) to[out=-30, in=30, looseness=6] node[right] {$1_B$} (B);
\end{tikzpicture}
$$

An identity arrow is uniquely determined by its object: if $u$ and $u'$ both act as
two-sided units on $A$, then $u = u \circ u' = u'$ by applying each unit law once.
The same one-line argument recurs throughout the subject: an object defined by a
universal property is unique.

## Isomorphism

With composition and identities in hand, the categorical notion of "sameness" is
available, and it is the arrows, not the elements, that define it.

> **Definition (Isomorphism).** An arrow $f : A \to B$ is an **isomorphism** if
> there is an arrow $g : B \to A$ with $g f = 1_A$ and $f g = 1_B$. The arrow $g$ is
> the **inverse** of $f$, written $f^{-1}$; it is unique when it exists. Objects $A$
> and $B$ are **isomorphic**, written $A \cong B$, when some isomorphism $A \to B$
> exists.

Uniqueness of the inverse is the identity argument again: if $g$ and $h$ both invert
$f$, then $g = g(fh) = (gf)h = h$.[^bw-iso] The isomorphisms in $\mathbf{Set}$ are
exactly the bijections, but this is a small theorem, not a triviality — it amounts
to the fact that a function has a two-sided inverse precisely when it is injective
and surjective. In $\mathbf{Grp}$ the isomorphisms are the group isomorphisms; in
$\mathbf{Top}$ they are the homeomorphisms, and here a warning surfaces: a
continuous bijection need not be an isomorphism. The map $t \mapsto e^{2\pi i t}$
from $[0, 1)$ onto the unit circle is a continuous bijection whose inverse is not
continuous, so it is not an arrow-with-inverse in $\mathbf{Top}$.[^lein-iso] Being a
bijection on underlying sets is a fact about elements; being an isomorphism is a
fact about arrows, and the two come apart.

| Category | Objects | Arrows | Isomorphisms |
| --- | --- | --- | --- |
| $\mathbf{Set}$ | sets | functions | bijections |
| $\mathbf{Grp}$ | groups | homomorphisms | group isomorphisms |
| $\mathbf{Top}$ | spaces | continuous maps | homeomorphisms |
| a monoid $M$ | one object | elements of $M$ | invertible elements |
| a poset $P$ | elements of $P$ | relations $A \le B$ | equalities $A = B$ |

In the poset row, $A \cong B$ forces $A \le B \le A$, hence $A = B$ by
antisymmetry; a poset has no nontrivial isomorphisms.

## The universal-property preview

Forbidding a look inside objects forces every construction to be described by its
maps, and descriptions by maps have a rigidity that internal descriptions lack. Consider the terminal category's single object, or, in
$\mathbf{Set}$, a one-element set. A one-element set $T$ has the property that from
_every_ set $A$ there is exactly one function $A \to T$. That property mentions no
elements of $T$; it is entirely about arrows into $T$. And it pins $T$ down: any two
sets with this property are uniquely isomorphic.

> **Definition (Terminal object, preview).** An object $T$ of a category is
> **terminal** if for every object $A$ there is exactly one arrow $A \to T$. Any two
> terminal objects are isomorphic by a unique isomorphism.

$$
% caption: A terminal object $T$ receives exactly one arrow from each object; the
% dashed unique arrows are the entire content of the definition.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\node (T) at (3,0) {$T$};
\node (A) at (0,1.3) {$A$};
\node (B) at (0,0) {$B$};
\node (C) at (0,-1.3) {$C$};
\draw[->, acc, thick, dashed] (A) -- (T) node[midway, above] {$!$};
\draw[->, acc, thick, dashed] (B) -- (T);
\draw[->, acc, thick, dashed] (C) -- (T) node[midway, below] {$!$};
\node[draw=acc, circle, inner sep=1pt] at (3,0) {};
\end{tikzpicture}
$$

> **Worked example (Terminal object in $\mathbf{Set}$).** A one-element set
> $T = \{\ast\}$ is terminal: for any set $A$ the only function $A \to T$ is the
> constant map $a \mapsto \ast$, since $\ast$ is the sole available value. Take a
> second one-element set $T' = \{\bullet\}$. The unique arrows $u : T \to T'$ and
> $u' : T' \to T$ satisfy $u' \circ u = 1_T$ and $u \circ u' = 1_{T'}$, because
> each composite is the only self-map of a one-element set. Hence $T \cong T'$ by a
> unique isomorphism. The empty set is not terminal: no function goes from a
> nonempty set into $\emptyset$.

This shape — _for every object there exists a unique arrow such that some diagram
commutes_ — is a **universal property**. Products, quotients, free groups, function
spaces, and limits are all defined this way, and each is thereby determined up to
unique isomorphism. The proof that a terminal object is unique up to unique
isomorphism is worked in full in
[the lesson on universal properties](/category-theory/universal-properties/universal-properties).
Once objects are anonymous, the only way to specify one is to say how everything
maps to it, and that specification, when it succeeds, admits no ambiguity.

## Building new categories from old

Two constructions appear immediately and recur constantly.

- **The opposite category.** Every category $\mathcal{A}$ has a **dual** or
  **opposite** $\mathcal{A}^{\mathrm{op}}$ with the same objects and
  $\mathcal{A}^{\mathrm{op}}(B, A) = \mathcal{A}(A, B)$: every arrow is reversed,
  identities are unchanged, and composition runs backwards. Applying the
  construction twice returns $\mathcal{A}$.
- **The product category.** Given $\mathcal{A}$ and $\mathcal{B}$, the **product**
  $\mathcal{A} \times \mathcal{B}$ has pairs $(A, B)$ as objects and pairs
  $(f, g) : (A, B) \to (A', B')$ as arrows, composed componentwise.

The opposite category underlies **duality**, the principle that every
definition, theorem, and proof has a mirror image obtained by reversing all arrows.
The dual of "terminal" is "initial" (exactly one arrow _out_ of the object); the
dual of a monomorphism is an epimorphism; the dual of a product is a coproduct. A
single proof, read forwards and backwards, yields two theorems. Duality and these
constructions return in
[the lesson on constructions on categories](/category-theory/universal-properties/constructions-on-categories),
and the special arrows dual to isomorphism in
[the lesson on special morphisms](/category-theory/foundations/special-morphisms).

> **Worked example (The opposite of a poset).** View the divisor poset
> $D = \{1, 2, 3, 6\}$ under divisibility as a thin category, with arrows
> $1 \to 2$, $1 \to 3$, $2 \to 6$, $3 \to 6$ and their composites. The opposite
> $D^{\mathrm{op}}$ reverses every arrow: the same four elements ordered by
> reverse divisibility, with arrows $6 \to 2$, $6 \to 3$, $2 \to 1$, $3 \to 1$.
> The element $6$, which receives an arrow from every object of $D$, is the
> element with an arrow _to_ every object of $D^{\mathrm{op}}$, so a terminal
> object of $D$ is an initial object of $D^{\mathrm{op}}$.

## Consequences of the axioms

A graph, a partial associative composition, and units are all the definition
requires. From that alone the notions of isomorphism, terminal object, duality,
and universal property are already available, and they apply verbatim to sets,
groups, spaces, monoids, and orders. Three constructions build on the axioms and
nothing else: [functors](/category-theory/foundations/functors) compare whole
categories, [natural transformations](/category-theory/foundations/natural-transformations)
compare functors, and the Yoneda lemma recovers an object from the arrows into it.

[^lein-def]: **Leinster**, _Basic Category Theory_, §1.1, Definition 1.1.1 and Remarks 1.1.2 — the data and axioms of a category, the $\operatorname{Hom}$ notation, domain and codomain, and the uniqueness of the composite of a string of arrows (including the empty string as an identity).
[^lein-examples]: **Leinster**, §1.1, Examples 1.1.8 — a one-object category as a monoid, a one-object category with all arrows invertible as a group, and a category with at most one arrow between objects as a preordered set.
[^bw-iso]: **Barr & Wells**, _Category Theory for Computing Science_, §2.7.2–2.7.3 — inverse arrows and the proof that an inverse, when it exists, is unique.
[^lein-iso]: **Leinster**, §1.1, Definition 1.1.4 and Examples 1.1.5–1.1.7 — isomorphisms defined by a two-sided inverse; the isomorphisms in $\mathbf{Set}$, $\mathbf{Grp}$, $\mathbf{Top}$, and the continuous bijection $[0,1) \to S^1$ that is not a homeomorphism.
