# Given a collection of measurable sets $\{E_i\}_{i=1}^{\infty}$ is $f(x)=\sum\limits_{i=1}^{\infty} (1/2)^{i}\chi_{E_{i}}(x)$ measurable?

My Problem

I question this simply because the inverse image of the interval $(a,b)$ seems to admit uncountable unions:

$$f^{-1}((a,b))=\begin{cases} \bigcup\limits_\alpha T_\alpha & T_\alpha=(\bigcap\limits_{i=1}^{n_\alpha}E_{k_i})-(\bigcup\limits_{j\neq k_i}E_j) \text{ and } a<\sum\limits_{i=1}^{n_\alpha}(1/2)^{k_i}\chi_{E_{k_i}}<b\end{cases}$$

$$\text{ Where }n_\alpha \text{ can be infinite.}$$

Digging deeper it seem that it is possible (not really sure) to construct a $\sigma$-Algebra $\mathfrak{M}$, where this condition is possible.

Finding a counterexample:

(Attempt)

Let $\varphi: \mathbb{R}\to \{0,1\}^{\mathbb{N}}$ be injective. Then we construct sets $E_i=\{x\in \mathbb{R}: \varphi_i(x)=1\}$. With this let $\mathfrak{M}$ be generated by $\{E_i\}_{i=1}^{\infty}$. Then it is clear that every point $x\in \mathbb{R}$ has that: $$(\bigcap\limits_{\varphi_i(x)=1}E_i)-(\bigcup\limits_{\varphi_j(x)=0}E_j)=\{x\}$$

Clearly with a scenerio as the one above uncountable unions could make $f^{-1}((a,b))$ nonmeasurable. But I assume that something about the second condition forces the union to be measurable. I am just unsure how.

Since each $E_i$ is measurable, each function $\chi_{E_{i}}$ is measurable.
Let $f_n:=\sum_{i=1}^n\frac{1}{2^i}\chi_{E_{i}}$.
Then each $f_n$ is measurable and $f$ is the pointwise limit of the functions $f_n$.
Consequence: $f$ is measurable.