# Abstract Algebra/Functions

## Definition

A function ${\displaystyle \operatorname {f} }$ is a triplet ${\displaystyle (A,B,G)}$ such that:

• ${\displaystyle A}$ is a set, called the domain of ${\displaystyle \operatorname {f} }$
• ${\displaystyle B}$ is a set, called the codomain of ${\displaystyle \operatorname {f} }$
• ${\displaystyle G}$ is a subset of ${\displaystyle A\times B}$, called the graph of ${\displaystyle \operatorname {f} }$

In addition the following two properties hold:

1. ${\displaystyle \forall x\in A,\exists y\in B\mid (x,y)\in G}$.
2. ${\displaystyle \forall x\in A,y\in B,y'\in B{\mbox{, then }}(x,y)\in G{\mbox{ and }}(x,y')\in G\Rightarrow y=y'}$.

${\displaystyle \forall x\in A}$ we write ${\displaystyle \operatorname {f} (x)}$ for the unique ${\displaystyle y\in B}$ such that ${\displaystyle (x,y)\in G}$.

We say that ${\displaystyle \operatorname {f} }$ is a function from ${\displaystyle A}$ to ${\displaystyle B}$, which we write:

${\displaystyle \operatorname {f} :A\rightarrow B}$

### Example

Let's consider the function from the reals to the reals which squares its argument. We could define it like this:

${\displaystyle \operatorname {f} :\mathbb {R} \rightarrow \mathbb {R} }$
${\displaystyle \operatorname {f} :x\mapsto x^{2}}$

### Remark

As you see in the definition of a function above, the domain and codomain are an integral part of the definition. In other words, even if the values of ${\displaystyle \operatorname {f} (x)}$ don't change, changing the domain or codomain changes the function.

Let's look at the following four functions.

The function:

${\displaystyle \operatorname {f_{1}} :\mathbb {R} \rightarrow \mathbb {R} }$
${\displaystyle \operatorname {f_{1}} :x\mapsto x^{2}}$

is neither injective nor surjective (these terms will be defined later).

The function:

${\displaystyle \operatorname {f_{2}} :\mathbb {R} \rightarrow \mathbb {R} _{\geq 0}}$
${\displaystyle \operatorname {f_{2}} :x\mapsto x^{2}}$

is not injective but surjective.

The function:

${\displaystyle \operatorname {f_{3}} :\mathbb {R} _{\geq 0}\rightarrow \mathbb {R} }$
${\displaystyle \operatorname {f_{3}} :x\mapsto x^{2}}$

is injective but not surjective.

The function:

${\displaystyle \operatorname {f_{4}} :\mathbb {R} _{\geq 0}\rightarrow \mathbb {R} _{\geq 0}}$
${\displaystyle \operatorname {f_{4}} :x\mapsto x^{2}}$

is injective and surjective

As you see, all four functions have the same mapping but all four are different. That's why just giving the mapping is insufficient; a function is only defined if its domain and codomain are known.

## Image and preimage

For a set ${\displaystyle E}$, we write ${\displaystyle {\mathcal {P}}(E)}$ for the set of subsets of ${\displaystyle E}$.

Let ${\displaystyle \operatorname {f} :A\rightarrow B}$. We will now define two related functions.

The image function:

${\displaystyle \operatorname {f} :{\mathcal {P}}(A)\rightarrow {\mathcal {P}}(B),S\subseteq A\mapsto \{\operatorname {f} (x)\mid x\in S\}}$

The preimage function:

${\displaystyle \operatorname {f^{-1}} :{\mathcal {P}}(B)\rightarrow {\mathcal {P}}(A),T\subseteq B\mapsto \{x\in A\mid \operatorname {f} (x)\in T\}}$

Note that the image and preimage are written respectively like ${\displaystyle \operatorname {f} }$ and its inverse (if it exists). There is however no ambiguity because the domains are different. Note also that the image and preimage are not necessarily inverse of one another. (See the section on bijective functions below).

