Solution (source code)

= Solution

The rank is defined recursively by
$$
\operatorname{rank}(x)=\sup\{\operatorname{rank}(y)+1:y\in x\}.
$$
For a nonzero <limit> ordinal $\alpha$, every <function> $f:\alpha\to\alpha$, viewed as a set of ordered pairs, has rank $\alpha$, and the set of all such <functions> consequently has rank $\alpha+1$.

The von Neumann hierarchy is
$$
V_0=\varnothing,\qquad V_{\gamma+1}=\mathcal P(V_\gamma),
\qquad V_\lambda=\bigcup_{\gamma<\lambda}V_\gamma
$$
for <limit> $\lambda$. Foundation permits induction down the membership relation and shows that the ranks of all elements of a set form a set of ordinals. If $\rho=\operatorname{rank}(x)$, then every element of $x$ lies in $V_\rho$, so $x\subseteq V_\rho$ and hence $x\in V_{\rho+1}$. Thus every set occurs in the hierarchy.