The limit of composition of two functions I need your help in solving this limits problem.

Let $f$ and $g$ be two functions defined everywhere. If $\lim_{u\to b} f(u) = c$ 
  and $\lim_{x\to a} g(x) = b$, then you may believe that $\lim_{x\to a} f(g(x)) = c$. This
  problem shows that this is not always true.
Consider functions $f$ and $g$ defined as follows: $g(x) = 0$ for all $x \in\mathbb  R$ and
  $$    f(u) = \begin{cases} 0, \quad & \text{ if } u \ne 0, \\
           1, &\text{ if } u = 0\end{cases}$$
(a) Compute $\lim_{u\to 0} f(u)$
  (b) Compute $f(g(x))$ for $x \in\mathbb R$ and hence compute $\lim_{x\to 0} f(g(x))$.
  (c) Can you redefine $f(0)$ so that $\lim_{x\to 0} f(g(x)) = f(\lim_{x\to 0} g(x))$ ?

I tried solving and was getting my solution but it's confusing and I am not able to confirm it. So I need your answer to help me out.
 A: You were given the functions 
$$f(u) = \begin{cases} 
         0 & \mbox{if $u \neq 0$}\\
         1 & \mbox{if $u = 0$} \end{cases}$$
and 
$g(x) = 0~\forall~x \in \mathbb{R}$
(a) Since $f(u) = 0$ whenever $u \neq 0$, 
$\lim_{u \rightarrow 0} f(u) = \lim_{u \rightarrow 0} 0 = 0$
(b) Since $g(x) = 0$ for each $x \in \mathbb{R}$, 
$f(g(x)) = f(0) = 1$ 
for each $x \in \mathbb{R}$.  Hence, 
$\lim_{x \rightarrow 0} f(g(x)) = \lim_{x \rightarrow 0} 1 = 1$
(c) If we redefine $f(0) = 0$ so that the function $f(x)$ is continuous, 
$\lim_{x \rightarrow 0}f(g(x)) = \lim_{x \rightarrow 0} f(0) = \lim_{x \rightarrow 0} 0 = 0$
and 
$f(\lim_{x \rightarrow 0} g(x)) = f(\lim_{x \rightarrow 0} 0) = f(0) = 0$
A: First of all, think about it. What is this question asking you?
You should expect that if $$\lim_{x \to 0}g(x) = a$$
and $$\lim_{x \to a} f(x) = c$$
then $$\lim_{x \to 0}f(g(x)) = f(\lim_{x \to 0}g(x))= c$$
because if $g(x)$ is approaching $a$, and we're evaluating $f$ at $g(x)$, then this should be the same thing as $\lim_{x \to a} f(x) = c$
This isn't always the case, however.  Let's look at the functions we're given:
$$\lim_{x \to 0} g(x) = 0$$ $$\lim_{x \to 0} f(x) = 0$$
So we see that $$\lim_{x \to 0}f(g(x)) = 0$$ but $$\lim_{x \to 0}f(g(x)) \neq f(\lim_{x \to 0}g(x))$$, because $$f(\lim_{x \to 0}g(x)) = f(0) = 1$$
In fact, it's possible for this to happen as $x \to a$ if $f$ is not continuous at $x = a$
Notice that if $f(0) = 0$, then the equality does hold, so $$\lim_{x \to 0}f(g(x)) = f(\lim_{x \to 0}g(x))$$
because $$\lim_{x \to 0}f(g(x)) = 0$$ and $$f(\lim_{x \to 0}g(x)) = f(0) = 0$$
A: If we think about it, the issue here is that $ g(\mathbb{R}) $ collapsed to $ \{ 0 \} $, making $ f \circ g $ always take value $ 1 $, even though $ f $ takes value $ 0 $ on every deleted neighborhood of $ 0 $.
Here is the right general result (I'll take $ f $ as the first function, to get a more natural notation) :
Theorem: Let $ f : A(\subseteq \mathbb{R}) \rightarrow  \mathbb{R} $, and let $ x_0 \in \mathbb{R} $ be a limit point of $ A $ [ meaning for every $ \epsilon > 0 $, there is a point of $ A $ different from $ x_0 $ in $ (x_0 - \epsilon, x_0 + \epsilon) $ ]. Say $ y_0 := \lim_{x\to x_0} f(x) $ exists, and let $ g : B(\subseteq \mathbb{R}) \rightarrow \mathbb{R} $ be such that $ y_0 $ is a limit point of $ B $ and $ f(A\backslash\{x_0\}) \subseteq B\backslash\{y_0\} $.
This gives $ A\backslash \{x_0\} \stackrel{f}{\longrightarrow} B\backslash\{y_0\} \stackrel{g}{\longrightarrow} \mathbb{R} $. Suppose $ \lim_{y\to y_0} g(y) = L $.

To summarise, $ A\backslash\{x_0\} \stackrel{f}{\longrightarrow} B\backslash\{y_0\} \stackrel{g}{\longrightarrow} \mathbb{R} $, where $ x_0 $ is a limit point of $ A $, $ y_0 $ is a limit point of $ B $, and $ \lim_{x\to x_0} f(x) = y_0 $, $ \lim_{y\to y_0} g(y) = L. $

Then $ \lim_{x\to x_0} g(f(x)) = L $.
Proof: Let $ \epsilon > 0 $.
There exists $ \delta_1 > 0 $ such that every $ y $ in $ B\backslash\{y_0\} $ with $ |y-y_0| < \delta_1 $ satisfies $ |g(y) - L| < \epsilon $.
Now there exists a $ \delta_2 > 0 $ such that for every $ x $ in $ A\backslash\{x_0\} $ with $ |x-x_0|<\delta_2$ we have $ f(x) $ is in $ B\backslash\{y_0\} $ with $ |f(x) - y_0| < \delta_1 $.
Hence for every $ x $ in $ A \backslash\{x_0\} $ with $ |x-x_0| < \delta_2 $ we have $ |g(f(x)) - L | < \epsilon $, as needed.

Note: Here $ A, B $ are arbitrary subsets of $ \mathbb{R} $ (so for instance $ A $ can be a half-open interval with an endpoint $ x_0 $, etc.)
