I'll denote the identity function by [tex]\mathrm{Id}[/tex]. Then for any functions [tex]f[/tex] with inverse [tex]f^{-1}[/tex],
[tex]\begin{cases}f\circ\mathrm{Id}=f\\\mathrm{Id}\circ f=f\\f\circ f^{-1}=\mathrm{Id}\end{cases}[/tex]
One important fact is that composition is associative, meaning for functions [tex]f,g,h[/tex], we have
[tex](f\circ g)\circ h=f\circ(g\circ h)[/tex]
So given
[tex]h=f\circ g[/tex]
we can compose the functions on either side with [tex]g^{-1}[/tex]:
[tex]h\circ g^{-1}=(f\circ g)\circ g^{-1}=f\circ(g\circ g^{-1})[/tex]
then apply the rules listed above:
[tex]h\circ g^{-1}=f\circ\mathrm{Id}=f[/tex]