Digital Garden
Maths
Discrete Maths
Relations & Functions
Relations

Relations

In mathematics we use many symbols such as \leq, \geq, <<, >>, ==, \neq to represent the relationship between two objects. These symbols are called relations or relational operators because they convey the relationship between two objects. These realtions are defined on a specific set. For example, the relation \leq is defined on the set of real numbers R\mathbb{R}. To define a relation, we need to specify a set of order pairs that relates a set AA's elements to each other i.e. is a subset of A×AA \times A: These order pairs are special as (a,b)(a, b) is used to define the relationship between aa and bb, so we can say that "aa relates to bb".

R{(a,b)A×A}R \subseteq \{(a, b) \in A \times A\}

Because the relations is defined on the same set twice it is called a homogeneous relation, from the Greek word "homo" meaning "same" or "identical".

Lets now put this all together and define a relation on the set A={1,2,3,4}A = \{1, 2, 3, 4\}:

R={(1,1),(1,3),(3,1),(3,3),(2,2),(2,4),(4,2),(4,4)}A×AR = \{(1, 1), (1, 3), (3, 1), (3, 3), (2, 2), (2, 4), (4, 2), (4, 4)\} \subseteq A \times A

If we then take an element of the realtion such as (1,1)(1, 1) it means that 11 relates to 11 and (1,3)(1, 3) means that 11 relates to 33. The relation shown above can be thought of as "has the same parity" as 11 and 33 are both odd and 22 and 44 are both even. This relationship can also be denoted as followed:

(a,b)R    aRb(a, b) \in R \iff aRb

This means that if the order pair (a,b)(a, b) is in the relation RR, then aa relates to bb, so aRbaRb. If they are not in the relation, then aa does not relate to bb and we can denote this as aRba \cancel{R} b.

There are many ways to show relations such as a table or a directed graph, sometimes also called a digraph, arrow diagram or mapping diagram. The table below shows the relation RR defined above:

RR1234
11010
20101
31010
40101

The directed graph of the relation RR:

A directed graph of the relation above.

Empty Relation

The empty relation is a relation that has no elements in it. This means that no elements in the set relate to each other. The empty relation is denoted by \emptyset or {}\{\}. In other words if:

R=R = \emptyset

Then for all elements a,bAa, b \in A:

(a,b)R or aRb(a, b) \notin R \text{ or } a \cancel{R} b

Universal Relation

The universal relation is a homogeneous relation that contains all possible order pairs of the set AA. This means that every element in the set relates to every other element. The universal relation is denoted by A×AA \times A.

R=A×AR = A \times A

This means that for all elements a,bAa, b \in A:

(a,b)R or aRb(a, b) \in R \text{ or } aRb

Properties of Relations

Depending on the relationship between the elements of a set, a relation can have different properties.

Reflexive

A relation RR is reflexive if every element in the set AA relates to itself.

aA,(a,a)R\forall a \in A, (a, a) \in R

An example of a reflexive relation is the relation \leq on the set of real numbers R\mathbb{R} as every number is less than or equal to itself.

We can see in the table below that every element has a "1" in the diagonal and therefore the relation is reflexive. The same can be seen in the diagram where every element has a loop to itself.

An example of a reflexive relation.

Irreflexive

A relation RR is irreflexive if no element in the set AA relates to itself.

aA,(a,a)R\forall a \in A, (a, a) \notin R

An example of an irreflexive relation is the relation << on the set of real numbers R\mathbb{R} as no number is less than itself.

We can see in the table below that every element has a "0" in the diagonal and therefore the relation is irreflexive. The same can be seen in the diagram where no element has a loop to itself.

An example of an irreflexive relation.

Symmetric

A relation RR is symmetric if for every element (a,b)(a, b) in the relation, (b,a)(b, a) is also in the relation.

a,bA,(a,b)R    (b,a)R\forall a, b \in A, (a, b) \in R \implies (b, a) \in R

An example of a symmetric relation is the relation == on the set of real numbers R\mathbb{R} as if a=ba = b then b=ab = a.

We can see in the table below that if (a,b)(a, b) is in the relation then (b,a)(b, a) is also in the relation and therefore the relation is symmetric. This means that the table is symmetrical or mirrored along the diagonal. The same can be seen in the diagram where if there is an arrow from aa to bb then there is an arrow from bb to aa.

An example of a symmetric relation.

Antisymmetric

A relation RR is antisymmetric if for every element (a,b)(a, b) in the relation, (b,a)(b, a) is not in the relation unless a=ba = b.

a,bA,[(a,b)R(b,a)R]    a=b\forall a, b \in A, \big[(a, b) \in R \land (b, a) \in R\big] \implies a = b

An example of an antisymmetric relation is the relation \geq on the set of real numbers R\mathbb{R} as if aba \geq b and bab \geq a then a=ba = b.

We can see in the table below that if (a,b)(a, b) is in the relation and (b,a)(b, a) is also in the relation then the corresponding diagonal element is a "1" and therefore the relation is antisymmetric. The same can be seen in the diagram that there are no arrows from aa to bb and bb to aa only one way arrows and loops.

