A metric space question and doubt about the incorrect options. Let $(X,d)$ be a metric space and let $A\subseteq$ $X$. For $x\in$ $X$, define $d(x,A)=inf\{d(x,a):a\in A\}$. If $d(x,A)=0$, for all $x\in X$, then which of the following assertions must be true?


*

*$A$ is compact.

*$A$ is closed.

*$A$ is dense in X.

*$A=X$
What I tried in this question is that $d(x,A)=0$ $\implies$ $x\in A$ $\implies$ $X\subset A$ $\implies$ $X\subset \bar A$ $\implies$ $A$ is dense in $X$. (so in my opinion (3) should be correct.)
I am not so sure about this proof. I also wanted the proof of rest of the incorrect options why they are incorrect.
p.s. I know this is the duplicate question, but I also wanted to confirm that the above proof is correct and also if other options are correct or incorrect(why?), this is why I posted it separately. Please help!

 A: In general, for $A \neq \emptyset$ we have (exercise!)$$d(x,A) = 0 \iff x \in \overline{A}$$
In particular, this means your proof is flawed because $d(x,A) = 0 \implies x \in A$ is a false implication. For example, on $\mathbb{R}$ with the usual metric $d(0, ]0,1[) = 0$ yet $0 \notin ]0,1[$.
Thus your hypothesis says:
$$\forall x \in X: d(x,A) = 0 \iff \forall x \in X: x \in \overline{A}$$
$$\iff X = \overline{A}$$
$$\iff \mathrm{A \ is \ dense \ in \ X}$$
and (3) is the only correct option (density of $A$ in $X$ implies neither of the other conditions and is equivalent with your hypothesis).

In response to comment:
Let $d(x,A) = 0$.  Choose a sequence $(a_n)$ in $A$ with $d(x,a_n) \to \inf\{d(x,a): a \in A\} = d(x,A) = 0$.  This means that $a_n \to x$ so $x \in \overline{A}$.
Also, the other conditions are in general incorrect because $\mathbb{Q}$ is a dense in $\mathbb{R}$ but not closed, not equal to $\mathbb{R}$ and not compact. That is, $\mathbb{Q}$ provides a counterexample to (1), (2),(4).
