A function continuous on all irrational points

That is discontinuous at all rational points is the easy part.

Let $x\not\in \mathbb Q, \ \epsilon>0$ and consider the sets $$U_1=\left\{y\in[0,1]:f(y)<\epsilon\right\}\text{ and }U_2=\{y\in[0,1]:f(y)\geq\epsilon\}.$$ To show that $f$ is continuous at $x$ we have to show that $U_1$ contains an interval $(x-\delta,x+\delta)$ for sufficiently small $\delta$.

Note that $U_2\subset \mathbb Q$ and that $\dfrac mn\in U_2\iff n\leq \dfrac1\epsilon$. Also for a fixed $n\in\mathbb N, \dfrac mn\in[0,1]\iff m\in\{0, 1, 2, \ldots, n\}$. Therefore $U_2$ is finite.

Since $U_1\cup U_2=[0,1], \ U_1\cap U_2=\emptyset, \ x\in U_1$and $U_2$ is finite it follows that for some $\delta>0$, $U_2$ and $(x-\delta,x+\delta)$ are disjoint and therefore $ (x-\delta,x+\delta)\subseteq U_1$ This means that $f$ is continuous at $x$.


So you need to know that for any irrational $x$, any sufficiently good rational approximation has sufficiently large denominator. That is, fix an $N >0$, then we can find an $\epsilon_N >0$ so that whenever $|q-x|<\epsilon_N$, $q=\frac{a}{b}$ with $b>N$. I haven't done much but slightly rewrite the definition of continuity. Why is it that good rational approximations of irrational numbers have large denominators? It basically comes down to the division algorithm. Look at all the multiples of $\frac{1}{2}$. Our $x$ misses them, so we can put some small ball $\epsilon_1$ around $x$ so it misses all of the multiples of $\frac{1}{2}$. Here I'm implicitly using the division algorithm. Now look at multiples of $\frac{1}{3}$, $x$ misses all of them, so there is an $\epsilon_2$ such that....

Use this idea to write a formal proof.