Solution (source code)

= Solution

The answer <qubit> enters the <Boolean quantum oracle> in $|-\rangle=(|0\rangle-|1\rangle)/\sqrt2$, because the <Pauli X gate> followed by the <Hadamard gate> maps $|0\rangle$ to $|-\rangle$. Since $X|-\rangle=-|-\rangle$, <quantum phase kickback> multiplies the $|xy\rangle$ component by $(-1)^{f(x,y)}$ and leaves the answer <qubit> unchanged. The two input <qubits> enter in the <uniform quantum superposition> $|++\rangle$. Thus
$$
\boxed{|\psi_{abcd}\rangle=\frac{(-1)^d}{2}\sum_{x,y\in\{0,1\}}(-1)^{axy+bx+cy}|xy\rangle\otimes|-\rangle.}
$$
Equivalently, using the <Controlled-Z gate> and the <Pauli Z gate>,
$$
|\psi_{abcd}\rangle=(-1)^d\bigl[C_Z^a(Z^b\otimes Z^c)|++\rangle\bigr]\otimes|-\rangle.
$$
Here the exponent in the phase may be evaluated as an ordinary integer, since its parity agrees with the <exclusive or> expression. In particular, $d$ contributes only a <global phase>.