Decomposition of $|110\rangle \leftrightarrow |000\rangle$ Exchange Gate

How to implement a 3 qubit gate, that exchanges the level $$|110\rangle$$ and $$|000\rangle$$, with elementary gates (CNOT, SWAP, Toffoli, local gates, etc.(everything Qiskit allows)): $$U=\pmatrix{ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\ 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\\ }=?$$ I tried to decompose the unitaries hamiltonian $$U=\exp(-i\pi$$$$H$$$$)$$ in the Zeeman basis, but it doesn't looks not very promising.

One simple idea would be to introduce an ancilla (I'm sure there will be protocols without an ancilla as well) that starts in $$|0\rangle$$. You can use a Toffoli (and some X gates) to flip the ancilla if the system is in the state $$|000\rangle$$. You can also do the same if it's in state $$|110\rangle$$. So, the ancilla is in state $$|1\rangle$$ if you need to flip the first two bits. In other words, two controlled-not gates will do the job. Then you just have to undo the computation of the ancilla.

I believe the following does the same without an ancilla (although you'll want to check it carefully:

The theory was basically that controlled off the third qubit being 0, you essentially wanted to do a swap of the first two qubits (and swap can be composed of 3 controlled-nots). Except that swap usually preserves 00 and 11, switching 01 and 10, so if we perform an $$X$$ on one of the qubits, that means 01 and 10 are preserved, swapping 00 and 11. An initial construction would make many gates controlled off the third qubit, but it turns out these are unnecessary -- if the central toffoli does nothing, everything else cancels.

• +1 thanks...  – draks ... Sep 8 '20 at 10:05
• Just realised that this is a Fredkin gate modulo some NOTs, right? – draks ... Sep 11 '20 at 5:59
• Yes, indeed. NOTs both pre- and post-action on the control qubit and one of the others. – DaftWullie Sep 11 '20 at 7:42

If you're only looking to implement a gate in Qiskit that swaps $$\lvert000\rangle$$ and $$\lvert110\rangle$$ without worrying about the underlying gates, the easiest way to do that would be to create a NumPy array containing the matrix and attach that to the circuit using QuantumCircuit.iso.

The code would look roughly like this:

from qiskit import QuantumCircuit, execute, Aer
import numpy as np

unitary = np.zeros((8,8))
unitary[0][6] = unitary[6][0] = 1
unitary[1][1] = unitary[2][2] = unitary[3][3] = unitary[4][4] = unitary[5][5] = unitary[7][7] = 1

ckt = QuantumCircuit(3)
ckt.iso(unitary, [0,1,2,3], [])
ckt.measure_all()

execute(ckt, backend=Aer.get_backend('qasm_simulator'), shots=1024).result()

# do what you want with the result


Do keep in mind qiskit's "reverse-ordering" of qubits when you're playing around with this! Hope this helps...

• +1 thanks, good hint for upcoming tasks... – draks ... Sep 8 '20 at 10:05