Let $C\subset \mathbb{R}$ be the Cantor set, obtained from the interval $[0,1]\subset \mathbb{R}$ by removing the middle thirds of successive subintervals. That is, assuming $C_n$ constructed we let $C_{n+1}$ be the union of the intervals obtained by removing the middle thirds of all intervals contained in $C_n$ in the case we let $C_0=[0,1]$. In that case,
$$C = \bigcap_{n=0}^\infty C_n.$$
Now, I'm trying to show that there is a bijection between $C$ and the set of all sequences $(x_n)_{n\in \mathbb{N}}$ such that $x_n =0,1$. In other words, the sequences $x : \mathbb{N}\to \{0,1\}$. On this question I'm just concerned with the construction of a sequence associated to points of $C$.
Reading a little bit about the Cantor set, I've seem that every point inside $C$ can be written as
$$a = \sum_{k=1}^\infty a_k3^{-k},$$
where each $a_k$ is either $0$ or $2$. If we rewrite this as
$$a = \sum_{k=1}^\infty \dfrac{2}{3^k}b_k$$
i.e., if we set $2b_k = a_k$, and if we assume the map $a\mapsto (b_k)_{k\in \mathbb{N}}$ is a bijection then we are done, because each $b_k$ is either $0$ or $1$.
Although I've "got the idea" of the construction, I didn't quite understand how to write it down rigorously. The idea I've got is: if $x\in C$ then $x\in C_1$, so it can be on two subintervals. If it is on the first, associate $a_1=0$ if it is on the second $a_1 = 2$. In either case, $x\in C_2$ and is in one of the two subintervals of the subinterval of $C_1$ where $x$ is. In that case if it is on the first, associate $a_2=0$ and on the second $a_2 = 2$. Continuing this process for all $n\in \mathbb{N}$ we get a sequence $(a_n)_{n\in \mathbb{N}}$ and also the associated sequence $(b_n)_{n\in \mathbb{N}}$ with $b_n\in \{0,1\}$.
I'm in doubt on how to write down this properly in a rigorous way. I imagine I need to define $a_1$ and then define $a_n$ in terms of $a_{n-1}$. My way to write this is:
Let $a\in C$ be given. Since $a\in C$, we have $a\in C_n$ for all $n\in \mathbb{N}$. In particular, $a\in C_1$. If $a \in [0,1/3]$ set $a_1 = 0$, if $a\in [2/3,1]$ set $a_2 = 2$. Now supposing defined $a_1,\dots,a_{n-1}$ define $a_n$ in the following way: $C_{n-1}$ is the union of $2^{n-1}$ disjoint intervals $I_k$, if $a\in I_{k_0}$, since $a\in C_n$ also, we have that $a$ has to be in one of the two disjoint pieces of $I_{k_0}$ obtained when we build $C_n$. If he is on the first, set $a_n =0$, if on the second, set $a_n = 2$.
Is this correct? I feel it is not quite rigorous. Also, why $0$ and $2$? Why not $0$ on the first subinterval and $1$ on the second? I didn't quite get this idea yet.
So, how to understand and write more correctly this construction?