Approximation of measurable function via simple functions [Proof] Let's denote by $\mathfrak{M}$ the set of all measurable subsets of $\mathbb{R}^d$. I mean the Lebesgue measure.
Definition: Let $\{E_k\}_{k=1}^{N}\in\mathfrak{M}$ with $m(E_k)<\infty$ then the function of the form $\varphi(x)=\sum \limits_{k=1}^{N}a_k\chi_{E_K}(x)$ is called simple function.
Theorem: Let $f:X\to [0,+\infty]$ is measurable function, then there exist the sequence of real-valued simple functions $\{s_n(x)\}_{n=1}^{\infty}$ on $X$ such that $0\leq s_1\leq s_2\leq \dots\leq f$ and $s_n\to f$ pointwise.
This is the theorem from Stein Shakarchi's book but I have found the following proof (not from the book).
Honestly to say two moments of the proof are quite not precise.
1) Note that we can write the function $\phi_n(x)$ in the following form $$\phi_n(x)=\sum \limits_{k=0}^{n2^n-1}\frac{k}{2^n}\chi_{\left[\frac{k}{2^n},\frac{k+1}{2^n}\right)}(x)+n\chi_{[n,+\infty)}(x)$$ But this function is not simple simple since the interval $[n,+\infty)$ has infinite measure.
2) When we compose any function on the left with simple function, namely $\phi_n\circ f(x)$ we get the following function $$\phi_n\circ f(x)=\sum \limits_{k=0}^{n2^n-1}\frac{k}{2^n}\chi_{f^{-1}\left[\frac{k}{2^n},\frac{k+1}{2^n}\right)}(x)+n\chi_{f^{-1}[n,+\infty)}(x),$$ since $f$ is measurable then we know that each set $f^{-1}\left[\frac{k}{2^n},\frac{k+1}{2^n}\right)$ and $f^{-1}[n,+\infty)$ is measurable but why their measure is finite?


Different authors use different definitions for simple functions, for example, Rudin defines
$s$ to be simple if its range is finite. So, $1_{[n,\infty)}$ is simple in Rudin's world.
If you use the finite measure (and finite range) definition then try
$s'_n(x) = \phi_n(f(x)) \cdot 1_{[-n,n]^d}(x)$. Then $s_n'$ has the same properties
as $s_n$ except that you lose uniform convergence on sets on which $f$ is bounded.
