= Solution
This circuit is the <swap test>. If the two pure states are identical up to a physically irrelevant <global phase>, then $|\langle\psi|\phi\rangle|=1$ and outcome one never occurs. If they are distinct, then $|\langle\psi|\phi\rangle|<1$ and each run produces outcome one with positive probability $p_1$.
Run the circuit independently on fresh copies. Observing even one outcome one proves that the states differ. If no one occurs in $N$ runs, that event has probability
$$
p_0^N
=\left[\frac{1+|\langle\psi|\phi\rangle|^2}{2}\right]^N
$$
when the states differ, which tends to zero as $N\to\infty$. Repetition therefore distinguishes equality from inequality with arbitrarily high probability.
Back to article page