Definition:Relation

Let $$S \times T$$ be the cartesian product of two sets $$S$$ and $$T$$.

A relation in $$S$$ to $$T$$ is an arbitrary subset $$\mathcal{R} \subseteq S \times T$$.

What this means is that a binary relation "relates" (certain) elements of one set with (certain) elements of another. Not all elements need to be related.

When $$\left({s, t}\right) \in \mathcal{R}$$, we can write: $$s \mathcal{R} t$$.

Two relations $$\mathcal{R}_1 \subseteq S_1 \times T_1, \mathcal{R}_2 \subseteq S_2 \times T_2$$ are equal iff:


 * $$S_1 = S_2$$
 * $$T_1 = T_2$$
 * $$\left({s, t}\right) \in \mathcal{R}_1 \iff \left({s, t}\right) \in \mathcal{R}_2$$.

If $$S = T$$, then $$\mathcal{R} \subseteq S \times S$$, and $$\mathcal{R}$$ is referred to as a relation in $$S$$ or relation on $$S$$.

Domain and Range
The domain of a relation $$\mathcal{R} \subseteq S \times T$$ is the set $$S$$ and can be denoted $$\mathrm {Dom} \left({\mathcal{R}}\right)$$.

The range of a relation $$\mathcal{R} \subseteq S \times T$$ is the set $$T$$ and is denoted $$\mathrm {Rng} \left({\mathcal{R}}\right)$$ or $$\mathrm {Ran} \left({\mathcal{R}}\right)$$.

Some authors use the term "codomain" instead of "range".

Image
The definition of a relation given here as a subset of the Cartesian product of two sets gives a "static" sort of feel to the concept.

However, we can also consider a relation as being an operator, where you feed an element $$s \in S$$ (or a subset $$S_1 \subseteq S$$) in at one end, and you get a set of elements $$T_s \subseteq T$$ out of the other.

Thus we arrive at the following definition.

The image (or image set) of $$\mathcal{R}$$ of a relation $$\mathcal{R} \subseteq S \times T$$ is the set:

$$\mathrm {Im} \left ({\mathcal{R}}\right) = \mathcal{R} \left ({S}\right) = \left\{ {t \in T: \exists s \in S: \left({s, t}\right) \in \mathcal{R}}\right\}$$

Similarly, we can talk about the image of an element or subset of the domain:

For any relation $$\mathcal{R} \subseteq S \times T$$, the image of $$s \in S$$ by $$\mathcal{R}$$ is defined as:

$$\mathrm {Im} \left ({s}\right) = \mathcal{R} \left ({s}\right) = \left\{ {t \in T: \left({s, t}\right) \in \mathcal{R}}\right\}$$

That is, $$\mathcal{R} \left ({s}\right)$$ is the set of all elements of $$\mathrm {Dom} \left({\mathcal{R}}\right)$$ related to $$s$$ by $$\mathcal{R}$$.

For any relation $$\mathcal{R} \subseteq S \times T$$, the image of $$A \subseteq S$$ by $$\mathcal{R}$$ is:

$$\mathrm {Im} \left ({A}\right) = \mathcal{R} \left ({A}\right) = \left\{ {t \in T: \exists s \in A: \left({s, t}\right) \in \mathcal{R}}\right\}$$

If $$A = \mathrm {Dom} \left({\mathcal{R}}\right)$$, we have:

$$\mathrm {Im} \left ({\mathrm {Dom} \left({\mathcal{R}}\right)}\right) = \mathcal{R} \left ({\mathrm {Dom} \left({\mathcal{R}}\right)}\right) = \mathrm {Im} \left ({\mathcal{R}}\right)$$

It is also clear that $$\forall s \in S: \mathcal{R} \left ({s}\right) = \mathcal{R} \left ({\left\{{s}\right\}}\right)$$.

While the use of $$\mathrm {Im} \left ({A}\right)$$ etc. can be useful, it is arguably preferable in some situations to use $$\mathcal{R} \left ({A}\right)$$, as this makes it more apparent to exactly what relation the image refers. This is the terminology which we are planning to use from here on in.

Also note: The two notations $$s \mathcal{R} t$$ and $$\mathcal{R} \left ({s}\right) = t$$ do not mean the same thing.

The first means: "$$s$$ is related to $$t$$ by $$\mathcal{R}$$" (which does not exclude the possibility of there being other elements of $$T$$ to which $$s$$ relates).

The second means "The complete set of elements of $$T$$ to which $$s$$ relates consists of $$\left\{ {t}\right\}$$" (and is technically an abuse of notation - it really ought to read "$$\mathcal{R} \left ({s}\right) = \left\{ {t}\right\}$$").