An example of an antisymmetric relation.

Asymmetric

A relation RR is asymmetric if for every element (a,b)(a, b) in the relation, (b,a)(b, a) is not in the relation, even if a=ba = b. So it can be thought of as a stricter version of antisymmetric or a combination of antisymmetric and irreflexive.

a,bA,(a,b)R    (b,a)R\forall a, b \in A, (a, b) \in R \implies (b, a) \notin R

An example of an asymmetric relation is the relation << on the set of real numbers R\mathbb{R} as if a<ba < b then bab \nless a.

We can see in the table below that if (a,b)(a, b) is in the relation then (b,a)(b, a) is not in the relation and all the diagonal elements are "0" and therefore the relation is asymmetric. The same can be seen in the diagram that there are no arrows from aa to bb and bb to aa and no loops.

An example of an asymmetric relation.

Transitive

A relation RR is transitive if for every element (a,b)(a, b) and (b,c)(b, c) in the relation, (a,c)(a, c) is also in the relation.

a,b,cA,[(a,b)R(b,c)R]    (a,c)R\forall a, b, c \in A, \big[(a, b) \in R \land (b, c) \in R\big] \implies (a, c) \in R

An example of a transitive relation is the relation \leq on the set of real numbers R\mathbb{R} as if aba \leq b and bcb \leq c then aca \leq c.

We can see in the table below that if (a,b)(a, b) and (b,c)(b, c) are in the relation then (a,c)(a, c) is also in the relation and therefore the relation is transitive. The same can be seen in the diagram that if there is an arrow from aa to bb and bb to cc then there is an arrow from aa to cc.

An example of a transitive relation.
Info

Importantly note if for example (a,b)R(a,b) \in R and (b,a)R(b,a) \in R then (a,a)(a,a) and (b,b)(b,b) must also be in the relation for it to be transitive.

Relations between Sets

Relations can also be defined between two different sets, this is called a heterogeneous relation, from the Greek word "hetero" meaning "different". This means that the relation RR is a subset of the Cartesian product of the two sets AA and BB, rather than between the cartesian product of the same set AA.

RA×BR \subseteq A \times B

The first set AA is called the domain and the second set BB is called the codomain. This means that the relation assigns elements of the domain to elements of the codomain. This can be shown in a directed graph where the elements of the domain are on the left and the elements of the codomain are on the right.

An example of a relation between two different sets.

Depending on the relationship between the elements of the two sets not all elements of the codomain are assigned to an element of the domain. The elements of the codomain that are assigned to an element of the domain are called the range of the relation. So in the above diagram the domain is {1,2,5,7}\{1,2,5,7\} and the codomain is {a,c,m,n}\{a,c,m,n\} and the range of the relation is {a,c,n}\{a,c,n\}.

Info

When defining a relation between two differenet sets the order matters. This is obvious as if we have a relation between two sets AA and BB then the order pair (a,b)(a, b) is not the same as (b,a)(b, a).

Identity Relations

The identity relation is a special type of relation that is only defined for homogenous relations. The identity relation is a relation where every element in the set relates to itself and no other elements. It is a reflexive, symmetric and transitive relation and is denoted by IAI_A where AA is the set that the relation is defined on.

IA={(a,a)A×A}I_A = \{(a, a) \in A \times A\}

Inverse Relations

The inverse of a relation RR is a relation that is the opposite of RR i.e. it "undo's" the relationship between the elements of the set. The inverse of a relation RR is denoted by R1R^{-1}.

R1={(b,a)A×A(a,b)R}R^{-1} = \{(b, a) \in A \times A | (a, b) \in R\}

This means that if (a,b)(a, b) is in the relation RR then (b,a)(b, a) is in the inverse relation R1R^{-1}. In other words the domain and codomain of the realtion RR is swapped in the inverse relation R1R^{-1} and become the codomain and domain respectively.

When visualising the inverse relation in a directed graph the arrows are simply reversed.

On the left is the original relation p and on the right is its inverse relation q.

Composition of Relations

Relations can also be combined or chained together to form a new relation. This is called the composition of relations. The composition of two relations RR and SS is denoted by RSR \circ S and is defined as:

RS={(a,c)A×CbB,(a,b)R(b,c)S}R \circ S = \{(a, c) \in A \times C | \exists b \in B, (a, b) \in R \land (b, c) \in S\}

This means that if there is an element (a,b)(a, b) in the relation RR and an element (b,c)(b, c) in the relation SS then there is an element (a,c)(a, c) in the composition of the two relations RSR \circ S.

When visualising the composition of relations in a directed graph the arrows are simply chained together.

An example of the composition of two relations.
Info

Importantly note that the composition of relations is not commutative i.e. RSSRR \circ S \neq S \circ R.

Also note that the relations are denoted from left to right i.e. RSR \circ S means that RR is applied first and then SS is applied. Unlike functions where fgf \circ g means that gg is applied first and then ff is applied.