# Composition of relations

In mathematics, the composition of binary relations is a concept of forming a new relation SR from two given relations R and S, having as its most well-known special case the composition of functions.

## Definition

$S\circ R=\{(x,z)\in X\times Z\mid \exists y\in Y:(x,y)\in R\land (y,z)\in S\}.$ In particular fields, authors might denote by RS what is defined here to be SR. The convention chosen here is such that function composition (with the usual notation) is obtained as a special case, when R and S are functional relations. Some authors prefer to write $\circ _{l}$ and $\circ _{r}$ explicitly when necessary, depending whether the left or the right relation is the first one applied.

A further variation encountered in computer science is the Z notation: $\circ$ is used to denote the traditional (right) composition, but ⨾ ; (a fat open semicolon with Unicode code point U+2A3E) denotes left composition. This use of semicolon coincides with the notation for function composition used (mostly by computer scientists) in Category theory, as well as the notation for dynamic conjunction within linguistic dynamic semantics. The semicolon notation (with this semantic) was introduced by Ernst Schröder in 1895.

The binary relations $R\subseteq X\times Y$ are sometimes regarded as the morphisms $R\colon X\to Y$ in a category Rel which has the sets as objects. In Rel, composition of morphisms is exactly composition of relations as defined above. The category Set of sets is a subcategory of Rel that has the same objects but fewer morphisms. A generalization of this is found in the theory of allegories.

## Properties

Composition of relations is associative.

The inverse relation of SR is (SR)-1 = R−1S−1. This property makes the set of all binary relations on a set a semigroup with involution.

The compose of (partial) functions (i.e. functional relations) is again a (partial) function.

If R and S are injective, then SR is injective, which conversely implies only the injectivity of R.

If R and S are surjective, then SR is surjective, which conversely implies only the surjectivity of S.

The set of binary relations on a set X (i.e. relations from X to X) together with (left or right) relation composition forms a monoid with zero, where the identity map on X is the neutral element, and the empty set is the zero element.

## Join: another form of composition

{{#invoke:main|main}}

Other forms of composition of relations, which apply to general n-place relations instead of binary relations, are found in the join operation of relational algebra. The usual composition of two binary relations as defined here can be obtained by taking their join, leading to a ternary relation, followed by a projection that removes the middle component.