$\Omega$ be a set $(A_n)_{n \in \mathbb{N}}$ $\mathcal{A}:= \left\{\bigcup_{i \in I} A_i : I \subseteq \mathbb{N} \right\}$ a sigma algebra.
How can I show that a measurable function $f: (\Omega, \mathcal{A}) \to (\mathbb{R}, \mathcal{B}(\mathbb{R}))$ is constant on each $A_n$?
I know that since $f$ is measurable, we have $f^{-1}(\mathcal{B}) \subset \mathcal{A}$. Then I tried to come up with a contradiction. I assumed that $f$ is not constant, meaning that $\exists a,b \in A_n$ such that $f(a) \neq f(b).$ I think that both $f(a)$ and $f(b)$ are elements of $\mathcal{B}(\mathbb{R})$ since they're just points, so open, and the Borel-Algebra contains all open sets. I'm stuck here.
Can anyone help?
 A: Remark that $f$ is $\mathcal A-\mathcal B(\mathbb R)-$measurable if and only if $$\forall \omega \in \Omega , f^{-1}(\{f(\omega )\})\cap A_i\in \{A_i,\varnothing \}.$$
Suppose that $f$ is not constant on some $A_i$, i.e. there are $a,b\in A_i$ s.t. $f(a)\neq f(b)$. In particular, $f^{-1}(\{f(a)\})\cap A_i\subsetneq A_i$, and thus, $f^{-1}(\{f(a)\})\notin \mathcal A$.

Edit
a set $S$ is $\mathcal A-$measurable if and only if there is a sequence $\{i_n\}_{n\in\mathbb N}\subset \mathbb N$ s.t. $S=\bigcup_{n=1}^\infty A_{i_n}$. Since $\{f(\omega )\}$ is a Borel set for all $\omega \in \Omega $, if $f^{-1}(\{f(\omega )\})\notin \mathcal A$ for at least one $\omega \in \Omega $, then your function won't be measurable. Now, you'll have that $f^{-1}(\{f(\omega )\})\cap A_i$ is either included in $A_i$ or empty. So, if $f^{-1}(\{f(\omega )\})\cap A_i$ is not in $\{A_i,\varnothing \}$ for at least one $\omega $ and one $i$, then $f^{-1}(\{f(\omega )\})$ won't be measurable, and thus $f$ won't be measurable either.
