Let \(S \subset R\) be the set of discontinuities of \(f\text{,}\) that is, \(S = \bigl\{ x \in R : o(f,x) > 0 \bigr\}\text{.}\) Suppose \(S\) is a measure zero set: \(m^*(S) = 0\text{.}\) The trick to proving that \(f\) is integrable is to isolate the bad set into a small set of subrectangles of a partition. A partition has finitely many subrectangles, so we need compactness. If \(S\) were closed, then it would be compact and we could cover it by finitely many small rectangles. Unfortunately, \(S\) itself is not closed in general, but the following set is. Given \(\epsilon > 0\text{,}\) define
\begin{equation*}
S_\epsilon \coloneqq \bigl\{ x \in R : o(f,x) \geq \epsilon \bigr\} .
\end{equation*}
By
Proposition 10.4.2,
\(S_\epsilon\) is closed, and as it is also a subset of the bounded
\(R\text{,}\) \(S_\epsilon\) is compact. Moreover,
\(S_\epsilon \subset S\) and
\(S\) is of measure zero, so
\(S_\epsilon\) is of measure zero. Via
Proposition 10.3.7, finitely many open rectangles
\(O_1,O_2,\ldots,O_k\) cover
\(S_\epsilon\) and
\(\sum_{j=1}^\infty V(O_j) < \epsilon\text{.}\)
The set \(T \coloneqq R \setminus ( O_1 \cup \cdots \cup O_k )\) is closed, bounded, and so compact. As \(o(f,x) < \epsilon\) for all \(x \in T\text{,}\) for each \(x \in T\text{,}\) there is a \(\delta > 0\) such that \(o(f,x,\delta) < \epsilon\text{,}\) so there exists a small closed rectangle \(T_x \subset B(x,\delta)\) with \(x\) in the interior of \(T_x\text{,}\) such that
\begin{equation*}
\sup_{y\in T_x} f(y) - \inf_{y\in T_x} f(y) < \epsilon.
\end{equation*}
The interiors of the rectangles
\(T_x\) cover
\(T\text{.}\) As
\(T\) is compact, finitely many such rectangles
\(T_1, T_2, \ldots, T_m\) cover
\(T\text{.}\) Construct a partition
\(P\) out of the endpoints of the rectangles
\(T_1,T_2,\ldots,T_m\) and
\(O_1,O_2,\ldots,O_k\) (ignoring those that are outside the endpoints of
\(R\)). The subrectangles
\(R_1,R_2,\ldots,R_p\) of
\(P\) are such that every
\(R_j\) is contained in
\(T_\ell\) for some
\(\ell\) or the closure of
\(O_\ell\) for some
\(\ell\text{.}\) Order the rectangles so that
\(R_1,R_2,\ldots,R_q\) are those that are contained in some
\(T_\ell\text{,}\) and
\(R_{q+1},R_{q+2},\ldots,R_{p}\) are the rest. See
Figure 10.12. So
\begin{equation*}
\sum_{j=1}^q V(R_j) \leq V(R)
\qquad \text{and} \qquad
\sum_{j=q+1}^p V(R_j)
\leq
\sum_{\ell=1}^k V(O_\ell)
< \epsilon .
\end{equation*}
The second estimate holds because the \(R_j\) that are subsets of \(\widebar{O}_\ell\) give a partition of \(\widebar{O}_\ell\) and hence their volumes sum to \(V(O_\ell)\text{.}\) Let \(m_j\) and \(M_j\) be the inf and sup of \(f\) over \(R_j\) as usual. If \(R_j \subset T_\ell\) for some \(\ell\text{,}\) then \(M_j-m_j < \epsilon\text{.}\) Let \(B \in \R\) be such that \(\sabs{f(x)} \leq B\) for all \(x \in R\text{,}\) so \(M_j-m_j \leq 2B\) over all rectangles. Then
\begin{equation*}
\begin{split}
U(P,f)-L(P,f)
& =
\sum_{j=1}^p (M_j-m_j) V(R_j)
\\
& =
\left(
\sum_{j=1}^q (M_j-m_j) V(R_j)
\right)
+
\left(
\sum_{j=q+1}^p (M_j-m_j) V(R_j)
\right)
\\
& <
\left(
\sum_{j=1}^q \epsilon\, V(R_j)
\right)
+
\left(
\sum_{j=q+1}^p 2 B\, V(R_j)
\right)
\\
& <
\epsilon\, V(R)
+
2B \epsilon = \epsilon \bigl(V(R)+2B\bigr) .
\end{split}
\end{equation*}
We can make the right-hand side as small as we want, and hence \(f\) is integrable.
For the other direction, suppose \(f\) is Riemann integrable on \(R\text{.}\) Let \(S\) be the set of discontinuities of \(f\) again. Consider the sequence of sets
\begin{equation*}
S_{1/k} = \bigl\{ x \in R : o(f,x) \geq \nicefrac{1}{k} \bigr\}.
\end{equation*}
Fix a \(k \in \N\text{.}\) Given an \(\epsilon > 0\text{,}\) find a partition \(P\) with subrectangles \(R_1,R_2,\ldots,R_p\) such that
\begin{equation*}
U(P,f)-L(P,f) =
\sum_{j=1}^p (M_j-m_j) V(R_j)
< \epsilon .
\end{equation*}
Suppose \(R_1,R_2,\ldots,R_p\) are ordered so that the interiors of \(R_1,R_2,\ldots,R_{q}\) intersect \(S_{1/k}\text{,}\) while the interiors of \(R_{q+1},R_{q+2},\ldots,R_p\) are disjoint from \(S_{1/k}\text{.}\) Let \(R_j^\circ\) denote the interior of \(R_j\text{.}\) Suppose \(j \leq q\) and consider \(x \in R_j^\circ \cap S_{1/k}\text{.}\) Let \(\delta > 0\) be small enough so that \(B(x,\delta) \subset R_j\text{.}\) As \(x \in S_{1/k}\text{,}\) we get \(o(f,x,\delta) \geq o(f,x) \geq \nicefrac{1}{k}\text{,}\) which, along with \(B(x,\delta) \subset R_j\text{,}\) implies \(M_j-m_j \geq \nicefrac{1}{k}\text{.}\) Then
\begin{equation*}
\epsilon >
\sum_{j=1}^p (M_j-m_j) V(R_j)
\geq
\sum_{j=1}^q (M_j-m_j) V(R_j)
\geq
\frac{1}{k}
\sum_{j=1}^q V(R_j) .
\end{equation*}
In other words,
\(\sum_{j=1}^q V(R_j) < k \epsilon\text{.}\) Let
\(G\) be the set of all boundaries of all the subrectangles of
\(P\text{.}\) The set
\(G\) is of measure zero (it can be covered by finitely many sets from
Example 10.3.5). We find
\begin{equation*}
S_{1/k} \subset R_1^\circ \cup R_2^\circ \cup \cdots \cup R_q^\circ \cup G .
\end{equation*}
As \(G\) can also be covered by open rectangles arbitrarily small volume, \(S_{1/k}\) must be of measure zero. As
\begin{equation*}
S = \bigcup_{k=1}^\infty S_{1/k}
\end{equation*}
and a countable union of measure zero sets is of measure zero, \(S\) is of measure zero.