Estimation ยท Algorithms

SWAP test

Theorem statement

For any $n$-qubit states $\ket{\psi}$ and $\ket{\phi}$, the state $\ket{\psi'} = \mathtt{H}_1 \mathtt{CSWAP}\mathtt{H}_1\ket{0,\psi,\phi}$ satisfies $$ \bra{\psi'}(\ket{1}\!\bra{1}\otimes I^{\otimes 2n})\ket{\psi'} = (1-|\langle\psi|\phi\rangle|^2) / 2. $$
$\mathtt{H}_1$
Hadamard gate acting on the control qubit.
$\mathtt{CSWAP}$
Controlled-SWAP gate exchanging the two target registers when the control qubit is one.

Sources

  1. Quantum fingerprinting

    Harry Buhrman, Richard Cleve, John Watrous, Ronald de Wolf, 2001

  2. Stabilization of Quantum Computations by Symmetrization

    Adriano Barenco, Andre Berthiaume, David Deutsch, Artur Ekert, Richard Jozsa, Chiara Macchiavello, 1997

Lean context

Copy a short prompt with the import, theorem name, citations, and public source link.

Open Lean source