Construction of a function of a countable set of Cantor sets The following is an exercise from Bruckner's Real Analysis:

Construct a functions $ f : [ 0 , 1 ] \to [ 0 , 1 ] $ as follows. Let $ \{ I _ n \} $ be an enumeration of the open intervals in $ [ 0 , 1 ] $ having rational endpoints. For each $ n \in \mathbb N $, let $ K _ n \subset I _ n $ be a cantor set of positive Lebesgue measure such that the sequence $ \{ K _ n \} $ is pairwise disjoint and $ \sum _ { n = 1 } ^ \infty \lambda ( K _ n ) = 1 $. Define $ f _ n $ on $ K _ n $ to be continuous on $ K _ n $, nondecreasing, and such that $ f _ n ( K _ n ) = [ 0 , 1 ] $. Let
$$ f ( x ) = \begin {cases}
f _ n ( x ) \text , & \text {if } x \in K _ n \text ; \\
0 \text , & \text {if } x \in [ 0 , 1 ] \setminus \bigcup _ { n = 1 } ^ \infty K _ n \text .
\end{cases} $$
$ \ $ (a) Show that $ f $ is Lebesgue measurable.
$ \ $ (b) Show that $ f ( I ) = [ 0 , 1 ] $ for every open interval $ I \subset [ 0 , 1 ] $.
$ \ $ (c) Using the sets $ K _ n $, find continuous functions on $ [ 0 , 1 ] $ that approximate $ f $ in the Lusin sense.
$ \ $ (d) Does there exists $ g \in \mathcal B _ 1 $ such that $ g = f \ \lfloor \text {a.e.} \rfloor $?

I represent only ideas I have for each part and if I am in a right track I'll start fill the gaps and make them rigorous.
(a) $ \{ f < a \} = f ^ { - 1 } ( I \cap [ 0 , 1 ] ) $ for some $ I \subset \mathbb R $. I don't know if $ f $ is continuous but if is, then $ f ^ { - 1 } ( I \cap [ 0 , 1 ] ) = f ^ { - 1 } ( I ) \cap [ 0 , 1 ] $ is some open interval in $ [ 0 , 1 ] $ hence there are a set of disjoint intervals each containing some $ K _ n $ and $ J = \bigcup _ n K _ n $. And countable union of a sequence of $ K _ n $ is measurable. Since $ a \in \mathbb R $ was arbitrary so $ f $ is Lebesgue measurable.
(b) Each open interval $ I $ in $ [ 0 , 1 ] $ equals a disjoint union of intervals each contains some $ K _ n $ and image of each $ K _ n $ is $ [ 0 , 1 ] $ by $ f _ n $ and $ f = f _ n $ when restricted to each $ K _ n $, so $ f ( I ) = \bigcup _ { n = 1 } ^ \infty [ 0 , 1 ] = [ 0 , 1 ] $.
(c) Because $ \sum _ { n = 1 } ^ \infty \lambda ( K _ n ) = 1 < + \infty $ so there is some $ N $ such that $ \sum _ { n = N } ^ \infty \lambda ( K _ n ) = \epsilon $, and $ \bigcup _ { n = 1 } ^ \infty K _ n $ is closed with a measure differs $ 1 - \epsilon $ and $ f $ on that is continuous since it is on each $ K _ n $ and can be extend to a continuous $ g $ on $ [ 0 , 1 ] $ by Tietze extension theorem.
(d) Probably there is no Baire-1 $ g $ because there is a theorem that if $ f $ is finite a.e. and measurable on $ X $ then there exists Baire-2 $ g $ such that $ f = g $ a.e. and no similar theorem was for Baire-1 in the same book!
A detailed guidance would be much appreciated.
 A: Base: The hypothesis of the exercise:

*

*Every open interval with rational endpoints is in the enumeration $\{I_n\}$

*For every open interval $I_n$ with rational endpoints there is a Cantor set $K_n \subset I_n$  of positive Lebesgue measure.

*The sequence $\{K_n\}$  is pairwise disjoint.

*$\sum_{n=1}^\infty \lambda(K_n) =1$.

*$f_n$ is defined on $K_n$.

*$f_n$ is continuous and non-decreasing.

