Let C\mathcal C be a . If

f:XYandg:YZf : X \to Y \quad\text{and}\quad g : Y \to Z

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

gf:XZ.g\circ f : X \to Z.

Composition is required to satisfy:

  • Associativity: for f:WXf:W\to X, g:XYg:X\to Y, h:YZh:Y\to Z,
    h(gf)=(hg)f.h\circ(g\circ f) = (h\circ g)\circ f.
  • Unit laws: using the 1X1_X,
    f1X=f,1Yf=ff\circ 1_X = f,\qquad 1_Y\circ f = f
    whenever f:XYf:X\to Y.

This abstracts in set theory.

Examples
  1. In Set\mathbf{Set}, if f:XYf:X\to Y and g:YZg:Y\to Z are , then gfg\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.