Solution (source code)

= Solution

An $\mathcal A$-simple function is a <measurable function> taking finitely many values, written $s=\sum_{j=1}^m a_j\mathbf1_{A_j}$ with disjoint measurable $A_j$. For nonnegative <simple functions> define $\int s\,d\mu=\sum_j a_j\mu(A_j)$, with $0\cdot\infty=0$. Refining two disjoint descriptions shows this value is independent of the description. For nonnegative measurable $h$, define
$$
\int h\,d\mu=\sup\left\{\int s\,d\mu: s\text{ simple},\ 0\le s\le h\right\}.
$$
For a real measurable $f$, put $f^+=\max(f,0)$ and $f^-=\max(-f,0)$. It is <Lebesgue integrable> when $\int|f|d\mu<\infty$, equivalently both positive and negative parts have finite integrals. Then
$$
\boxed{\int f\,d\mu=\int f^+d\mu-\int f^-d\mu}.
$$
This includes <Lebesgue integrable> signed <simple functions>, whose integral is the same finite weighted sum.