Question About Proof On Integrability of a function I am confused on the answer given for the question part (a) Let $I = [0 , 1]$; let $Q = I \times I$. Define $f: Q \to \mathbb{R}$ by letting $f(x , y) = 1 /q$ if y is rational and $x = p/q$.
For the part "For the first sum, there are at most 4 subrectangles  including points where (,)=1/⩾1/N", it does not make sense that there are 4m subrectangles max as An only puts a restriction on x, not y. So technically y can be divided finer than N and there can be much more than 4m subrectangles. 
 A: The argument in that answer remains valid with some clarification. The choice of $4m$ can be replaced with $2m$ and the partition $P$ can be formed from subrectangles of unit length in the $y-$direction.  
To prove integrability, we only need to show that for any $\epsilon > 0$ there exists a partition $P$ of $[0,1]^2$ such that $U(P,f) - L(P,f) < \epsilon$.  It was shown in the linked answer that for every partition $P$ we have $L(P,f) = 0$.  Thus, it remains to show there is a partition for which $U(P,f) < \epsilon$.
Again, choose an integer $N$ such that $1/N < \epsilon/2$ and let $m$ denote the number of elements in the (finite) set $$A_N = \{x \in \mathbb{Q} \cap [0,1]: x = p/q, (p,q) = 1, q \leqslant N \}$$
Take a partition $Q = (x_0,x_1,\ldots,x_n)$ of the interval $[0,1]$ where $\|Q\| = \max_{1 \leqslant j \leqslant n}(x_j - x_{j-1}) < \frac{\epsilon}{4m}.$
Now form a partition $P$ of the rectangle $[0,1]^2$ where the subrectangles are $R_j = [x_{j-1},x_j]\times [0,1]$ for $j = 1, 2, \ldots, n$ and note that the volumes of subrectangles are bounded as 
$$v(R_j) \leqslant \|P\| < \frac{\epsilon}{4m}\cdot 1 = \frac{\epsilon}{4m}$$
With $M_j = \sup_{(x,y) \in R_j} f(x,y)$, the upper sum can be written as 
$$U(P,f) = \sum_{R_j\cap A_N \neq \emptyset}M_j \, v(R_j) + \sum_{R_j\cap A_N= \emptyset}M_j \, v(R_j) $$
Note that there are at most $2m $ rectangles contributing to the first sum and  $M_j$ is always bounded above by $1$. Thus, 
$$ \sum_{R_j\cap A_N \neq \emptyset}M_j \, v(R_j) < 2m \cdot 1 \cdot \|Q\| = \frac{\epsilon}{2} $$
In the second sum where $R_j \cap A_N = \emptyset$, points of the form $(p/q,y) \in R_j$ where $y$ is rational must have $q > N$ and $f(x,y) = 1/q < 1/N < \epsilon/2$
Thus,
$$\sum_{R_j\cap A_N = \emptyset}M_j \, v(R_j) < \frac{\epsilon}{2} \sum_{R_j\cap A_N = \emptyset} \, v(R_j) < \frac{\epsilon}{2},$$
and $U(P,f) < \epsilon$.
