In themathematics ofbinary relations, thecomposition of relations is the forming of a new binary relationR ;S from two given binary relationsR andS. In thecalculus of relations, the composition of relations is calledrelative multiplication,[1] and its result is called arelative product.[2]: 40 Function composition is the special case of composition of relations where all relations involved arefunctions.
The worduncle indicates a compound relation: for a person to be an uncle, he must be the brother of a parent. Inalgebraic logic it is said that the relation of Uncle () is the composition of relations "is a brother of" () and "is a parent of" ().
Beginning withAugustus De Morgan,[3] the traditional form of reasoning bysyllogism has been subsumed by relational logical expressions and their composition.[4]
If and are two binary relations, thentheir composition is the relation
In other words, is defined by the rule that says if and only if there is an element such that (that is, and).[5]: 13
Thesemicolon as aninfix notation for composition of relations dates back toErnst Schröder's textbook of 1895.[6]Gunther Schmidt has renewed the use of the semicolon, particularly inRelational Mathematics (2011).[2]: 40 [7] The use of the semicoloncoincides with the notation for function composition used (mostly by computer scientists) incategory theory,[8] as well as the notation for dynamic conjunction within linguisticdynamic semantics.[9]
A small circle has been used for the infix notation of composition of relations byJohn M. Howie in his books consideringsemigroups of relations.[10] However, the small circle is widely used to representcomposition of functions, whichreverses the text sequence from the operation sequence. The small circle was used in the introductory pages ofGraphs and Relations[5]: 18 until it was dropped in favor of juxtaposition (no infix notation).Juxtaposition 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[11] prefer to write and explicitly when necessary, depending whether the left or the right relation is the first one applied. A further variation encountered in computer science is theZ notation: is used to denote the traditional (right) composition, while left composition is denoted by a fat semicolon. The unicode symbols are ⨾ and ⨟.[12][13]
Binary relations are morphisms in thecategory. InRel the objects aresets, the morphisms are binary relations and the composition of morphisms is exactly composition of relations as defined above. The categorySet of sets and functions is asubcategory of where the maps are functions.
Given aregular category, its category of internal relations has the same objects as, but now the morphisms are given by subobjects in.[14] Formally, these arejointly monicspans between and. Categories of internal relations areallegories. In particular. Given afield (or more generally aprincipal ideal domain), the category of relations internal tomatrices over, has morphisms thelinear subspaces. The category of linear relations over thefinite field is isomorphic to the phase-free qubitZX-calculus modulo scalars.
Finite binary relations are represented bylogical 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 and An entry in thematrix 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 forcomputing the conclusions traditionally drawn by means of hypothetical syllogisms andsorites."[15]
Consider a heterogeneous relation that is, where and are distinct sets. Then using composition of relation with itsconverse there are homogeneous relations (on) and (on).
If for all there exists some such that (that is, is a(left-)total relation), then for all so that is areflexive relation or where I is the identity relation Similarly, if is asurjective relation then In this case The opposite inclusion occurs for adifunctional relation.
The composition is used to distinguish relations of Ferrer's type, which satisfy
Let { France, Germany, Italy, Switzerland } and { French, German, Italian } with the relation given by when is anational language ofSince both and is finite, can be represented by alogical matrix, assuming rows (top to bottom) and columns (left to right) are ordered alphabetically:
Theconverse relation corresponds to thetransposed matrix, and the relation composition corresponds to thematrix product when summation is implemented bylogical disjunction. It turns out that the matrix contains a 1 at every position, while the reversed matrix product computes as:This matrix is symmetric, and represents a homogeneous relation on
Correspondingly, is theuniversal relation on hence any two languages share a nation where they both are spoken (in fact: Switzerland).Vice versa, the question whether two given nations share a language can be answered using
For a given set the collection of allbinary relations on forms aBoolean lattice ordered byinclusion Recall thatcomplementation reverses inclusion: In thecalculus of relations[16] it is common to represent the complement of a set by an overbar:
If is a binary relation, let represent theconverse relation, also called thetranspose. Then the Schröder rules areVerbally, one equivalence can be obtained from another: select the first or second factor and transpose it; then complement the other two relations and permute them.[5]: 15–19
Though this transformation of an inclusion of a composition of relations was detailed byErnst Schröder, in factAugustus De Morgan first articulated the transformation as Theorem K in 1860.[4] He wrote[17]
With Schröder rules and complementation one can solve for an unknown relation in relation inclusions such asFor instance, by Schröder rule and complementation gives which is called theleft residual of by.
Just as composition of relations is a type of multiplication resulting in a product, so someoperations compare to division and produce quotients. Three quotients are exhibited here: left residual, right residual, and symmetric quotient. The left residual of two relations is defined presuming that they have the same domain (source), and the right residual presumes the same codomain (range, target). The symmetric quotient presumes two relations share a domain and a codomain.
Definitions:
Using Schröder's rules, is equivalent to Thus the left residual is the greatest relation satisfying Similarly, the inclusion is equivalent to and the right residual is the greatest relation satisfying[2]: 43–6
One can practice the logic of residuals withSudoku.[further explanation needed]
A fork operator has been introduced to fuse two relations and into The construction depends on projections and understood as relations, meaning that there are converse relations and Then thefork of and is given by[18]
Another form of composition of relations, which applies to general-place relations for is thejoin operation ofrelational 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. For example, in thequery languageSQL there is the operationjoin (SQL).