*$f_n(K_n)=[0,1]$
The exercise does not ask to prove that those hypothesis can be actually satisfied (they can, but it is not part of the exercise to prove it). For the exercise as stated we must assume those hypothesis.
item (a) For each $r \in \Bbb N$ define
$$g_r(x) = \left \{ \begin{array}[c,r] \;f_n(x)  & \text{, if } x \in K_n  \text{ and }  n \leq r \\
0  & \text{, if }x \in  [0,1] \setminus \bigcup_{n=1}^r K_n
\end{array} \right .$$
Since, the sequence $\{K_n\}_n$ is pairwise disjoint, it is clear that $f$ and $g_r$ are well-defined as functions. Moreover, it is clear that for all $r$, $g_r$ is Lebesgue measurable and $\{g_r\}_r$ converges pointwise to $f$. So $f$ is Lebesgue measurable.
item (b) Given any open interval $I \subseteq [0,1]$, then there is an open interval $I_s$ with rational endpoints, such that $I_s \subseteq I$. So, we have $K_s \subseteq I_s \subseteq I$. Then $[0,1] = f(K_s) \subseteq f(I)$
On the other hand, it is immediate that $f(I) \subseteq [0,1]$. So we have, $f(I)=[0,1]$.
item (c) Since, for each $r \in \Bbb N$, $K_1, \cdots K_r$ are disjoint closed sets, and, for each $n \leq r$, $f_n$ is a continuous function defined on $K_n$, there is a continuous function $h_r$ such that $h_r(x) = f_n(x)$, if $ x \in K_n $   and   $n \leq r$.
Note that  $\bigcup_{n=1}^r K_n$ is a closed set and , for all $x \in  \bigcup_{n=1}^r K_n$, we have $h_r(x) = f(x).
Since $\sum_{n=1}^\infty \lambda(K_n) =1$, we have
$$\lambda \left ([0,1] \setminus \bigcup_{n=1}^r K_n \right) = 1 - \sum_{n=1}^r \lambda(K_n) = \sum_{n=k+1}^\infty \lambda(K_n)$$
Given any $\varepsilon >0$, let $r$ be such that $\sum_{n=k+1}^\infty \lambda(K_n) < \varepsilon$.  Then  $\lambda \left ([0,1] \setminus \bigcup_{n=1}^r K_n \right) < \varepsilon$. So the continuous functions $h_r$ approximate $f$ in Lusin sense.
item (d) For all $n$, since $K_n$ is compact, let $M_n = \max K_n$  and $m_n = \min K_n$. Since, for all $x \in K_n$, $f(x) = f_n(x)$ and $f_n$ is continuous on $K_n$, non-decreasing and $f_n(K_n)=[0,1]$, we have:

*

*$f(m_n) = 0$ and $f(M_n) =1$.

*for all $\varepsilon >0$, there is $\delta >0$ such that $f([m_n, m_n+\delta)\cap K_n) \subset [0,\varepsilon)$ and $f((M_n-\delta,M_n]\cap K_n) \subseteq (1-\varepsilon,1]$.

Suppose that $g=f$ a.e..
Since $K_n$ is a Cantor set of positive measure, we have that $[m_n, m_n+\delta)\cap K_n$ and $(M_n-\delta,M_n]\cap K_n$ both have positive measure (this is a consequence of the construction Cantor sets with positive measure). So, there is $x \in [m_n, m_n+\delta)\cap K_n$ such that $g(x) =f(x) \in [0,\varepsilon)$  and there is $y \in (M_n-\delta,M_n]\cap K_n$ such that $g(y)=f(y) \in (1-\varepsilon,1]$.
So, for all $K_n$ and all $\varepsilon >0$, there are $x, y \in K_n$ such that  $g(x) \in [0,\varepsilon)$ and $g(y) \in (1-\varepsilon,1]$.
So, for all $\varepsilon >0$ and all $I\subset [0,1] $, $I$ an open interval, we have that there is at least on $K_n \subset I$ (see beginning of item (b)). So, there are $x, y \in I$ such that  $g(x) \in [0,\varepsilon)$ and $g(y) \in (1-\varepsilon,1]$.
So, $g$ is discontinuous in every point of $[0,1]$. But, Theorem 1.19 i Brucker's Book, we know that, if $g$ was Baire 1 function, then the set points where $g$ is discontinuous should be of first-category. But $[0,1]$ is not of first category. So $g$ is not a Baire 1 function.
So, we have prove that if $g=f$ a.e. then $g$ is not  a Baire 1 function.
So, the answer to item (d) is NO. There is no Baire 1 function $g$ such that $g=f$ a.e..
