Confused by Baby Rudin chapter $3$ problem $19$ 
Associate to each sequence $a={a_n}$, in which $a_n$ is $0$ or $2$, the real number $x(a)=\sum \frac{a_n}{3^n}$. Prove all the $x(a)$ is precisely the Cantor set.

My attempt: 
If I let $a_n=2$ then $x(a)=1$, $a_n=0,\text{ then }   x(a)=0$. So, $x(a)\in [0,1]$. That problem looks right and I need a more precise proof. I notice when I take $a_n=2$, I do the sum from $1$ to $n$ it always the right point of interval
I know a technology that proof two set are equal if I prove $A\subset B\,\text{ and }B \subset A$ then $A=B$ but it seems like I can’t use that technology.
 A: There's nothing to be said really. It's intuitively very clear because at each step you're throwing out the middle interval which has numerator $1$ in the corresponding digit in the base $3$ expansion. If you want to make it rigorous, it will only get ugly and will not give you any new insight. But here's an ugly proof for a simple beautiful fact:
Let's say that $x \in C = \cap_{n=1}^{\infty}C_n$. Then for each $n\in\mathbb{N}$, $x \in C_n$ where $C_n$ is the union of $2^n$ disjoint intervals of length $\frac{1}{3^n}$. This means that for each $n\in\mathbb{N}$ you can find a number $0\leq y_n \leq 3^{n+1}-1$ such that $$x \in [\frac{y_n}{3^{n+1}}, \frac{y_n+1}{3^{n+1}}]$$
It remains to show that $$y_n \equiv 0 \pmod{3^k} \,\,\text{ or }\,\, y_n \equiv 2 \pmod{3^k}\,\,\,\text{ for } k<n$$
You can prove this by induction. It is trivially true for the base case $m=1$. Assuming it's true for all $m \leq n$, consider step $m=n+1$ of the construction of Cantor's set. At step $n$, we have assumed that $x \in [\frac{y_n}{3^{n+1}}, \frac{y_n+1}{3^{n+1}}]$ where $y_n = 3^{n-1}j_n + a_n$ where $a_n=0,2$; so we know which subinterval in $C_n$ we're at. Let's divide this interval into three intervals of equal length. Our new $y_{n+1}$ will then be given by $3y_{n}+a_{n+1}$ where $a_{n+1}=0,2$. This proves that 
$$y_n \equiv 0 \pmod{3^k} \,\,\text{ or }\,\, y_n \equiv 2 \pmod{3^k}\,\,\,\text{ for } k<n+1$$
Now we have found a sequence $\{a_n\}_{n=1}^{\infty}$ that satisfies the following relations
$$\frac{y_n}{3^{n+1}}\leq x < \frac{y_n+1}{3^{n+1}}$$
And $y_n = 3y_{n-1} + a_n$. This gives that $y_n=3(3y_{n-2}+a_{n-1})+a_n=9y_{n-2}+3a_{n-1}+a_n$. Continuing in this way, we have
$$y_n = 3^{n-1}y_1 + 3^{n-2}a_2 + \cdots + 3a_{n-1} + a_n$$
where $y_1 = a_1$. This shows that 
$$\frac{\sum_{i=1}^n 3^{n-i}a_i}{3^{n+1}} \leq x < \frac{\sum_{i=1}^n 3^{n-i}a_i + 1}{3^{n+1}}$$
$$\sum_{i=1}^n \frac{a_i}{3^{i+1}} \leq x < \sum_{i=1}^n \frac{a_i}{3^{i+1}} + \frac{1}{3^{n+1}}$$
So, $x \to 0.a_1a_2\cdots$ in base $3$ where $a_n = 0 \text{ or } 2$ and $\{a_n\}_{n=1}^{\infty}$ is your desired sequence. Conversely, given a sequence $\{a_n\}_{n=1}^{\infty}$ which satisfies $a_n=0$ or $a_n=2$ for all $n\in\mathbb{N}$, the above inequalities and construction shows that $x \in C$. $\fbox{Q.E.D.}$
