Naive set theory: Functions
The concept of function
You have probably encountered the concept of function before as a kind of machine that produces output for given input. In this theory page, we will introduce a function as a binary relation between sets with special properties.
Definition of a function
Function
Let \(X\) and \(Y\) be sets. A function from \(X\) to \(Y\), also called a map or mapping, is a relation \(G_f\) from \(X\) to \(Y\), also referred to as the graph of \(f\), with the following two properties:
- For every \(x\in X\), there exists a \(y\in Y\) such that \((x,y)\in G_f\);
- For every \(x\in X\) and all \(y,z\in Y\): if \((x,y)\in G_f\) and \((x,z)\in G_f\), then \(y=z\).
In other words: \(f\) is a function from \(X\) to \(Y\) if for each element \(x\) of the set \(X\) there is exactly one element \(y\) of \(Y\) such that \((x,y)\) is an element of \(G_f\). A function is often specified via a function rule; see the examples.
If \((x,y)\in G_f\), we usually denote this as \(y=f(x)\) and call \(y\) the image of \(x\) under \(f\) and \(x\) an original of \(y\) under \(f\). We often denote a function \(f\) as \(f:\;X\rightarrow Y\). The set \(X\) is called the domain of the function, just like with any relation, and sometimes denoted as \(D_f\); \(Y\) is called the codomain. The range or complete image of the function \(f\) consists of the set of all images under \(f\). Instead of \(\mathrm{ran}(f)\), we usually write \(\mathrm{im}(f)\) or \(R_f\).
Let \(f:\;X\rightarrow Y\) be a function from \(X\) to \(Y\) and \(W\subset Y\). Then the preimage \(f^{-1}(W)\) of \(W\) under \(f\) is defined as \[f^{-1}(W)=\{x\in X\mid f(x)\in W\}\text.\]
Examples
\[\begin{aligned}&f:\;\mathbb{N}\rightarrow \mathbb{N},\\ &f(x)=\begin{cases} 0& \text{for even }x\\ 1&\text{for odd }x\end{cases}\end{aligned}\] \[\begin{aligned}&g:\;\{a,b,c\}\rightarrow \{\alpha,\beta,\gamma\},\\ &g(a)=\alpha, g(b)=\beta, g(c)=\gamma\end{aligned}\] \[\begin{aligned}&h:\;\{a,\alpha,b\}\rightarrow \{A,B,C\},\\ &h(a)=A, h(\alpha)=A, h(b)=B, \end{aligned}\] \[\begin{aligned}&F:\;\mathbb{R}\backslash\{0\}\rightarrow \mathbb{R}\\ &F(x)=\frac{1}{x}\end{aligned}\] But unlike \(F\), \[\begin{aligned}&G:\;\mathbb{R}\rightarrow \mathbb{R}\\ &G(x)=\frac{1}{x}\end{aligned}\] is not a function because the image of \(0\) is not well-defined via the rule.
Equality of functions
Equality of functions
Two functions \(f\) and \(g\) are equal if they are defined over the same domain and for every \(x\) in the domain:\(f(x)=g(x)\).
In other words, the functions \(f\) and \(g\) are equal if and only if their graphs are equal, i.e. \(G_f=G_g\).
Sometimes it is also required that the codomain of \(f\) and \(g\) are equal to each other. This, for example, results in the functions \(f:\;\mathbb{Z}\rightarrow \mathbb{Z}, f(x)=|x|\) and \(g:\;\mathbb{Z}\rightarrow \mathbb{N}, g(x)=|x|\) not being equal.
Example
\[\begin{aligned}&f:\;\mathbb{R}\rightarrow \mathbb{R},\\ &f(x)=\sin(2x)\end{aligned}\] and \[\begin{aligned}&g:\;\mathbb{R}\rightarrow \mathbb{R},\\ &g(x)=2\sin(x)\cos(x)\end{aligned}\] are equal functions, specified in two ways.
Restriction of a function
Restriction of a function
Let \(f:\;X\rightarrow Y\) be a function from \(X\) to \(y\) and \(W\subset X\). The restriction of \(f\) to \(W\) is the function \(f{\restriction}_{W}:\; W\rightarrow Y\) defined by \(f{\restriction}_W(x)=f(x)\) for all \(x\in W\). In other words, as a relation: \(G_{f{\restriction}_W}=\bigl\{(x,y)\in G_f\mid x\in W\bigr\}\).
The image of \(W\) under \(f\) is \(\{f(x)\mid x\in W\bigr\}\).
Examples
\[\begin{aligned}&f:\;\mathbb{Z}\rightarrow \mathbb{Z},\quad f(n)=\begin{cases} 0 &\text{if }n<0\\ 1&\text{if }n\ge 0\end{cases}\\[0.25cm]&f{\restriction}_\mathbb{N}:\;\mathbb{N}\rightarrow \mathbb{Z}, \quad f{\restriction}_\mathbb{N}(n)=1\end{aligned}\]
\[\begin{aligned}&g:\;\mathbb{R}\rightarrow \mathbb{R},\quad g(x)=\cos \pi x\\[0.25cm]&g{\restriction}_\mathbb{Z}:\;\mathbb{Z}\rightarrow \mathbb{R}, \quad g{\restriction}_\mathbb{Z}(n)=(-1)^n\end{aligned}\]
Identity function and characteristic function The identity function \(\mathrm{id}_X\) on a nonempty set \(X\) is defined as \(\mathrm{id}_X(x)=x\) for all \(x\in X\).
Let \(X\) be a nonempty set and \(W\subset X\). The characteristic function \({\large\chi}_W\) of \(W\) in \(X\), also called indicator function of \(W\) in \(X\) and sometimes also denoted as \(1_W\), is the function \({\large\chi}_W:\; X\rightarrow \{0,1\}\) defined by \({\large\chi}_W(x)=\begin{cases} 1 &\text{if }x\in W\\ 0 &\text{if }x\in X\backslash W\end{cases}\).