Proving the chain rule First see the first comment on this post 
how to prove the chain rule?
and this post in general 
Chain rule proof doubt
So we begin by proving the chain rule by assuming we have $f,g$ where $f$ is differential at $x_0$ and $g$ at $f(x_0)$. We consider
$$\frac{g(f(x))-g(f(x_0))}{x-x_0}=\frac{g(f(x))-g(f(x_0))}{f(x)-f(x_0)}\frac{f(x)-f(x_0)}{x-x_0}$$
So we need to avoid the cases where $f(x)=f(x_0)$. Of course, if there are finitely many of them, we just toss them out and we are good to go. So my book defines $y_0=f(x_0)$
$$\frac{g(y)-g(y_0)}{y-y_0}$$
 and, for each $y \in D'$ (the domain of $g$), and defines $h(y_0)=g'(y_0)$ so we have
$$lim_{y\to y_0}h(y)=g'(y_0)=h(y_0)$$ so $h$ is continuous as defined and they assert this gives us our result since the resulting products will have limits and so on.
How do we deal with the case where say $f(x)=f(x_0)$ everywhere? How do we deal with it when there are infinitely many points $f(x)=f(x_0)$. If someone could be very rigorous in proving and explaining the chain rule it would be greatly appreciated.  
 A: Note that because $g'(f(x_0))$ exists there exists a constant $C$ such that $|g(y) - g(f(x_0))| \le C|y - f(x_0)|$ for $y$ near $f(x_0).$
Two cases: 1. $f'(x_0) = 0.$ Here we have, as $x \to x_0,$  
$$| (g(f(x)) - g(f(x_0)) )/(x-x_0)| \le C|(f(x) - f(x_0))/(x-x_0)| \to C\cdot 0 = 0.$$
That gives the desired result in this case.
Case 2: $f'(x_0) \ne 0.$ Then for $x$ close to $x_0, x \ne x_0,$ we have $f(x) \ne f(x_0).$ Here the usual smoke-and-mirrors proof works.
A: The usual proof proceeds as follows.  We have that $g$ is a differentiable function and therefore we have 
$$\Delta g(y)=g(y+\Delta y)-g(y)=g'(y)\Delta y+\epsilon(\Delta y)\Delta y$$
where $\epsilon$ is a function of $\Delta y$ given by
$$\epsilon(\Delta y)=
\begin{cases}
\frac{g(y+\Delta y)-g(y)}{\Delta y}-g'(y)&, \Delta y\ne 0\\\\
0&,\Delta y = 0
\end{cases}
$$

It is important to point out that in the notation we are using here, $\epsilon(\Delta y)$ denotes a function $\epsilon$ of  $\Delta y$, and not a number $\epsilon$ multiplied by a number $\Delta y$.

Note that $\epsilon(\Delta y) \to 0$ as $\Delta y\to 0$ and therefore, $\epsilon(\Delta y)$ is continuous as a function of $\Delta y$ at $\Delta y=0$!
Now, suppose $y$ is a differentiable function of $x$, say $y=f(x)$.  Then, we denote $y+\Delta y=f(x+\Delta x)$ and 
$$\Delta g(f(x))=g(f(x+\Delta x))-g(f(x))=\left(g'(f(x))+\epsilon(\Delta y)\right)\times\left(f(x+\Delta x)-f(x)\right)$$
Note that since $f$ is continuous, then as $\Delta x\to 0$, $\Delta y\to 0$.  Therefore, we have
$$\begin{align}
\lim_{\Delta x\to 0}\frac{\Delta g(f(x))}{\Delta x}&=\lim_{\Delta x\to 0}\frac{g(f(x+\Delta x))-g(f(x))}{\Delta x}\\\\
&=\lim_{\Delta x\to 0}\left(\left(g'(f(x))+\epsilon(\Delta y)\right)\times \frac{f(x+\Delta x)-f(x)}{\Delta x}\right)\\\\
&=g'(f(x))f'(x)
\end{align}$$
as expected!  And we never needed to worry whether $f(x+\Delta x)-f(x)=0$.
A: When $f(x)=f(x_0)$, we can substitute $f(x_0)$ with $f(x)$. This gives us
$$\lim_{x\to x_0}\frac{g(f(x))-g(f(x))}{x-x_0}$$
We can simplify this to
$$\lim_{x\to x_0}\frac 0{x-x_0}$$
which evaluates to $0$. Since $f'(x)$ must equal $0$ under these conditions, this is consistent with the chain rule, because $g'(f(x))f'(x)=0$ by the zero product property.
