In the mathematical field of category theory, an allegory is a category that has some of the structure of the category Rel of sets and binary relations between them. Allegories can be used as an abstraction of categories of relations, and in this sense the theory of allegories is a generalization of relation algebra to relations between different sorts. Allegories are also useful in defining and investigating certain constructions in category theory, such as exact completions.
In this article we adopt the convention that morphisms compose from right to left, so means "first do, then do ".
An allegory is a category in which
R\colonX\toY
R\circ\colonY\toX
R\circ\circ=R
(RS)\circ=S\circR\circ;
R,S\colonX\toY
R\capS\colonX\toY
R\capR=R,
R\capS=S\capR,
(R\capS)\capT=R\cap(S\capT);
(R\capS)\circ=R\circ\capS\circ;
R(S\capT)\subseteqRS\capRT
(R\capS)T\subseteqRT\capST;
RS\capT\subseteq(R\capTS\circ)S.
R\subseteqS
R=R\capS.
A first example of an allegory is the category of sets and relations. The objects of this allegory are sets, and a morphism
X\toY
R
R\circ
yR\circx
xRy
In a category, a relation between objects and is a span of morphisms
X\getsR\toY
X\getsS\toY
X\getsT\toY
X\getsR\toY\getsS\toZ
R\toY\getsS
X\getsR\gets\bullet\toS\toZ.
Composition of relations will be associative if the factorization system is appropriately stable. In this case, one can consider a category, with the same objects as, but where morphisms are relations between the objects. The identity relations are the diagonals
X\toX x X.
A regular category (a category with finite limits and images in which covers are stable under pullback) has a stable regular epi/mono factorization system. The category of relations for a regular category is always an allegory. Anti-involution is defined by turning the source/target of the relation around, and intersections are intersections of subobjects, computed by pullback.
A morphism in an allegory is called a map if it is entire
(1\subseteqR\circR)
(RR\circ\subseteq1).
C\cong\operatorname{Map}(\operatorname{Rel}(C)).
In an allegory, a morphism
R\colonX\toY
f\colonZ\toX
g\colonZ\toY
gf\circ=R
f\circf\capg\circg=1.
A\cong\operatorname{Rel}(\operatorname{Map}(A)).
A unit in an allegory is an object for which the identity is the largest morphism
U\toU,
Additional properties of allegories can be axiomatized. Distributive allegories have a union-like operation that is suitably well-behaved, and division allegories have a generalization of the division operation of relation algebra. Power allegories are distributive division allegories with additional powerset-like structure. The connection between allegories and regular categories can be developed into a connection between power allegories and toposes.