$A$ : closed set in $\mathbb{R}^n$
$B$ : compact set in $\mathbb{R}^n$
$A \cap B=\phi.$
$d$ : distance function
Then, prove that \begin{equation} \text{For all } x \in B, \text{ there exists } a_x \in A \text{ such that } d(x, A)=d(x, a_x). \end{equation}
$\bigg(d(x,A)=\inf\{d(x,y) | y \in A\} \bigg)$
I think that I should use the continuity of distance function.
For all $x\in B$, define $f(x):=d(x,A) \ (x\in B).$
Because $B$ is compact and $f$ is continuous, $f(B)$ is also compact. Thus there exists maximum value and minimum value of $f(B)$.
But this idea didn't work.
I would like you to give me some ideas.