\( \newcommand{\id}{\operatorname{id}} \newcommand{\dom}{\operatorname{dom}} \newcommand{\cod}{\operatorname{cod}} \newcommand{\powerset}[1]{\mathbb{P}\left({#1}\right)} \newcommand{\set}[2]{\left\{{#1}:{#2}\right\}} \)

Functions and Relations

Last update to this page: Thursday, 6 October 2022.

Relations

Recall the definition of a relation.

Let \( A \) and \( B \) be sets. A relation \( A \xrightarrow{R} B \) from \( A \) to \( B \) is a subset \( R \subseteq A \times B \).

We will sometimes say \( R \) is a relation on a set \( S \) to mean a that \( R \) is a relation \( S \xrightarrow{R} S \).

Here is a small example of a relation.

We have a relation \( \{1, 2, 3\} \xrightarrow{R} \{4, 5\} \) given by \( R = \{(1, 4), (2, 4), (1, 5)\} \).

Relations are a mathematical model of relationships between the elements of various sets. The following is a very concrete example illustrating this idea.

Let \( P = \set{x}{x\text{ is a person}} \). There are many meaningful relations on the set \( P \).

  1. The relation \( P \xrightarrow{sis} P \) is defined by \( (x, y) \in sis \) when \( x \) and \( y \) are sisters.
  2. The relation \( P \xrightarrow{mot} P \) is defined by \( (x, y) \in mot \) when \( x \) is the mother of \( y \).
  3. The relation \( P \xrightarrow{stu} P \) is defined by \( (x, y) \in stu \) when \( x \) was in a class taught by \( y \).
  4. The relation \( P \xrightarrow{fri} P \) is defined by \( (x, y) \in fri \) when \( x \) any \( y \) are mutually friends.

It is cumbersome to write "\( (x, y) \in R \)". We often abbreviate using infix notation \( x\, R\, y \) instead.

We will often depict relations using diagrams. For a relation \( A \xrightarrow{R} B \), we will arrange the elements of \( A \) at the left, the elements of \( B \) at the right, and draw a line segment between two elements \( a \in A \) and \( b \in B \) when \( a\, R\, b \). Doing so, we can depict the relation from Example 1 above in the following way.

Sorry, your browser does not support SVG.

Relations have very little structure; in particular, there are no requirements on the subset \( R \subseteq A \times B \). If we add some simple conditions on our relations, they often become more meaningful.

The following notion is a mathematical abstraction of some fundamental properties of equality.

An equivalence relation on set \( S \) is a relation \( R \subseteq S \times S \) such that

Reflexive
For all \( x \in S \) we have \( x\, R\, x \).
Symmetric
For all \( x, y \in S \) we have \( x\, R\, y \) implies \( y\, R\, x \).
Transitive
For all \( x, y, z \in S \) we have both \( x\, R\, y \) and \( y\, R\, z \) implies \( x\, R\, z \).

Notice that reflexivity, symmetry, and transitivity only make sense when we have a relation \( R \subseteq S \times S \).

The following are some examples of equivalence relations:

  1. Equality is an equivalence relation on any given set.
  2. Let \( P \) be the set of all people. The relation \( P \xrightarrow{BDay} P \) defined by \( x\, Bday\, y \) when \( x \) and \( y \) have the same birthday is an equivalence relation on \( P \).

The following set gives a relation on the set \( S = \{0, 1, 2, 3, 4\} \).

\begin{align*} \{ (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, 1), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4) \} \end{align*}

Is this relation reflexive? Symmetric? Transitive?

For each subset \( X \subseteq \{\text{reflexive}, \text{symmetric}, \text{transitive}\} \) construct a relation which has precisely the properties in \( X \). Find minimal examples (in terms of cardinality of the relation \( R \) and the set \( S \)).

Let \( F \subseteq \powerset{S} \) for set \( S \), and suppose \( \emptyset \notin F \).

  1. Is the relation \( F \xrightarrow{I} F \) where \( (A, B) \in I \) when \( A \cap B \neq \emptyset \) always an equivalence relation?
  2. Is the relation \( F \xrightarrow{D} F \) where \( (A, B) \in D \) when \( A \cap B = \emptyset \) always an equivalence relation?
  3. Is the relation \( F \xrightarrow{R} F \) where \( (A, B) \in R \) when \( \#A = \#B \) always an equivalence relation?

We can visualize a relation \( R \subseteq S \times T \) is via a directed graph (we'll learn more about these later). Our directed graph has a point representing each element of \( S \cup T \) and an arrow pointing from \( s \) to \( t \) whenever \( s\, R\, t \).

Sorry, your browser does not support SVG.

The relation \( R = \{(1, 2), (2, 3), (3, 1), (1, 1)\} \) on \( [3] \) has the following directed graph:

Draw the directed graph for the relation from Example 1.

Another very important type of relation is called a partial ordering; this type of relation abstracts properties of the \( \leq \) relation on real numbers.

A partial order on a set \( S \) is a reflexive and transitive relation \( R \) on \( S \) such that

Antisymmetric
For all \( x, y \in S \) we have both \( x\, R\, y \) and \( y\, R\, x \) implies \( x = y \).

We have already seen some partial orders in the class. In particular, the following are partial orders.

  1. Usual ordering on \( \mathbb{R} \), \( \mathbb{Q} \), \( \mathbb{Z} \), \( \mathbb{N}_0 \).
  2. Divisibility Relation on \( \mathbb{N}_0 \).
  3. The subset relation on \( \powerset{S} \) is a partial ordering.

Functions

Functions are the language of higher mathematics!

Let \( A \) and \( B \) be sets. A function \( f \colon A \to B \) is a relation \( f \subseteq A \times B \) such that for all \( a \in A \) there is a unique \( b \in B \) such that \( (a, b) \in f \). The set \( A \) is called the source or domain of \( f \), written \( \dom(f) = A \). The set \( B \) is called the target or codomain of \( f \), written \( \cod(f) = B \).

Usually we will write \( f(a) = b \) rather than \( (a,b)\in f \) or \( a\, f\, b \).

For every set \( A \) there is an identity function \( \id_A \colon A \to A \) having \( \id_A(a) = a \) for all \( a \in A \).

Functions \( f \) and \( g \) with the same domain and codomain are equal when \( f(x) = g(x) \) for all \( x \in \dom(f) \).

As relations, functions are special; functions take an input and produce a unique output for that input.

Given two compatible functions, we can get another function from them!

Functions \( f \colon A \to B \) and \( g \colon B \to C \) have composition \( g \circ f \colon A \to C,~~x \mapsto g(f(x)) \).

For all \( f \colon A \to B \), \( g \colon B \to C \), and \( h \colon C \to D \) we have \( h \circ (g \circ f) = (h \circ g) \circ f \).

For all \( x\in\dom(f) \) we have the following equalities, completing the proof.

\begin{align*} (h \circ (g \circ f))(x) &= h((g \circ f)(x)) \\ &= h(g(f(x))) \\ &= (h \circ g)(f(x)) \\ &= ((h \circ g) \circ f)(x) . \end{align*}

Let \( f \colon A \to B \) be a function.

  1. The preimage of a set \( S \subseteq B \) under \( f \) is the set \( f^{-1}(S) = \set{x \in A}{f(x) \in S} \).
  2. The image of a set \( T \subseteq A \) under \( f \) is the set \( f(T) = \set{f(x) \in B}{x \in T} \).

The next several propositions are straightforward applications of the definitions presented here. The proofs are left to you as a method of checking your understanding.

Let \( f \colon A \to B \) be a function.

  1. If \( S \subseteq T \subseteq A \), then \( f(S) \subseteq f(T) \).
  2. If \( S \subseteq T \subseteq B \), then \( f^{-1}(S) \subseteq f^{-1}(T) \).

Let \( f \colon A \to B \) be a function.

  1. For all \( S \subseteq A \) we have \( S \subseteq f^{-1}(f(S)) \).
  2. For all \( T \subseteq B \) we have \( f(f^{-1}(T)) \subseteq T \).

Let \( f \colon A \to B \) be a function and \( S, T \subseteq A \). The following all hold:

  1. \( f(S \cup T) = f(S) \cup f(T) \)
  2. \( f(S \cap T) \subseteq f(S) \cap f(T) \)
  3. \( f(S \setminus T) \supseteq f(S) \setminus f(T) \)

Find examples of functions and subsets for which the above subset relations are strict.

The following proposition makes a nice exercise.

Let \( f \colon A \to B \) be a function and \( S, T \subseteq B \). The following all hold.

  1. \( f^{-1}(S \cup T) = f^{-1}(S) \cup f^{-1}(T) \)
  2. \( f^{-1}(S \cap T) = f^{-1}(S) \cap f^{-1}(T) \)
  3. \( f^{-1}(S \setminus T) = f^{-1}(S) \setminus f^{-1}(T) \)

Let \( f \colon A \to B \) be a function.

  1. Function \( f \) is injective or into when for all \( a, a' \in A \) we have \( f(a) = f(a') \) implies \( a = a' \).
  2. Function \( f \) is surjective or onto when for all \( b \in B \) there exists an \( a \in A \) such that \( f(a) = b \).
  3. Function \( f \) is bijective or a one-to-one correspondence when \( f \) is both injective and surjective.

The identity function \( \id_A \colon A \to A \) is bijective.

Write down examples of functions which are injective, surjective, and bijective. Can you write down a function which is injective but not surjective? How about one which is surjective but not injective?

If \( f \) is injective, can you strengthen Proposition 1? What if \( f \) is surjective?

In Calculus, you may have studied some inverse functions (the Inverse Function Theorem needs them!).

Let \( f \colon A \to B \) be a function.

  1. A left inverse of \( f \) is a function \( g \colon B \to A \) such that \( g \circ f = \id_A \).
  2. A right inverse of \( f \) is a function \( g \colon B \to A \) such that \( f \circ g = \id_B \).
  3. An inverse of \( f \) is a function \( g \colon B \to A \) such that \( g \) is both a left inverse of \( f \) and a right inverse of \( f \).

The function \( \id_A \) is its own inverse.

Find functions that have a left inverse but no right inverse and vice-versa.

The following proposition gives the relationship between invertibility and the properties above.

Let \( f \colon A \to B \) be a function with \( A \neq \emptyset \).

  1. Function \( f \) has a left inverse if and only if \( f \) is injective.
  2. Function \( f \) has a right inverse if and only if \( f \) is surjective.
  3. Function \( f \) has an inverse if and only if \( f \) is bijective.

Let \( f \colon A \to B \) be a function.

Part 1: Supposing \( f \) has a left inverse \( g \), then \( (g \circ f)(a) = a \) for all \( a \in A \). Thus \( g(f(a)) = a \) for all \( a \in A \). If \( f(a) = f(a') \) for some \( a,a' \in A \), then \( a = g(f(a)) = g(f(a')) = a' \); hence \( f \) is injective. Supposing \( f \) is injective, fix an element \( a_0\in A \) (this is why we need \( A\neq\emptyset \)) and define

\begin{equation*} g(x)= \begin{cases} a &\text{if } x = f(a) \text{ for some } a \in A \\ a_0 &\text{otherwise} \end{cases} \end{equation*}

for all \( x \in B \). If \( f(a) = f(a') \), then \( a = a' \) by injectivity; thus \( g \) is well-defined. Moreover \( (g \circ f)(x) = g(f(x)) = x \) for all \( x \in A \); hence \( g \circ f = \id_A \) and \( g \) is a left inverse of \( f \).

Part 2: Supposing \( f \) has a right inverse \( g \), then \( (f \circ g)(b) = b \) for all \( b \in B \). Thus for all \( b \in B \) one has \( g(b) \in A \) and \( f(g(b)) = b \); hence \( f \) is surjective. Supposing \( f \) is surjective, we fix for all \( b \in B \) an element \( a_b \in A \) with \( f(a_b) = b \).\footnote{This is possible by an abstract axiom of set theory (called the Axiom of Choice). Mathematicians argued for a long time over whether or not this is a good axiom because it has a lot of weird consequences. To learn more, email me…} Now define \( g \colon B \to A \) by \( g(b) = a_b \); note that this is well-defined by surjectivity of \( f \). Moreover \( (f \circ g)(x) = f(g(x)) = f(a_x) = x \) for all \( x \in B \); hence \( f \circ g = \id_B \) and \( g \) is a right inverse of \( f \).

Part 3: Supposing \( f \) has an inverse, \( f \) has both a left and right inverse; hence by Part 1 and Part 2, \( f \) is both injective and surjective, and thus bijective. If \( f \) is bijective, then \( f \) is injective and surjective by definition; thus by Part 1 and Part 2 \( f \) has a left inverse \( g \) and a right inverse \( g' \). Now \[ g = g \circ \id_B = g \circ (f \circ g') = (g \circ f) \circ g' = \id_A \circ g' = g' \] and hence \( g \) is both a left and right invere for \( f \).

Let \( f \colon A \to B \) be a function.

  1. If \( f \) is injective, then for all \( S \subseteq \dom(f) \) we have \( f^{-1}(f(S)) = S \).
  2. If \( f \) is surjective, then for all \( T \subseteq \cod(f) \) we have \( f(f^{-1}(S)) = S \).

Exercise (HINT: you can use the preceeding proposition).