TITLE: A nice enumeration of $R(\omega)$
QUESTION [6 upvotes]: Define $R(0)=0=\emptyset, R(n+1)=P(R(n))$ and $R(\omega) = \cup_{n < \omega} R(n)$. Thus $R(\omega)$ is the set of all sets, which are build out of finitely many braces and $0$.
Consider the following relation $E$ on $\omega$: If and only if the $n$th number in the binary representation of $m$ is $1$, then $n E m$. Now I want to construct an isomorphism $(R(\omega),\in) \cong (\omega,E)$ [This is an exercise in Kunen's set theory]. After some playing around I've come up with the following definition:
$g : R(\omega) \to \omega, g(x) = \sum_{y \in x} 2^{g(y)}$.
This is a well-defined recursion, since $rank(y) < rank(x)$. If $g$ is injective, then it is easy to see that $x \in y \Leftrightarrow g(x) E g(y)$. However I don't see this; neither why $g$ is surjective.

REPLY [7 votes]: It is easier to build the isomorphism in the other direction, and indeed we can see that the map is forced upon us. There is a unique isomorphism.
Specifically, you want a map $h:\mathbb{N}\to R(\omega)$ such that $n\mathrel{E} m\iff h(n)\in h(m)$. This very equivalence tells you that you must define $h(m)=\{ h(n) \mid n\mathrel{E} m\}$. This function is defined by recursion, and obviously preserves $E$ to $\in$. Thus it is injective. It is surjective because your function $g$ is the inverse. QED
If one knows about the Mostowski collapse, then you can see immediately that $h$ is precisely the Mostowski collapse of $(\mathbb{N},E)$, which is a well-founded extensional relation. This provides another way to see that $h$ is an isomorphism.