let $f : [0,1]^2\rightarrow \mathbb{R}$ be defined by setting $f(x, y) = 0$ if $y \neq x$, and $f(x, y) = 1$ if $y = x$. Show that $f$ is integrable You have tried the following way: Give $\varepsilon>0$,  Take any partition P, $0=t_0<t_1<...<t_n=1$ of $[0,1]$ so $U(P,f)-L(P,f)=\sum_{i=1}^{n}(M_i-m_i)\Delta t_i$ And like  $M_i=1$ for any $i$ an $m_i=0$ for any $i$ then $U(P,f)-L(P,f)=\sum_{i=1}^{n}\Delta t_i$, so $U(P,f)-L(P,f)=1-0<\varepsilon$, Is it well?
 A: Consider a tagged partition $P \equiv x_{i,j}= (\frac{i}{n},\frac{j}{n})$ with $0 \le i \le n$ and $0 \le j \le n$ where $n \in \mathbb N$ and $t_{i,j} \in (x_{i,j},x_{i+1,j}) \times (x_{i+1,j},x_{i+1,j+1})$ for $0 \le i \le n-1$ and $0 \le j \le n-1$.
Then you can prove that
$$0 \le \sum_{0 \le i \le n-1, 0 \le j \le n-1} f(t_{i,j})(x_{i+1,j}-x_{i,j})(x_{i,j+1}-x_{i,j}) \le \frac{1}{n}$$ by considering the cases where $i = j$ or $i \neq j$.
Based on that, you can conclude that $f$ is Riemann integrable.
A: Don't forget you are integrating on a square, not a line. Integrating on the $ n$ squares where the function doesn't vanish, $U(P,f)-L(P,f)=n (\Delta t) ^2 = \Delta t$ so take $\Delta t < \epsilon $. 
Update:
Divide $[0,1]\times [0,1]$ in $n^2$ squares of size $\Delta t =\frac 1n$. Each square has area $ (\Delta t) ^2$.
In the $n$ squares of the diagonal, the minimum value of $f$ is $0$ and the maximum is $1$, so this $n$ squares add $n (\Delta t) ^2$ to the value of $U(P,f)$ and $0$ to the value of $L(P,f)$. The remaining squares add $0$ to both because $f$ is zero on them. So for this partition, $L(P,f)=0$ and $U(P,f)=n (\Delta t) ^2=\frac 1 {\Delta t} (\Delta t) ^2 = \Delta t$.
Now for any $\epsilon >0$ you can take $n>\frac 1{\epsilon}$ and conclude that $U(P,f)=\Delta t = \frac 1n < \epsilon$. So $\inf U(P,f) \leq 0$ and we already know a partition for which $L(P,f)=0$, proving that $f$ is integrable, with zero integral, and without need of considering more partitions. 
For an intuitive point of view, the set $\{(x,y)\in [0,1]^2: x=y \}$ is too small (has no area), and so $f$ is too similar to the zero function. Therefore it's integrable, and the integral is zero. More precisely, that set has zero measure and the function is, from a measure theory point if view, equivalent to the zero function. 
