Prove that $\displaystyle\sum_{i=1}^m a_i\mu(A_i)=\sum_{\varepsilon, \delta}f_{\varepsilon \delta} \mu(A_\varepsilon \cap B_\delta) $ Suppose a simple function $f$ has two representations $f=\displaystyle\sum^m_{i=1}a_i \textbf{1}_{B_k}$. For $\varepsilon=(\varepsilon_1,...,\varepsilon_m)\in \{0,1\}^m$, define $A_\varepsilon=A^{\varepsilon_1}\cap A^{\varepsilon_2}...A^{\varepsilon_m}$ where $A_k^0=A_k^{\complement}$ and $A_k^1=A_k$. Define similarly $B_\delta $ for $\delta\in \{0,1\}^n$. Set $f_{\varepsilon \delta}=\displaystyle\sum_{k=1}^m \varepsilon_ka_k$ if $A_\varepsilon \cap B_\delta \ne \emptyset$ and $f_{\varepsilon \delta}=0 $ otherwise. Prove that for any measure $\mu$
$$\displaystyle\sum_{i=1}^m a_i\mu(A_i)=\displaystyle\sum_{\varepsilon, \delta}f_{\varepsilon \delta} \mu(A_\varepsilon \cap B_\delta) \ \ \ \ \ \ (*)$$ and deduce that 
$$\displaystyle\sum_{i=1}^m a_i\mu(A_i)=\displaystyle\sum_{j=1}^n b_i\mu(B_j)$$
I can understand the RHS of $(*)$,but I have no idea how to prove the equality. I tried to expand all the terms, but it was terrible. 
 A: The question at its current format is not that very clear to me. I think the hint might be useful in any case.
Big Hint
First of all see that for a given $B_1,\dots,B_n$, $B_\delta$'s are disjoint sets covering the whole space for all $\delta\in\{0,1\}^n$. This means that for each set $B_i=\cup_{\delta,\delta_i=1}B_\delta$, which means:
$$
\mathbf 1_{B_i}=\sum_{\delta}\delta_i\mathbf 1_{B_\delta}.
$$
As a consequence:
$$
\sum_{i=1}^n b_i\mathbf 1_{B_i}=\sum_{i=1}^n b_i \sum_{\delta}\delta_i\mathbf 1_{B_\delta}=\sum_{\delta}(\sum_{i=1}^n b_i \delta_i)\mathbf 1_{B_\delta}\\
=\sum_{\delta}(\sum_{i=1}^n b_i \delta_i)\mathbf 1_{B_\delta}=\sum_\delta f_{b\delta}\mathbf 1_{B_\delta},
$$
where $f_{b\delta}=\sum_{i=1}^n b_i \delta_i$. Hence: 

$$
\sum_{i=1}^n b_i\mathbf 1_{B_i}=\sum_\delta f_{b\delta}\mathbf 1_{B_\delta}.
$$

Now using the disjointness of $B_\delta$'s, we have
$$
\mathbf 1_{A}=\sum_{\delta}\mathbf 1_{A\cap B_\delta}=\sum_{\delta}\mathbf 1_{A}\mathbf 1_{B_\delta}.
$$
and therefore
$$
\sum_{i=1}^m a_i\mathbf 1_{A_i}=\sum_{\epsilon}f_{a\epsilon}\mathbf 1_{A_\epsilon}=\sum_{\delta,\epsilon}f_{a\epsilon}\sum_{\delta}\mathbf 1_{A_\epsilon\cap B_\delta}\\
=\sum_{\delta,\epsilon}f_{a\epsilon}\mathbf 1_{A_\epsilon\cap B_\delta}.
$$
Hence:

$$
\sum_{i=1}^m a_i\mathbf 1_{A_i}=\sum_{\delta,\epsilon}f_{a\epsilon}\mathbf 1_{A_\epsilon\cap B_\delta}.
$$

and 

$$
\sum_{i=1}^m a_i\mu({A_i})=\sum_{\delta,\epsilon}f_{a\epsilon}\mu({A_\epsilon\cap B_\delta}).
$$

