TITLE: Separability requirement for Measurable distance?
QUESTION [8 upvotes]: I was looking up Egorov's Theorem on Wikipedia. http://en.wikipedia.org/wiki/Egorov%27s_theorem
One of the conditions is that the functions attain values in a separable metric space M, and in the "Discussion of assumptions" section following the theorem, the following is stated:
"The separability of the metric space is needed to make sure that for M-valued, measurable functions f and g, the distance d(f(x), g(x)) is again a measurable real-valued function of x."
Can someone explain how to prove the boldfaced statement? 
[EDIT]To be precise, I want to know how to prove "If the metric space M is separable, and the functions f and g are measurable functions attaining values in M, then the distance function d(f(x),g(x)) is measurable."
Thanks!

REPLY [6 votes]: A more elegant and intuitive way (that I've come up with upon finishing the direct proof, so I'll leave it anyway...) to show it is as follows: if $M$ is a separable metric space, it is second-countable.
From that it follows that open sets are Borel in $M^2$ (with respect to the square of Borel algebra of $M$; this is because we don't need uncountable unions to form open sets).
In particular, continuous functions from $M^2$ to $\bf R$, such as $d$, are Borel with respect to product algebra. On the other hand, $x\mapsto (f(x),g(x))$ is obviously measurable with respect to the product Borel algebra, so the composition of this and $d$ is measurable.