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).$