Bell State Measurement Algorithm I'm relatively new to quantum computation and am taking a course in it. I was wondering if it is possible to code an algorithm which would be able to take an input of a 2 qubit state and perform a bell state measurement in order to which of the four bell states the two qubits are in. Or more plainly, an algorithm which would be able to perform a bell state measurement. If it is possible, are there any libraries you recommend to deal with quantum states like projectq or qiskit? Thanks.
 A: A Bell state is prepared with Hadamard gate applied on first qubit and CNOT gate with control on first qubit and target on second qubit.
As a quantum computation is reversible, putting transpose conjugate of above mentioned gate in reverse order returns the original input.
So, assume that you have some unknown Bell state at the input. Then simply put firstly CNOT gate on first and second qubit, then Hadamard gate on first qubit (note that transpose conugate to Hadamard and CNOT gates are the same gates) a measure both qubits in computational basis. Based on result of measurement, you can decide which Bell state was on input:

*

*measured: $|00\rangle$, Bell state was: $\frac{1}{\sqrt{2}}(|00\rangle+|11\rangle)$

*measured: $|01\rangle$, Bell state was: $\frac{1}{\sqrt{2}}(|01\rangle+|10\rangle)$

*measured: $|10\rangle$, Bell state was: $\frac{1}{\sqrt{2}}(|00\rangle-|11\rangle)$

*measured: $|11\rangle$, Bell state was: $\frac{1}{\sqrt{2}}(|01\rangle-|10\rangle)$
See this circuit:

The first part prepares Bell state ($\frac{1}{\sqrt{2}}(|01\rangle-|10\rangle)$) in particular). Assume that this state was given to us. The second part of the circuit is used to recognize which state was given to us. In this case, $|11\rangle$ will be returned with 100 % probability, hence you know that your were given $\frac{1}{\sqrt{2}}(|01\rangle-|10\rangle)$.
