# Category theory

Category theory is a general theory of mathematical structures and their relations that was introduced by Samuel Eilenberg and Saunders Mac Lane in the middle of the 20th century in their foundational work on algebraic topology. Nowadays, category theory is used in almost all areas of mathematics, and in some areas of computer science. In particular, many constructions of new mathematical objects from previous ones, that appear similarly in several contexts are conveniently expressed and unified in terms of categories. Examples include quotient spaces, direct products, completion, and duality. Schematic representation of a category with objects X, Y, Z and morphisms f, g, g ∘ f. (The category's three identity morphisms 1X, 1Y and 1Z, if explicitly represented, would appear as three arrows, from the letters X, Y, and Z to themselves, respectively.)

A category is formed by two sorts of objects, the objects of the category, and the morphisms, which relate two objects called the source and the target of the morphism. One often says that a morphism is an arrow that maps its source to its target. Morphisms can be composed if the target of the first morphism equals the source of the second one, and morphism composition has similar properties as function composition (associativity and existence of identity morphisms). Morphisms are often some sort of function, but this is not always the case. For example, a monoid may be viewed as a category with a single object, whose morphisms are the elements of the monoid.

The second fundamental concept of category is the concept of a functor, which plays the role of a morphism between two categories $C_{1}$ and $C_{2}:$ it maps objects of $C_{1}$ to objects of $C_{2}$ and morphisms of $C_{1}$ to morphisms of $C_{2}$ in such a way that sources are mapped to sources and targets are mapped to targets (or, in the case of a contravariant functor, sources are mapped to targets and vice-versa). A third fundamental concept is a natural transformation that may be viewed as a morphism of functors.