How can I show that continuous functions are borel? We say that a function $f:\mathbb R\longrightarrow \mathbb R$ is borel if $f^{-1}(B)$ is borel for all borel $B$. So let $f:\mathbb R\longrightarrow \mathbb R$ a continuous function. How can I prove that it's borel ? I know that if $U$ is open, then $f^{-1}(U)$ is open and thus borel. If I can write every borel set as a union and intersection of open sets, then it works, but I'm not sure that it's true.
 A: Let $\mathscr M=\left \{ E\in \mathscr B(Y):f^{-1}(E)\in \mathscr B(X) \right \}$.
1). If $E\in \mathscr M$, then so is $Y\setminus E$, because $f^{-1}(Y\setminus E)=X\setminus f^{-1}(E)\in \mathscr B(X).$
2). If $E_i\in \mathscr M$ for $i\in \mathbb N$, then so is $\bigcup_iE_i$,because $f^{-1}(\bigcup_iE_i)=\bigcup_if^{-1}(E_i)\in \mathscr B(X).$
3). $\varnothing \in \mathscr M$ trivially. 
Now, 1), 2) and 3) show that $\mathscr M$ is a $\sigma-$algebra which contains the opens in $Y$, so in fact $\mathscr M=\mathscr B(Y), $ which in turn implies that $E\in \mathscr B(Y)\Rightarrow f^{-1}(E)\in \mathscr B(X).$
A: Lemma: 

Let $f:X\to Y$ and $\mathcal E\subset \mathcal P(Y)$. Then $\sigma(f^{-1}(\mathcal E))=f^{-1}(\sigma(\mathcal E))$ 



*

*$\fbox{$\subset$}$ Since $\sigma(\mathcal E)$ is a $\sigma$-algebra,  $f^{-1}(\sigma(\mathcal E))$ is a $\sigma$-algebra as well, and it's easy to check that $f^{-1}(\mathcal E)\subset f^{-1}(\sigma(\mathcal E))$. Therefore $\sigma(f^{-1}(\mathcal E))\subset f^{-1}(\sigma(\mathcal E))$.

*$\fbox{$\supset$}$ Let $\mathcal{S}=\{B\in\mathcal{P}(Y)\; ; \;f^{-1}(B)\in\sigma\left(f^{-1}\left(\mathcal{E}\right)\right)\}$. You can check that $\mathcal S$ is a $\sigma$-algebra that contains $\mathcal E$. As a result $\sigma(\mathcal E) \subset \mathcal S$, that is to say $f^{-1}(\sigma(\mathcal E))\subset \sigma\left(f^{-1}\left(\mathcal{E}\right)\right)$.

Here, $\mathcal E$ is the collection of open sets and $\sigma(\mathcal E)$ is the collection of Borel sets.
A: Hint: use the following result:

Theorem: Let $(X,\mathcal{M})$ and $(Y,\mathcal{N})$ be given. Assume $\mathcal{N}$ is generated by $\mathcal{E}$ (i.e. $\mathcal{N}=\sigma(\mathcal{E})$). If $f\colon X\rightarrow Y$ satisfies
  $$
E\text{ is in }\mathcal{E}\implies f^{-1}(E)\text{ is in }\mathcal{M},
$$
  $f$ is measurable.

For a proof, see this answer.
