If $f'(x) = 0$ for all $x \in \mathbb{Q}$, is $f$ constant? Let $f$ be a differentiable function on $\mathbb{R}$ such that
$$f'(x)=0,\forall x\in \mathbb Q.$$
Prove or disprove that
$$f(x)=c$$
for some constant $c$. I've heard this problem is true, but I'm not sure. Can you prove it or provide a counterexample?
Auxiliary question: I wonder the converse of it, if $f′=0$ for all irrational, can we say that $f$ is constant?
 A: It's false, you can find an answer here. (French)

The proposed function is 
  $$
g(x)= \inf\{d(x,E_k)^{1/k}: k\in \mathbb{N}\} 
$$
  where $E_k$ is the closed discrete set $\{p/2^k : p\in \mathbb{Z}\}$

A: [I use a construction given by Rooij and Schikhof in A second course on real functions, Example 13.2.]
Let $\Omega$ be the collection of all continuous functions $\omega : \mathbb{R} \to (0, + \infty)$ having the following property: for all $a<b \in \mathbb{R}$, $$ \left| \frac{1}{b-a} \int_a^b \omega(x) dx \right| \leq 4 \omega(a).$$
Let $\alpha_1,\beta_1,\alpha_2,\beta_2,\dots$ be pairwise distinct real numbers. Then the authors show that one can construct $\omega_1,\omega_2, \dots \in \Omega$ such that for each $n \in \mathbb{N}$ we have, writing $f_n:= \omega_1+ \cdots + \omega_n$:
$$f_n \leq \left( \frac{n}{n+1} \right)^2, \ \ f_n(\alpha_i) \geq \left( \frac{n-1}{n} \right)^2, \ \ f_n(\beta_i) < \frac{n}{n+1} \cdot \frac{i}{i+1}.$$
Afterward, they show that $\displaystyle F(x):= \sum\limits_{i \geq 1} \int_0^x \omega_i(t)dt$ is well-defined and differentiable with $F'(x)= \sum\limits_{i \geq 1} \omega_i(x)$. In particular, because $F'(x)= \lim\limits_{n \geq + \infty} f_n(x)$, we have $$F'(\alpha_i)=1, \ \ F'(\beta_i) \leq \frac{i}{i+1}.$$
Let $f$ denote the function given by the construction above with $\{\alpha_1,\alpha_2,\dots \}= \mathbb{Q}$ and $\{\beta_1= \sqrt{2}, \beta_2, \dots \}$. Let $g$ denote the function given by the consruction above with $\{A_1= \sqrt{2},A_2, \dots\}= \mathbb{Q} \cup \{\sqrt{2} \}$ and $\{B_1, B_2, \dots\}$.
Let $G:=f-g$. Then $G'(q)=0$ for all $q \in \mathbb{Q}$ and $G'(\sqrt{2}) \leq \frac{1}{2}-1=- \frac{1}{2} <0$. In particular, from the mean value theorem, we deduce that $G$ is not constant since its derivate does not vanish everywhere.

For your second question, it is a consequence of Darboux's theorem that a function is constant if its derivative vanishes on $\mathbb{R} \backslash \mathbb{Q}$. 
Indeed, $f'(\mathbb{R})$ has to be an interval $I$, but $f'(\mathbb{R} \backslash \mathbb{Q})= \{0\}$, so $I$ is in fact countable: necessarily, $I$ is the singleton $\{0\}$, that is $f'$ vanish everywhere. Now, it may be deduced that $f$ is constant from the mean value theorem.
