If $f \circ g$ is invertible, is $(f \circ g)^{-1} = g^{-1} \circ f^{-1}$? If $f \circ g$ is invertible, is $(f \circ g)^{-1} = g^{-1} \circ f^{-1}$?
If not can someone give me a counterexample?
 A: Let $ f:\{0,1\} \rightarrow \{0\} $ be defined by
$ f(0) = 0 = f(1) $
and define $ g:\{0\} \rightarrow \{0\} $ with obvious mapping $g(0) = 0$ 
then $ f \circ g  $ is defined from $ \{0\} $ to $ \{0\} $ with $ (f \circ g) (0) = 0 $ and $ (f \circ g)^{-1} (0) = 0 $
but f is not invertible.
A: It is true if $f$ and $g$ are invertible. You can check this directly by using the definition of inverse function.
But neither $f$ nor $g$ need to be invertible for $f\circ g$ to be invertible.  To find a counterexample, I suggest looking for a noninjective $f$ and a nonsurjective $g$.
A: In my view. I think if we take them as binary relations, then we would have
$g^{-1} \circ f^{-1}$
=$\left \{(z,x) \in \operatorname{dom}(f^{-1}) \times \operatorname{ran}(g^{-1})|\exists y \in  \operatorname{ran}(f^{-1}) \cap \operatorname{dom}(g^{-1})((z,y) \in f^{-1}\land(y,x) \in g^{-1})\right \}$
=$\left \{(z,x) \in  \operatorname{ran}(f) \times \operatorname{dom}(g)|\exists y \in \operatorname{dom}(f) \cap  \operatorname{ran}(g)((y,z) \in f\land(x,y) \in g)\right \}$
=$\left (\left  \{(x,z) \in \operatorname{dom}(g) \times  \operatorname{ran}(f)|\exists y \in \operatorname{dom}(f) \cap  \operatorname{ran}(g)((y,z) \in f\land(x,y) \in g)\right  \}\right )^{-1}$
=$(f\circ g)^{-1}$
That means $g^{-1} \circ f^{-1}=(f\circ g)^{-1}$ always holds regardless of whether they are invertible functions

For the direct proof of invertible function.  We need to prove


*

*$dom((f \circ g)^{-1})=dom(g^{-1} \circ f^{-1})$

*for all $z \in dom((f \circ g)^{-1})$, $(f \circ g)^{-1}(z)=g^{-1} \circ f^{-1}(z)$
proof.
(1) Suppose that $z \in dom((f \circ g)^{-1})$, let $x=(f \circ g)^{-1}(z)$. Then $f \circ g(x)=z$. Hence $f^{-1}(z)=g(x)$. Consequently $g^{-1} \circ f^{-1}(z)=x$. Therefore $z \in dom(g^{-1} \circ f^{-1})$. 
Suppose that $z \in dom(g^{-1} \circ f^{-1})$, let $x=g^{-1} \circ f^{-1}(z)$, analogously $x=(f \circ g)^{-1}(z)$.
Therefore $dom((f \circ g)^{-1})=dom(g^{-1} \circ f^{-1})$.
(2) According to the proof of (1) $g^{-1} \circ f^{-1}(z)=(f \circ g)^{-1}(z)$ for all $z$ in the domain of $(f \circ g)^{-1}$.
$\Box$
