Problem 3.04 Let $f:A \longrightarrow \mathbb{R}$ and let $P$ the partition of $A$. Show that $f$ is integrable if and only if each subrectangle $S$ the function $f|_S$ is integrable and that in this case $\int_A f = \sum_S \int_S f|_S$.
My attempt:
$(\Longrightarrow)$
If $f$ is integrable, then for each $\epsilon > 0$, exists a partition $P$ of $A$ such that $U(f,P) - L(f,P) < \epsilon$ by the lemma 3.1 on the Spivak's book. Let be $P'$ a refinement of partition $P$ of $A$ such that $P'$ is a partition for a subrectangle $S$ of $A$, so $U(f,P') - L(f,P') \leq U(f,P) - L(f,P) < \epsilon$ and follows that $f|_S$ is integrable on $A$.
$(\Longleftarrow)$
Let $P$ a partition of $A$. If $f|_S$ is integrable on $A$ for each subrectangle of $A$, then $U(f,P) - L(f,P) = \sum_S [U(f|_S,P) - L(f|_S,P)] < \sum_S \delta = \delta \sum_S 1$ for an $\delta$ arbitrary. Since the number of subrectangles of a partition of $A$ is finite, $\sum_S 1 := K \in \mathbb{R}$. Defining $\delta := \frac{\epsilon}{K}$, where $\epsilon$ is arbitrary, we have $U(f,P) - L(f,P) < \epsilon$, then $\int_A f$ is integrable. By the hypothesis that $f|_S$ is integrable on $A$ for each subrectangle $S$ of $A$, $L(f,P) = \sum_S L(f|_S,P)$ and $L(f,P) = \sum_S L(f|_S,P)$, we have
$$L(f,P) = \sum_S L(f|_S,P) \leq \sum_S \sup_P L(f|_S,P) = \sum_S \inf_P U(f|_S,P) \leq \sum_S U(f|_S,P) = U(f,P)$$
Since $f$ is integrable on $A$, $\sup_P L(f,P) = \sum_S \sup_P L(f|_S,P)$ and $\inf_P U(f,P) = \sum_S \inf_P U(f|_S,P)$, then $\int_A f = \sup_P L(f,P) = \sum_S \sup_P L(f|_S,P) = \sum_S \int_S f|_S$. $\square$
I would like to know if my attempt it's correct. Thanks in advance!