Category theory is a mathematical theory that deals in an abstract way with mathematical structures and relationships between them. Categories appear in most branches of mathematics, and in some areas of theoretical computer science and mathematical physics, and have been a unifying notion. Categories were first introduced by Samuel Eilenberg and Saunders Mac Lane in 1945, in connection with algebraic topology.
Category theory is halfjokingly known as "generalized abstract nonsense". See list of category theory topics for a breakdown of relevant articles.
Background
The study of categories is an attempt to capture what is commonly found in various classes of related mathematical structures.
An example
Consider the following example. The class Grp of groups consists of all objects having a "group structure". More precisely, Grp consists of all sets G endowed with a binary operation satisfying a certain set of axioms. One can proceed to prove theorems about groups by making logical deductions from the set of axioms. For example, it is immediately proved from the axioms that the identity element of a group is unique.
However, instead of focusing merely on the individual objects (groups) possessing a given structure, as mathematical theories have traditionally done, category theory emphasizes the morphisms — the structurepreserving processes — between these objects. It turns out that by studying these morphisms, we are able to learn far more about the structure of the objects than by simply focusing on the structures alone.
In the example of groups, the morphisms are the group homomorphisms. A group homomorphism between two groups "preserves the group structure" in a very precise way. In other words, we think of a group homomorphism as a "process" taking one group to another, in a way that carries along information about the structure of the first group into the second group. The study of group homomorphisms then provides a powerful tool for studying general properties of groups and consequences of the group axioms.
A similar type of investigation occurs in many mathematical theories. A category is an axiomatic formulation of this idea of relating mathematical structures to the structurepreserving processes between them. A systematic study of categories then allows us to prove general results about any class of mathematical structures and their processes which satisfy the axioms of a category. Since categories are ubiquitous throughout mathematics, category theory has developed an extensive toolbox of results and techniques useful to mathematicians in a variety of fields.
Categorical concepts
Category theory takes these ideas to another level. The key observation is that a category is itself a type of mathematical structure, so we should look for processes which preserve this structure in some sense. Such a process is called a functor, and it associates to every object of one category an object of another category, and to every morphism in the first category a morphism in the second. By studying categories and functors, we are not just studying a class of mathematical structures and the morphisms between them, we are studying the relationships between various classes of mathematical structure.
The importance of this train of thought cannot be overstated — many mathematical theories attempt to study a particular type of structure not by studying the structure itself, or even by studying the processes preserving the structure, but rather by relating the structure to another simpler, better understood structure. For example, this is the central underlying theme of algebraic topology — very difficult topological questions can be translated into algebraic questions which are much easier to solve. Certain "natural constructions", such as the fundamental group of a topological space, can be expressed as functors in this way.
Continuing along the same train of thought, different such constructions are often "naturally related", and this leads to the concept of natural transformation, a way to "map" one functor to another. Throughout mathematics, one encounters "natural isomorphisms", things that are (essentially) the same in a "canonical way". Many important constructions in mathematics can be studied in this context.
An analogy
A realworld analogy may be helpful. Although there is some distortion in the analogy, it may give some intuitive feel for these rather abstract concepts.
We can think of a category as a road map. Just as a road map gives little information about individual towns and cities, a category theorist is in some sense "unconcerned" about the actual objects in the category. What is important, in each case, is how we get from one place (or object) to another. Thus, the roads on a map are analogous to the morphisms of a category. Just as some roads are more important than others, some morphisms are more interesting than others. The isomorphisms, in particular, are those morphisms that are "twoway", or "reversible".
Functors can then be thought of as a way of translating information from one road map to another. For example, a bus route map will focus on information about bus routes but miss information about particular streets, while a street map will focus on all the streets, but leave out information about particular bus routes. Yet it is possible to meaningfully "translate" information about the bus route to information about the streets. For instance, if we cannot walk from point A to point B without also crossing street C, then there is certainly no bus route from point A to point B which does not also cross street C. A question about bus routes has been reduced to a simpler question about streets.
Historical notes
Categories, functors and natural transformations were introduced by Samuel Eilenberg and Saunders Mac Lane in 1945. Initially, the notions were applied in topology, especially algebraic topology, as an important part of the transition from homology (an intuitive and geometric concept) to homology theory, an axiomatic approach. It has been claimed, for example by or on behalf of Ulam, that comparable ideas were current in the later 1930s in the Polish school. These ideas were in some ways a continuation of the contributions of Emmy Noether in formalizing abstract processes in the first half of the 20thcentury. Noether realised that in order to understand a type of mathematical structure, one really needs to understand the processes preserving this structure. Eilenberg and Mac Lane gave an axiomatic formalization of this relation between structures and the processes preserving them.
Eilenberg/Mac Lane have said that their goal was to understand natural transformations; in order to do that, functors had to be defined; and to define functors one needed categories.
The subsequent development of the theory was powered first by the computational needs of homological algebra; and then by the axiomatic needs of algebraic geometry, the field most resistant to the RussellWhitehead view of united foundations. General category theory—an updated universal algebra with many new features allowing for semantic flexibility and higherorder logic—came later; it is now applied throughout mathematics.
Special categories called topoi can even serve as an alternative to axiomatic set theory as the foundation of mathematics. These broadlybased foundational applications of category theory are contentious; but they have been worked out in quite some detail, as a commentary on or basis for constructive mathematics. One can say, in particular, that axiomatic set theory still hasn't been replaced by the categorytheoretic commentary on it, in the everyday usage of mathematicians. The idea of bringing category theory into earlier, undergraduate teaching (signified by the difference between the BirkhoffMac Lane and later Mac LaneBirkhoff abstract algebra texts) has hit noticeable opposition.
Categorical logic is now a welldefined field based on type theory for intuitionistic logics, with application to the theory of functional programming and domain theory, all in a setting of a cartesian closed category as nonsyntactic description of a lambda calculus. At the very least, the use of category theory language allows one to clarify what exactly these related areas have in common (in an abstract sense).
Categories
Definition
A category C consists of
 a class ob(C) of objects:
 a class hom(C) of morphisms. Each morphism f has a unique source object a and target object b. We write f: a → b, and we say "f is a morphism from a to b". We write hom(a, b) (or hom_{C}(a, b)) to denote the homclass of all morphisms from a to b. (Some authors write Mor(a, b).)
 for every three objects a, b and c, a binary operation hom(a, b) × hom(b, c) → hom(a, c) called composition of morphisms; the composition of f : a → b and g : b → c is written as g o f or gf (Some authors write fg.)
