We define the Riemann function $R:\Bbb R\to\Bbb Q$ by $$R(x)=\begin{cases} \frac{1}{q} &\text{if }x=\frac pq\text{ for }\ p\in\Bbb Z\setminus\{0\},\ q\in\Bbb N\setminus\{0\}\text{ and }\operatorname{gcd}(p,q)=1\\ 0&\text{if }x\in\Bbb R\setminus\Bbb Q\\ 1&\text{if }x=0\end{cases}$$
Prove that for any $a \in\Bbb R$ ,$\lim_{x\to a}R(x)=0$
I tried to solve is using the fact that the irrationals are dense in real number, but I had no idea how to write it. While searching on internet, I wonder would this idea contradicts Dirichlet function?
No. You do not need to prove or assume any such thing. Although it is absolutely true.
You need to prove that for any $a \in \mathbb R$ and any $\epsilon > 0$ that there is a $\delta$ so that 1) either $0 \not \in (a-\delta,a+\delta)$ or $a = 0$. and 2) that if there are any rational numbers (other than $0$) in $(a-\delta, a+\delta)$[$*$] they are such that their denominators are all larger than $\frac 1{\epsilon}$
That will be enough to prove it even without proving that irrationals and the rationals are mutually dense.
Hint: If $a \ne 0$ find $q$ so that $\frac jq < |a| < \frac {j+1}q$. Any rational $r$ so that $\frac jq < r <\frac {j+1}q$ will have denominators that are larger than $q$ and $R(r) < \frac 1q$. ..... So if $q > \frac 1{\epsilon}$......
=====
[$*$] Of course, there always will be rational numbers in $(a-\delta,a+\delta)$. But you don't have to prove there will be. You just have to assume there might be. As for the irrationals since $|R(x) - 0| = 0 < \epsilon$ they are trivial to deal with. You don't have to prove there will be but just demonstrate that if there are $|R(x) - 0| = 0 < \epsilon$.