Some problem of the proof about measure theory. I just have been studying real analysis from Stein and I am puzzled of some details about proof of next theorem.

Theorem.Suppose $f$ is measurable on $\mathbb{R}^n$.Then there exists a squence of step functions $\{\psi_k\}_k^{\infty}$ that converges pointwise to $f(x)$ for almost every $x$.

The roughly proof is here:
First of all,we show that if $E$ is a measurable set with finite measure ,then $f=\chi_E$ can  be approximated by step functions.To do this,we have:

*

*$\forall \epsilon >0$,we have cubes $Q_1,\cdots,Q_N$ such that $m(E\bigtriangleup \bigcup_{j=1}^{N} Q_j)<\epsilon$.


*Then ,considering the grid formed by extending teh sides of these cubes,we see that there exist almost disjoint rectangles $R'_1,\cdots,R'_M$ such that $\bigcup_{j=1}^N Q_j=\bigcup_{j=1}^M R'_j$.


*We can take rectangles $R_j$ contained in $R'_j$.Then,we find a collection of disjoint rectangles that satisfy $m(E \bigtriangleup \bigcup_{j=1}^M R_j\le 2\epsilon$.Therefore,$f(x)=\sum_{j=1}^M \chi_{R_j}(x)$,and except possibly on a set of measure $\le 2\epsilon$.
But what I have puzzled is this:
Why for every $k\geq 1$, there exists a step funcion $\psi_K(x)$such that if $E_k = \{x|f(x)\neq \psi_k(x)\}$,then $m(E_k)\le 2^{-k}$.We just know that if $f(x)$ is a characteristic function ,then $f(x)$ can be approximated by step function.But for a general measuable function , we don't know detailed situations about it ,why I can choose a step function s.t. $E_k = \{x|f(x)\neq \psi_k(x)\}$ and $m(E_k)\le 2^{-k}$.I think previous proof can't state it.
 A: The definition $E_k = \{x : f(x) \ne \psi_k(x)\}$ is still for the proof in the case when $f = \chi_E$ for some measurable set $E$. You are correct that this definition of $E_k$ (and the proof in the case $f=\chi_E$) does not directly generalize to an arbitrary measurable function $f$.
However, the point is not to directly copy-paste the same proof (for the case $f = \chi_E$) to the general case of measurable $f$. The idea is to use the previous theorem, which states that there exists a sequence $\{\varphi_k\}_k$ of simple functions that converges to $f$. Then you apply the work described in your post to each $\varphi_k$ to obtain some step function $\psi_k$ that is close to $\varphi_k$, so that the sequence $\{\psi_k\}$ also converges to $f$.
Specifically, fix $k$ and consider $\varphi_k$ which is of the form $\varphi_k = \sum_{m=1}^M a_m \chi_{E_m}$. By the work in your post, there exists a step function $\psi_{k,m}$ such that $|\psi_{k,m}-\chi_{E_m}| < \frac{1}{|a_m| km}$ pointwise almost everywhere. Then with $\psi_k := \sum_{m=1}^M a_m \psi_{k,m}$ we have $|\varphi_k - \psi_k| \le \sum_{m=1}^m \frac{|a_m|}{|a_m| km} \le \frac{1}{k}$ pointwise almost everywhere. You can define $\psi_k$ to satisfy this inequality for each $k$.
Finally, to show $\psi_k \to f$ almost everywhere, note that by the triangle inequality, $|\psi_k - f| \le \frac{1}{k} + |\varphi_k - f|$ almost everywhere, so by choosing $k$ large enough, both terms are arbitrarily small pointwise almost everywhere.
