Solution (source code)

= Solution

For a <measurable set> $C$, (i) gives the joint acceptance <probability>
$$
\mathbb P(Y\in C,\mathrm{accept})
=\int_C\frac{\widetilde q(y)}{Z_q}
\frac{\widetilde p(y)}{M\widetilde q(y)}\,dy
=\frac1{MZ_q}\int_C\widetilde p(y)\,dy.
$$
Divide by $Z_p/(MZ_q)$ from (ii). The resulting <conditional probability> is
$$
\boxed{\mathbb P(Y\in C\mid\mathrm{accept})
=\frac1{Z_p}\int_C\widetilde p(y)\,dy
=\int_Cp(y)\,dy.}
$$
Thus every accepted value has target <probability density function> $p$. Repeating rejected trials with fresh <independent random variables> does not change this law: the contribution from acceptance on trial $j$ is multiplied by $(1-Z_p/(MZ_q))^{j-1}$, and summing that <geometric series> gives the same conditional law. Independent repetitions produce <independent> target draws.