Piecewise constant integral is independent of partitions I'm trying to prove the following proposition (from T.Tao's Analysis 1 book):
Let $I$ be a bounded interval, $f\colon I\to\mathbb{R}$ function piecewise constant with respect to both P and P' partitions of $I\Rightarrow p.c.\int_{[P]}f=p.c.\int_{[P']}f$ 
(where $\int_{[P]}f:=\sum_{J\in P}c_J |J|$, $c_J$ constant value $f$ assumes on each subinterval $J$ of $I$ (this is the meaning of piecewise constant);
a partition P of a bounded interval $I$ is a set of bounded intervals contained in $I$ such that every $x\in I$ lies in exactly one of the bounded intervals $J$ in P; 
P#P'$:=\{K\cap J:K\in $ P, J$\in$ P'$\}$)
Now, the book says to use the fact that $|I|=\sum_{J\in P}|J|$ to show that both integrals are equal to $p.c. \int_{[P\#P']}f$ so I did $\int_{[P]}f:=\sum_{J\in P}c_J |J|\overset{*}{=}\sum_{J\in P}(c_J \sum_{\{H\in P\#P':H\subset J\}}|H|)\overset{**}{=}\sum_{J\in P}(\sum_{\{H\in P\#P':H\subset J\}}c_H|H|)$ but I'm stuck here.
(*it's easy to see that $\{H\in$ P#P'; $H\subset J\}$ is a partition of each $J\in P$; 
** the subscript $c_J$ can be changed to $c_H$ since $f$ constant on $J\Rightarrow f$ constant with value $c_J$ on $H$ since $H\subset J$)
Any hints?
 A: Take $P=\left \{ a,x_1,\cdots, x_{n-2},b\right \}$ and $P'=\left \{ a,x'_1,\cdots, x'_{m-2},b\right \}$ be two partitions of $I=[a,b]$ and let $A_i=(x_{i-1},x_i]; 0\le i\le n$ where $a=x_0$ and $b=x_{n-1}$ and $B_j=(x_{j-1},x_j]; 0\le j\le m$ where $a=x_0$ and $b=x_{m-1}.$
Then, there are $\left \{ \alpha_i \right \}_i$ and $\left \{ \beta_j \right \}_j$ such that $f(x)=\sum_{i=0}^n \alpha_i \chi(A_i)=\sum_{i=0}^m \beta_j \chi(B_j).$
Now note that $\bigcup_{i,j} A_i\cap B_j=\bigcup_i A_i=\bigcup_j B_j=I$ are disjoint unions,  and that $\alpha_i=\beta_j$ on $A_i\cap B_j, $ so that 
$\int_I f=\sum_{i=0}^n \alpha_i |A_i|=\sum_{i=0}^n \alpha_i |A_i\cap I|=\sum_{i=0}^n \alpha_i |A_i\cap \bigcup_jB_j|=\sum_{i=0}^n\alpha_i(\sum_{j=0}^m|A_i\cap B_j|)=\sum_{i=0}^n\sum_{j=0}^m\alpha_i|A_i\cap B_j|=\sum_{i=0}^n\sum_{j=0}^m\beta_j|A_i\cap B_j|= \sum_{j=0}^m\sum_{i=0}^n\beta_j|A_i\cap B_j|=\\\sum_{j=0}^m\beta_j|\bigcup_i A_i\cap B_j|=\sum_{j=0}^m\beta_j|I\cap B_j|=\sum_{j=0}^m\beta_j|B_j|.$
A: First, we have $\mathrm{p.c.}\int_{[\mathbf{P}]}f = \sum_{J\in \mathbf{P}}c_{J}|J| = \sum_{J\in \mathbf{P}-\{\phi\}}c_{J}|J|$ since $|\phi| = 0$ so WLOG we may assume that both $\mathbf{P}$ and $\mathbf{P}\#\mathbf{P'}$ do not contain the empty set. For each $J\in\mathbf{P}$ let 
$$H_{J}:=\{H\in \mathbf{P}\#\mathbf{P'}: H\subseteq J\}$$
Claim: $J\neq J'$ iff $H_{J}\cap H_{J'}=\phi$.
This is clear since if $J\neq J'$ then $J\cap J'= \phi$.
Claim: $\cup_{J\in\mathbf{P}}H_{J} = \mathbf{P}\#\mathbf{P'}$
Let $H\in \mathbf{P}\#\mathbf{P'}$ then by definition $H = J\cap K$ for some  $J\in\mathbf{P}$ and $K\in\mathbf{P'}$. Since $J\cap K\subseteq J$ we have $H\in H_{J}$ and so $\mathbf{P}\#\mathbf{P'}\subseteq\cup_{J\in\mathbf{P}}H_{J}$. The other inclusion is clear.
Claim: $H_{J}$ is a partition of $J$.
$H_{J}$ is a finite set since $H_{J}\subseteq \mathbf{P}\#\mathbf{P'}$ and $\mathbf{P}\#\mathbf{P'}$ is finite. The members of $H_{J}$ are also the members of $\mathbf{P}\#\mathbf{P'}$ and are therefore mutually disjoint. So we need to show $\cup H_{J} = J$. Let $x\in J\subseteq I$ then since $\mathbf{P}\#\mathbf{P'}$ is a partition of $I$ there exists $H\in \mathbf{P}\#\mathbf{P'}$ such that $x\in H$. By the second claim, there exists $J'\in \mathbf{P}$ such that $H\in H_{J'}$. By the first claim $J'=J$ so $J\subseteq\cup H_{J}$. The other inclusion is clear.
Using the first and second claims we may write
$$\mathrm{p.c.}\int_{[\mathbf{P}\#\mathbf{P'}]}f = \sum_{H\in \cup_{J\in\mathbf{P}}H_{J}}c_{H}|H| = \sum_{J\in\mathbf{P}}\sum_{H\in H_{J}}c_{H}|H|$$
For each term in the inner sum $c_{H} = c_{J}$ since $H\subseteq J$ so we may pull out the constant value $c_{J}$ from the inner sum. Finally since $H_{J}$ is a partition of $J$ we have $\sum_{H\in H_{J}}|H| = |J|$ which completes the proof.
A: Proposition (Piecewise Constant Integrals are Independent of Partition): Let $I$ be a bounded interval, and let $f:I\to{\mathbb{R}}$ be a function. Suppose $\textbf{P}$ and $\textbf{P}'$ are two partitions of $I$ such that $f$ is piecewise constant with respect to $\textbf{P}$ and $\textbf{P}'$. Then $p.c.\int_{[\textbf{P}]}f=p.c.\int_{[\textbf{P}']}f$.
$\textit{Proof}$: It will suffice to show that
$$\sum_{J\in{\textbf{P}}}c_J|J|=\sum_{K\in{\textbf{P#P}'}}c_K|K|$$
Since by symmetry ($\textbf{P#P}'=\textbf{P}'\textbf{#P}$) we would have
$$\sum_{J\in{\textbf{P}'}}c_J|J|=\sum_{K\in{\textbf{P#P}'}}c_K|K|$$
from which the result would then follow from the transitivity of equality. First a lemma which will be needed later: let $J'\in{\textbf{P}}$ be arbitrary. We claim that:
$$c_{J'}|J'|=\sum_{K\in{\textbf{P#P}'}:K\subseteq{J'}}c_K|K|$$
To prove this, we note that the $c_K$ can be taken out of the summation since it is the same for each bounded interval in the set ${\{K\in{\textbf{P#P}'}:K\subseteq{J'}\}}$ (and in fact is just equal to $c_{J'}$). Then we note that $\{K\in{\textbf{P#P}'}:K\subseteq{J'}\}$ forms a partition of the bounded interval $J'$, so by Theorem $11.1.13$, the claim follows. Now to prove the main claim, we will induct on the cardinality $n$ of the finite partition $\textbf{P}$, using a strategy similar to what was employed in the proof of Theorem $11.1.13$. For each $n\in{\mathbb{N}}$, we define $P(n)$ to be the property that whenever $I'$ is a bounded interval and $g:I'\to{\mathbb{R}}$ is a function which is piecewise constant with respect to two partitions $\textbf{X},\textbf{Y}$ of $I'$ such that $\#\textbf{X}=n$ that we have
$$\sum_{J\in{\textbf{X}}}c_J|J|=\sum_{K\in{\textbf{Y}}}c_K|K|$$
where $c_J$ is the constant value of $g$ on $J$ for each $J\in{\textbf{X}}$ and $c_K$ is the constant value of $g$ on $K$ for each $K\in{\textbf{Y}}$. When $n=0$, then $\textbf{X}=\emptyset$, so $I'$ is also empty, so any partition of $I'$ (in particular the partition $\textbf{Y}$) can only contain the empty set or a point and the claim is trivial. Now assume the inductive hypothesis $P(n)$ for some $n\geq{0}$. Let $I$ be a bounded interval and $f:I\to{\mathbb{R}}$ be a function which is piecewise constant with respect to two partitions $\textbf{P}$ and $\textbf{P}'$ of $I$ such that $\#\textbf{P}=n+1$. We first note that $f$ is also piecewise constant with respect to the common refinement $\textbf{P#P}'$ since it is a finer partition of $I$ than $\textbf{P}$. From the proof of Theorem $11.1.13$ we see that if $I$ were the empty set or a point, then any partition of $I$ could only contain the empty set or points, and the claim would be trivial without even needing induction. So suppose $I$ is a non-degenerate bounded interval. But again from the proof of Theorem $11.1.13$, we see that it is always possible to find a bounded interval $J'\in{\textbf{P}}$ (as $\textbf{P}$ is non-empty) such that $I\setminus{J'}$ is still a bounded interval and that $\textbf{P}\setminus{\{J'\}}$ is still a partition of $I\setminus{J'}$. Finally, note that the set $(\textbf{P#P}')\setminus{\{K\in{\textbf{P#P}}':K\subseteq{J'}\}}$ forms a partition of $I\setminus{J'}$ as well. We can then make the following identifications with the earlier notation: $I'=I\setminus{J'}$, $g=f|_{I\setminus{J'}}$, $\textbf{X}=\textbf{P}\setminus{\{J'\}}$, $\textbf{Y}=(\textbf{P#P}')\setminus{\{K\in{\textbf{P#P}}':K\subseteq{J'}\}}$. In particular, once one verifies that $f|_{I\setminus{J'}}$ is still piecewise constant with respect to $\textbf{P}\setminus{\{J'\}}$ and $(\textbf{P#P}')\setminus{\{K\in{\textbf{P#P}}':K\subseteq{J'}\}}$, one can safely apply the induction hypothesis to obtain:
$$\sum_{J\in{\textbf{P}\setminus{\{J'\}}}}c_J|J|=\sum_{K\in{\textbf{P#P}'}:K\not\subseteq{J'}}c_K|K|$$
Using the earlier lemma, we obtain:
$$\left(\sum_{J\in{\textbf{P}\setminus{\{J'\}}}}c_J|J|\right)+c_{J'}|J'|=\sum_{K\in{\textbf{P#P}'}:K\not\subseteq{J'}}c_K|K|+\sum_{K\in{\textbf{P#P}'}:K\subseteq{J'}}c_K|K|$$
Finally, using the laws of summation over finite sets, and rewriting $c_{J'}|J'|$ as $\sum_{J\in{\{J'\}}}c_J|J|$, the result follows.
