# The canonical form of a simple function (proof verification)

Lemma 1. Let $\{ E_i \}_{i=1}^n$ be a finite disjoint collection of measurable subsets of a set of finite measure $E$. For $1 \leq i \leq n$, let $a_i$ be a real number. $$\text{ If \varphi = \sum_{i=1}^n a_i \cdot \chi_{E_i} on E, then \int_E \varphi = \sum_{i=1}^n a_i \cdot m(E_i). }$$

Proof. The collection $\{ E_i \}_{i=1}^n$ is disjoint but the above may not be the canonical representation since the $a_i$’s may not be distinct. We must account for possible repetitions. Let $\{\lambda_1, \dotsc, \lambda_m\}$ be the distinct values taken by $\varphi$. For $1 \leq j \leq m$, set $A_j = \{ x \in E \mid \varphi(x) = \lambda_j \}$. By definition of the integral in terms of canonical representations, $$\int_E \varphi = \sum_{j=1}^m \lambda_j \cdot m(A_j).$$ For $1 \leq j \leq m$, let $I_j$ be the set of indices $i$ in $\{1, \dotsc, n\}$ for which $a_i = \lambda_j$. Then $\{1, \dotsc, n\} = \bigcup_{j=1}^m I_j$, and the union is disjoint. Moreover, by finite additivity of measure, $$\text{ m(A_j) = \sum_{i \in I_j} m(E_i) for all 1 \leq j \leq m. }$$ Therefore \begin{align*} \sum_{i=1}^n a_i \cdot m(E_i) &= \sum_{j=1}^m \left[ \sum_{i \in I_j} a_i \cdot m(E_i) \right] = \sum_{j=1}^m \lambda_j \left[ \sum_{i \in I_j} m(E_i) \right] \\ &= \sum_{j=1}^m \lambda_j \cdot m(A_j) = \int_E \varphi. \end{align*}

(Original image here.)

This is from the text by Royden. I can follow up to $\int_E \varphi = \sum_{j=1}^m \lambda_j \cdot m(A_j)$. But, I don't understand the highlighted line. Does this mean that we divide $A_j$ into $n$ dices? If it is, there are exactly $n$ numbers of $a_i$, which are equal to $\lambda_j$, so I think that it cannot make $a_i$ distinct, which is supposed to be solved in this lemma. I appreciate for any hint.

At the start of the proof Royden notes that the $a_j$ may not be distinct and that the proof needs these coefficients to be distinct to work. To achieve this, he sets $\{\lambda_1, \lambda_2 \ldots \lambda_m \}$ to be the distinct values taken from the $\{a_n\}$. So you know that $m \leq n$ and $\# \{a_1, a_2 \ldots a_n\} \geq \# \{\lambda_1, \lambda_2 \ldots \lambda_m \}$.
So, if $n \not= m$ we must have repeats (duplicates) in the $\{a_n\}$. The set $I_j$ collects duplicates together: $I_1$ contains all the indices (subscripts, in this case) of the $\{a_n\}$ where $a_j = a_1$. As a concrete example, suppose $\{a_1, a_2, a_3, a_4, a_5\} = \{2,-1,2,4,-1 \}$. Then $\{\lambda_1, \lambda_2, \lambda_3 \} = \{2, -1, 4\}$ and $I_1 = \{1,3\}, \ I_2 = \{2,5\}$ and $I_3 = \{4\}$.
You might want to draw a graph of that to see exactly how it works, but you now have a canonical decomposition using the $A_j$ and $\lambda_j$. After this Royden sums over the indices contained in the $I_j$ -- so instead of summing over all numbers from $1$ to $n$ (e.g. $\sum_{i=1}^n$) he sums over just those numbers in an $I_j$ (e.g. $\sum_{i \in I_j}$; in our example above $\sum_{i \in I_1} \equiv \sum_{i=1,3}$)