Canonical: https://knowlpedia.com/algebra-category-theory/composition-category/

# Composition of morphisms

The rule that composes morphisms in a category, generalizing function composition.

Let \(\mathcal C\) be a [category](https://knowlpedia.com/algebra-category-theory/category/). If
\[
f : X \to Y \quad\text{and}\quad g : Y \to Z
\]
are [morphisms](https://knowlpedia.com/algebra-category-theory/morphism/) in \(\mathcal C\), their **composition** is a morphism
\[
g\circ f : X \to Z.
\]

Composition is required to satisfy:

- **Associativity:** for \(f:W\to X\), \(g:X\to Y\), \(h:Y\to Z\),
  \[
  h\circ(g\circ f) = (h\circ g)\circ f.
  \]
- **Unit laws:** using the [identity morphisms](https://knowlpedia.com/algebra-category-theory/identity-morphism/) \(1_X\),
  \[
  f\circ 1_X = f,\qquad 1_Y\circ f = f
  \]
  whenever \(f:X\to Y\).

This abstracts [composition of functions](https://knowlpedia.com/shared-foundations/composition/) in set theory.

## Examples

1. In \(\mathbf{Set}\), if \(f:X\to Y\) and \(g:Y\to Z\) are [functions](https://knowlpedia.com/shared-foundations/function/), then \(g\circ f\) is the usual function composition.
2. In \(\mathbf{Grp}\), composition is composition of group homomorphisms.
3. In \(\mathbf{Top}\), composition is composition of continuous maps.
