TITLE: Correcting the set in my proof.
QUESTION [5 upvotes]: The question was:
Find $\int_{[0, \pi/2]} f$ if  $$f(x) = \begin{cases} 
      \sin{x}, & if  \cos(x) \in \mathbb{Q}, \\
      \sin^2{x}, &  if \cos(x) \not\in \mathbb{Q}.
   \end{cases}$$
My answer was:
Assume that $0 \leq x \leq \pi/2$, then taking the cosine of this, we get $\cos 0 \geq \cos x \geq \cos (\pi/2),$ so, $1 \geq \cos (x) \geq 0$ (because $\cos (x)$ is a decreasing function in this interval.)\
Now, by monotonicity of measure $$m\{x \in [0, \pi/2] \mid \cos(x)\in \mathbb Q\} \subseteq m\{[0, \pi/2] \cap  \mathbb{Q}\}.$$
But,$m\{[0, \pi/2] \cap  \mathbb{Q}\} = 0.$\
This is because $\mathbb{Q}$ is countable and hence its measure is 0 and $\{[0, \pi/2] \cap  \mathbb{Q}\} \subset \mathbb{Q}$, then by monotonicity of measure $m\{[0, \pi/2] \cap  \mathbb{Q}\} = 0.$\ 
And since the integral of  each integrable function $f$ on a set of measure equal to $0$ is $0$, we have:\
$\int_{[0, \pi/2]} f = \int_{[0, \pi/2] \cap  \mathbb{Q}} f + \int_{[0, \pi/2] \cap  \mathbb{Q}^c} f = 0 + \int_{[0, \pi/2] \cap  \mathbb{Q}^c} f = \int_{[0, \pi/2] \cap  \mathbb{Q}^c}  \sin^2{x}  = \int_{[0, \pi/2] \cap  \mathbb{Q}}  \sin^2{x} + \int_{[0, \pi/2] \cap  \mathbb{Q}^c}  \sin^2{x} dx = \int_{[0, \pi/2]}  \sin^2{x} dx,$\
Where in the last equality we have changed the Lebesgue integral over  $[0, \pi/2]$ into Riemann integral over $[0, \pi/2]$ because our function $\sin^2{x}$ is Riemann integrable and bounded by $[0,1]$ and the domain of integration is closed and bounded interval then by \textbf{ Theorem 3, on page 73} the Lebesgue integral is the Riemann integral.\
Now we can compute this integral:\
$$\int_0^{\pi/2}f(x)\,\mathrm d x=\int_0^{\pi/2}\sin^2(x)\,\mathrm d x = \int_0^{\pi/2} \{ \frac{1 - \cos{2x}}{2} \} d x = \frac{\pi}{4} - ( \frac{1}{4} \times 0) = \frac{\pi}{4}. $$ 
But it turns out that:
My justification in this step:
$$m\{x \in [0, \pi/2] \mid \cos(x)\in \mathbb Q\} \subseteq m\{[0, \pi/2] \cap  \mathbb{Q}\}.$$ was wrong, could anyone help me correct this step please?

REPLY [2 votes]: Expanding a little on my comment...We need to show that we can ignore the $\cos x \in \Bbb{Q}$ case and just integrate $\sin^2$. Moreover, this is true when integrating over any subset $J \subseteq \Bbb{R}$, not just $J = [0, \pi/2]$.
I claim that $X = \{x \in J: \cos x \in \Bbb{Q} \}$ is countable. If this is true, then $X$ has measure zero, and deleting that case in the definition of $f$ does not change the integral of $f$, as required.
We can assume $J = \Bbb{R}$ since this gives us the largest $X$. Note that for any $y \in \Bbb{R}$, if we define $C_y$ as $\{x \in \Bbb{R}: \cos x = y\}$, then $C_y$ is countable (look at the way horizontal lines meet the cosine graph). $X$ is just $\bigcup_{y \in \Bbb{Q}} C_y$, so it's a countable union of countable sets. So $X$ is countable, as required.