I didn't understand the proof of the chain rule From a lecture note about analysis:
For differentiable functions $f$ and $g$
$$
(g\circ f)'(x_0)=g'(f(x_0))f'(x_0).
$$
Proof: Consider the limit $$\lim_{x \to x_0}{\frac{g(f(x))-g(f(x_0))}{x-x_0}}.$$ Note that $$\lim_{x \to x_0}{\frac{g(f(x))-g(f(x_0))}{x-x_0}}=\lim_{x \to x_0}{\frac{g(f(x))-g(f(x_0))}{f(x)-f(x_0)}\cdot\frac{f(x)-f(x_0)}{x-x_0}}$$; the second term converges to $f'(x_0)$, while the first term (since $x-x_0\to 0$ implies $f(x)-f(x_0)\to 0$ by the continuity of $f$) converges to $$\lim_{x \to x_0}{\frac{g(f(x))-g(f(x_0))}{f(x)-f(x_0)}}=g'(f(x_0)).$$
Question Why is the bold sentence necessary? Didn't we already assume that $g$ is differentiable at $f(x_0)$? Why didn't he write "..., while the first term converges to $g'(f(x_0))$ by assumption."? 
 A: Knowing that $\lim_{x\to x_0}f(x)=f(x_0)$ is what is required to say that $$\lim_{x\to x_0}\frac{g(f(x))-g(f(x_0))}{f(x)-f(x_0)}=\lim_{u\to f(x_0)}\frac{g(u)-g(f(x_0))}{u-f(x_0)},$$ which is $g'(f(x_0))$ by differentiability of $g$ at $f(x_0)$.

Unfortunately, this proof has a substantial hole in it: the claim $$\frac{g(f(x))-g(f(x_0))}{x-x_0}=\frac{g(f(x))-g(f(x_0))}{f(x)-f(x_0)}\cdot\frac{f(x)-f(x_0)}{x-x_0}$$ makes sense only when $f(x)-f(x_0)\ne 0.$ If $f$ is a constant function (at least locally, near $x_0$), for example, then this manipulation makes no sense at all (though in that case, we've other recourse). This is why in this proof of the chain rule, alternate means are taken to bring the $g'(f(x_0))$ analog term in, without risking division by $0$. Does that answer your commented question, or are there particular steps in that proof that you don't understand?
A: To see the necessity of the continuity let's see an example. So let
$$f(x)=\left\{\begin{array}\\
1&\text{if}\ x>0\\
0&\text{if}\ x\leq0
\end{array}\right.$$
then clearly $f$ isn't countinuous at $0$ and let $g(x)=x$ then
$$\lim_{x\to0^+}g(f(x))=g(1)=1\neq0=g(0)=\lim_{x\to0^-}g(f(x))$$
so the limit doesn't exist.
A: The problem is that we want $f(x)-f(x_0)$ to behave like $x-x_0$. The only question is, does it go to 0 like $x-x_0$ does? Because in the definition of the derivative, you need the denominator to go to 0. The denominator only goes to 0 if $f(x)$ goes to $f(x_0)$ as $x$ goes to $x_0$, which is the definition of continuity at $x_0$. So the only way that the limit equals the derivative is if $f$ is continuous there, but that always happens by a previous lemma.
