A category is the following data:
- Objects: A collection of objects.
- Morphisms: For any objects , a collection of morphisms. Every element in is termed a morphism from (i.e., with source or domain ) to (i.e., with target or co-domain ). The morphism sets for different pairs of objects are disjoint. Note that is also written as . The collection is sometimes also denoted or simply .
- Identity morphism: For every object , a distinguished morphism . This is called the identity morphism of .
- Composition rule: For , a map, called composition of morphisms, from to . This map is denoted by .
satisfying the following compatibility conditions:
- Associativity of composition: For , with , we have .
- Identity behaves as an identity: For , with , we have .
The collections of objects and morphisms need not be sets. If the collection of objects is a set, and the collection of morphisms between any two objects is a set, the category is termed a small category. If the collection of morphisms between any two objects is a set, the category is termed a locally small category.