I need help proving the following fact. Let $(X,\textbf{X})$ be a measurable space. Then $f:X \to \mathbb{R}$ is X-measurable iff $f^{-1}(E) \in \textbf{X}$, $\forall E \in \textbf{B}$.
Defns and notations: $X$ is a set, X is a $\sigma$-algebra of subsets of $X$, $f^{-1}(E):=\{x \in X: f(x) \in E \}$, B is the $\sigma$-algebra of subsets of $\mathbb{R}$ generated by open intervals $(a,b)$. $f$ is X-measurable means $f^{-1}( \alpha, \infty) \in \textbf{X}$, $\forall \alpha \in \mathbb{R}$.
What I have: "$\leftarrow$" is easy since $( \alpha, \infty) \in \textbf{B}$. I'm struggling with the formal way to argue "$\to$". Informally, I know the preimage $f^{-1}(E)$ is well-behaved wrt the operations of unions, intersections, complements, etc:
$$f^{-1}(\cup_{i=1}^\infty E_i)=\cup_{i=1}^\infty f^{-1}(E_i), f^{-1}(E^c)=(f^{-1}(E))^c$$ Thus, since everything in B is generated by those operations starting from open intervals $(a,b)$, we should have that, starting from sets of the form $f^{-1}(a,b)$ and applying the same operations, we "stay" in X.
Sorry I'm new to measure theory and still trying to pick up how proofs of this nature are done.