# Show that $\forall f\in C(X)\ \ f(x_n) \to f(x)\implies x_n \to x$.

I'm working on a problem which amounts to showing that if $$X$$ is a compact metric space and $$C(X)$$ is the space of continuous functions $$X\to\mathbb{R},$$

$$\forall f\in C(X)\ \ f(x_n) \to f(x)\implies x_n \to x$$

I've done a fair amount of functional analysis (with weak and weak* convergence) but I'm not sure that this result is true.

If it isn't, please let me know, otherwise, I would appreciate a hint to get me started.

• @Randall you beat me by one second. – Thomas Jan 17 '20 at 20:07
• Of course this is possible if $X\subset\mathbb{R}$, but it doesn't make sense otherwise. – AlephNull Jan 17 '20 at 20:07
• Let $f(t)=d(t,x)$ and ignore that $X$ is compact? – Hagen von Eitzen Jan 17 '20 at 20:25
• As Hagen pointed out, you don't need compactness. – peter a g Jan 17 '20 at 20:38
• Note that since $f$ can be any continuous function this is a lot stronger than weak convergence. – copper.hat Jan 17 '20 at 22:17

Let $$X$$ be a compact metric space. Assume there exist a sequence $$(x_n)$$ in $$X$$ not converging to a point $$x\in X$$ having the property:
We consider the following continuous (help) function $$h:X\to \Bbb R$$, defined for $$y\in X$$ by $$h(y):=d(y,x)\ .$$ It is continuous because of $$|h(y)-h(y')|=|d(y,x)-d(y',x)|\le d(y,y')\ .$$ (The last is true, because it is equivalent to $$-d(y,y')\le d(y,x)-d(y',x)\le d(y,y')$$, and each $$\le$$ reduces equivalently to a triangle inequality.)
It is given that $$h(x_n)\to h(x)$$, i.e. $$d(x_n,x)\to 0$$. This implies $$x_n\to x$$.
The statement is true. Assume by contradiction that $$x_n \nrightarrow x$$. This implies that for some $$\epsilon > 0$$, there exists a subsequence $$x_{n_k}$$ such that $$d(x_{n_k}, x) > \epsilon$$. Now, choose $$f: X \rightarrow \mathbb{R}$$ where $$f(y) = d(y, x)$$ and note that $$f\in C(X)$$. Finally, note that $$f(x_{n_k}) > \epsilon > 0 = f(x)$$ so the subsequence $$f(x_{n_k})$$ is not convergent to $$f(x)$$ which implies that $$f(x_n)\nrightarrow f(x)$$; a contradiction