Lebesgue criterion for Riemann-integrability and Heine-Borel Theorem I am looking at a proof for the Lebesgue criterion for Riemann-integrability.

Definition:
Let $osc(f,M):=\sup \limits_{x \in M} f(x) - \inf \limits_{x \in M} f(x)$ denote the oscillation of $f$ on the set $M$ and
$\sigma(f,M,x):=\inf \limits_{r>0} osc(f,M \cap B_r(x))=\lim_{r \to
> 0+} osc(f,M \cap B_r(x))$  denote the oscillation of $f$ at a point
$x \in M$.

In the proof $f: Z \to \mathbb{R}, Z \subset \mathbb{R}^n$ and $Z(\epsilon):=\{x \in Z:\sigma(f,Z,x) \geq \epsilon\}$ and I have already proven that it is compact.

Proof extract:
Let $Z(\epsilon)$ have content zero for all $\epsilon>0$. Thus, for a
given $\epsilon>0$ there exist finitely many cells whose interiors
cover $Z(\epsilon)$ and have content less than $\epsilon$. This means
we can construct a partition $P=\{Z_{\alpha},\alpha \in A\}$ of $Z$
that can be split into two disjoint classes $\{Z_{\alpha}\}_{\alpha
> \in A'}$ and $\{Z_{\alpha}\}_{\alpha \in A''}$ such that
$$Z_{\alpha} \cap Z(\epsilon)=\emptyset \quad \text{for} \quad \alpha \in A' \quad \text{and} \quad Z(\epsilon) \subset \left[\bigcup_{\alpha \in A''} \mathring Z_{\alpha}\right], \sum \limits_{\alpha \in A''} |Z_{\alpha}|<\epsilon.$$
Since $\sigma(f,Z,x)<\epsilon$ for $\alpha \in A'$, we can assume without loss of generality that
$$osc(f,Z_{\alpha})<\epsilon \quad \text{for all} \quad \alpha \in A'.$$
Note that the Heine-Borel Theorem ensures that, if needed, we can
always find a refinement of the partition $P$ that satisfies the
property.

Now my question is why the Heine-Borel Theorem ensures that we can find such a partition? I think that we only need that a compact set is bounded. A proof would go like this.
Proof idea:
To shows that $osc(f,Z_{\alpha})<\epsilon$ for all $\alpha \in A'$ we can simply let $x \in Z_\alpha, \alpha \in A'$. Then $\sigma(f,Z,x)<\epsilon$, so there is an $r_1$ such that $osc(f,Z \cap B_{r_1}(x))<\epsilon$. In addition, since $Z_{\alpha}$ is compact, there exists $r_2$ such that $Z_{\alpha} \subset Z \cap B_{r_2}(x)$.
Now if $r_2<r_1$, then
$osc(f,Z_{\alpha})=osc(f,Z \cap Z_{\alpha}) \leq osc(f,Z \cap B_{r_2}(x)) \leq osc(f,Z \cap B_{r_1}(x))<\epsilon.$
Otherwise we can refine the partition until $r_2<r_1$ holds.
Am I on the right track here?
Thanks a lot!
 A: To fix ideas, assume that $f$ is defined on $[a,b]$ and it bounded.
Assume that the set of discontinuities $D$ has no content, that is, has Lebesgue measure zero (except for the  notion of measure zero which appears in many Calculus books, no further measure theory needed)
In your notation, let
$$Z(\varepsilon)=\{x\in[a,b]: \sigma_f(x)\geq\varepsilon\}$$
where
$$\sigma_f(x)=\lim_{\delta\searrow 0}\big(\sup\{f(z)-f(y):x,y\in B(x;\delta)\cap[a,b]\}\big)$$.
The set of discontinuities $D$ of $f$ can be written as
$$
D=\bigcup_k Z\big(\frac{1}{k}\big)$$
The OP claims that he has proven that $Z(\varepsilon)$ is compact.
This is true and we will used this fact.

*

*Here once instance where  Heine-Borel theorem maybe applied:

Since $D$ has measure zero, so does each  $Z(1/k)$ since $Z(1/k)\subset D$. Thus, for each $k$, there exists a countable collection of open intervals covering $Z(1/k)$ whose lengths add up to less than $\frac1k$. Since $Z(1/k)$ is compact, a finite collection of such open intervals cover $Z(1/k)$ and still the sum of lengths of the intervals on the sub collections add up to something less than $\frac1k$. Let $A_k$ be the union of the open intervals in the finite collection.

*

*Here is how partitions that satisfy the Darboux condition may be obtained using Heine-Borel's theorem.

The set $[a,b]\setminus A_k$ is the union of a finite collection of pairwise disjoint closed subintervals of $[a,b]$.

Lemma: If  $\sigma_f(x)<\varepsilon$ for all $x\in[c,d]\subset[a,b]$, then exists $\delta>0$ such that $\operatorname{osc}(f,T)<\epsilon$ for all $T\subset[c,d]$ with $\operatorname{diam}(T)<\delta$.
}
Here is a short proof and another instance where Heine-Borel may be applied.
Let $x\in [c,d]$. Since $\sigma_f(x)<\varepsilon$, there is $\delta_x>0$ such that $\operatorname{osc}(f,B(x;\delta_x)\cap[c,d])<\varepsilon$. The collection of all
$B(x;\delta_x/2)$ forms an open cover of $[c,d]$. By compactness, there are $x_1,\ldots,x_k$ with $[c,d]\subset\cup^k_{j=1}B(x_j;\delta_j/2)$. Let
$\delta=\min\{\delta_j/2\}$. If $T\subset[c,d]$ with
$\text{diam}(T)<\delta$, then  is fully contained in at least one
$B(x_j;\delta_j)$ so $\operatorname{osc}_f(T)<\epsilon$.

With this Lemma at hand, we have that each of the closed subintervals of which $[a,b]\setminus A_k$ is made of can be further split in subsets of length at most $\delta_k$ ($\varepsilon=\frac{1}{k}$) so that on each subinterval of the subdivision $\operatorname{osc}$ is less than $\frac1k$. The set of endpoints  of all this resulting subintervals, along with the endpoints of the open subintervals that cover $Z(1/k)$ and of which $A_k$ is made of form a partition $\mathcal{P}_k$ of $[a,b]$.

*

*Here is an estimation of the Darboux sums:

Suppose $P$ is a partition of $[a,b]$ that is finer than $\mathcal{P}_k$. Then the Darboux sum can be split as
$$
U(P,f)-L(P,f)=\sum^n_{j=1}(M_jf-m_jf)\Delta x_j  = S_1+ S_j
$$
where
$S_1$ contains terms corresponding to subintervals that contain points in $Z(1/k)$, and $S_2$ contained terms corresponding to the remaining terms. Notice that  a term is in $S_2$ iff the corresponding subinterval is fully contained in $[a,b]\setminus A_k$.
For $S_1$ we have
$$
S_1\leq \frac{M-m}{k}
$$
where $M=\sup_{x\in[a,b]}f(x)$ and $m=\inf_{x\in[a,b]}f(x)$.
For $S_2$ we have
$$
S_2\leq \frac{b-a}{k}
$$
Putting this together,
$$
U(P,f)-L(P,f)\leq \frac{M-m+b-a}{k}
$$
The conclusion (that is, integrability of $f$ over $[a,b]$) follows by taking $k$ large enough.
