[step:Contract the $P''$-steps to recover a $G$-derivation]Continue with the $G'$-derivation $S = \tau_0 \to_{G'} \cdots \to_{G'} \tau_N = w$. Let $i_1 < i_2 < \cdots < i_m$ be the indices of the $P''$-steps; the remaining $N - m$ steps are $P'$-steps.
Define, for $0 \leq j \leq N$, the "devariablised" string
\begin{align*}
\psi_j &:= \hat{X}^{-1}\!\left(\text{the result of reapplying $X$ to each terminal of $\tau_j$}\right).
\end{align*}
More precisely, let $Y: \Omega' \to \Omega$ be the inverse renaming
\begin{align*}
Y(x) &:= \begin{cases} a & \text{if } x = X_a \in V_X, \\ a & \text{if } x = a \in \Sigma, \\ A & \text{if } x = A \in V, \end{cases}
\end{align*}
and $\hat{Y}: (\Omega')^\star \to \Omega^\star$ its functorial extension. Note $Y$ sends both $a$ and $X_a$ to $a$, collapsing the two copies of $\Sigma$ inside $\Omega'$ into one; it is not an inverse to $X$ in the strict sense but rather a two-to-one retraction. We set $\psi_j := \hat{Y}(\tau_j)$.
We show: if the step $\tau_j \to_{G'} \tau_{j+1}$ is a $P'$-step, then $\psi_j \to_G \psi_{j+1}$ or $\psi_j = \psi_{j+1}$; if it is a $P''$-step, then $\psi_j = \psi_{j+1}$.
- *$P'$-step.* The step uses a rule $\hat{X}(\gamma) \to \hat{X}(\delta) \in P'$ at positions $\mu, \nu \in (\Omega')^\star$:
\begin{align*}
\tau_j &= \mu\, \hat{X}(\gamma)\, \nu, & \tau_{j+1} &= \mu\, \hat{X}(\delta)\, \nu.
\end{align*}
Applying $\hat{Y}$ and using it is a monoid homomorphism,
\begin{align*}
\psi_j &= \hat{Y}(\mu)\, \hat{Y}(\hat{X}(\gamma))\, \hat{Y}(\nu), & \psi_{j+1} &= \hat{Y}(\mu)\, \hat{Y}(\hat{X}(\delta))\, \hat{Y}(\nu).
\end{align*}
We claim $\hat{Y}(\hat{X}(\gamma)) = \gamma$ for every $\gamma \in \Omega^\star$: on a terminal $a$ we have $\hat{Y}(\hat{X}(a)) = Y(X_a) = a$, and on a variable $A$ we have $\hat{Y}(\hat{X}(A)) = Y(A) = A$, so $\hat{Y} \circ \hat{X} = \mathrm{id}_{\Omega^\star}$ by homomorphic extension. Therefore
\begin{align*}
\psi_j &= \hat{Y}(\mu)\, \gamma\, \hat{Y}(\nu), & \psi_{j+1} &= \hat{Y}(\mu)\, \delta\, \hat{Y}(\nu),
\end{align*}
and since $(\gamma \to \delta) \in P$ by definition of $P'$, this is a valid $G$-step: $\psi_j \to_G \psi_{j+1}$.
- *$P''$-step.* The step uses a rule $X_a \to a$:
\begin{align*}
\tau_j &= \mu X_a \nu, & \tau_{j+1} &= \mu a \nu.
\end{align*}
Applying $\hat{Y}$,
\begin{align*}
\psi_j &= \hat{Y}(\mu)\, Y(X_a)\, \hat{Y}(\nu) = \hat{Y}(\mu)\, a\, \hat{Y}(\nu), \\
\psi_{j+1} &= \hat{Y}(\mu)\, Y(a)\, \hat{Y}(\nu) = \hat{Y}(\mu)\, a\, \hat{Y}(\nu).
\end{align*}
Hence $\psi_j = \psi_{j+1}$: $P''$-steps are contracted to no-ops.
Assembling the chain $(\psi_0, \psi_1, \dots, \psi_N)$ and removing consecutive duplicates produces a sequence of genuine $G$-derivation steps from $\psi_0 = \hat{Y}(S) = S$ to $\psi_N = \hat{Y}(w) = w$ (the latter holds because $w \in \Sigma^\star$ and $\hat{Y}$ fixes terminals of $\Sigma$). This is a $G$-derivation of $w$ from $S$, so $w \in \mathcal{L}(G)$.[/step]