Problem to apply composite function limit theorem Let there be functions $$f(x)=x, if\ \ x\in \mathbb{Q},$$ $$f(x)=0, if\ \ x\not\in \mathbb{Q}$$ and $$g(x)=1,if\ \ x\neq 0,$$ $$g(x)=0,if\ \  x=0.$$ Consequently, $$g(f(x))=1, if \ \ x\in \mathbb{Q}\setminus \{0\}\ \  and \ \ g(f(x))=0, if\ \ x\in(\mathbb{R}\setminus\mathbb{Q})\cup\{0\}.$$  Also, $\displaystyle\lim_{x\to 0} f(x)=0$, $\displaystyle\lim_{x\to 0} g(x)=1$ and $f(x)\neq 0,$ near to $0$. However, $\displaystyle\lim_{x\to 0} g(f(x))$ does not exist. In other words, composite functions limit theorem is not true. What happend? Which of the theorem conditions isn't working? Am I doing something wrong? Thanks
I remind that Composite function limit theorem says: Let there be $f\colon A\to \mathbb{R}$, $g\colon B\to \mathbb{R}$, with $f(A)\subseteq B$, $x_0$ is a limit point of A, $u_0$ is a limit point of $B$ and $f(x)\neq u_0$, for all $x$ near on $x_0$. If $\displaystyle\lim_{x\to x_0}f(x)=u_0$ and $\displaystyle\lim_{y\to u_0} g(y)=k\in \mathbb{R}$, then $\displaystyle\lim_{x\to x_0} g(f(x))=k$.
 A: This example doesn’t satisfy the hypotheses in the theorem you provided. In particular, the part that says

…and $f(x)\neq u_0$, for all $x$ near on $x_0$.

In your example, $x_0=u_0=0$, $k=1$. The problem is that it is not true that $f(x)\neq 0$ in a neighbourhood of $0$. Thus, this is not a counterexample to the theorem you wrote.
A: Your "composite function" limit theorem is probably $(1)$, which is immediate from the sequence-based characterisation of continuity, i.e. $(2)$ below. Your function $f$ is nowhere continuous except at $0$ and $g$ is nowhere continuous (and you can verify this using $(1)$). Moreover, your claim that $\displaystyle\lim_{x\to 0} g(x)=1$ is incorrect (otherwise, $g$ would be continuous at $0$!). Hence, you are not in the conditions of $(1)$ and you cannot apply this result.
$(1)$: Let $g$ be continuous at $a$ and assume $f(x)\stackrel{x \to a}{\to} L$ for some $L \in \mathbb{R}$. Then $g(f(x))\stackrel{x \to a}{\to} g(L)$
$(2)$: Let $g$ be continuous at $L$. Then for any sequence $x_n$ with $x_n \to L$, $g(x_n) \to g(L)$
A: You just discovered the subtility between the two different definitions of the limit. Your function $g$ does not go to $0$ at $0$ with this definition of the limit :
$$
f(x) \underset{x \rightarrow x_0}{\longrightarrow} \ell \Longleftrightarrow \left( \forall \epsilon > 0,~~\exists \delta > 0,~~\forall x \in \mathbb R,~~|x-x_0| < \delta \Longrightarrow |f(x)-\ell| < \epsilon\right)
$$
because it is here required that $g(0) = 0$. With your definition of the limit
$$
f(x) \underset{x \rightarrow x_0}{\longrightarrow} \ell \Longleftrightarrow \left( \forall \epsilon > 0,~~\exists \delta > 0,~~\forall x \in \mathbb R,~~0 < |x-x_0| < \delta \Longrightarrow |f(x)-\ell| < \epsilon\right)
$$
you don't ask anything for the value of $f(x_0)$. For more details Wikipedia.
