101. Inverses of functions
The number $1/2$ is the “multiplicative inverse” of the number 2 because their product is 1. A similar relationship can hold between functions, but because functional composition is not normally commutative, one has to specify which way the composite is taken.
101.1 Definition: inverse of a function
If $F\colon A \to B$ and $G\colon B \to A$, then $G$ is a left inverse to $F$, and $F$ is a right inverse to $G$, if
$$G \circ F = \mathrm{id}_{A} \tag{101.1}$$
If $G$ is both a left and a right inverse to $F$, in other words if both Equation (101.1) and
$$F \circ G = \mathrm{id}_{B} \tag{101.2}$$
hold, then $G$ is an inverse to $F$.
101.1.1 Usage A function that has an inverse is said to be invertible.
101.1.2 Fact It follows from the definition that if $G$ is an inverse to $F$, then $F$ is an inverse to $G$.
101.1.3 Fact The definition of inverse function can be expressed in other ways equivalent to Definition 101.1.
a) $G$ is the inverse of $F$ if and only if for all $a \in A$, $G(F(a)) = a$ and for all $b \in B$, $F(G(b)) = b$. (Both equations must hold.)
b) $G$ is the inverse of $F$ if and only if the following diagrams commute:

101.1.4 Example Let $F\colon \{1,3,5\} \to \{2,3,4\}$ be the function that takes 1 to 3, 3 to 4 and 5 to 2. Then the function $G\colon \{2,3,4\} \to \{1,3,5\}$ that takes 2 to 5, 3 to 1 and 4 to 3 is the inverse of $F$. (And $F$ is the inverse of $G$.)
101.1.5 Example Example 98.2.2(3) above says that the squaring function is a left inverse to the square root function: squaring the positive square root gives you what you started with. It is not the inverse, however: taking the square root of the square won’t give you the number you started with if it is negative. On the other hand, the cubing function is the inverse of the cube root function.
A function can have more than one left inverse (Problem 101.2.6) but not more than one inverse:
101.2 Theorem: Uniqueness Theorem for Inverses
If $F\colon A \to B$ has an inverse $G\colon B \to A$, then $G$ is the only inverse to $F$.
Proof The proof uses the definition of inverse, Theorem 98.2 and Example 98.2.3: If $H\colon B \to A$ is another inverse of $F$, then
$$H = H \circ \mathrm{id}_{B} = H \circ (F \circ G) = (H \circ F) \circ G = \mathrm{id}_{A} \circ G = G$$
101.2.1 Usage The fact that if a function has an inverse, it has only one, means that we can give the inverse a name: The inverse of $F$, if it exists, is denoted $F^{-1}$.
101.2.2 Remark The uniqueness theorem also means we have a rule of inference: Given $F\colon A \to B$ and $G\colon B \to A$,
$$G \circ F = \mathrm{id}_{A},\ F \circ G = \mathrm{id}_{B} \vdash G = F^{-1} \tag{101.4}$$
101.2.3 Exercise Which of the following functions have inverses? If it has one, give the inverse (by describing its graph or by a formula).
a) $F\colon \{1,2,3,4\} \to \{3,4,5,6\}$, with $1 \mapsto 3$, $2 \mapsto 4$, $3 \mapsto 6$, and $4 \mapsto 5$.
b) $G\colon \{1,2,3,4\} \to \{3,4,5,6,7\}$, with $1 \mapsto 3$, $2 \mapsto 4$, $3 \mapsto 6$, and $4 \mapsto 5$.
c) $H\colon \{1,2,3,4\} \to \{3,4,5,6\}$ with $1 \mapsto 3$, $2 \mapsto 5$, $3 \mapsto 6$, and $4 \mapsto 5$.
d) $n \mapsto 2n\colon \mathrm{N} \to \mathrm{N}$.
e) $n \mapsto n+1\colon \mathrm{N} \to \mathrm{N}$.
f) $n \mapsto n+1\colon \mathrm{Z} \to \mathrm{Z}$.
g) $n \mapsto (1/n)\colon \mathrm{N} - \{0\} \to \mathrm{R}$.
h) $K\colon \{1,2,3,4,5\} \to \{1,2,3\}$ with $K(n) = \operatorname{floor}((n+1)/2)$.
(Answer on page 248.)
101.2.4 Exercise Which of the functions in Exercise 101.2.3 have (a) left inverses, (b) right inverses? (Answer on page 248.)
101.2.5 Exercise Show that if a function $G$ has an inverse $F$, then it has only one left inverse and that is $F$. (Answer on page 248.)
101.2.6 Exercise Let $I\colon \mathrm{R}^{+} \to \mathrm{R}$ denote the inclusion function. Show that $I$ has infinitely many left inverses.
The inverse of the composite of two functions which have inverses is the composite of the inverses, only in the reverse order:
101.3 Theorem: The Shoe-Sock Theorem
If $F\colon A \to B$ and $G\colon B \to C$ both have inverses, then
$$(G \circ F)^{-1} = F^{-1} \circ G^{-1}$$
101.3.1 Remark The name comes from the fact that the inverse of putting on your socks and then putting on your shoes is taking off your shoes and then taking off your socks.
Proof To prove the Shoe-Sock Theorem, we will prove that
$$(F^{-1} \circ G^{-1}) \circ (G \circ F) = \mathrm{id}_{A} \tag{101.5}$$
and
$$(G \circ F) \circ (F^{-1} \circ G^{-1}) = \mathrm{id}_{C} \tag{101.6}$$
and then apply Rule (101.4), page 147. To prove Equation (101.5), we note that the following diagram commutes: the left and right triangles are the diagrams in Figure (101.3), and the middle triangle is the left triangle in Figure (100.3).

