Relation (mathematics)

[[File:Relación binaria 01.svg|thumb|300px|Illustration of an example relation on a set $A = \{ a, b, c, d \}$. An arrow from $x$ to $y$ indicates that the relation holds between $x$ and $y$. The relation is represented by the set

{ (a,a),}} $(a,b),$ $(a,d),$ $(b,a),$ $(b,d),$ $(c,b),$ $(d,c),$ ${{math|(d,d) } }}$ of ordered pairs.]] In mathematics, a relation on a set may, or may not, hold between two given members of the set. As an example, "is less than" is a relation on the set of natural numbers; it holds, for instance, between the values $1$ and $3$ (denoted as $1 < 3$), and likewise between $3$ and $4$ (denoted as $3 < 4$), but not between the values $3$ and $1$ nor between $4$ and $4$, that is, $3 < 1$ and $4 < 4$ both evaluate to false. As another example, "is sister of is a relation on the set of all people, it holds e.g. between Marie Curie and Bronisława Dłuska, and likewise vice versa. Set members may not be in relation "to a certain degree" – either they are in relation or they are not.

Formally, a relation $R$ over a set $X$ can be seen as a set of ordered pairs $(x,y)$ of members of $X$. The relation $R$ holds between $x$ and $y$ if $(x,y)$ is a member of $R$. For example, the relation "is less than" on the natural numbers is an infinite set $R_{less}$ of pairs of natural numbers that contains both $(1,3)$ and $(3,4)$, but neither $(3,1)$ nor $(4,4)$. The relation "is a nontrivial divisor of on the set of one-digit natural numbers is sufficiently small to be shown here: $R_{dv} = \{ (2,4), (2,6), (2,8), (3,6), (3,9), (4,8) \}$; for example $2$ is a nontrivial divisor of $8$, but not vice versa, hence $(2,8) ∈ R_{dv}$, but $(8,2) ∉ R_{dv}$.

If $R$ is a relation that holds for $x$ and $y$ one often writes $xRy$. For most common relations in mathematics, special symbols are introduced, like "$<$" for "is less than", and "$|$" for "is a nontrivial divisor of", and, most popular "$=$" for "is equal to". For example, "$1 < 3$", "$1$ is less than $3$", and "$(1,3) ∈ R_{less}$" mean all the same; some authors also write "$(1,3) ∈ (<)$".

Various properties of relations are investigated. A relation $R$ is reflexive if $xRx$ holds for all $x$, and irreflexive if $xRx$ holds for no $x$. It is symmetric if $xRy$ always implies $yRx$, and asymmetric if $xRy$ implies that $yRx$ is impossible. It is transitive if $xRy$ and $yRz$ always implies $xRz$. For example, "is less than" is irreflexive, asymmetric, and transitive, but neither reflexive nor symmetric. "is sister of is transitive, but neither reflexive (e.g. Pierre Curie is not a sister of himself), nor symmetric, nor asymmetric; while being irreflexive or not may be a matter of definition (is every woman a sister of herself?), "is ancestor of is transitive, while "is parent of is not. Mathematical theorems are known about combinations of relation properties, such as "a transitive relation is irreflexive if, and only if, it is asymmetric".

Of particular importance are relations that satisfy certain combinations of properties. A partial order is a relation that is reflexive, antisymmetric, and transitive, an equivalence relation is a relation that is reflexive, symmetric, and transitive, a function is a relation that is right-unique and left-total (see below).

Since relations are sets, they can be manipulated using set operations, including union, intersection, and complementation, leading to the algebra of sets. Furthermore, the calculus of relations includes the operations of taking the converse and composing relations.

