$\forall B\in\mathcal{B}\quad X^{-1}(B)=\bigcup_{i}\{A_{i}\mid x_{i}\in B\}$ Here is a claim that I came across in a book along with its proof that I couldn't follow. I need someone to explain it to me, please.

*

*$\mathcal{B}$ is Borel set.

*$\mathcal{F}=\sigma(A_{i}\mid i=1;\ldots,n)$ has only finitely many atoms

Proposition:
If $X$ is simple function over $\mathcal{F}$ then $X$ is $\mathcal{F}$-measurable. Conversely, if $X$ is $\mathcal{F}$-measurable and if $\mathcal{F}$ is atomic, then $X$ is simple function over $\mathcal{F}$.
Proof:
If $\forall i, A_i\in\mathcal{F}$, then for all $B\in\mathcal{B}$:
$$X^{-1}(B)=\bigcup_{i}\{A_{i}\mid x_{i}\in B\}\in \mathcal{F} \mbox{(because the union is finite)} $$.
I couldn't understand why :
$$\forall B\in\mathcal{B}\quad X^{-1}(B)=??\bigcup_{i}\{A_{i}\mid x_{i}\in B\} $$
my attempts:
$$\forall B\in\mathcal{B}\quad X^{-1}(B)=\{X\in \mathcal{B}\}=\{\omega\in\Omega\mid X(\omega)\in B\}=\{\omega\in\Omega\mid \sum_{i=1}^{n}x_{i}1_{A_{i}}(\omega)\in B\}$$
Even if I am right, I still can't figure out how: $$\{\omega\in\Omega\mid \sum_{i=1}^{n}x_{i}1_{A_{i}}(\omega)\in B\}=\bigcup_{i}\{A_{i}\mid x_{i}\in B\}$$
 A: Some clarifications. This is not a full answer since your question isn't fully explained, still. See the Wikipedia page on atoms in measure theory. I'm not entirely convinced that you're using the standard definition of atom, so I'll recall it here:

An atom is a measurable set $A$ (most authors take it to be of finite positive measure and so will I) such that if $B\subseteq A$ is measurable then $\mu(B)\in\{0,\mu(A)\}$.

And an atomic measure space is typically defined as one where every set of positive measure contains an atom. If the measure space is sigma-finite, this implies that the measure space has a countable partition into disjoint atoms (of finite measure) modulo a null set. This is also equivalent to being atomic.
In your case, we're dealing with something slightly different. Here, I infer that $(\Omega,\mathcal{F},\mu)$ is your measure space where there is a distinguished pairwise disjoint family $\{A_i\}_{i=1}^n\subseteq\Omega$ such that $\mathcal{F}$ is the sigma-algebra generated by the $A_i$. This space is atomic (if you take $\mu$ finite) (why?) but that isn't the definition of atomic. Now, any simple function $X:\Omega\to\Bbb R$ is clearly measurable, without us needing to suppose anything further about the measure space (I implicitly equip $\Bbb R$ with the Borel measure algebra and will dispense with $\mathcal{B}$ notation).
We want to prove that any measurable $X:\Omega\to\Bbb R$ is simple. This is very similar to the fact that any measurable function on a (finite) atom is almost everywhere constant. With regards to your proof, I have two points to make.
Point 1): The comment "Because the union is finite" is completely unnecessary; any countable union of measurable sets is measurable, by definition of sigma-algebra.
Point 2): You are quite right that: $$X^{-1}(B)=\{\omega\in\Omega:X(\omega)\in B\}$$However we know that $X^{-1}(B)$ is a measurable set, if $B$ is, since $X$ is supposed measurable. You haven't explained what the $x_i$ are... but if the  $\{A_i\}$ are taken to be disjoint, then I can help. If $X^{-1}(B)$ is nonempty, there must then be some $i$ such that $A_i\cap X^{-1}(B)\subseteq A_i$ is nonempty as $X^{-1}(B)$ is measurable. However there are, by disjointness, no measurable subsets of $A_i$ other than $\emptyset$ and $A_i$ itself. Thus, $X^{-1}(B)\cap A_i=A_i$. This is true for any $A_j$ which $X^{-1}(B)$ intersects; thus, either $X^{-1}(B)$ is empty or there are some $\{j_k\}_{k=1}^m$, $1\le m,j_k\le n$, with: $$X^{-1}(B)=\bigsqcup_{k=1}^m A_{j_k}$$I think this answers the question you intended, but it's unclear.
