Solution (source code)

= Solution

Use <entanglement-assisted discrimination of a Pauli basis>. Define the known single-<qubit> <unitary operator> $V$ by $V|0\rangle=|\psi\rangle$ and $V|1\rangle=|\psi^\perp\rangle$. Prepare the device input $A$ and a reference <ancilla qubit> $R$ in
$$
|\Omega\rangle_{AR}=(V_A\otimes I_R)|\phi_+\rangle
=\frac{|\psi\rangle_A|0\rangle_R+|\psi^\perp\rangle_A|1\rangle_R}{\sqrt2}.
$$
Apply the unknown device once to $A$, then apply the known inverse $V^\dagger$ to $A$. Since
$$
V^\dagger U_0V=I,\quad V^\dagger U_1V=Z,\quad
V^\dagger U_2V=X,\quad V^\dagger U_3V=iY,
$$
the possible two-<qubit> outputs are
$$
\begin{aligned}
U_0:&\quad (|00\rangle+|11\rangle)/\sqrt2,\\
U_1:&\quad (|00\rangle-|11\rangle)/\sqrt2,\\
U_2:&\quad (|01\rangle+|10\rangle)/\sqrt2,\\
U_3:&\quad (|01\rangle-|10\rangle)/\sqrt2.
\end{aligned}
$$
These are the four mutually <orthogonal> <Bell states>. A <Bell-basis measurement> therefore identifies the device with certainty. Explicitly, apply a <controlled-NOT gate> $A\to R$, then a <Hadamard gate> on $A$, followed by <computational-basis measurements>. The readouts $00,10,01,11$ identify $U_0,U_1,U_2,U_3$, respectively. Thus \b[one use of the device and one reference qubit suffice].