We define ${\displaystyle \operatorname {Im} _{\operatorname {f} }:=\operatorname {f} (A)}$, which we call the image of ${\displaystyle \operatorname {f} }$.

For any ${\displaystyle y\in B}$, we call ${\displaystyle \operatorname {f^{-1}} (\{y\})}$ the support of ${\displaystyle y}$.

Proposition: Let ${\displaystyle \operatorname {f} :A\rightarrow B}$. Then

1. ${\displaystyle \forall S\subseteq A,S\subseteq f^{-1}(f(S))}$
2. ${\displaystyle \forall T\subseteq B,f(f^{-1}(T))\subseteq T}$

### Example

Let's take again the function:

${\displaystyle \operatorname {f} :\mathbb {R} \rightarrow \mathbb {R} }$
${\displaystyle \operatorname {f} :x\mapsto x^{2}}$

Let's consider the following examples:

${\displaystyle \operatorname {f^{-1}} (\{4\})=\{-2,2\}}$
${\displaystyle \operatorname {f^{-1}} (\mathbb {R} _{<0})=\emptyset }$
${\displaystyle \operatorname {f} (\mathbb {R} _{\geq 0})=\mathbb {R} _{\geq 0}}$

## Further definitions

Let ${\displaystyle \operatorname {f} :B\rightarrow C}$ and ${\displaystyle \operatorname {g} :A\rightarrow B}$. We define ${\displaystyle \operatorname {f} \circ \operatorname {g} :A\rightarrow C}$ by ${\displaystyle (\operatorname {f} \circ \operatorname {g} )(x):=\operatorname {f} (\operatorname {g} (x))}$, which we call the composition of ${\displaystyle \operatorname {f} }$ and ${\displaystyle \operatorname {g} }$.

Let ${\displaystyle A}$ be a set. We define the identity function on A as

${\displaystyle \operatorname {id_{A}} :A\rightarrow A,x\mapsto x}$

## Properties

Definition: A function ${\displaystyle \operatorname {f} :A\rightarrow B}$ is injective if

${\displaystyle \forall x\in A,x'\in A,\operatorname {f} (x)=\operatorname {f} (x')\Rightarrow x=x'}$

Lemma: Consider a function ${\displaystyle \operatorname {f} :A\rightarrow B}$ and suppose ${\displaystyle A\neq \emptyset }$. Then ${\displaystyle \operatorname {f} }$ is injective if and only if there exists a function ${\displaystyle \operatorname {g} :B\rightarrow A}$ with ${\displaystyle \operatorname {g} \circ \operatorname {f} =\operatorname {id_{A}} }$.
Proof:
${\displaystyle '\Rightarrow '}$:
Suppose ${\displaystyle \operatorname {f} }$ is injective. As ${\displaystyle A\neq \emptyset }$ let's define ${\displaystyle m}$ as an arbitrary element of ${\displaystyle A}$. We can then define a suitable function ${\displaystyle \operatorname {g} :B\rightarrow A}$ as follows:

