Let $(\Omega, \mathcal{F}, \mathbb{P})$ be a probability space, let $E$ be a countable subset of $\mathbb{R}$, let $f$ be a bounded function on $E$, and let $X:\Omega \to \mathbb{R}$ be a random variable with $X(\Omega) \subset E$.
Is it true that the function $f \circ X: \Omega \to \mathbb{R}$ is a random variable (on the given probability space)?
Naturally, if $E$ were a finite set, this would certainly be true; but I'm having trouble proving this (or coming up with a counterexample) in this case.
Let's see... If $B$ is a Borel subset of $\mathbb{R}$, then $f^{-1}(B)$ is a countable (possibly finite) subset of $E$ (which is a subset of $\mathbb{R}$). Obviously, I'd like to now say that $f^{-1}(B)$ must be a Borel subset of $\mathbb{R}$, so that I could conclude that $X^{-1}(f^{-1}(B)) \in \mathcal{F}$, but I don't see any reason why that should necessarily be the case. Presumably the boundedness of $f$ could play some role here, but I'm not seeing how that helps either...
For any Borel set $A$ note that $f^{-1}(A)$ is a countable set (since it is contained in $E$). Hence $f^{-1}(A)$ is a Borel set. (Any countable set is Borel). It follows that $X^{-1} (f^{-1}(A))$ is in $\mathcal F$ so $f\circ X$ is a random variable.