Gates · Multi-controlled gate
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.
Exact & formalUpdated
1 step across 3 wires. Hover a step, or press play to go through them in order.
Expected outcomes
- control=1: |1,0,1⟩ → |1,1,0⟩100%
- control=0: targets unchanged100%
- Steps1
- Wires3
- Qubits3
- Depth1 native / 5 two-qubit gates (Smolin–DiVincenzo)
- Conserved quantityHamming weight of targets
- Papers2
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).
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.
4 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.
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.
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.
4 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.
- Qubits
- 3
- Depth
- 1 native / 5 two-qubit gates (Smolin–DiVincenzo)
- Conserved quantity
- Hamming weight of targets
- Truth table
- swap(a,b) iff c=1
- Decomposition
- 5 two-qubit gates (Smolin & DiVincenzo 1996)
- Self-inverse
- CSWAP² = I
- Gate family
- Non-Clifford, conservative
CSWAPon 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.
Nobody has reviewed this record for gaps yet.
OPENQASM 3.0;
include "stdgates.inc";
qubit[3] q;
x q[0];
x q[2];
cswap q[0], q[1], q[2];Related entries
- Toffoli (CCX) gate
Gates
- SWAP gate
Gates
- Quantum kernel support-vector classifier
Algorithms
References
- Five two-bit quantum gates are sufficient to implement the quantum Fredkin gate
John A. Smolin, David P. DiVincenzo · 1996
Gives a five two-qubit-gate construction of the Fredkin (CSWAP) gate, improving on the naive CNOT–Toffoli–CNOT sandwich.
- Elementary gates for quantum computation
Adriano Barenco, Charles H. Bennett, Richard Cleve, David P. DiVincenzo, Norman Margolus, Peter Shor, Tycho Sleator, John A. Smolin, Harald Weinfurter · 1995
Shows that single-qubit U(2) gates plus CNOT are universal and gives explicit decompositions for controlled-U, Toffoli, and Fredkin gates.