Solution (source code)

= Solution

First suppose $F$ is a <closed set>. If $x\notin F$, the definition in part (ii) gives an <open ball> $B(x,r)$ disjoint from $F$. Thus every $y\in F$ has $d(x,y)\geq r$, and the <distance to a set> satisfies $\operatorname{dist}(x,F)\geq r>0$. Its contrapositive is the required implication.

Conversely, suppose that zero <distance to a set> forces membership. For $x\notin F$ we have $\operatorname{dist}(x,F)>0$. Choose $0<r<\operatorname{dist}(x,F)$. Then $B(x,r)\cap F=\varnothing$, proving $X\setminus F$ is an <open set>. Hence
$$
\boxed{F\text{ is closed}\ \Longleftrightarrow\ \forall x\in X,\quad\operatorname{dist}(x,F)=0\Rightarrow x\in F}.
$$
For $F=\varnothing$, use the extended-real convention $\inf\varnothing=+\infty$: both assertions hold, with the implication vacuous. Part (b) only uses nonempty sets, so all its <distances to a set> are ordinary finite real numbers.