Proving the Cantor set is closed I am trying to understand the accepted answer to Proving the Cantor set is closed (without using the fact "the intersection of closed sets is closed"). I don't see where $t$ comes from, nor why $s$ and $t$ are necessarily positive rather than just non-negative. I also don't see how one can say "If $x_n < x$ then $x_n \leq \sum_{k=1}^{r-1}\frac{d_k}{3^k}+3^{−r}$, whence $x−x_n \geq s$, and similarly, if $x_n > x$ then $x_n-x \geq t$". Any assistance in explaining the details of the proof would be appreciated.
 A: For your first question:
When they write, "Then $x$ has a ternary expansion containing a first digit $d_r=1$, and not all subsequent digits $=0$ or all subsequent digits $=2$," they mean $x$ looks something like $0.2202...1...$*
But they clarify that they don't want to be in the position where $x=0.2202...1\dot0$ in which case we would have $x\in C$ because $x=0.2202...0\dot2$. Neither do we want $x=0.2202...1\dot2$ in which case $x=0.2202...2\dot0$ so again $x\in C$.
Therefore, x is strictly between $0.2202...1\dot0$ and $0.2202...1\dot2$ and this STRICT inequality allows us to take positive numbers $s=x-0.2202...1\dot0$ and $t=0.2202...1\dot2-x$.
For your second question:
Because $x_n\in C$, and $x_n < x=0.2202...1...$,
then $x_n\le0.2202...\dot0$ otherwise $x_n$ would have $1$ as its $r$th digit and this would mean $x_n\notin C$.
(*Note that I am writing using $0.2202...1...$ rather than the sigma notation to give an intuition to the proof. Of course the choice of $2202$ here is arbitrary.)
A: We have
$$x=0.d_1d_2\ldots d_{r-1}1d_{r+1}\ldots\,,$$
where there is at least one $k>r$ such that $d_k\ne 0$ and at least one $k>r$ such that $d_k\ne 2$. (All expansions here are ternary.) This means that $x$ is strictly between
$$a=0.d_1d_2\ldots d_{r-1}1=\sum_{k=1}^r\frac{d_k}{3^k}$$
and
$$b=0.d_1d_2\ldots d_{r-1}1222\ldots=0.d_1d_2\ldots d_{r-1}2=\frac2{3^r}+\sum_{k=1}^{r-1}\frac{d_k}{3^k}\,.$$
We now set
$$s=x-a=\sum_{k\ge r+1}\frac{d_k}{3^k}=x-3^{-r}-\sum_{k=1}^{r-1}\frac{d_k}{3^k}$$
and
$$t=b-x=\left(\frac2{3^r}+\sum_{k=1}^{r-1}\frac{d_k}{3^k}\right)-x\,;$$
$a<x<b$, so $s,t>0$. Now we have $a+s=x=b-t$, i.e.,
$$x=\sum_{k=1}^{r-1}\frac{d_k}{3^k}+3^{-r}+s=\sum_{k=1}^{r-1}\frac{d_k}{3^k}+2\cdot3^{-r}-t\,.$$
Now notice that since members of $C$ must have ternary expansions that do not contain $1$, the smallest member of $C$ greater than $$a=\sum_{k=1}^{r-1}\frac{d_k}{3^k}+3^{-r}=0.d_1d_2\ldots d_{r-1}1$$ is $0.d_1d_2\ldots d_{r-1}2=b$: there are no members of $C$ lying strictly between $a$ and $b$. This means that if $y\in C$, then either $y\le a$, or $y\ge b$. In particular, if $x_n<x$, then $x_n\le a$, so $x-x_n\ge x-a=s>0$, and if $x_n>x$, then $x_n\ge b$, so $x_n-x\ge b-x=t>0$, simply because $x_n\in C$.