Preimage
Every $$s \in \mathrm {Dom} \left({\mathcal{R}}\right)$$ such that $$t \in \mathcal{R} \left ({s}\right)$$ is called a preimage of $$t$$.

This can be expressed in terms of the inverse of $$\mathcal{R}$$:

$$\mathcal{R}^{-1} \left ({t}\right) = \left\{{s \in \mathrm {Dom} \left({\mathcal{R}}\right): s \mathcal{R} t}\right\}$$

The preimage is therefore also known as the inverse image.

Note that:
 * $$t \in \mathrm {Im} \left ({\mathcal{R}}\right)$$ may have more than one preimage.
 * It is possible for $$t \in \mathrm {Rng} \left({\mathcal{R}}\right)$$ to have no preimages at all.

The preimage of $$Y \subset \mathrm {Rng} \left({\mathcal{R}}\right)$$ is:

$$\mathcal{R}^{-1} \left ({Y}\right) = \left\{{s \in \mathrm {Dom} \left({\mathcal{R}}\right): \exists y \in Y: s \mathcal{R}y}\right\}$$

If no element of $$Y$$ has a preimage, then $$\mathcal{R}^{-1} \left ({Y}\right) = \varnothing$$.

The preimage of a relation $$\mathcal{R}$$ is:

$$\mathrm{Im}^{-1} \left ({\mathcal{R}}\right) = \mathcal{R}^{-1} \left ({\mathrm {Rng} \left({\mathcal{R}}\right)}\right) = \left\{{s \in \mathrm {Dom} \left({\mathcal{R}}\right): \exists t \in \mathrm {Rng} \left({\mathcal{R}}\right): \left({s, t}\right) \in \mathcal{R}}\right\}$$

Particular Relations
The Trivial Relation

The trivial relation is the relation $$\mathcal{R} = S \times T$$ in $$S$$ to $$T$$ such that every element of $$S$$ relates to every element in $$T$$:

$$\mathcal{R}: S \times T: \forall \left({s, t}\right) \in S \times T: s \mathcal{R} t$$

The Null Relation

The empty set $$\mathcal{R} = \varnothing$$ is a relation in $$S$$ to $$T$$ such that no element of $$S$$ relates to any element in $$T$$:

$$\mathcal{R}: S \times T: \forall \left({s, t}\right) \in S \times T: \lnot s \mathcal{R} t$$

This is also sometimes referred to as a "trivial relation" by some authors, but to save confusion it's better to use this term specifically to mean the one defined above.

The Diagonal Relation

The diagonal relation is a relation in $$S$$ such that:

$$\Delta_S = \left\{{\left({x, x}\right): x \in S}\right\} \subseteq S \times S$$

This is sometimes called the equality relation and denoted $$I_S$$.

It is also referred to it as the diagonal set or diagonal subset, but it can be useful to retain the emphasis that it is indeed a relation.

Categories of Relations
Many-to-One

A relation $$\mathcal{R}$$ is many-to-one if:

$$\mathcal{R}\subseteq S \times T: \forall x \in \mathrm{Dom} \left({\mathcal{R}}\right): \left({x, y_1}\right) \in \mathcal{R}\land \left({x, y_2}\right) \in \mathcal{R} \Longrightarrow y_1 = y_2$$

That is, every element of the domain of $$\mathcal{R}$$ relates to no more than one element of its range.

If in addition, every element of the domain relates to one element in the range, the many-to-one relation is known as a mapping (or function).

One-to-Many

A relation $$\mathcal{R}$$ is one-to-many if:

$$\mathcal{R} \subseteq S \times T: \forall y \in \mathrm{Im} \left({\mathcal{R}}\right): \left({x_1, y}\right) \in \mathcal{R} \land \left({x_2, y}\right) \in \mathcal{R} \Longrightarrow x_1 = x_2$$

That is, every element of the image of $$\mathcal{R}$$ is related to by exactly one element of its domain.

Note that the condition on $$t$$ concerns the elements in the image, not the range - so a one-to-many relation may leave some element(s) of the range unrelated.

It is clear that the inverse of a one-to-many relation is a many-to-one relation, and vice versa.

One-to-One

A relation $$\mathcal{R}$$ is one-to-one if it is both many-to-one and one-to-many.

That is, every element of the domain of $$\mathcal{R}$$ relates to no more than one element of its range, and every element of the image is related to by exactly one element of the domain.

Compare this with a one-to-one mapping, in which every element of the domain is mapped to an element of the range.

Many-to-Many

A relation $$\mathcal{R}$$ is many-to-many if it is neither many-to-one nor one-to-many.

That is, there is no restriction to the number of elements relating to or being related to by any individual element.