Integral written as the integral of a measure Let $(X,\mathcal M,\mu)$ be a measure space and let $f\in L^1(X,\mu)$ be a positive function. Show that $$\int_X f \, d\mu=\int_{(0,\infty)} \mu(\{f>t\}) \, dt.$$

The quick way is to use Fubini:
$$
\begin{align}
& \int_{(0,\infty)} \mu(\{f>t\}) \, dt=\int^\infty_0 \int _X \chi _{(\{f>t\})} \, d\mu \, dt = \int_X \int^\infty_0 \chi _{(\{f>t\})} \, dt \, d\mu \\[10pt]
= {} & \int_X \int_0^{f(x)} 1 \, dt \, d\mu = \int_X f(x) \, d\mu
\end{align}
$$
but it's kind of cheating I think because Fubini is non-trivial. 
But here's one very basic way:
Define $E_{nk} = \left\{x \in X\mid f(x) > \frac{k}{2^n}\right\}$
Then set $f_n = \frac{1}{2^n} \sum_{k=1}^{4^n} \chi _{E_{nk}}$ so that 
$$\tag1\int_X f_n \, d\mu = \frac{1}{2^n} \sum_{k=1}^{4^n} \mu E_{nk}$$
Now, $f_n$ increases to $f$ so the MCT says $$\tag2\int_X f\,d\mu = \lim_{n\to\infty} \int_X f_n\,d\mu.$$
As $\left \{ x\in X\mid f(x)>t \right \} = \bigcup_{n \in \mathbb{N}} \left \{ x \in X\mid f_n(x)>t \right \}$
we have $\mu\left \{ x\in X\mid f(x)>t \right \} = \lim_{n\to\infty} \mu\left \{ x \in X\mid f_n(x)>t \right \}$  
so we may apply MCT again: 
$$\tag3\int_0^\infty \mu \left \{ x\in X\mid f(x)>t \right \} \, dt=\lim_{n\to \infty} \int_0^\infty \mu \left \{ x\in X\mid f_n(x)>t \right \} \, dt$$
Observe now that $\mu E_{nk}=\mu\left\{x \in X\mid f(x) \gt \frac{k}{2^n} \right\} = \mu \left \{ x\in X\mid f_n(x)>t\right \}$ whenever $1\leq k \leq 4^n$ and  $\frac{k-1}{2^n} < t\leq \frac{k}{2^n}$ and $0$ if $t>4^n$. 
But then this means that $$\tag4\int_0^\infty \mu \left \{ x\in X\mid f_n(x) > t\right \} \, dt = \frac{1}{2^n} \sum_{k=1}^{4^n} \mu E_{nk}$$
$(1)$ and $(4)$ give $\int_X f_n \, d\mu = \int_0^\infty \mu \left \{ x\in X\mid f_{n}(x)>t\right \} \, dt$ 
and now taking limits and invoking $(2)$ and $(3)$ give the result. 
