Solution (source code)

= Solution

For the lower-qubit controlled rotation, the control is the upper <qubit> and only the subspace $|10\rangle,|11\rangle$ rotates. Write $u=\cos(\theta/2)$ and $v=\sin(\theta/2)$. Unitary conjugation of its diagonal populations gives $cu^2+dv^2$ and $cv^2+du^2$, together with off-diagonal coherences. The ideal crush gradient stipulated in the source removes those coherences without changing populations. Therefore
$$
\boxed{c'=\frac{c+d+\cos\theta(c-d)}2,\qquad d'=\frac{c+d-\cos\theta(c-d)}2,\qquad \alpha=\cos\theta.}
$$
The other two populations remain $a,b$. This <controlled-transfer gate> is not unitary as a complete operation because it includes <dephasing>.

For an upper-qubit target, the lower <qubit> is the control: the mixed subspace is $|01\rangle,|11\rangle$. Thus
$$
\boxed{(a,b,c,d)\longmapsto\left(a,\frac{b+d+\cos\theta(b-d)}2,c,\frac{b+d-\cos\theta(b-d)}2\right).}
$$
The population $a$ of $|00\rangle$ is unaffected in either direction because its control bit is zero. The <dephasing> step also leaves this diagonal population unchanged, so any sequence of these controlled-transfer gates preserves $a$.