such that the following axioms hold:
 (associativity) if f : a → b, g : b → c and h : c → d then h o (g o f) = (h o g) o f, and
 (identity) for every object x, there exists a morphism 1_{x} : x → x called the identity morphism for x, such that for every morphism f : a → b, we have 1_{b} o f = f = f o 1_{a}.
From these axioms, one can prove that there is exactly one identity morphism for every object. Some authors use a slight variation of the definition in which each object is identified with the corresponding identity morphism.
The morphisms of a category are sometimes called arrows due to the influence of commutative diagrams.
For examples and properties of categories, see the category article.
Morphisms
Main article morphism
A morphism f : a → b is called
 a monomorphism (or monic) if fg_{1} = fg_{2} implies g_{1} = g_{2} for all morphisms g_{1}, g_{2} : x → a.
 an epimorphism (or epic) if g_{1}f = g_{2}f implies g_{1} = g_{2} for all morphisms g_{1}, g_{2} : b → x.
 an isomorphism if it is both monic and epic; equivalently, if there exists a morphism g : b → a with fg = 1_{b} and gf = 1_{a}.
 an endomorphism if a = b. The class of endomorphisms of a is denoted end(a).
 an automorphism if f is both an endomorphism and an isomorphism. The class of automorphisms of a is denoted aut(a).
Relations among morphisms (such as fg = h) can most conveniently be represented with commutative diagrams, where the objects are represented as points and the morphisms as arrows.
Functors
Main article functor
Functors are structurepreserving maps between categories. They can be thought of as morphisms in the category of all (small) categories.
A (covariant) functor F from the category C to the category D
 associates to each object x in C an object F(x) in D;
 associates to each morphism f : x → y a morphism F(f) : F(x) → F(y)
such that the following two properties hold:
 F(1_{x}) = 1_{F(x)} for every object x in C.
 F(g o f) = F(g) o F(f) for all morphisms f : x → y and g : y → z.
A contravariant functor F from C to D is a functor that "turns morphisms around" ("reverses all the arrows"). Specifically, F is contravariant if whenever f : x → y is a morphism in C, then F(f) : F(y) → F(x). The quickest way to define a contravariant functor is as a covariant functor from the opposite category C^{op} to D.
For examples and properties of functors see the functor article.
Natural transformations and natural isomorphisms
Main article natural transformation
A natural transformation is a relation between two functors. Functors often describe "natural constructions" and natural transformations then describe "natural homomorphisms" between two such constructions. Sometimes two quite different constructions yield "the same" result; this is expressed by a natural isomorphism between the two functors.
Definition
If F and G are (covariant) functors between the categories C and D, then a natural transformation from F to G associates to every object x in C a morphism η_{x} : F(x) → G(x) in D such that for every morphism f : x → y in C, we have η_{y} o F(f) = G(f) o η_{x}; this means that the following diagram is commutative:

