Rudin's PMA: problem 2.17 I'm reading Rudin's Principle of Mathematical Analysis and trying problem 17 of chapter 2.

Let $E$ be the set of all $x\in [0,1]$ whose decimal expansion contains only the digits $4$ and $7$. Is $E$ countable? Is $E$ dense in $[0,1]$? Is $E$ compact? Is $E$ perfect?

My argument is the following:

*

*Is $E$ countable? No. - Use Cantor's diagonal process as in the proof of theorem 2.14 of baby Rudin: Take a countable subset of $E$, namely $A=\{a_n:n\in\mathbb{N}\}$ and construct a sequence whose $n$-th member is $7$ if $n$-th digit of $a_n$ is $4$ and $4$ if $n$-th digit of $a_n$ is $7$. Then this new sequence differs from any other member of $A$. Thus every countable subset of $E$ is proper, it follows that $E$ is uncountable (for otherwise $E$ would be a proper subset of $E$).


*Is $E$ dense in $[0,1]$? No. - There's no member of $E$ between $0.1$ and $0.2$: Because it must start with $0.1...$ and $1$ is not allowed for a member of $E$.


*Is $E$ compact? No. - Since by theorem 2.34 of baby Rudin, compact subsets of metric spaces are closed. So if $E$ is not closed, then it must not be compact. I will show that $E^c$ is not open. Take $x\in E^c$. Then we need to find a open ball $B_r(x)=\{y\in [0,1]:|x-y|<r\}$. But for every $r>0$, $B_r(x)$ must contain a number at least one of whose digits contains $4$ or $7$; otherwise there would be a gap inside the ball (a segment, actually). So  $E$ is not closed (since $E$ closed $\iff$ $E^c$ open).


*Is $E$ perfect? No. - Direct from the definition: a perfect set is a closed set whose members are limit points.
Is my argument valid?
 A: *

*Your application of Cantor's diagonal process is correct.

*Nice observation that $[0.1,0.2] \subseteq E^\complement$.

*$E$ is in fact closed.  Take $x = \overline{0.a_1a_2\cdots} \in E^\complement$, where the $n$-th decimal place $a_n \in \{0,\dots,9\}$ for all $n \in \Bbb{N}$.  Since $x \notin E$, there exists $m \in \Bbb{N}$ such that $a_m \notin \{4, 7\}$.  Let's choose the least possible value of $m$, and choose $r$ sufficiently small so that $B_r(x) \subseteq E^\complement$ by defining $r = \color{red}{\frac{1}{100}\min}\{|x - c_i| \mid i \in \{1,\dots,4\}\}$.  Observe that $E$ is "locally bounded" by the intervals $[c_1,c_2]$ and $[c_3,c_4]$.
$$\bbox[36px, yellow, border: 2px solid red]{\begin{array}{rrrrrrrrrr}
\rlap{\style{display: inline-block; transform: scale(10,1)}{-}} {\Large [} & {\large \bullet} & \llap{\style{display: inline-block; transform: scale(10,1)}{-}} {\Large ]} & {\style{display: inline-block; transform: scale(10,1)}{-}} & {\Large |} {\style{display: inline-block; transform: scale(10,1)}{-}} & {\style{display: inline-block; transform: scale(10,1)}{-}} {\Large |}  & {\style{display: inline-block; transform: scale(10,1)}{-}} & \rlap{\style{display: inline-block; transform: scale(10,1)}{-}} {\Large [} & {\large \bullet} & \llap{\style{display: inline-block; transform: scale(10,1)}{-}} {\Large ]} \\
c_1 & \begin{matrix}\uparrow \\ E\end{matrix} & c_2 & \rlap{\small\overline{0.a_1a_2\cdots a_{\color{red}{m-1}}5/6}} & & & & c_3 & \begin{matrix}\uparrow \\ E\end{matrix} & c_4
\end{array}}\\
\text{Figure 1: range of possible values of numbers in $E$}$$


*

*$c_1 = \overline{0.a_1a_2\cdots a_{\color{red}{m-1}} \color{red}{4}4}$

*$c_2 = \overline{0.a_1a_2\cdots a_{\color{red}{m-1}} \color{red}{4}8}$

*$c_3 = \overline{0.a_1a_2\cdots a_{\color{red}{m-1}} \color{red}{7}4}$