Equation (101.6) is proved similarly.
Another fact with a similar proof (left as an exercise) is:
101.4 Theorem
If $F$ has an inverse, then $(F^{-1})^{-1} = F$.
101.4.1 Remark Another way of saying this is that a function is the inverse of its own inverse.
101.4.2 Exercise Prove Theorem 101.4.
A final fact about inverses is the very important:
101.5 Theorem: Characterization of invertible functions
A function $F\colon A \to B$ has an inverse if and only if it is a bijection.
101.5.1 Remark The importance of Theorem 101.5 lies in the fact that having an inverse is defined in terms of functional composition but being a bijection is defined in terms of application of the function to an element of its domain. Any time a mathematical fact connects two such differently-described ideas it is probably useful.
Proof I will go through the proof in some detail since it ties together several of the ideas of this chapter. We have to prove an equivalence, which means two implications.
First we show that if $F$ has an inverse then it is a bijection. Suppose $F$ has an inverse. We must show that it is injective and surjective. To show that it is injective, suppose $F(a) = F(a')$. Then
$$a = F^{-1}(F(a)) = F^{-1}(F(a')) = a'$$
(The first and last equations follow from 101.1.3a and the middle equation from the substitution property, Theorem 39.6.) So F is injective.
To show $F$ is surjective, let $b \in B$. We must find an element $a \in A$ for which $F(a) = b$. The element is $F^{-1}(b)$, since $F(F^{-1}(b)) = b$. Thus $F$ is bijective.
Now we must show that if $F$ is bijective, then it has an inverse. Suppose $F$ is bijective. We must define a function $G\colon B \to A$ which is the inverse of $F$. Let $b \in B$. Then, since $F$ is surjective, there is an element $a \in A$ for which $F(a) = b$. Since $F$ is injective there is exactly one such $a$. Let $G(b) = a$. Since $F(a) = b$, that says that $G(F(a)) = a$, which is half of what we need to show to prove (using Definition 101.1) that $G = F^{-1}$. The other thing needed is that $F(G(b)) = b$. But by definition of $G$, $G(b)$ is the element $a$ for which $F(a) = b$, so $F(G(b)) = b$. That finishes the proof.
101.5.2 Remarks
a) The second part of the proof says this: If $F(a) = b$, then $F^{-1}(b) = a$, and if $F^{-1}(b) = a$, then $F(a) = b$.
b) You might experiment with proving the contrapositives of the two implications in the preceding proof; some people find them easier to understand.
101.5.3 Exercise Write a formula for the inverse of each of these bijections.
a) $x \mapsto x^{2}\colon \mathrm{R}^{+} \to \mathrm{R}^{+}$.
b) $x \mapsto x-1\colon \mathrm{R} \to \mathrm{R}$.
c) $x \mapsto 2x\colon \mathrm{R} \to \mathrm{R}$.
d) $x \mapsto (1/x)\colon \mathrm{R} \to \mathrm{R}$.
(Answer on page 248.)
101.5.4 Exercise Prove that a function has a left inverse if and only if it is injective.
101.5.5 Exercise Prove that a function has a right inverse if and only if it is surjective.
101.5.6 Exercise Give a right inverse of the function $\mathrm{GCD}\colon \mathrm{N}^{+} \times \mathrm{N}^{+} \to \mathrm{N}^{+}$. (You are being asked to give the right inverse explicitly, not merely show it exists.)
101.5.7 Exercise Show that $\mathrm{GCD}\colon \mathrm{N}^{+} \times \mathrm{N}^{+} \to \mathrm{N}^{+}$ does not have a left inverse.
101.5.8 Exercise (hard) A function $F\colon A \to B$ is left cancellable if whenever $G\colon D \to A$ and $H\colon D \to A$ are functions for which $F \circ G = F \circ H$, then $G$ must be the same as $H$. Right cancellable is defined analogously. Prove that a function is left cancellable if and only if it is injective and right cancellable if and only if it is surjective.
101.5.9 Exercise (hard) Let $F\colon A \to B$ be a function and suppose $A$ has more than one element. Show that if $F$ has exactly one left inverse then the left inverse is also a right inverse (hence $F$ has an inverse).
101.5.10 Exercise (hard) Let $A$ and $B$ be sets. Let $\beta\colon \mathrm{Rel}(A,B) \to (\mathcal{P}B)^{A}$ defined in Problem 94.1.11, page 137. Let $\gamma\colon (\mathcal{P}B)^{A} \to \mathrm{Rel}(A,B)$ be the function (defined in Definition 53.3, page 76) that takes a function $F\colon A \to \mathcal{P}B$ to the relation $\alpha_{F}$ defined by
$$a \alpha_{F} b \text{ if and only if } b \in F(a)$$
Prove that $\gamma$ is the inverse of $\beta$ (hence $\beta$ is the inverse of $\gamma$).
Pages 146–150 of the book (PDF).