# For any point $a$ of a compact subset $S$ of a metric space $(X, p)$, prove that there exists a nearest point $c$ to $a$.

Let $S$ be a compact subset of $X$. Define a metric space $(X, p).$ Prove that for any point $a\in X$, there exists a nearest point $c$ in $S$ to $a$. Moreover, $c$ in $S$ such that $p(c,a)\leq p(x,a)$ for all $x \in S$.

My thought is to use function $f: S \to\mathbb R$, where $f(x)= p(x,a).$

Since your $f$ is continuous and $S$ is compact so is $f(S)$ but in $\mathbb{R}$. Hence $f(S)$ contains its infimum.
• How do you know $f$ is continuous? – Matt R. Oct 29 '14 at 0:13
• @ Matt R. The statement is ambiguous. I understand that $S$ is compact with respect to the topology induced by the metric $p$. Otherwise the result is not true. – Neutral Element Oct 29 '14 at 8:32
• Neutral Element, @MattR. $p$ is continuous and thus is continuous in each variable separately in particular is continuous at in the variable $x$ and then define for any $a \in X$, as OP has done, $f: S \to\mathbb R$, where $f(x)= p(x,a)$ ? – BCLC Oct 18 '18 at 7:49
$$p$$ is continuous and thus is continuous in each variable separately in particular is continuous at in the variable $$x$$ and then define for any $$a \in X$$, as you have done, $$f: S \to\mathbb R$$, where $$f(x)= p(x,a).$$