Solution (source code)

= Solution

Apply a <Hadamard gate> to qubit $A$, followed by a <controlled-NOT gate> with $A$ controlling $B$. The resulting <Bell-basis conversion circuit> is $U=\operatorname{CNOT}(H\otimes I)$ and gives
$$
U|ij\rangle=\frac{|0j\rangle+(-1)^i|1,j\oplus1\rangle}{\sqrt2}.
$$
Thus $00,01,10,11$ map respectively to $\Phi^+,\Psi^+,\Phi^-,\Psi^-$. The first input bit becomes the phase bit and the second becomes the parity bit.

Both gates are self-inverse, but inversion of their product reverses the order:
$$
\boxed{U^{-1}=U^\dagger=(H\otimes I)\operatorname{CNOT}.}
$$
So \b[the same two gates convert the <Bell basis> back to the <computational basis> when applied in reverse order]: first the controlled-NOT, then the Hadamard. Using the forward order twice does not generally work, since these gates do not commute. For example, $U|\Phi^+\rangle=(|00\rangle+|01\rangle-|10\rangle+|11\rangle)/2$, which is not a computational-basis state.