Random Variable and Simple Function Measurability Problem: As I've mentioned before, I am studying Probability and Measure Theory on my own, and I am using Resnick as the main text. I've been working through Ch. 3 on random variables, measurable maps, etc. and am somewhat stuck on one of the exercises.
Suppose we have a space $\Omega$ and a countable partition: {$B_n, n\geq 1$} of that space. Next, we define the sigma field $\mathcal{B}=\sigma(B_n,n\geq 1)$.
We are asked to show that a function $X:\Omega\rightarrow (-\infty,\infty]$ is $\mathcal{B}$-measurable iff it is of the form:
$\sum_{i=1}^\infty c_i 1_{B_i}$, for constants {$c_i$}.
Understanding/Attempt at a solution:
If I understand the problem (a large, but variable "if"), we need to prove that a random variable is measurable iff it can be expressed as a simple function, because simple functions are measurable. So, in effect, the random variable can only take values that correspond to some combination of disjoint sets that partition the space?
In my attempt, I start with $B_i \in \mathcal{B}$ and show that $X(\omega)=1_{B_i}(\omega)$ is measurable because $\varnothing, B_i^c, \Omega \in \mathcal{B}$.
I am not sure what to do next, although it seems like I should be trying to show that the inverse image of (c,$\infty$] under X should be a union of elements of $\mathcal{B}$.
Even then, it only feels like I am addressing the "if" part, and I'm not sure what to do with the "only if" part of the exercise.
As always, thank you for any help you can provide!
 A: Let's work through this in pieces. Since you've shown your work and are doing this for self-study, I'm going to be overly verbose in the interest of being explicit and complete (hopefully).
What does $\mathcal B$ look like?
Since $\{B_n\}$ is a countable partition then we know intersections are empty, hence in $\sigma(B_n,n \geq 1)$, and by closure under countable unions, we know that for each $I \subset \mathbb N$, $\bigcup_{i \in I} B_i$ must also be in the $\sigma$-algebra. So a good first guess might be to look at the system
$$
\mathcal F := \big\{ \bigcup_{i \in I} B_i: I \subset \mathbb N \big\} \>.
$$
Clearly $\mathcal F \subset \mathcal B$ as described above. Check the axioms to see that $\mathcal F$ is, itself, a $\sigma$-algebra and conclude that $\mathcal F = \mathcal B$.
$X$ is a random variable.
Suppose $\newcommand{\o}{\omega} X(\o) = \sum_n c_n 1_{B_n}(\o)$. Then, since $\o$ is in exactly one $B_n$, $X$ has (at most) countable range and we can check measurability by looking at the sets $\{\o:X(\o) = x\}$. But,
$$
\{\o:X(\o) = x\} = \bigcup_n \{B_n : c_n = x\} \in \mathcal B \>.
$$
Thus, $X$ is a random variable.
All random variables look like $X$.
Suppose $X$ is a random variable measurable with respect to $\mathcal B$.
The key is to work with the "right" sets. For each $B_n$, choose an $\o_n \in B_n$ and set $x_n = X(\o_n)$. Then $X^{-1}(\{x_n\})$ is measurable since $\{x_n\} \in \mathcal B(\mathbb R)$. But, this implies that there exists $I \subset \mathbb N$ such that
$$
X^{-1}(\{x_n\}) = \bigcup_{i \in I} B_i \>.
$$
Since $X(\o_n) = x_n$, we have that $B_n \subset \bigcup_{i \in I} B_i$ and so for all $\o \in B_n$, $X(\o) = X(\o_n) = x_n$. In other words, $X$ is constant on each $B_n$.
There are only countably many $B_n$, so $X$ can take at most a countable number of values. Let these (distinct) values be $a_1, a_2,\ldots$ and take $A_n = X^{-1}(\{a_n\})$. Then, $A_n$ are disjoint, partition $\Omega$ and are composed of the union of sets $B_n$ such that each such union is pairwise disjoint. For example, for $n \neq m$,
$$
A_n := X^{-1}(\{a_n\}) = \bigcup_{i \in I_n} B_i \>,
$$
and
$$
A_m := X^{-1}(\{a_m\}) = \bigcup_{i \in I_m} B_i \>,
$$
and $I_n \bigcap I_m = \varnothing$.
Now we have enough to explicitly construct $X$. For a given $I_n$, set $c_i = a_n$ for all $i \in I_n$. Then, $X = \sum_i c_i 1_{B_i}$ as desired.
Side note: Resnick is a quite good book, particularly for self-study. However, be aware that there are a nonnegligible number of exercises that appear in chapters for which the necessary theory to solve them has not yet been introduced or developed. (I'm not speaking of this particular exercise, though.)
A: *

*As you noticed, $x\mapsto \mathbf 1_{B_j}(x)$ is measurable for each $j$ and so is $x\mapsto c_j\mathbf 1_{B_j}(x)$. A sum for measurable functions is measurable hence $x\mapsto \sum_{j=1}^nc_j\mathbf 1_{B_j}(x)$ is measurable. To get that $x\mapsto \sum_{i=1}^{+\infty}c_i\mathbf 1_{B_i}(x)$ is measurable, just use the fact that a simple limit of measurable functions is measurable. 

*To see the converse take $j_0\in \Bbb N$ and $x\in B_{j_0}$ (assuming that $B_{j_0}\neq \emptyset$, otherwise just put $c_{j_0}=0$). We have that $x\in X^{-1}(\{X(x)\})$ and the latest set is $\mathcal B$-measurable and non-empty. You can characterize the elements of $\mathcal B$: it consists of the unions of the form $\bigcup_{j\in J}B_j$, where $J\subset \Bbb N$. Hence $X^{-1}(\{X(x)\})\supset B_{j_0}$ and $X$ has the same value on $B_{j_0}$. 

