Distance to a closed set The distance between a point $a \in \mathbb{R}$ and a set $X \subset \mathbb{R}$ is defined as $$d(a,X) := \inf\{|x-a|: x \in X\}.$$ How to prove if $X$ is closed, then there is a $b \in X$ such that $d(a,X) = |b-a|$?
I've constructed a decreasing sequence converging to $d$ as follows: Given $r > d(a,X)$, there is a $x \in X$ such that $|x-a| < r$. Repeating the process with $r_{n+1} := \frac{d+r_n}{2}$ we get the inequality:
$$d \le |x_n-a| < r_n$$
It's easy to prove that $r_n \to d$, and therefore $|x_n-a| \to d$. If i could show the set $A := \{|x-a|: x\in X\}$ is closed, the result would be immediate. This is somehow my second question, is true that for every closed set $X$, the set $|X| := \{|x|: x\in X\}$ is closed?
Be free to contribute alternative proofs, i would appreciate.
 A: Hint: Pick a $b \in X$. Then, it is enough to look only to the set $Y:= \{ x \in X | d(a, x) \leq d(a, b) \}$.
Then $Y= X \cap B_{ d(a, b)}(a)$, where the second set is the closed ball.. Now, $Y$ is closed and bounded thus compact...
Can you prove that there exists a $y \in Y$ so that $d(a,y)= d(a, Y)$? Keep in mind that now you have compactness instead of closure....
To complete the proof
Let $d =d(a, X)=d(a,Y)$. Then for each $n$ you can find some $x_n \in Y$ so that $d \leq d(a,x_n) \leq d+\frac{1}{n}$.
The sequence $x_n \subset Y$ must have a cluster point $y \in Y$, since $Y$ is compact.
Question: What is $d(a,y)$?
A: Another way to look at this: Letting $r$ be sufficiently large, $d(a,X) = d(a, X \cap B(0,r))$, where $B(0,r)$ is the closed ball of radius $r$ centered at the origin. Use the triangle inequality to show that $|a - x|$ is a continuous function of $x$ for $x  \in X \cap B(0,r)$. Since $ X \cap B(0,r)$ is compact, it achieves its minimum value at some $b \in X \cap B(0,r)$, and this $b$ will minimize $|a - b|$ over all $b \in X$ as well since $d(a,X) = d(a, X \cap B(0,r))$.
Yet another way: Let $E_n = \{x \in X: |x - a| \leq d(a,X) + {1 \over n}\}$. The $E_n$'s are nested compact sets and thus have nonempty intersection i.e. you can choose $b \in \cap_n E_n$. Then since $d(a,X) \leq |a - b| \leq d(a,X) + {1 \over n}$ for all $n$, you must have $|a - b| = d(a,X)$.
