← Atlas

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

View frozen graph

q[0]q[1]q[2]Step 1 of 1 · CSWAP · on q[0], q[1], q[2]CSWAP

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

Definition

CSWAP∣c,a,b⟩=∣c, (1−c)a+cb, (1−c)b+ca⟩={∣c,a,b⟩c=0∣c,b,a⟩c=1\mathrm{CSWAP}|c,a,b\rangle = |c,\, (1-c)a + cb,\, (1-c)b + ca\rangle = \begin{cases} |c,a,b\rangle & c=0 \\ |c,b,a\rangle & c=1 \end{cases}

As an 8×88\times 8 permutation matrix, CSWAP\mathrm{CSWAP} is the identity on the four c=0c=0 basis states and the identity except for exchanging ∣101⟩↔∣110⟩|101\rangle\leftrightarrow|110\rangle on the c=1c=1 block (the ∣100⟩|100\rangle and ∣111⟩|111\rangle states, having a=ba=b, are unaffected by the swap).

Action and conservation law

Unlike Toffoli, which computes a genuinely new bit (the AND), CSWAP\mathrm{CSWAP} only ever permutes its two target bits. This makes it conservative: the Hamming weight of the two target qubits is invariant under CSWAP\mathrm{CSWAP}, 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 bb CNOT-copied onto aa'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

  • CSWAP2=I\mathrm{CSWAP}^2 = I: applying the same controlled-swap twice restores the input.
  • CSWAP\mathrm{CSWAP} is the core primitive of the SWAP test: preparing a control qubit in ∣+⟩|+\rangle, applying CSWAP\mathrm{CSWAP} between two unknown states, then measuring the control in the XX basis estimates ∣⟨ψ∣ϕ⟩∣2|\langle\psi|\phi\rangle|^2 without ever measuring ∣ψ⟩|\psi\rangle or ∣ϕ⟩|\phi\rangle directly.
  • Like Toffoli, CSWAP\mathrm{CSWAP} has no native two-qubit hardware realization and must be compiled from the elementary gate set for execution.

References

Exact & formal
  • Basis-state truth table
  • Unitary / matrix equivalence
  • Peer-reviewed paper
Method
Apply CSWAP to all eight computational-basis inputs and confirm the two target bits exchange exactly when the control is |1⟩, and are unchanged when it is |0⟩.
Result
Pass · CSWAP|1,a,b⟩ = |1,b,a⟩ and CSWAP|0,a,b⟩ = |0,a,b⟩ for all four (a,b) pairs.
OpenQASM 3 standard gate set ↗
Kind
curated reference
Reviewed by
Leona Quantum curation pass
License
CC BY 4.0-compatible reference metadata
fredkinconditional swapthree qubitconservative logic

Atlas stars stay in the public catalog. Saving this entry to your workspace starts an unstarred private copy.