Continuous functions measurable in metric spaces?

Let $(X,d)$ and $(Y,d')$ be metric spaces.

A function $f:X \to Y$ is continuous if $\forall x \in X \forall \epsilon>0 \exists \delta>0: \forall y \in Y d(x,y)<\delta \implies d'(f(x),f(y))<\epsilon$

A function $f:X \to Y$ is measurable if $\forall S \in \mathcal{Y}: f^{-1}(S) \in \mathcal{X}$, where $\mathcal{X}$ and $\mathcal{Y}$ are generated by the open sets.

If $f:X \to Y$ is continuous, is $f$ measurable?

What changes if we generate $\mathcal{X}$ and $\mathcal{Y}$ by the open balls instead of the open sets?

One might think that all continuous functions are measurable. However, this statement depends on the precise definition of continuous and measurable (see e.g. Example of a continuous function that is not measurable).

• The fourth comment (Daniel Fischer's) on that question sums up the situation pretty well. – Omnomnomnom Jun 2 '17 at 21:15
• The "Borel $\sigma$-algebra" is the measure generated by open balls (actually it's usually defined as being generated by open rectangles, but the consequence is the same). – Omnomnomnom Jun 2 '17 at 21:37
• The two definitions are equivalent. The point of that question is that not every open set is an open ball. However, once you've decided that open balls are measurable, you can deduce that all open sets are measurable. – Omnomnomnom Jun 2 '17 at 22:07
• I have double-checked what you say, and provided an answer based on this. Feel free to provide your own answer of course. However, the two definitions are not always equivalent, and I have provided a source that shows this. – Peter Jun 4 '17 at 11:11

Generated by open sets: For the $\epsilon-\delta$ style definition, an equivalent definition is that all preimages of open sets are open (see For continuous functions, preimage of open set is open.). This suffices to prove that $f$ is measurable.