A C\mathcal C consists of:

  • a collection of Ob(C)\mathrm{Ob}(\mathcal C),
  • for each pair A,BOb(C)A,B\in\mathrm{Ob}(\mathcal C), a set of HomC(A,B)\mathrm{Hom}_{\mathcal C}(A,B),
  • a partially defined operation
    :HomC(B,C)×HomC(A,B)HomC(A,C),(g,f)gf,\circ:\mathrm{Hom}_{\mathcal C}(B,C)\times \mathrm{Hom}_{\mathcal C}(A,B)\to \mathrm{Hom}_{\mathcal C}(A,C), \quad (g,f)\mapsto g\circ f,
  • and for each object AA, an idAHomC(A,A)\mathrm{id}_A\in \mathrm{Hom}_{\mathcal C}(A,A).

The category axioms are the following two laws.

Axioms
  1. Associativity. For any composable morphisms
    AfBgChDA \xrightarrow{f} B \xrightarrow{g} C \xrightarrow{h} D
    one has
    (hg)f  =  h(gf)HomC(A,D).(h\circ g)\circ f \;=\; h\circ (g\circ f)\in \mathrm{Hom}_{\mathcal C}(A,D).
  1. Identity laws. For any morphism f:ABf:A\to B,
    idBf=fandfidA=f.\mathrm{id}_B\circ f = f \quad\text{and}\quad f\circ \mathrm{id}_A = f.

These axioms ensure that one can unambiguously write composites like hgfh\circ g\circ f without parentheses.

Examples
  1. Set\mathbf{Set}. Objects are and morphisms are . Composition is ordinary function composition and identities are .
  1. Grp\mathbf{Grp}. Objects are groups and morphisms are group homomorphisms; composition and identities are the usual ones.
  1. R-ModR\text{-}\mathbf{Mod}. Objects are left RR-modules and morphisms are RR-linear maps; composition and identities are the usual ones.