2
$\begingroup$

enter image description here

Hi. I'm trying to make a circuit including some Toffoli gates in Qiskit.

The problem is that, because of connectivity between qubits, some gates should be modified to satisfy it.

I've read this post similar to this problem: How is it possible to perform a c-not on 4 qubits using the same control qubits on IBM Q computers?

This helped me a lot, but I'm still uncertain that these two circuits are equivalent &

SWAP gates applied to $q_1, q_2, q_3$ don't affect after all works are done.

Thanks a lot.

$\endgroup$
2
$\begingroup$

Yes, they are equivalent. You've managed to include the "uncompute" sequences of swaps after the Toffoli, which are quite easy to overlook.

The way that I convinced myself that it was correct was to take each of the qubits $q_1$ to $q_3$ in turn ($q_0$ and $q_4$ being obvious). You can go from the start, and trace its effective position through the swaps and check that each of them comes out in the correct place (i.e. the same position as it started) and that what started as $q_3$ goes through the control of the Toffoli.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.