Lebesgue function as countable sum I was reading this old question:
Prove that every Lebesgue measurable function is equal almost everywhere to a Borel measurable function
I've found out a solution by myself,but I can't undestand an answer that an user gave.
The answer is in 2 steps.
The first step claims that every non-negative lebesgue function can be written as countable sum of terms $\chi_{A_n}  \alpha_n$, with $A_n$ lebesgue measurable set.
I think that's false, it looks strange. Can anyone help me to clarify this?
 A: This is just a reformulation of something you find in any book on measure theory:


If $f\ge0$ is measurable then there is a sequence of non-negative simple functions $\phi_n$ increasing to $f$.


Indeed, saying $\phi_n\to f$ is the same as $$f=\phi_1+(\phi_2-\phi_1)+\dots.$$
For each fixed $n$, the function $\phi_{n+1}-\phi_n$ is a non-negative simple function, so it is a finite sum $$\phi_{n+1}-\phi_n=\sum\alpha_j\chi_{E_j},$$with $\alpha_j\ge0$.
A: Let me show a slightly different approach, that uses base $2$. For simplicity, I will only consider $f$ with $0\leq f\leq1$. This is no hurdle, since $$
f=\sum_{n=1}^\infty [n+f_n]\,1_{\{n-1\leq f\leq n\}},
$$
where $f_n=f-n$ satisfies $0\leq f_n\leq 1$. 
For $0\leq f\leq 1$, then we have
$$
f=\sum_{n=1}^\infty 2^{-n}\,1_{\{2^nf\in E_n\}}^\vphantom{E}=\sum_{n=1}^\infty 2^{-n}\,1_{f^{-1}(2^{-n}E_n)},
$$
where $$ E_n=\bigcup_{n=1}^\infty [2n-1,2n)
$$
Basically, the sets $E_n$ are used to detect if the $n^{\rm th}$ binary digit is 1 (for that, we use the "odd" intervals). 
