Infimum of distance in compact metric spaces. Let $(A,d)$ be a metric space with $B\subseteq A$. If $B$ is compact, then it is bounded and closed. If $y\in A$ then there exists $x\in B$ so that $\inf\{d(y,z) : z\in B\} = d(y,x)$. It is reasonable to me but I don't know how to prove it. I would be very pleased if you give me a hint. Thanks.
 A: Because of the definition of $\inf$, we have a sequence $z_n\in B$ such that $d(y,z_n)\to d(y,B)$. Since $B$ is compact, $z_n$ has a convergent subsequence within $B$..
A: The basic fact is that the metric $d$, as a function from $X \times X$ to $\mathbb{R}$, is a continuous function, e.g. see here. It follows from this that for fixed $y$, the function $d_y$ that sends $x  \in B$ to $d(y,x)$ is also continuous (as a 2-fold restriction of $d$). As such $d_y$ assumes a minimum on $B$, as all continuous real-valued functions on $B$ do. 
A: Let $D$ be a real number.
If $d(x,y)>D$ for all $x\in B$, then the open sets $U_n=\{x\colon d(x,y)>D+\frac1n\}$ cover $B$. As $B$ is compact, there is a finite subcover and as the $U_n$ are linearly ordered, there is in fact a single $U_n$ with $B\subseteq U_n$. But then $d(x,y)>D+\frac1n$ for all $x\in B$ and hence $D<\inf\{d(x,y)\colon x\in B\}$.
Thus if $D\ge \inf\{d(x,y)\colon x\in B\}$, then there exists $x\in B$ with $d(x,y)\le D$. Especially, there exists $x\in B$ with $d(x,y)=\inf\{d(x,y)\colon x\in B\}$.