*$c_4 = \overline{0.a_1a_2\cdots a_{\color{red}{m-1}} \color{red}{7}8}$
Recall that $x = \overline{0.a_1a_2\cdots a_{\color{red}{m-1}} a_m a_{m+1} a_{m+2} \cdots}$, so $$r \le \frac{44 \cdot 10^{-(m+1)}}{100} < \frac{50 \cdot 10^{-(m+1)}}{100} = \frac{5}{10^{m+2}}.$$  When we add/minus $r$ to/from $x$, the new number $x \pm r$ "won't differ too much from $x$".  Consider $x - r$ ( or $x + r$).  Either one of the following cases occurs:


*

*the $m$-th decimal place is still $a_m \notin \{4,7\}$, so $x - r \notin E$.

*the $m$-th decimal place is changed by $1$ (digit $0 \to 9$ also counts).  A necessary condition for this to happen is that $a_{m+1} \in \{0,9\}$.  (To see this, imagine examples like $0.95 + 0.05 = 1$.)  In this case, the $(m + 1)$-th decimal place of $x-r$ would be either $0$ or $9$, so $x - r \notin E$.


Thus, any number in $B_r(x)$ can't belong to $E$.  Therefore, $E^\complement$ is open and $E$ is closed.  Since $E$ is bounded, Heine–Borel Theorem tells us that $E$ is compact.
Your mistake is the wrong deduction from "$B_r(x)$ must contain a number at least one of whose digits contains $4$ or $7$" to "$E^\complement$ is not open".  To be a member of $E$, the decimal $y \in B_r(x)$ should consist merely in digits $4$ and $7$, not just "at least one" digit.
Remarks: The choice of $r$ is a bit tricky and the verification is a bit tedious, but it's still doable.

*$E$ is a perfect set.  The idea is that $$0.4\overset{\bullet}{7}, 0.44\overset{\bullet}{7}, 0.444\overset{\bullet}{7}, \cdots \to 0.\overset{\bullet}{4}.$$  Each term $0.4\dots4\overset{\bullet}{7}$ on LHS contains digit $7$, so it's different from RHS $0.\overset{\bullet}{4}$, and thus it lies in a deleted neighbourhood of $0.\overset{\bullet}{4}$.  To finish the proof, just repeat this idea for any $x \in E$.
For any $x = \overline{0.a_1a_2\cdots} \in E$ I'm going to construct a sequence $(y_n)_n$ in $E$ so that $\lim\limits_n y_n = x$.  For all $n \in \Bbb{N}$, define $y_n = \overline{0.b_1b_2\cdots b_{m-1} b_m b_{m+1}}$, where $$b_m = \begin{cases} a_m \quad &\text{ if } m \le n \\ \max(\{4,7\}\setminus\{a_m\}) & \text{ if } m > n \end{cases}.$$ $\require{HTML}$
$$
\bbox[yellow, 5px, border: 2px solid red]{
\begin{array}{rrrrrrrrrr}
x & = & 0. & a_1 & a_2 & \cdots & a_{n-1} & a_n & a_{n+1} & \cdots \\
\style{display: inline-block; transform: rotate(90deg)}{\ne} & & & \style{display: inline-block; transform: rotate(90deg)}{=} & \style{display: inline-block; transform: rotate(90deg)}{=} & \style{display: inline-block; transform: rotate(90deg)}{=} & \style{display: inline-block; transform: rotate(90deg)}{=} & \style{display: inline-block; transform: rotate(90deg)}{=} & \style{display: inline-block; transform: rotate(90deg)}{\ne} & \style{display: inline-block; transform: rotate(90deg)}{\ne} \\
y_n & = & 0. & b_1 & b_2 & \cdots & b_{n-1} & b_n & b_{n+1} & \cdots
\end{array}} \\
\text{Figure 2: construction of approaching sequence $(y_n)_n$ in $E'$ from $x \in E$}
$$
It's clear that for all $n \in \Bbb{N}$, $y_n \ne x$ and $y_n \in E$, but $\lim\limits_n y_n = x$, so $x \in E'$.
A possible cause of your mistake: Since your response to the previous question is incorrect, you might think that $E$ is not closed, so there exists a sequence $(y_n)_n$ in $E$ "escaping" from $E$, so there might exists limit point $y$ not in $E$
