The Problem (Chain rule) : Let $J \subset \mathbb{R}$. Let $f : J \to \mathbb{R}$ be differentiable at $c \in J$. Let $J_1 \subset \mathbb{R}$ be such that $f(J) \subset J_1$. Let $g : J_1 \to \mathbb{R}$ be differentiable at $f(c)$. Then to show that : $g \circ f$ is differentiable at $c$ and $$(g \circ f)'(c)=g'\{f(c)\} \cdot f'(c)$$
I know that there are ready-made proofs available. But I still wanted to build a proof on my own intuition. Unfortunately I have a gap in the proof (which is described in the highlighted paragraph under Case 2). How do I fill it? Any help would be greatly appreciated.
My Approach :
Case 1 : $\exists p>0$ such that $x \in (c-p,c+p) \cap J \setminus \{c\} \implies f(x) \neq f(c)$.
Given, $g$ is differentiable at $f(c)$. This means that the following limit exists
$$\lim_{y \to f(c)} \frac{g(y)-g\{f(c)\}}{y-f(c)}$$
Suppose this limit equals $L$. Fix $\epsilon > 0$. Then $\exists \delta > 0,$ such that
$$y \in (f(c)-\delta,f(c)+\delta) \cap J_1 \setminus \{f(c)\} \implies \left| \frac{g(y)-(g \circ f)(c)}{y-f(c)} - L \right| < \epsilon $$
Since $f(J) \subset J_1$, we can say that
$$y \in (f(c)-\delta,f(c)+\delta) \cap f(J) \setminus \{f(c)\} \implies \left| \frac{g(y)-(g \circ f)(c)}{y-f(c)} - L \right| < \epsilon \tag{1}$$
Now, suppose $y_0 \in (f(c)-\delta,f(c)+\delta) \cap f(J) \setminus \{f(c)\}$. Then, $y_0 \in f(J) \setminus \{f(c)\},$ which implies that $\exists x_0 \in J \setminus \{c\}$ such that $f(x_0)=y_0$
Consider the set $$A:=\big\{x \in J \setminus \{c\}\,\,\big|\,\,f(x) \in (f(c)-\delta,f(c)+\delta) \cap f(J) \setminus \{f(c)\} \big\}$$
It follows from the definition and $(1)$ that $$x \in A \implies \left| \frac{(g \circ f)(x)-(g \circ f)(c)}{x-c}-L \right| < \epsilon \tag{2}$$
Now it is enough to show that $\exists \alpha > 0$ such that $(c-\alpha,c+\alpha) \cap J \setminus \{c\} \subset A$. Because in that case we have
$$x \in (c-\alpha,c+\alpha) \cap J \setminus \{c\} \implies \left| \frac{(g \circ f)(x)-(g \circ f)(c)}{x-c}-L \right| < \epsilon$$
Since $\epsilon > 0$ is arbitrary we can say that $g \circ f$ is differentiable at $c$ and $(g \circ f)'(c)=L$
To show that such $\alpha > 0$ exists, we use continuity of $f$ at the point $c$. $\delta > 0$ is fixed before. Then $\exists \beta > 0$ such that $$x \in (c-\beta,c+\beta) \cap J \implies f(x) \in (f(c)-\delta, f(c)+\delta)$$
Together with the fact that $f(x) \in f(J) \,$ for all $\, x \in J,$ we have
$$x \in (c-\beta,c+\beta) \cap J \implies f(x) \in (f(c)-\delta, f(c)+\delta) \cap f(J)$$
But what we really want to show is that $\exists \alpha > 0$ such that $$x \in (c-\alpha,c+\alpha) \cap J \setminus \{c\} \implies f(x) \in (f(c)-\delta, f(c)+\delta) \cap f(J) \setminus \{f(c)\}$$
Choose $\alpha=\min\{\beta,p\}$ Then $(c-\alpha,c+\alpha) \cap J \setminus \{c\} \subset A$ and we are done showing that $g \circ f$ is differentiable at $c$ and $(g \circ f)'(c)=L$.
To compute $L,$ we note that \begin{align} L&=\lim_{x \to c;\,x \in J \setminus \{c\}}\frac{(g \circ f)(x)-(g \circ f)(c)}{x-c}\\ &=\lim_{x \to c;\,x \in (c-\alpha,c+\alpha) \cap J \setminus \{c\}}\frac{(g \circ f)(x)-(g \circ f)(c)}{x-c}\,\,\,\,\text{(limit is local)}\\ &=\lim_{x \to c;\,x \in (c-\alpha,c+\alpha) \cap J \setminus \{c\}}\bigg\{\frac{(g \circ f)(x)-(g \circ f)(c)}{f(x)-f(c)} \cdot \frac{f(x)-f(c)}{x-c}\bigg\}\\ &\big[\text{Since } x \in (c-\alpha,c+\alpha) \cap J \setminus \{c\} \implies f(x) \neq f(c)\big]\\ &=\lim_{x \to c;\,x \in (c-\alpha,c+\alpha) \cap J \setminus \{c\}}\frac{(g \circ f)(x)-(g \circ f)(c)}{f(x)-f(c)} \cdot \lim_{x \to c;\,x \in (c-\alpha,c+\alpha) \cap J \setminus \{c\}} \frac{f(x)-f(c)}{x-c}\\ &=\lim_{f(x) \to f(c)}\frac{g\{f(x)\}-g\{f(c)\}}{f(x)-f(c)} \cdot \lim_{x \to c} \frac{f(x)-f(c)}{x-c}\\ &\big[\text{Since } f \text{ is continuous at } c\big]\\ &=\lim_{y \to f(c)}\frac{g(y)-g\{f(c)\}}{y-f(c)} \cdot \lim_{x \to c} \frac{f(x)-f(c)}{x-c}\\ &\big[\text{Since in this step } f(x) \text{ is essentially playing a dummy role, we can rename it as we wish} \big]\\ &=g'\{f(c)\} \cdot f'(c)\\ &\big[\text{Since } g \text{ is differentiable at } f(c) \text{ and } f \text{ is differentiable at } c \big]\\ \end{align}
Case 2 : For every $p>0, \exists z \in (c-p,c+p) \cap J \setminus \{c\}$ such that $f(z)=f(c)$.
This is where I'm stuck! In this case, It is impossible to find $\alpha > 0$ such that $(c-\alpha,c+\alpha) \cap J \setminus \{c\} \subset A$. It seems to me that we have to consider this case separately and check that $g \circ f$ is differentiable at $c$. But how do I show that? Assuming that $(g \circ f)'(c)$ exists, I've completed the rest of the proof. But the absence of an argument for existence of the concerned derivative leaves a big hole in the proof. Please help!
Suppose $g \circ f$ is differentiable at $c$. Then we have $$\lim_{x \to c}\frac{(g \circ f)(x)-(g \circ f)(c)}{x-c}=(g \circ f)'(c) \tag{3}$$
Since $f$ is differentiable at $c,$ we have
$$\lim_{x \to c}\frac{f(x)-f(c)}{x-c}=f'(c)$$
We use the sequential characterization of limit, i.e. for any sequence $(x_n)$ in $J$ such that $x_n \to c,$ we have $$\lim_{n \to \infty}\frac{f(x_n)-f(c)}{x_n-c} = f'(c) \tag{4}$$
Now for every $n \in \mathbb{N}, \exists t_n \in (c-\frac{1}{n},c+\frac{1}{n}) \cap J \setminus \{c\}$ such that $f(t_n)=f(c)$. Clearly, $t_n \to c$ and
$$\lim_{n \to \infty}\frac{f(t_n)-f(c)}{t_n-c} = 0$$
Since $(4)$ holds for any sequence $(x_n)$ in $J$ such that $x_n \to c,$ it holds for $(t_n)$. Hence we have $$f'(c)=0$$
Also, $f(t_n) \in f(J) \subset J_1$. Hence $g$ is defined at $f(t_n)$ for each $n \in \mathbb{N}$. Since $f(t_n)=f(c)$ for all $n \in \mathbb{N},$ we have $(g \circ f)(t_n)=(g \circ f)(c)$ for all $n \in \mathbb{N}$. Hence $$\lim_{n \to \infty}\frac{(g \circ f)(t_n)-(g \circ f)(c)}{t_n-c}=0 \tag{5}$$
Again using the sequential characterization of limit on $(3),$ we have $$\lim_{n \to \infty}\frac{(g \circ f)(t_n)-(g \circ f)(c)}{t_n-c}=(g \circ f)'(c) \tag{6}$$
From $(5)$ and $(6),$ we have $$(g \circ f)'(c)=0$$
Thus we trivially have $(g \circ f)'(c)=g'\{f(c)\} \cdot f'(c)$ $[$Since $LHS=0=RHS]$. $\blacksquare$