If $f$ and $g$ are continuous the limit of the composition is the composition of the limit, so the implication follows. But what if $f$ and $g$ are not continuous? There exist counter examples to the implication? Or does it follow also in this case?
2 Answers
No, not necessarily: we can abuse the fact that the definition of limit ignores the value the function may take there.
For example, take $a = l = k = 0$ and let $f,g:\mathbb R \to \mathbb R$ be as follows.
$$f(x) := 0,\qquad\text{ and}$$
$$g(x) := \begin{cases} 1 & x = 0 \\ 0 & x \neq 0\end{cases}.$$
Then:
$$\lim_{x\to 0} g(x) = \lim_{x\to 0} f(x) = 0,$$
but $g(f(x)) = 1$ for all $x \in \mathbb R$, so $\displaystyle\lim_{x \to 0} g(f(x)) = 1$, not $0$.
Claim The statement in the title holds if and only if one of the following hold:
- $g$ is continuous at $l$, or
- There is some neighbourhood of $a$ (excluding $a$) on which $f$ does not obtain the value $l$.
Proof
Case 1. Assume $g$ is continuous at $l$.
Let $\epsilon > 0$. Since $\lim_{y \to l}g(y) = k$ and $g(y) = k$ (by continuity), there exists $\delta>0$ such that
$$ 0 \boldsymbol{\leq} |y - l| < \delta \implies |g(y)-k| < \epsilon. \tag{1}$$
(Note that we can only use "$\leq$" at $\ast$ because it is continuous!)
Since $\lim_{x \to a}f(x) = l$, there exists $\eta>0$ such that
$$ 0 < |y - l| < \eta \implies |f(x)-l| < \delta. \tag{2}$$
which, combined with one, gives you the limit you want.
Case 2. Assume there is some neighbourhood of $a$ (excluding $a$) on which $f$ does not obtain $l$ at all: i.e., there exists $\tau>0$ such that
$$0<|x - a|<\tau \implies f(x) \neq l. \tag{3}$$
Then, repeating the argument for the first case:
Given $\epsilon > 0$, since $\lim_{y \to l}g(y) = k$, there exists $\delta>0$ such that
$$ 0 < |y - l| < \delta \implies |g(y)-k| < \epsilon. \tag{4}$$
(And without continuity, that's all we get.)
Since $\lim_{x \to a}f(x) = l$, there exists $\eta>0$ such that
$$ 0 < |y - l| < \eta \implies |f(x)-l| < \delta. \tag{5}.$$
But moreover, combining $(5)$ with $(3)$ gives
$$ 0 < |y - l| < \min(\eta,\tau) \implies 0 < |f(x)-l| < \delta, \tag{6}$$
which you can combine with $(4)$ to get the desired limit.
Case 3. Assume $g$ is discontinuous at $l$, and that $f$ attains the value $l$ on any (arbitrarily small) neighbourhood of $a$.
We'll use a sequence. You can prove (by contradiction — with the second assumption) that there must be a sequence of points $$(x_n)_{n=1}^∞ \to a,$$ with $x_n \neq a$ for any $n$, such that, for every $n \in \mathbb N$,
$$f(x_n) = l.$$
Consequently,
$$g(f(x_n)) = g(l),$$
and by the discontinuity of $g$ at $l$, $k \neq g(l)$.
For contradiction, assume that $fg(x) \to k$ as $x \to a$. Then (by the equivalent sequential definition of continuous limit), every sequence $(k_n)_{n=1}^\infty\to a$ with $k_n \neq a$ satisfies
$$g(f(k_n)) \to k.$$
But aha! $(x_n)_n$ is exactly an example of a sequence for which $g(f(k_n)) \not\to k$ (because it already converges to $g(l)\neq k$).
We can construct some simple functions as counter-example: Define $f:A \to B$ and $g:B \to C$ as $$f(x) = y_0 \quad \text{(constant function)}$$ and $$g(y) = z_1 \text{ if }y \neq y_0 \text{ and } g(y) = z_2 \text{ if }y = y_0.$$ Then $f(x) \to y_0$ as $x \to x_0$ (arbitrary point), and $g(y) \to z_1$ as $y \to y_0$. But $g(f(x)) \to z_2$ as $x \to x_0$.