Gives a five two-qubit-gate construction of the Fredkin (CSWAP) gate, improving on the naive CNOT–Toffoli–CNOT sandwich.
doi.org/10.1103/physreva.53.2855 ↗Fredkin (CSWAP) gate
A three-qubit controlled-swap gate that conditionally exchanges two target qubits, useful for reversible routing logic and as a component of the SWAP test for state overlap.
Atlas stars stay in the public catalog. Saving this entry to your workspace starts an unstarred private copy.
Fredkin is the conditional-routing counterpart to Toffoli's conditional-logic: instead of computing a Boolean function it moves data, and unlike Toffoli it is also conservative (it preserves the total Hamming weight of the two target bits).
Circuit & simulation
What this takes and returns
Takes3 qubitsWhat joins here
Takes a 3-qubit register and states no assumption about what is on it. That is the whole condition: anything returning 3 qubits can feed it.
3 entries meet this end · 1 entry lines up on shape, composition unverified. Named below.
Returns3 qubitsWhat joins here
Returns a 3-qubit register a next stage can take. This is the end that joins.
2 entries meet this end · 14 entries line up on shape, composition unverified. Named below.
A unitary. The same register goes in and comes out, and this entry states no assumption about what is on it — which is what lets anything of the same width feed it. See all 29 →
The widths and types line up. What is not established is everything a width does not carry — the basis convention, the normalisation, the state each was written to start from — so this is not a claim that the two compose.
How it works
Definition
As an permutation matrix, is the identity on the four basis states and the identity except for exchanging on the block (the and states, having , are unaffected by the swap).
Action and conservation law
Unlike Toffoli, which computes a genuinely new bit (the AND), only ever permutes its two target bits. This makes it conservative: the Hamming weight of the two target qubits is invariant under , a structural property Fredkin and Toffoli's original 1982 paper on conservative reversible logic used to model computation with a fixed particle count.
Decomposition
The naive decomposition is a CNOT–Toffoli–CNOT sandwich (target CNOT-copied onto 's role, a Toffoli implementing the conditional exchange, then the CNOT undone) — 2 CNOTs plus 1 Toffoli, which itself costs 6 more CNOTs. Smolin and DiVincenzo (1996) improved on this with an explicit five-two-qubit-gate construction, showing the naive count is not optimal and giving numerical evidence that five is minimal.
Key identities
- : applying the same controlled-swap twice restores the input.
- is the core primitive of the SWAP test: preparing a control qubit in , applying between two unknown states, then measuring the control in the basis estimates without ever measuring or directly.
- Like Toffoli, has no native two-qubit hardware realization and must be compiled from the elementary gate set for execution.
Implementation
OPENQASM 3.0;
include "stdgates.inc";
qubit[3] q;
x q[0];
x q[2];
cswap q[0], q[1], q[2];Quantum vs classical
Classical baseline
Use a classical state-vector or matrix simulation at the same width, precision, and measurement objective.
Quantum claim
The quantum record demonstrates a state or operator behavior; it does not make classical simulation or communication costs disappear.
How to compare
Compare fidelity, samples, gate depth, noise, memory, and the cost of preparing and reading the state.
Declared gaps
Nobody has reviewed this record for gaps yet.
Literature & references
Shows that single-qubit U(2) gates plus CNOT are universal and gives explicit decompositions for controlled-U, Toffoli, and Fredkin gates.
arxiv.org/abs/quant-ph/9503016 ↗