Distance from Subset of Real Numbers

Theorem
Let $S$ be a subset of the set of real numbers $\R$.

Let $x \in \R$ be a real number.

Let $\map d {x, S}$ be the distance between $x$ and $S$.

Then:
 * $(1): \quad x \in S \implies \map d {x, S} = 0$
 * $(2): \quad$ If $S$ is bounded above and $x = \sup S$, then $\map d {x, S} = 0$
 * $(3): \quad$ Similarly, if $S$ is bounded below and $x = \inf S$, then $\map d {x, S} = 0$
 * $(4): \quad$ If $I$ is a closed real interval, then $\map d {x, I} = 0 \implies x \in I$
 * $(5): \quad$ If $I$ is an open real interval apart from $\O$ or $\R$, then $\exists x \notin I: \map d {x, I} = 0$.

Proof
From the definition of distance:
 * $\forall x, y \in \R: \map d {x, y} = \size {x - y}$

Thus:
 * $\displaystyle \map d {x, S} = \map {\inf_{y \mathop \in S} } {\size {x - y} }$

$x \in S \implies \map d {x, S} = 0$:

Consider the set $T = \set {\size {x - y}: y \in S}$.

This has $0$ as a lower bound as Absolute Value is Bounded Below by Zero.

So:
 * $\displaystyle \map d {x, S} = \map {\inf_{y \mathop \in S} } {\size {x - y} } \ge 0$

If $x \in S$ then:
 * $\size {x - x} = 0 \in T$

and so:
 * $\displaystyle 0 \le \map {\inf_{y \mathop \in S} } {\map d {x, y} }$

Thus:
 * $\displaystyle \map d {x, S} = \map {\inf_{y \mathop \in S} } {\map d {x, y} } = 0$

If $S$ is bounded above and $x = \sup S$, then $\map d {x, S} = 0$:

Let $x = \sup S$.

Then:
 * $\forall y \in S: \size {x - y} = x - y$

So we need to show that no $h > 0$ can be a lower bound for $T = \set {\size {x - y}: y \in S}$.

Suppose this is false, and $\exists h > 0: \forall y \in S: x - y \ge h$.

But then:
 * $\forall y \in S: y \le x - h$

and hence $x - h$ is an upper bound for $T$ smaller than $x = \sup S$.

But this is supposed to be the supremum, that is the smallest upper bound.

So there is no such $h > 0$ and so $\map d {x, S} = 0$.

If $S$ is bounded below and $x = \inf S$, then $\map d {x, S} = 0$:

Consider $\map d {-x, S'}$ where $S' = \set {-x: x \in S}$.

By Negative of Infimum is Supremum of Negatives:
 * $x = \inf S \implies-x = \sup S'$

Thus from the above, $\map d {-x, S'} = 0$ and hence the result.

If $I$ is a closed real interval, then $\map d {x, I} = 0 \implies x \in I$:

Since $I$ is an interval, if $x \notin I$ then $x$ is either an upper bound or a lower bound for $I$.

Suppose $x$ is an upper bound for $I$.

Let $B$ be the supremum of $I$.

Then because $I$ is closed, $B \in I$.

So:

Now from Infimum Plus Constant:
 * $\inf_{y \mathop \in S} \size {x - y} = x - B + \inf_{y \mathop \in S} \size {B - y}$

But we also have:
 * $x - B \ge 0$
 * $\map d {B, S} \ge 0$
 * $\map d {x, S} = 0$

So it follows that $x = B$ and so $x \in I$.

A similar argument applies if $x$ is a lower bound for $I$.

If $I$ is an open real interval apart from $\O$ or $\R$, then $\exists x \notin I: \map d {x, I} = 0$:

As $I \ne \O$ and $I \ne \R$ it follows that one of the following applies:


 * $\exists a, b \in \R: I = \openint a b$
 * $\exists a \in \R: I = \openint a \to$
 * $\exists b \in \R: I = \openint \gets b$

It follows by the definition of open real interval that $I$ has either an infimum $a$, or a supremum $b$, or both. Thus the required value of $x$, from what has been proved above, is either $a$ or $b$.