If $f:S_1\rightarrow S_2, C^{\infty}$ is invertible and $f^{-1}$ is differentiable, so $f^{-1}$ is $C^{\infty}$ I am trying to follow some notes of classes and the professor wrote. It is a result for differentiable applications between surfaces.

If $f:S_1\rightarrow S_2, C^{\infty}$ is invertible and $f^{-1}$ is differentiable, so $f^{-1}$ is $C^{\infty}$.
Proof: If $g=f^{-1}$, so $g ~\circ~f=I $ and $dg_{f(p)}\circ df_p=I$. Then, $dg_{f(p)}=(df_p)^{-1}=Inv~\circ df_p$. Therefore, $g$ is $C^{\infty}$.

I could follow the steps, but do not get how obtain the conclusion "therefore...".
Many thanks.
 A: While it's possible that the teacher is referring to the theorem that mathcounterexamples.net cites in their answer, I suspect that the argument is more elementary, since we have an additional assumption.
We are assuming that $f$ is $C^\infty$, invertible, and that $f^{-1}$ is differentiable.
The given proof is reasonable, but I'll expand a bit on it to hopefully make it more clear.
Let $g=f^{-1}$. We know $g\circ f = \textrm{id}$. Therefore $dg_{f(p)}\circ df_p = I$ for all points $p$ (using chain rule and the differentiability of $g$). But $f$ is invertible, so $df$ is also invertible everywhere, so $dg_{f(p)} = (df_p)^{-1}$. However $df_p$ is invertible everywhere and $C^\infty$, so $(df_p)^{-1}$ is also $C^\infty$ by the chain rule (both $df_p$ and $M\mapsto M^{-1}$ are $C^\infty$).
But this tells us that $dg_{f(p)}$ is a smooth function of $p$.
Side note: This proof has an error. We want to conclude that $dg_q$ is smooth in $q$, but instead we end up with $dg_{f(p)}$ is a smooth function of $p$.
This can be fixed by the following slightly more complicated argument.
First swap the order. We know $f\circ g = \textrm{id}$. Thus 
$$df_{g(q)} \circ dg_q = I$$ for all points $q$. Hence
$$dg_q = (df_{g(q)})^{-1}.$$
Once again, since $df$ and $M\mapsto M^{-1}$ are $C^\infty$, we have that 
$h(p):=(df_p)^{-1}$ is a $C^\infty$ function of $p$. However, the function on the right hand
side is now $h(g(q))$. Thus the function on the right hand side is as differentiable as $g$ is. However, if $g$ is differentiable, then the right hand side is differentiable, so the left hand side $dg_q$ is differentiable. However, that means that $g$ is twice differentiable. Therefore it is three times differentiable, and thus four times differentiable, and so on. (Formalize this with an induction).
This tells us that $g$ is $C^\infty$, as desired.
A: It is a theorem that if $f : E \to F$ where $E,F$ are Banach spaces and $f$ is $\mathcal C^n$ and the derivative is continuous and invertible at each point, then $f^{-1}$ is differentiable and also $\mathcal C^n$.
I imagine that your teacher is referring to this theorem. The proof is not trivial.
