Prove that $f(x)=\begin{cases}1& \text{if x is rational},\\0 &\text{if x is irrational}\end{cases}$ is discontinuous at every real number. Let $f:\Bbb{R}\to \Bbb{R}$ be defined by
$$f(x)=\begin{cases}1& \text{if x is rational},\\0 &\text{if x is irrational.}\end{cases}$$
Prove that $f$ is discontinuous at every real number. I realize that if $x_0\in\Bbb{R} $, then every neighborhood of $x_0$ contains rational points (at which $f(x)=1$) and contains irrational points (at which $f(x)=0$). I see that the existence of $\lim\limits_{x\to x_0}f(x)$ is also in question. From here, I don't know how to proceed. Can anyone help me out? 
 A: 
Main idea: Choose any arbitrary $c\in\Bbb{R}$ and then show that the function $f$ is discontinuous at $c$. What we shall do is- we
  shall try  find a sequence $\{a_n\}$ in $\Bbb{R}$ converging to $c$,
  but the sequence $\{f(a_n)\}$ does not converge to $f(c)$. But to do
  this, we need to consider two cases- either $c\in\Bbb{Q}$ or
  $c\notin\Bbb{Q}$. So, let us proceed...


CASE $1$:  $c\in\Bbb{Q}$
Let us define a sequence $\{a_n\}$ by $a_n:=c-{\sqrt 2 \over n}\:\forall n\in\Bbb{N}$
It is easy to see that, $a_n\in\Bbb{R}\backslash\Bbb{Q}\:\:\forall n\in\Bbb{N}$ and hence $f(a_n)=0\:\forall n\in\Bbb{N}$ $\implies \lim_{n\to\infty}f(a_n)=0\ne1=f(c)$
Again, $\lim_{n\to\infty}a_n=\lim_{n\to\infty}(c-{\sqrt 2 \over n})=c$
Thus, we get a sequence $\{a_n\}$, which converges to c, but the sequence $\{f(a_n)\}$ does not converge to $f(c)$. So, we are done for $c\in\Bbb{Q}$.
CASE $2$:  $c\in\Bbb{R}\backslash\Bbb{Q}$
Now, since $\Bbb{Q}$ is dense in $\Bbb{R}$, we can get a sequence $\{a_n\}$ of rational numbers which converges to $c$. Thus $\lim f(a_n)=1\ne 0=f(c)$. So, we are done for $c\in\Bbb{R}\backslash\Bbb{Q}$ also.
Thus, we get for any $c\in\Bbb{R}$, $f$ is discontinuous at $c$.
Since $c\in\Bbb{R}$ is arbitrary, $f$ is discontinuous $\forall c\in\Bbb{R}$ i.e. $f$ is discontinuous on the whole real line.
N.B. This type of function is known as Dirichlet Function which is nowhere continuous. 
A: $\Bbb Q$ is dense in $\Bbb R$ so for $x_0$ being irrational we have  a sequence of rational terms $(a_n)$ convergent to $x_0$. Now if $f$ is continuous at $x_0$ then
$$1=\lim_{n\to\infty}f(a_n)=f(x_0)=0$$
which is a contradiction. Same reasoning for $x_0$ being rational and by using that $\Bbb R\setminus \Bbb Q$ is also dense in $\Bbb R$.
A: Just for a different take on this problem: 
A function ${\displaystyle f:X\rightarrow Y}$ is continuous at a point ${\displaystyle x\in X}$ if and only if ${\displaystyle f^{-1}(V)}$ is a neighborhood of $x$ for every neighborhood $V$ of ${\displaystyle f(x)}$ in $Y$.
Take any arbitrary point $x\in \mathbb{R}$ and consider a neighborhood of $f(x)$. Consider the neighborhood $V_1=(.5,1.5)$ or the neighborhood $V_2=(-.5,.5)$. We know that $f(x)$ is in one of those open sets. But then $f^{-1}(V)$ is not a neighborhood at all. $f^{-1}(V_1)$ are only rational values and  $f^{-1}(V_2)$ are only irrational values. Neither of these could be a neighborhood in the reals because every open ball in the reals contains both rational and irrational values. 
