TITLE: Does there exist a real valued function $f$ such that $\lim_{x\rightarrow q} f(x) = \infty$ for all $q\in\mathbb{Q}$
QUESTION [6 upvotes]: Does there exist a real valued function $f$ such that $\lim_{x\rightarrow q} f(x)
 = \infty$ for all $q\in\mathbb{Q}$?

My answer is no. If $f$ exists, then let us define
$$g(x) = \left\{ 
  \begin{array}{l l}
     \frac{1}{1+|f(x)|} & \quad \text{if } x\in \mathbb{Q}^c\\
     0 & \quad \text{if } x\in \mathbb{Q}\\
   \end{array} \right. \\$$
and we see $g$ is continuous only on rational numbers, which is a contradicts the fact that the set of continuity points is a $G_\delta$ set. 
Is my solution correct? And do you guys know if there is any good direct argument?

REPLY [5 votes]: Your argument is fine. Here is a direct way to show that the function does not exist:
So suppose the map exists and define
$$ A_n=\{ x\in \Bbb{R} : \exists \delta_x>0 : 0<|u-x|<\delta_x \Rightarrow f(u)>n \}.$$
Then $A_n$ is open and dense (since it contains all the rationnals).
Define now:
$$ B_n=\{ x\in \Bbb{R} : \exists \epsilon_x>0 : |u-x|<\epsilon_x \Rightarrow f(u)>n\} .$$
$B_n$ is also open. And in fact also dense. To see this note that when $x\in A_n$ then $(x-\delta_x,x)$ and $(x,x+\delta_x)$ are subsets of $B_n$. So the closure of $B_n$ contains $A_n$ which was dense.
Now, by Baire the intersection of $B_n$ is non-empty. But for every $y\in \cap_n B_n$ we have $f(y)>n$ for all $n$ so $f(y)=+\infty$ and the map was not real-valued in the first place.