${\displaystyle \operatorname {g} (y):=\left\{{\begin{array}{ll}{\mbox{the unique }}x\in A\mid \operatorname {f} (x)=y&{\text{, if }}y\in \operatorname {Im} _{\operatorname {f} }\\m&{\text{, else}}\\\end{array}}\right.}$

It is now easy to verify that ${\displaystyle \operatorname {g} \circ \operatorname {f} =\operatorname {id_{A}} }$.
${\displaystyle '\Leftarrow '}$:
Suppose there is a function ${\displaystyle \operatorname {g} :B\rightarrow A}$ with ${\displaystyle \operatorname {g} \circ \operatorname {f} =\operatorname {id_{A}} }$. Then ${\displaystyle \forall x,x'\in A,\operatorname {f} (x)=\operatorname {f} (x')\Rightarrow \operatorname {g} (\operatorname {f} (x))=\operatorname {g} (\operatorname {f} (x'))\Rightarrow x=x'}$. ${\displaystyle \operatorname {f} }$ is thus injective.
Q.E.D.

Definition: A function ${\displaystyle \operatorname {f} :A\rightarrow B}$ is surjective if

${\displaystyle \forall y\in B,\exists x\in A\mid \operatorname {f} (x)=y}$

Lemma: Consider a function ${\displaystyle \operatorname {f} :A\rightarrow B}$. Then ${\displaystyle \operatorname {f} }$ is surjective if and only if there exists a function ${\displaystyle \operatorname {g} :B\rightarrow A}$ with ${\displaystyle \operatorname {f} \circ \operatorname {g} =\operatorname {id_{B}} }$.
Proof:
${\displaystyle '\Rightarrow '}$:
Suppose ${\displaystyle \operatorname {f} }$ is surjective. We can define a suitable function ${\displaystyle \operatorname {g} :B\rightarrow A}$ as follows:

${\displaystyle \operatorname {g} (y):={\mbox{an }}x\in A\mid \operatorname {f} (x)=y}$

It is now easy to verify that ${\displaystyle \operatorname {f} \circ \operatorname {g} =\operatorname {id_{B}} }$.
${\displaystyle '\Leftarrow '}$:
Suppose there is a function ${\displaystyle \operatorname {g} :B\rightarrow A}$ with ${\displaystyle \operatorname {f} \circ \operatorname {g} =\operatorname {id_{B}} }$. Then ${\displaystyle \forall y\in B{\mbox{, let }}x:=\operatorname {g} (y)}$. Then ${\displaystyle \operatorname {f} (x)=\operatorname {f} (\operatorname {g} (y))=y}$. ${\displaystyle \operatorname {f} }$ is thus surjective.
Q.E.D.

Definition: A function ${\displaystyle \operatorname {f} :A\rightarrow B}$ is bijective if it is both injective and surjective.

Lemma: A function ${\displaystyle \operatorname {f} :A\rightarrow B}$ is bijective if and only if there exists a function ${\displaystyle \operatorname {g} :B\rightarrow A}$ with ${\displaystyle \operatorname {g} \circ \operatorname {f} =\operatorname {id_{A}} }$ and ${\displaystyle \operatorname {f} \circ \operatorname {g} =\operatorname {id_{B}} }$. Furthermore it can be shown that such a ${\displaystyle \operatorname {g} }$ is unique. We write it ${\displaystyle \operatorname {f^{-1}} :B\rightarrow A}$ and call it the inverse of ${\displaystyle \operatorname {f} }$.
Proof:
Left as an exercise.

Proposition: Consider a function ${\displaystyle \operatorname {f} :A\rightarrow B}$. Then

1. ${\displaystyle f}$ is injective iff ${\displaystyle \forall S\subseteq A,f^{-1}(f(S))=S}$
2. ${\displaystyle f}$ is surjective iff ${\displaystyle \forall T\subseteq B,f(f^{-1}(T))=T}$
3. ${\displaystyle f}$ is bijective iff the image and preimage of ${\displaystyle f}$ are inverse of each other

Example: If ${\displaystyle A}$ and ${\displaystyle B}$ are sets such that ${\displaystyle B\subseteq A}$, there exists an obviously injective function ${\displaystyle i\,:\,B\rightarrow A}$, called the inclusion ${\displaystyle B\subseteq A}$, such that ${\displaystyle i(b)=b}$ for all ${\displaystyle b\in B}$.

Example: If ${\displaystyle \sim }$ is an equivalence relation on a set ${\displaystyle X}$, there is an obviously surjective function ${\displaystyle \pi \,:\,X\rightarrow X/\sim }$, called the canonical projection onto ${\displaystyle X/\sim }$, such that ${\displaystyle \pi (x)=[x]}$ for all ${\displaystyle x\in X}$.

Theorem: Define the equivalence relation ${\displaystyle \sim }$ on ${\displaystyle A}$ such that ${\displaystyle a\sim b}$ if and only if ${\displaystyle f(a)=f(b)}$. Then, if ${\displaystyle f:A\rightarrow B}$ is any function, ${\displaystyle f}$ decomposes into the composition

${\displaystyle A{\stackrel {\pi }{\longrightarrow }}A/\sim {\stackrel {\tilde {f}}{\longrightarrow }}\mathrm {im} f{\stackrel {i}{\longrightarrow }}B}$

where ${\displaystyle \pi }$ is the canonical projection, ${\displaystyle i}$ is the inclusion ${\displaystyle \mathrm {im} \,f\subseteq B}$, and ${\displaystyle {\tilde {f}}}$ is the bijection ${\displaystyle {\tilde {f}}([a])=f(a)}$ for all ${\displaystyle a\in A}$.

Proof: The definition of ${\displaystyle {\tilde {f}}}$ immediately implies that ${\displaystyle f=i\circ {\tilde {f}}\circ \pi }$, so we only have to prove that ${\displaystyle {\tilde {f}}}$ is well defined and a bijection. Let ${\displaystyle a,a^{\prime }\in A}$. Then ${\displaystyle [a]=[a^{\prime }]\,\Rightarrow \,a\sim a^{\prime }\,\Rightarrow \,f(a)=f(a^{\prime })}$. This shows that the value of ${\displaystyle {\tilde {f}}([a])}$ is independent of the representative chosen from ${\displaystyle [a]}$, and so it is well-defined.

For injectivity, we have ${\displaystyle {\tilde {f}}([a])={\tilde {f}}([a^{\prime }])\,\Rightarrow \,f(a)=f(a^{\prime })\,\Rightarrow \,[a]=[a^{\prime }]}$, so ${\displaystyle {\tilde {f}}}$ is injective.

For surjectivity, let ${\displaystyle b\in \mathrm {im} \,f}$. Then there exists an ${\displaystyle a\in A}$ such that ${\displaystyle f(a)=b}$, and so ${\displaystyle {\tilde {f}}([a])=b}$ by definition of ${\displaystyle {\tilde {f}}}$. Since ${\displaystyle b}$ is arbitrary in ${\displaystyle \mathrm {im} \,f}$, this proves that ${\displaystyle {\tilde {f}}}$ is surjective.

Q.E.D.

Definition: Given a function ${\displaystyle f\,:\,X\rightarrow Y}$, ${\displaystyle f}$ is a

(i) Monomorphism if given any two functions ${\displaystyle g,h\,:\,W\rightarrow X}$ such that ${\displaystyle f\circ g=f\circ h}$, then ${\displaystyle g=h}$.

(ii) Epimorphism if given any two functions ${\displaystyle g,h\,:\,Y\rightarrow Z}$ such that ${\displaystyle g\circ f=h\circ f}$, then ${\displaystyle g=h}$.

Theorem: A function between sets is

(i) a monomorphism if and only if it is injective.

(ii) an epimorphism if and only if it is surjective.

Proof: (i) Let ${\displaystyle f\,:\,B\rightarrow C}$ be a monomorphism. Then, for any two functions ${\displaystyle g,h\,:\,A\rightarrow B}$, ${\displaystyle f(g(a))=f(h(a))\,\Rightarrow \,g(a)=h(a)}$ for all ${\displaystyle a\in A}$. This is the definition if injectivity. For the converse, if ${\displaystyle f}$ is injective, it has a left inverse ${\displaystyle f^{\prime }}$. Thus, if ${\displaystyle f(g(a))=f(h(a))}$ for all ${\displaystyle a\in A}$, compose with ${\displaystyle f^{\prime }}$ on the left side to obtain ${\displaystyle g(a)=h(a)}$, such that ${\displaystyle f}$ is a monomorphism.

(ii) Let ${\displaystyle f\,:\,A\rightarrow B}$ be an epimorphism. Then, for any two functions ${\displaystyle g,h\,:\,B\rightarrow C}$, ${\displaystyle g(f(a))=h(f(a))\,\Rightarrow \,g(b)=h(b)}$ for all ${\displaystyle a\in A}$ and ${\displaystyle b\in B}$. Assume ${\displaystyle \mathrm {im} f\neq B}$, that is, that ${\displaystyle f}$ is not surjective. Then there exists at least one ${\displaystyle b\in B}$ not in ${\displaystyle \mathrm {im} \,f}$. For this ${\displaystyle b}$ choose two functions ${\displaystyle g,h}$ which coincide on ${\displaystyle \mathrm {im} \,f}$ but disagree on ${\displaystyle \{b\}}$. However, we still have ${\displaystyle g(f(a))=h(f(a))}$ for all ${\displaystyle a\in A}$. This violates our assumtion that ${\displaystyle f}$ is an epimorphism. Consequentally, ${\displaystyle f}$ is surjective. For the converse, assume ${\displaystyle f}$ is surjective. Then the epimorphism property immediately follows.

Q.E.D.

Remark: The equivalence between monomorphism and injectivity, and between epimorphism and surjectivity is a special property of functions between sets. This not the case in general, and we will see examples of this when discussing structure-preserving functions between groups or rings in later sections.

Example: Given any two sets ${\displaystyle A}$ and ${\displaystyle B}$, we have the canonical projections ${\displaystyle \pi _{A}\,:\,A\times B\rightarrow A}$ sending ${\displaystyle (a,b)}$ to ${\displaystyle a}$, and ${\displaystyle \pi _{B}\,:\,A\times B\rightarrow B}$ sending ${\displaystyle (a,b)}$ to ${\displaystyle b}$. These maps are obviously surjective.

In addition, we have the natural inclusions ${\displaystyle i_{A}\,:\,A\rightarrow A\coprod B}$ and ${\displaystyle i_{B}\,:\,B\rightarrow A\coprod B}$ which are obviously injective as stated above.

### Universal properties

The projections and inclusions described above are special, in that they satisfy what are called universal properties. We will give the theorem below. The proof is left to the reader.

Theorem: Let ${\displaystyle A,B,C}$ be any sets.

(i) Let ${\displaystyle f\,:\,C\rightarrow A}$ and ${\displaystyle g\,:\,C\rightarrow B}$. Then there exists a unique function ${\displaystyle u\,:\,C\rightarrow A\times B}$ such that ${\displaystyle f=\pi _{A}\circ u}$ and ${\displaystyle g=\pi _{B}\circ u}$ are simultaneously satisfied. ${\displaystyle u}$ is sometimes denoted ${\displaystyle f\times g}$.

(ii) Let ${\displaystyle f\,:\,A\rightarrow C}$ and ${\displaystyle g\,:\,B\rightarrow C}$. Then there exists a unique function ${\displaystyle u\,:\,A\coprod B\rightarrow C}$ such that ${\displaystyle f=u\circ i_{A}}$ and ${\displaystyle g=u\circ i_{B}}$ are simultaneously satifsied.

The canonical projections onto quotients also satisfy a universal property.

Theorem: Define the equivalence relation ${\displaystyle \sim }$ on ${\displaystyle X}$ and let ${\displaystyle f\,:\,X\rightarrow Y}$ be any function such that ${\displaystyle a\sim b\,\Rightarrow \,f(a)=f(b)}$ for all ${\displaystyle a,b\in X}$. Then there exists a unique function ${\displaystyle {\bar {f}}\,:\,X/\sim \rightarrow Y}$ such that ${\displaystyle f={\bar {f}}\circ \pi }$, where ${\displaystyle \pi \,:\,X\rightarrow X/\sim }$ is the canonical projection.