In the mathematics of binary relations, the composition of relations is the forming of a new binary relation R;S from two given binary relations R and S. In the calculus of relations, the composition of relations is called relative multiplication, and its result is called a relative product. Function composition is the special case of composition of relations where all relations involved are functions. The word uncle indicates a compound relation: for a person to be an uncle, he must be the brother of a parent. In algebraic logic it is said that the relation "is uncle of" (xUz) is the composition of relations "is a brother of" (xBy) and "is a parent of" (yPz). U=B;P is equivalent to: xUz if and only if ∃y. xBy and yPz. Beginning with Augustus De Morgan, the traditional form of reasoning by syllogism has been subsumed by relational logical expressions and their composition.
Definition If R⊆X×Y and S⊆Y×Z are two binary relations, then their composition R;S is the relation R;S={(x,z)∈X×Z: there exists y∈Y such that (x,y)∈R and (y,z)∈S}. In other words, R;S⊆X×Z is defined by the rule that says (x,z)∈R;S if and only if there is an element y∈Y such that xRySz (that is, (x,y)∈R and (y,z)∈S).
Notational variations The semicolon as an infix notation for composition of relations dates back to Ernst Schröder's textbook of 1895. Gunther Schmidt has renewed the use of the semicolon, particularly in Relational Mathematics (2011). The use of the 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. A small circle (R∘S) has been used for the infix notation of composition of relations by John M. Howie in his books considering semigroups of relations. However, the small circle is widely used to represent composition of functions g(f(x))=(g∘f)(x), which reverses the text sequence from the operation sequence. The small circle was used in the introductory pages of Graphs and Relations until it was dropped in favor of juxtaposition (no infix notation). Juxtaposition (RS) is commonly used in algebra to signify multiplication, so too, it can signify relative multiplication. Further with the circle notation, subscripts may be used. Some authors prefer to write ∘l and ∘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: ∘ is used to denote the traditional (right) composition, while left composition is denoted by a fat semicolon. The unicode symbols are ⨾ and ⨟.
Mathematical generalizations Binary relations R⊆X×Y are morphisms R:X→Y in the category of relations 𝖱𝖾𝗅. Its objects are sets, its morphisms are binary relations and the composition of morphisms is exactly composition of relations as defined above. The category of sets 𝖲𝖾𝗍 of sets and functions is a subcategory of 𝖱𝖾𝗅 where the maps X→Y are functions f:X→Y. Given a regular category 𝕏, its category of internal relations 𝖱𝖾𝗅(𝕏) has the same objects as 𝕏, but now the morphisms X→Y are given by subobjects R⊆X×Y in 𝕏. Formally, these are jointly monic spans between X and Y. Categories of internal relations are allegories. In particular 𝖱𝖾𝗅(𝖲𝖾𝗍)≅𝖱𝖾𝗅. Given a field k (or more generally a principal ideal domain), the category of relations internal to matrices over k, 𝖱𝖾𝗅(𝖬𝖺𝗍(k)), has morphisms n→m the linear subspaces R⊆kn⊕km. The category of linear relations over the finite field 𝔽2 is isomorphic to the phase-free qubit ZX-calculus modulo scalars.
Properties Composition of relations is associative: R;(S;T)=(R;S);T. The converse relation of R;S is (R;S)𝖳=S𝖳;R𝖳. This property makes the set of all binary relations on a set a semigroup with involution. The composition of (partial) functions (that is, functional relations) is again a (partial) function. If R and S are injective, then R;S is injective, which conversely together with the requirement that S is also left total on range(R) implies the injectivity of only R. If R and S are surjective, then R;S is surjective, which conversely implies the surjectivity of only S. The set of binary relations on a set X (that is, 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.
Composition in terms of matrices Finite binary relations are represented by logical matrices. The entries of these matrices are either zero or one, depending on whether the relation represented is false or true for the row and column corresponding to compared objects. Working with such matrices involves the Boolean arithmetic with 1+1=1 and 1×1=1. An entry in the matrix product of two logical matrices will be 1, then, only if the row and column multiplied have a corresponding 1. Thus the logical matrix of a composition of relations can be found by computing the matrix product of the matrices representing the factors of the composition. "Matrices constitute a method for computing the conclusions traditionally drawn by means of hypothetical syllogisms and sorites."
Heterogeneous relations Consider a heterogeneous relation R⊆A×B, that is, where A and B may be distinct sets. Then using composition of relation R with its converse R𝖳, there are homogeneous relations R;R𝖳 (on A) and R𝖳;R (on B). If for all x∈A there exists some y∈B, such that xRy (that is, R is a (left-)total relation), then for all x, xR;R𝖳x so that R;R𝖳 is a reflexive relation or I⊆R;R𝖳 where I is the identity relation {(x,x):x∈A}. Similarly, if R is a surjective relation then R𝖳;R⊇I={(x,x):x∈B}. In this case R⊆R;R𝖳;R. The opposite inclusion occurs for a difunctional relation. The composition R¯𝖳;R is used to distinguish relations of Ferrer's type, which satisfy R;R¯𝖳;R=R.
… excerpt ends here. Continue reading the full article.

