# Decompose bell measurement gate into combination of controlled-not gates and one-qubit gates

OPENQASM2.0 has only one two-qubit gate: controlled not. For a teleportation experiment, I need to perform a measurement in the Bell basis. That is, I need a two-qubit gate with matrix representation

$$\begin{bmatrix} 0&1&1&0\\ 0&-1&1&0\\ 1&0&0&1\\ 1&0&0&-1 \end{bmatrix}/\sqrt{2}.$$

To use this library, I need to decompose this gate into a combination of CNOTs and elementary single-qubit gates such as X,Y,Z, etc.

I don't expect the person answering this question to give the decomposition, but hope that they can point me to a helpful resource. I am familiar with linear algebra and have tools such as Mathematica.

• If you know how to create a Bell pair from any of the four states |00>, |01>, |10>, |11> using H and CNOT gates, then running the circuit backward (H and CNOT are self-inverse) will map any on of the 4 Bell states to the 4 computational basis states. Measure them and this will have implemented the Bell state measurement.
– holl
Dec 13, 2021 at 15:52

The key observation is that swapping the first and third column yields

$$\frac{1}{\sqrt2}\begin{bmatrix} 0 & 1 & 1 & 0 \\ 0 & -1 & 1 & 0 \\ 1 & 0 & 0 & 1 \\ 1 & 0 & 0 & -1 \end{bmatrix} \to \frac{1}{\sqrt2}\begin{bmatrix} 1 & 1 & 0 & 0 \\ 1 & -1 & 0 & 0 \\ 0 & 0 & 1 & 1 \\ 0 & 0 & 1 & -1 \end{bmatrix} = I\otimes H\tag1$$

where $$H=\frac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$$ is the Hadamard gate. The coefficients $$\frac{1}{\sqrt2}$$ are needed to ensure unitarity. The column swap corresponds to the permutation matrix

$$P = \begin{bmatrix} 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}\tag2$$

which maps $$|00\rangle$$ to $$|10\rangle$$ and $$|10\rangle$$ to $$|00\rangle$$. In other words, it flips the first qubit when the second qubit is in the $$|0\rangle$$ state. This is the usual controlled-NOT gate with two modifications: the first qubit is the target and the second is the control and the gate acts non-trivially if the control qubit is in the $$|0\rangle$$ state rather than the usual $$|1\rangle$$. Thus,

$$P = (I\otimes X)\circ\text{CNOT}_{2,1}\circ(I\otimes X).\tag3$$

Putting it all together, we get

$$\frac{1}{\sqrt2}\begin{bmatrix} 0 & 1 & 1 & 0 \\ 0 & -1 & 1 & 0 \\ 1 & 0 & 0 & 1 \\ 1 & 0 & 0 & -1 \end{bmatrix} = (I\otimes H) \circ (I\otimes X)\circ\text{CNOT}_{2,1}\circ(I\otimes X)\tag4$$

where the last expression is written in the linear algebraic convention, i.e. the corresponding gates are executed from right to left.

• This CNOT gate seems to be different from what IBM does; the matrix for their gate has identity for the upper left quadrant. The one needed to use this answer appears to be {{1,0,0,0},{0,0,0,1},{0,0,1,0},{0,1,0,0}} Dec 7, 2021 at 23:47
• It's the same gate, but with control and target qubits swapped. Dec 7, 2021 at 23:51