The above concept of relation has been generalized to admit relations between members of two different sets (heterogeneous relation, like "lies on" between the set of all points and that of all lines in geometry), relations between three or more sets (finitary relation, like "person $x$ lives in town $y$ at time $z$"), and relations between classes (like "is an element of on the class of all sets, see ).

Definition
Given a set $X$, a relation $R$ over $X$ is a set of ordered pairs of elements from $X$, formally: $R ⊆ \{ (x,y) | x, y ∈ X \}$.

The statement $(x,y) ∈ R$ reads "$x$ is $R$-related to $y$" and is written in infix notation as $xRy$. The order of the elements is important; if $x ≠ y$ then $yRx$ can be true or false independently of $xRy$. For example, $3$ divides $9$, but $9$ does not divide $3$.

Representation of relations
A relation $R_{el} =$ on a finite set $( (x,y) ∈ R × R &#124;$ may be represented as: A transitive relation $x^{2} + xy + y^{2} = 1 )$ on a finite set $R_{div}$ may be also represented as
 * Directed graph: Each member of $R$ corresponds to a vertex; a directed edge from $X$ to $X$ exists if and only if $x$.
 * Boolean matrix: The members of $y$ are arranged in some fixed sequence $(x,y) ∈ R$, ..., $X$; the matrix has dimensions $x_{1}$, with the element in line $x_{n}$, column $n × n$, being Yes check.svg, if $i$, and Dark Red x.svg, otherwise.
 * 2D-plot: As a generalization of a Boolean matrix, a relation on the –infinite– set $j$ of real numbers can be represented as a two-dimensional geometric figure: using Cartesian coordinates, draw a point at $(x_{i},x_{j}) ∈ R$ whenever $R$.
 * Hasse diagram: Each member of $(x,y)$ corresponds to a vertex; directed edges are drawn such that a directed path from $(x,y) ∈ R$ to $R$ exists if and only if $X$. Compared to a directed-graph representation, a Hasse diagram needs fewer edges, leading to a less tangled image. Since the relation "a directed path exists from $X$ to $x$" is transitive, only transitive relations can be represented in Hasse diagrams. Usually the diagram is laid out such that all edges point in an upward direction, and the arrows are omitted.

For example, on the set of all divisors of $y$, define the relation $(x,y) ∈ R$ by
 * $x$ if $y$ is a divisor of $12$ and $R_{div}$.

Formally, $x R_{div} y$ and $x$. The representation of $y$ as a Boolean matrix is shown in the middle table; the representation both as a Hasse diagram and as a directed graph is shown in the left picture.

The following are equivalent:
 * $x ≠ y$ is true.
 * A path from $X = \{ 1, 2, 3, 4, 6, 12 \}$ to $R_{div} = \{ (1,2), (1,3), (1,4), (1,6), (1,12), (2,4), (2,6), (2,12), (3,6), (3,12), (4,12), (6,12) \}$ exists in the Hasse diagram representing $R_{div}$.
 * An edge from $x R_{div} y$ to $(x,y) ∈ R_{div}$ exists in the directed graph representing $x$.
 * In the Boolean matrix representing $y$, the element in line $R_{div}$, column $x$ is "Yes check.svg".
 * In the Boolean matrix representing $y$, the element in line $R_{div}$, column $R_{div}$ is "Yes check.svg".

As another example, define the relation $x$ on $y$ by
 * $R_{el}$ if $R$.

The representation of $x R_{el} y$ as a 2D-plot obtains an ellipse, see right picture. Since $x^{2} + xy + y^{2} = 1$ is not finite, neither a directed graph, nor a finite Boolean matrix, not a Hasse diagram can be used to depict $R_{el}$.

Properties of relations
Some important properties that a relation $R$ over a set $X$ may have are:


 * : for all $R$, $R_{el}$. For example, $x ∈ X$ is a reflexive relation but $xRx$ is not.


 * (or ): for all $≥$, not $>$. For example, $x ∈ X$ is an irreflexive relation, but $xRx$ is not.

The previous 2 alternatives are not exhaustive; e.g., the red relation $>$ given in the diagram below is neither irreflexive, nor reflexive, since it contains the pair $≥$, but not $y = x^{2}$, respectively.


 * : for all $(0,0)$, if $(2,2)$ then $x, y ∈ X$. For example, "is a blood relative of" is a symmetric relation, because $x$ is a blood relative of $y$ if and only if $y$ is a blood relative of $x$.


 * : for all $xRy$, if $yRx$ and $x, y ∈ X$ then $xRy$. For example, $yRx$ is an antisymmetric relation; so is $x = y$, but vacuously (the condition in the definition is always false).


 * : for all $≥$, if $>$ then not $x, y ∈ X$. A relation is asymmetric if and only if it is both antisymmetric and irreflexive. For example, $xRy$ is an asymmetric relation, but $yRx$ is not.

Again, the previous 3 alternatives are far from being exhaustive; as an example over the natural numbers, the relation $>$ defined by $≥$ is neither symmetric (e.g. $xRy$, but not $x > 2$) nor antisymmetric (e.g. $5R1$, but also $1R5$), let alone asymmetric.


 * : for all $6R4$, if $4R6$ and $x, y, z ∈ X$ then $xRy$. A transitive relation is irreflexive if and only if it is asymmetric. For example, "is ancestor of" is a transitive relation, while "is parent of" is not.


 * : for all $yRz$, if $xRz$ then $x, y ∈ X$ or $x ≠ y$. For example, on the natural numbers, $xRy$ is connected, while "is a divisor of is not (e.g. neither $yRx$ nor $<$).


 * : for all $5R7$, $7R5$ or $x, y ∈ X$. For example, on the natural numbers, $xRy$ is strongly connected, but $yRx$ is not. A relation is strongly connected if, and only if, it is connected and reflexive.



Uniqueness properties:
 * Injective (also called left-unique ) : For all $≤$, if $<$ and $x, y, z ∈ X$ then $xRy$. For example, the green and blue relations in the diagram are injective, but the red one is not (as it relates both $zRy$ and $x = z$ to $−1$), nor is the black one (as it relates both $1$ and $1$ to $−1$).
 * Functional   (also called right-unique, right-definite or univalent) : For all $1$, if $0$ and $x, y, z ∈ X$ then $xRy$. Such a relation is called a . For example, the red and green relations in the diagram are functional, but the blue one is not (as it relates $xRz$ to both $y = z$ and $1$), nor is the black one (as it relates 0 to both −1 and 1).

Totality properties:


 * (also called or ): For all $−1$, there exists some $1$ such that $x ∈ X$. Such a relation is called a multivalued function. For example, the red and green relations in the diagram are total, but the blue one is not (as it does not relate $y ∈ X$ to any real number), nor is the black one (as it does not relate $xRy$ to any real number). As another example, $−1$ is a serial relation over the integers. But it is not a serial relation over the positive integers, because there is no $y$ in the positive integers such that $2$. However, $>$ is a serial relation over the positive integers, the rational numbers and the real numbers. Every reflexive relation is serial: for a given $x$, choose $1 > y$.


 * Surjective (also called right-total or onto): For all $<$, there exists an $y = x$ such that $y ∈ Y$. For example, the green and blue relations in the diagram are surjective, but the red one is not (as it does not relate any real number to $x ∈ X$), nor is the black one (as it does not relate any real number to $xRy$).

Combinations of properties

 * {| class="wikitable mw-collapsible" style="text-align:center;float:right;"

! ! ! ! ! ! ! Partial order ! Strict partial order ! Total order ! Strict total order ! Equivalence relation
 * + align="top" | Relations by property
 * Refl
 * Antisym
 * Yes
 * Subset
 * Subset
 * Irrefl
 * Asym
 * Yes
 * Strict subset
 * Strict subset
 * Refl
 * Antisym
 * Yes
 * Yes
 * Alphabetical order
 * Irrefl
 * Asym
 * Yes
 * Yes
 * Strict alphabetical order
 * Refl
 * Sym
 * Yes
 * Equality
 * }
 * }

Relations that satisfy certain combinations of the above properties are particularly useful, and thus have received names by their own.


 * : A relation that is reflexive, symmetric, and transitive. It is also a relation that is symmetric, transitive, and serial, since these properties imply reflexivity.

Orderings:


 * : A relation that is reflexive, antisymmetric, and transitive.


 * : A relation that is irreflexive, asymmetric, and transitive.


 * : A relation that is reflexive, antisymmetric, transitive and connected.


 * : A relation that is irreflexive, asymmetric, transitive and connected.

Uniqueness properties:


 * One-to-one: Injective and functional. For example, the green relation in the diagram is one-to-one, but the red, blue and black ones are not.
 * One-to-many: Injective and not functional. For example, the blue relation in the diagram is one-to-many, but the red, green and black ones are not.
 * Many-to-one: Functional and not injective. For example, the red relation in the diagram is many-to-one, but the green, blue and black ones are not.
 * Many-to-many: Not injective nor functional. For example, the black relation in the diagram is many-to-many, but the red, green and blue ones are not.

Uniqueness and totality properties:
 * A : A relation that is functional and total. For example, the red and green relations in the diagram are functions, but the blue and black ones are not.
 * An : A function that is injective. For example, the green relation in the diagram is an injection, but the red, blue and black ones are not.
 * A : A function that is surjective. For example, the green relation in the diagram is a surjection, but the red, blue and black ones are not.
 * A : A function that is injective and surjective. For example, the green relation in the diagram is a bijection, but the red, blue and black ones are not.

Operations on relations

 * : If $−1$ and $2$ are relations over $R$ then $S$ is the of $X$ and $R ∪ S = \{ (x, y) | xRy or xSy \}$. The identity element of this operation is the empty relation. For example, $R$ is the union of $S$ and $≤$, and $<$ is the union of $=$ and $≥$.


 * : If $>$ and $=$ are relations over $R$ then $S$ is the of $X$ and $R ∩ S = \{ (x, y) | xRy and xSy \}$. The identity element of this operation is the universal relation. For example, "is a lower card of the same suit as" is the intersection of "is a lower card than" and "belongs to the same suit as".


 * : If $R$ and $S$ are relations over $R$ then $S$ (also denoted by $X$) is the relative product of $S ∘ R = \{ (x, z) | there exists y ∈ X such that xRy and ySz \}$ and $R; S$. The identity element is the identity relation. The order of $R$ and $S$ in the notation $R$, used here agrees with the standard notational order for composition of functions. For example, the composition "is mother of" $S$ "is parent of" yields "is maternal grandparent of", while the composition "is parent of" $S ∘ R$ "is mother of" yields "is grandmother of". For the former case, if $∘$ is the parent of $∘$ and $x$ is the mother of $y$, then $y$ is the maternal grandparent of $z$.


 * : If $x$ is a relation over sets $z$ and $R$ then $X$ is the converse relation of $Y$ over $R^{T} = \{ (y, x) | xRy \}$ and $R$. For example, $Y$ is the converse of itself, as is $X$, and $=$ and $≠$ are each other's converse, as are $<$ and $>$.


 * : If $≤$ is a relation over $≥$ then $R$ (also denoted by $X$ or $\overline{R} = \{ (x, y) | x, y ∈ X and not xRy \}$) is the complementary relation of $R$. For example, $&not;R$ and $R$ are each other's complement, as are $=$ and $≠$, $⊆$ and $⊈$, and $⊇$ and $⊉$, and, for total orders, also $∈$ and $∉$, and $<$ and $≥$. The complement of the converse relation $>$ is the converse of the complement: $$\overline{R^\mathsf{T}} = \bar{R}^\mathsf{T}.$$


 * : If $≤$ is a relation over $R^{T}$ and $R$ is a subset of $X$ then $S$ is the of $X$ to $R_{|S} = \{ (x, y) | xRy and x, y ∈ S \}$. The expression $R$ is the  of $S$ to $R_{|S} = \{ (x, y) | xRy and x ∈ S \}$; the expression $R$ is called the  of $S$ to $R^{|S} = \{ (x, y) | xRy and y ∈ S \}$. If a relation is reflexive, irreflexive, symmetric, antisymmetric, asymmetric, transitive, total, trichotomous, a partial order, total order, strict weak order, total preorder (weak order), or an equivalence relation, then so too are its restrictions. However, the transitive closure of a restriction is a subset of the restriction of the transitive closure, i.e., in general not equal. For example, restricting the relation "$R$ is parent of $S$" to females yields the relation "$x$ is mother of the woman $y$"; its transitive closure does not relate a woman with her paternal grandmother. On the other hand, the transitive closure of "is parent of" is "is ancestor of"; its restriction to females does relate a woman with her paternal grandmother.

A relation $x$ over sets $y$ and $R$ is said to be a relation $X$ over $Y$ and $S$, written $X$, if $Y$ is a subset of $R ⊆ S$, that is, for all $R$ and $S$, if $x ∈ X$, then $y ∈ Y$. If $xRy$ is contained in $xSy$ and $R$ is contained in $S$, then $S$ and $R$ are called equal written $R$. If $S$ is contained in $R = S$ but $R$ is not contained in $S$, then $S$ is said to be than $R$, written $R$. For example, on the rational numbers, the relation $S$ is smaller than $R ⊊ S$, and equal to the composition $>$.

Theorems about relations

 * A relation is asymmetric if, and only if, it is antisymmetric and irreflexive.
 * A transitive relation is irreflexive if, and only if, it is asymmetric.
 * A relation is reflexive if, and only if, its complement is irreflexive.
 * A relation is strongly connected if, and only if, it is connected and reflexive.
 * A relation is equal to its converse if, and only if, it is symmetric.
 * A relation is connected if, and only if, its complement is anti-symmetric.
 * A relation is strongly connected if, and only if, its complement is asymmetric.
 * If relation $≥$ is contained in relation $> ∘ >$, then
 * If $R$ is reflexive, connected, strongly connected, left-total, or right-total, then so is $S$.
 * If $R$ is irreflexive, asymmetric, anti-symmetric, left-unique, or right-unique, then so is $S$.
 * A relation is reflexive, irreflexive, symmetric, asymmetric, anti-symmetric, connected, strongly connected, and transitive if its converse is, respectively.

Examples

 * Order relations, including strict orders:
 * Greater than
 * Greater than or equal to
 * Less than
 * Less than or equal to
 * Divides (evenly)
 * Subset of
 * Equivalence relations:
 * Equality
 * Parallel with (for affine spaces)
 * Is in bijection with
 * Isomorphic
 * Tolerance relation, a reflexive and symmetric relation:
 * Dependency relation, a finite tolerance relation
 * Independency relation, the complement of some dependency relation
 * Kinship relations

Generalizations
The above concept of relation has been generalized to admit relations between members of two different sets. Given sets $S$ and $R$, a heterogeneous relation $X$ over $Y$ and $R$ is a subset of $X$. When $Y$, the relation concept described above is obtained; it is often called homogeneous relation (or endorelation) to distinguish it from its generalization. The above properties and operations that are marked "" and "", respectively, generalize to heterogeneous relations. An example of a heterogeneous relation is "ocean $\{ (x,y) | x∈X, y∈Y \}$ borders continent $X = Y$". The best-known examples are functions with distinct domains and ranges, such as $x$.