$\varphi$ is integrable if and only if $f=g$ 
Let $f,g:[a,b]\to\mathbb R$ continuous functions, with $f(x)\leq g(x)$ for every $x\in[a,b]$. Define $\varphi:[a,b]\to\mathbb R$ by 
  $$
\varphi(x)=
\left\{
\begin{array}{cc}
f(x) &,\mbox{ if } x\in\mathbb Q\cap[a,b],\\
g(x) &,\mbox{ if } x\not\in\mathbb Q\cap[a,b].
\end{array}
\right.
$$
  Prove that
  $$
\tag 1
\underline{\int_a^b} \varphi(x)dx = \int_a^b f(x)dx\quad \mbox{ and }\quad \overline{\int_a^b} \varphi(x)dx = \int_a^b g(x)dx. 
$$
  Conclude that $\varphi$ is integrable if and only if $f=g$.

I already proved $(1)$ and $f=g \Longrightarrow \varphi$ integrable is obvious. I need help to prove that $\varphi$ integrable $\Longrightarrow f=g$
 A: $Q\cap [a,b]$ is a set of measure $0$.  Since $\phi (x)=g(x)$ almost everywhere, $\int_a^b\phi(x)dx=\int_a^bg(x)dx$, irrespectve of $f(x)$. 
A: If you have (1), then suppose that $\varphi$ is integrable, then upper and lower integrals should be the same number and then,
$$\int_a^b f(x)dx=\int_a^bg(x)dx$$
or qeuivalently
$$\int_a^b(g(x)-f(x))dx=0$$
But because $f(x)\le g(x)$, you have a nonnegative continuous function with zero integral. It isvery easy (by way of contradiction, for example) to see that this funcion must to be zero. Hence $f(x)-g(x)=0$.
A: If $\phi$ is integrable then $\displaystyle \int_a^b f(x) \, dx = \int_a^b g(x) \, dx$, or equivalently, $\displaystyle \int_a^b g(x) - f(x) \, dx = 0.$ If there is a single point $x_0 \in (a,b)$ with $f(x_0) < g(x_0)$, continuity gives you an $\epsilon > 0$ satisfying
$$(x_0 - \epsilon, x_0 + \epsilon) \subset (a,b)$$ and $f(x) < g(x)$ for all $x \in (x_0 - \epsilon, x_0 + \epsilon)$. Then
$$0 = \int_a^b g(x) - f(x) \, dx \ge  \int_{x_0 - \epsilon}^{x_0 + \epsilon} g(x) - f(x) \, dx > 0 $$
which is a contradiction. Thus $f(x) = g(x)$ for all $x \in (a,b)$ and by continuity, for all $x \in [a,b]$ too.
