It's well known that in a metric space $M$, if $(x_n)_{n=1}^{\infty}$ is a sequence converging to $x$, then $f(x_n) \to f(x)$ as $n \to \infty$ for every continuous, real-valued function $f$. What about a converse of sorts? That is, if $f(x_n) \to f(x)$ for every continuous $f: M \to \mathbb{R}$, does it follow that $x_n \to x$ in $M$ as $n \to \infty$?
My gut instinct told me "no" but I was unable to formulate a counterexample. So, I tried to come up with a proof, and this is as far as I got:
If $x_n \not\to x$ as $n \to \infty$ then there are two possibilities: either $(x_n)_{n=1}^{\infty}$ diverges, or $(x_n)_{n=1}^\infty$ converges to something else, which would be an immediate contradiction. So, suppose that $(x_n)$ diverges. Then $\{x_1, x_2, \ldots\}$ is a closed set in $M$. Note that this implies $\{x_1, x_2, \ldots \} = f^{-1}(\{0\})$ for some continuous $f:M \to \mathbb{R}$. By hypothesis, $f(x_n) \to f(x)$ as $n \to \infty$, but this implies $f(x) = 0$, meaning $x \in \{x_1, x_2, \ldots\}$. I feel that this should be some sort of contradiction, but I'm not sure that I see how.
I think I'm missing something basic here, but would appreciate any help!
It is true.
The function $M \to \mathbb{R}$ given by $y \mapsto d(x,y)$ is continuous so
$$d(x, x_n) \xrightarrow{n\to\infty} d(x,x) = 0$$
so $x_n \xrightarrow{n\to\infty} x$.