The two functors F and G are called naturally isomorphic if there exists a natural transformation from F to G such that η_{x} is an isomorphism for every object x in C.
Examples
If K is a field, then for every vector space V over K we have a "natural" injective linear map V → V^{**} from the vector space into its double dual. These maps are "natural" in the following sense: the double dual operation is a functor, and the maps form a natural transformation from the identity functor to the double dual functor. If we restrict to finitedimensional vector spaces, we even obtain a natural isomorphism: "Every finitedimensional vector space is naturally isomorphic to its double dual."
Consider the category Ab of abelian groups and group homomorphisms. For all abelian groups x, y and z, we have a group isomorphism

hom(x, hom(y, z)) → hom(xy, z).
These isomorphisms are "natural" in the sense that they define a natural transformation between the two involved functors Ab^{op} × Ab^{op} × Ab → Ab.
Universal constructions, limits, and colimits
Main articles universal property, limit (category theory)
Using the language of category theory, many areas of mathematical study can be cast into appropriate categories, such as the categories of all sets, groups, topologies, and so on. These categories surely have some objects that are "special" in a certain way, such as the empty set or the product of two topologies. Yet, in the definition of a category, objects are considered to be atomic; i.e. we do not know, whether an object A is a set, a topology, or any other abstract concept. Hence, the challenge is to define special objects without referring to the internal structure of these objects. But how can we define the empty set without referring to elements, or the product topology without referring to open sets?
The solution is to characterize these objects in terms of their relations to other objects, as given by the morphisms of the respective categories. Thus the task is to find universal properties that uniquely determine the objects of interest. Indeed, it turns out that numerous important constructions can be described in a purely categorical way. The central concept which is needed for this purpose is called [categorical] limit, and can be dualized to yield the notion of a colimit.
Equivalent categories
Main articles equivalence of categories, isomorphism of categories
It is a natural question to ask, under which conditions two categories can be considered to be "essentially the same", in the sense that theorems about one category can readily be transformed into theorems about the other category. The major tool one employs to describe such a situation is called equivalence of categories. It is given by appropriate functors between two categories. Categorical equivalence has found numerous applications in mathematics.
Further concepts and results
The definitions of categories and functors provide only the very basics of categorical algebra. Additional important topics are listed below. Although there are strong interrelations between all of these topics, the given order can be considered as a guideline for further reading.
 The functor category D^{C} has as objects the functors from C to D and as morphisms the natural transformations of such functors. The Yoneda lemma is one of the most famous basic results of category theory; it describes representable functors in functor categories.

Duality: Every statement, theorem, or definition in category theory has a dual which is essentially obtained by "reversing all the arrows". If one statement is true in a category C then its dual will be true in the dual category C^{op}. This duality, which is transparent at the level of category theory, is often obscured in applications and can lead to surprising relationships.

Adjoint functors: A functor can be left (or right) adjoint to another functor that maps in the opposite direction. Such a pair of adjoint functors typically arises from a construction defined by a universal property; it can be seen as a more abstract and powerful view on universal properties.
Higherdimensional categories
Many of the above concepts, especially equivalence of categories, adjoint functor pairs, and functor categories, can be situated into the context of higherdimensional categories. Briefly, if we consider a morphism between two objects as a "process taking us from one object to another", then higherdimensional categories allow us to profitably generalise this by considering "higherdimensional processes".
For example, (strict) 2category is a category together with "morphisms between morphisms", i.e. processes which allow us to transform one morphism into another. We can then "compose" these "bimorphisms" both horizontally and vertically, and we require a 2dimensional "exchange law" to hold, relating the two composition laws. In this context, the standard example is Cat, the 2category of all (small) categories, and in this example, bimorphisms of morphisms are simply natural transformations of morphisms in the usual sense. Another basic example is to consider a 2category with a single object  these are essentially monoidal categories.
This process can be extended for all natural numbers n, and these are called ncategories . There is even a notion of ωcategory corresponding to the ordinal number ω. For a conversational introduction to these ideas, see John Baez: The Tale of ncategories.
References
 Adámek, Jiří, Herrlich, Horst, & Strecker, George E. (1990). Abstract and Concrete Categories. Originally publ. John Wiley & Sons. ISBN 0471609226. (now free online edition)
 Barr, Michael, & Wells, Charles (2002). Toposes, Triples and Theories. (revised and corrected free online version of Grundlehren der mathematischen Wissenschaften (278). SpringerVerlag,1983)
 Borceux, Francis (1994). Handbook of Categorical Algebra.. Vols. 5052 of Encyclopedia of Mathematics and its Applications. Cambridge: Cambridge University Press.
 Lawvere, William, & Schanuel, Steve. (1997). Conceptual Mathematics: A First Introduction to Categories. Cambridge: Cambridge University Press.
 Mac Lane, Saunders (1998). Categories for the Working Mathematician (2nd ed.). Graduate Texts in Mathematics 5. Springer. ISBN 0387984038.
See also
External links