[guided]We now formalize the idea of repeatedly choosing a new element of $X$. The recursive value at stage $\alpha$ must be determined only by the earlier values, that is, by a function whose domain is $\alpha$. For each ordinal $\alpha \in \theta$, let $\mathcal{H}_\alpha$ denote the set of all functions $h: \alpha \to X \cup \{\ast\}$. For $h \in \mathcal{H}_\alpha$, define
\begin{align*}
S_{\alpha,h} := X \setminus \{h(\beta) : \beta \in \alpha \text{ and } h(\beta) \in X\}.
\end{align*}
This set is exactly the part of $X$ that remains after removing the earlier values recorded by $h$.
Define the stage rule
\begin{align*}
G_\alpha: \mathcal{H}_\alpha &\to X \cup \{\ast\}\\
h &\mapsto
\begin{cases}
c(S_{\alpha,h}), & S_{\alpha,h} \neq \varnothing,\\
\ast, & S_{\alpha,h} = \varnothing.
\end{cases}
\end{align*}
The map $G_\alpha$ is well-defined: $S_{\alpha,h} \subset X$, and if $S_{\alpha,h}$ is nonempty, then $S_{\alpha,h}$ lies in $\mathcal{P}(X) \setminus \{\varnothing\}$, so $c(S_{\alpha,h}) \in S_{\alpha,h} \subset X$; if $S_{\alpha,h}$ is empty, the value is the marker $\ast \in X \cup \{\ast\}$.
By the [Transfinite Recursion Theorem](/theorems/???), applied to the ordinal $\theta$ and the stage rules $G_\alpha$, there is a unique function
\begin{align*}
y: \theta &\to X \cup \{\ast\}
\end{align*}
such that $y(\alpha) = G_\alpha(y|_\alpha)$ for every $\alpha \in \theta$.
At stage $\alpha \in \theta$, define the remaining subset of $X$ before stage $\alpha$ by
\begin{align*}
R_\alpha := X \setminus \{y(\beta) : \beta \in \alpha \text{ and } y(\beta) \in X\}.
\end{align*}
Because $R_\alpha = S_{\alpha,y|_\alpha}$, the recursive equation says
\begin{align*}
y(\alpha) :=
\begin{cases}
c(R_\alpha), & R_\alpha \neq \varnothing,\\
\ast, & R_\alpha = \varnothing.
\end{cases}
\end{align*}
If $R_\alpha$ is nonempty, then $c(R_\alpha)$ is defined and lies in $R_\alpha$. If $R_\alpha$ is empty, the construction has exhausted $X$, and the value is the marker $\ast$.
We prove that exhaustion occurs before stage $\theta$. Suppose, toward a contradiction, that $R_\alpha \neq \varnothing$ for every $\alpha \in \theta$. Then the recursive definition gives $y(\alpha) = c(R_\alpha) \in X$ for every $\alpha \in \theta$.
We next check injectivity. Let $\beta, \alpha \in \theta$ with $\beta \in \alpha$. At stage $\alpha$, the value $y(\beta)$ has already been chosen, so $y(\beta)$ lies in the set removed from $X$ when forming $R_\alpha$. Since $y(\alpha) \in R_\alpha$, it follows that $y(\alpha) \neq y(\beta)$. Thus distinct ordinals below $\theta$ are sent to distinct elements of $X$, and $y: \theta \to X$ is injective.
This contradicts the defining property of $\theta$: no injection from $\theta$ into $X$ exists. Therefore there is some $\gamma \in \theta$ such that $R_\gamma = \varnothing$.[/guided]