# Relation (mathematics)

In mathematics, a **binary relation** is a general concept that defines some relation between the elements of two sets. It is a generalization of the more commonly understood idea of a mathematical function, but with fewer restrictions. A binary relation over sets X and Y is a set of ordered pairs (*x*, *y*) consisting of elements x in X and y in Y.^{[1]} It encodes the common concept of relation: an element x is *related* to an element y, if and only if the pair (*x*, *y*) belongs to the set of ordered pairs that defines the *binary relation*. A binary relation is the most studied special case *n* = 2 of an n-ary relation over sets *X*_{1}, ..., *X*_{n}, which is a subset of the Cartesian product *X*_{1} × ... × *X*_{n}.^{[1]}

Binary relations are used in many branches of mathematics to model a wide variety of concepts. These include, among others:

A function may be defined as a special kind of binary relation.^{[2]} Binary relations are also heavily used in computer science, such as in a relational database management system (RDBMS).

A binary relation over sets X and Y is an element of the power set of *X* × *Y*. Since the latter set is ordered by inclusion (⊆), each relation has a place in the lattice of subsets of *X* × *Y*. A binary relation is either a homogeneous relation or a heterogeneous relation depending on whether *X* = *Y* or not.

Since relations are sets, they can be manipulated using set operations, including union, intersection, and complementation, and satisfying the laws of an algebra of sets. Beyond that, operations like the converse of a relation and the composition of relations are available, satisfying the laws of a calculus of relations, for which there are textbooks by Ernst Schröder,^{[3]} Clarence Lewis,^{[4]} and Gunther Schmidt.^{[5]} A deeper analysis of relations involves decomposing them into subsets called *concepts*, and placing them in a complete lattice.

In some systems of axiomatic set theory, relations are extended to classes, which are generalizations of sets. This extension is needed for, among other things, modeling the concepts of "is an element of" or "is a subset of" in set theory, without running into logical inconsistencies such as Russell's paradox.

The terms *correspondence*,^{[6]} *dyadic relation* and *two-place relation* are synonyms for binary relation, though some authors use the term "binary relation" for any subset of a Cartesian product *X* × *Y* without reference to X and Y, and reserve the term "correspondence" for a binary relation with reference to X and Y.

A *binary relation* *R* over sets *X* and *Y* is a subset of *X* × *Y*.^{[1]}^{[7]} The set *X* is called the **domain**^{[1]} or *set of departure* of *R*, and the set *Y* the *codomain* or *set of destination* of *R*. In order to specify the choices of the sets *X* and *Y*, some authors define a *binary relation* or *correspondence* as an ordered triple (*X*, *Y*, *G*), where *G* is a subset of *X* × *Y* called the *graph* of the binary relation. The statement (*x*, *y*) ∈ *R* reads "*x* is *R*-related to *y*" and is written in infix notation as *xRy*.^{[3]}^{[4]}^{[5]}^{[note 1]} The *domain of definition* or *active domain*^{[1]} of *R* is the set of all *x* such that *xRy* for at least one *y*. The *codomain of definition*, *active codomain*,^{[1]} *image* or *range* of *R* is the set of all *y* such that *xRy* for at least one *x*. The *field* of *R* is the union of its domain of definition and its codomain of definition.^{[9]}^{[10]}^{[11]}

When *X* = *Y*, a binary relation is called a *homogeneous relation* (or *endorelation*). Otherwise it is a *heterogeneous relation*.^{[12]}^{[13]}

In a binary relation, 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.

Some important types of binary relations *R* over sets *X* and *Y* are listed below.

Totality properties (only definable if the domain *X* and codomain *Y* are specified):

Uniqueness and totality properties (only definable if the domain *X* and codomain *Y* are specified):

The identity element is the empty relation. For example, ≤ is the union of < and =, and ≥ is the union of > and =.

The identity element is the universal relation. For example, the relation "is divisible by 6" is the intersection of the relations "is divisible by 3" and "is divisible by 2".

The identity element is the identity relation. The order of *R* and *S* in the notation *S* ∘ *R*, used here agrees with the standard notational order for composition of functions. For example, the composition "is mother of" ∘ "is parent of" yields "is maternal grandparent of", while the composition "is parent of" ∘ "is mother of" yields "is grandmother of". For the former case, if *x* is the parent of *y* and *y* is the mother of *z*, then *x* is the maternal grandparent of *z*.

For example, = is the converse of itself, as is ≠, and < and > are each other's converse, as are ≤ and ≥. A binary relation is equal to its converse if and only if it is symmetric.

For example, = and ≠ are each other's complement, as are ⊆ and ⊈, ⊇ and ⊉, and ∈ and ∉, and, for total orders, also < and ≥, and > and ≤.

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 "*x* is parent of *y*" to females yields the relation "*x* is mother of the woman *y*"; its transitive closure doesn't 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.

Also, the various concepts of completeness (not to be confused with being "total") do not carry over to restrictions. For example, over the real numbers a property of the relation ≤ is that every non-empty subset *S* of **R** with an upper bound in **R** has a least upper bound (also called supremum) in **R**. However, for the rational numbers this supremum is not necessarily rational, so the same property does not hold on the restriction of the relation ≤ to the rational numbers.

A *homogeneous relation*(also called *endorelation*) over a set *X* is a binary relation over *X* and itself, i.e. it is a subset of the Cartesian product *X* × *X*.^{[17]}^{[18]} It is also simply called a (binary) relation over *X*. An example of a homogeneous relation is the relation of kinship, where the relation is over people.

A homogeneous relation *R* over a set *X* may be identified with a directed simple graph permitting loops, or if it is symmetric, with an undirected simple graph permitting loops, where *X* is the vertex set and *R* is the edge set (there is an edge from a vertex *x* to a vertex *y* if and only if *xRy*). It is called the *adjacency relation* of the graph.

Some important properties that a homogeneous relation R over a set X may have are:

The previous 2 alternatives are not exhaustive; e.g., the red binary relation *y* = *x*^{2} given in the section § Special types of binary relations is neither irreflexive, nor reflexive, since it contains the pair (0, 0), but not (2, 2), respectively.

Again, the previous 3 alternatives are far from being exhaustive; as an example over the natural numbers, the relation *xRy* defined by *x* > 2 is neither symmetric nor antisymmetric, let alone asymmetric.

If *R* is a homogeneous relation over a set *X* then each of the following is a homogeneous relation over *X*:

All operations defined in the section § Operations on binary relations also apply to homogeneous relations.