1.3.2: Kinds of Functions
It will be useful to introduce a kind of taxonomy for some of the kinds of functions which we encounter most frequently.
To start, we might want to consider functions which have the property that every member of the codomain is a value of the function. Such functions are called surjective, and can be pictured as in Figure \(\PageIndex{1}\).
A function \(f \colon A \rightarrow B\) is surjective iff \(B\) is also the range of \(f\) , i.e., for every \(y \in B\) there is at least one \(x \in A\) such that \(f(x) = y\) , or in symbols: \[(\forall y \in B)(\exists x \in A)f(x) = y.\nonumber\] We call such a function a surjection from \(A\) to \(B\) .
If you want to show that \(f\) is a surjection, then you need to show that every object in \(f\) ’s codomain is the value of \(f(x)\) for some input \(x\) .
Note that any function induces a surjection. After all, given a function \(f \colon A \to B\) , let \(f' \colon A \to \ran{f}\) be defined by \(f'(x) = f(x)\) . Since \(\ran{f}\) is defined as \(\Setabs{f(x) \in B}{x \in A}\) , this function \(f'\) is guaranteed to be a surjection
Now, any function maps each possible input to a unique output. But there are also functions which never map different inputs to the same outputs. Such functions are called injective, and can be pictured as in Figure \(\PageIndex{2}\).
A function \(f \colon A \rightarrow B\) is injective iff for each \(y \in B\) there is at most one \(x \in A\) such that \(f(x) = y\) . We call such a function an injection from \(A\) to \(B\) .
If you want to show that \(f\) is an injection, you need to show that for any elements \(x\) and \(y\) of \(f\) ’s domain, if \(f(x)=f(y)\) , then \(x=y\) .
The constant function \(f\colon \Nat \to \Nat\) given by \(f(x) = 1\) is neither injective, nor surjective.
The identity function \(f\colon \Nat \to \Nat\) given by \(f(x) = x\) is both injective and surjective.
The successor function \(f \colon \Nat \to \Nat\) given by \(f(x) = x+1\) is injective but not surjective.
The function \(f \colon \Nat \to \Nat\) defined by: \[f(x) = \begin{cases} \frac{x}{2} & \text{if $x$ is even} \\ \frac{x+1}{2} & \text{if $x$ is odd.} \end{cases}\nonumber\] is surjective, but not injective.
Often enough, we want to consider functions which are both injective and surjective. We call such functions bijective. They look like the function pictured in Figure \(\PageIndex{3}\). Bijections are also sometimes called one-to-one correspondences , since they uniquely pair elements of the codomain with elements of the domain.
A function \(f \colon A \to B\) is bijective iff it is both surjective and injective. We call such a function a bijection from \(A\) to \(B\) (or between \(A\) and \(B\) ).