Let C\mathcal C be a . If

f:X→Yandg:Y→Zf : X \to Y \quad\text{and}\quad g : Y \to Z

are in C\mathcal C, their composition is a morphism

g∘f:X→Z.g\circ f : X \to Z.

Composition is required to satisfy:

  • Associativity: for f:W→Xf:W\to X, g:X→Yg:X\to Y, h:Y→Zh:Y\to Z,
    h∘(g∘f)=(h∘g)∘f.h\circ(g\circ f) = (h\circ g)\circ f.
  • Unit laws: using the 1X1_X,
    f∘1X=f,1Y∘f=ff\circ 1_X = f,\qquad 1_Y\circ f = f
    whenever f:X→Yf:X\to Y.

This abstracts in set theory.

Examples
  1. In Set\mathbf{Set}, if f:X→Yf:X\to Y and g:Y→Zg:Y\to Z are , then g∘fg\circ f is the usual function composition.
  2. In Grp\mathbf{Grp}, composition is composition of group homomorphisms.
  3. In Top\mathbf{Top}, composition is composition of continuous maps.