The Bernstein–Vazirani algorithm, which solves the Bernstein–Vazirani problem, is a quantum algorithm invented by Ethan Bernstein and Umesh Vazirani in 1997.[1] It is a restricted version of the Deutsch–Jozsa algorithm where instead of distinguishing between two different classes of functions, it tries to learn a string encoded in a function. The Bernstein–Vazirani algorithm was designed to prove an oracle separation between complexity classes BQP and BPP.[1]
Given an oracle that implements a function
f\colon\{0,1\}n → \{0,1\}
f(x)
x
s\in\{0,1\}n
f(x)=x ⋅ s=x1s1 ⊕ x2s2 ⊕ … ⊕ xnsn
s
Classically, the most efficient method to find the secret string is by evaluating the function
n
x=2i
i\in\{0,1,...,n-1\}
\begin{align} f(1000 … 0n)&=s1\\ f(0100 … 0n)&=s2\\ f(0010 … 0n)&=s3\\ &\vdots\\ f(0000 … 1n)&=sn\\ \end{align}
In contrast to the classical solution which needs at least
n
s
Apply a Hadamard transform to the
n
|0\rangle ⊗
1 | |
\sqrt{2n |
Next, apply the oracle
Uf
|x\rangle\to(-1)f(x)|x\rangle
|b\rangle|x\rangle\to|b ⊕ f(x)\rangle|x\rangle
|0\rangle-|1\rangle | |
\sqrt{2 |
⊕
1 | |
\sqrt{2n |
Another Hadamard transform is applied to each qubit which makes it so that for qubits where
si=1
|-\rangle
|1\rangle
si=0
|+\rangle
|0\rangle
s
\{|0\rangle,|1\rangle\}
Graphically, the algorithm may be represented by the following diagram, where
H ⊗
n
|0\ranglen\xrightarrow{H ⊗
The reason that the last state is
|s\rangle
y
1 | |
2n |
n}(-1) | |
\sum | |
x\in\{0,1\ |
f(x)=
1 | |
2n |
n}(-1) | |
\sum | |
x\in\{0,1\ |
x ⋅ =
1 | |
2n |
n}(-1) | |
\sum | |
x\in\{0,1\ |
x ⋅ =1ifs ⊕ y=\vec{0},0otherwise.
s ⊕ y=\vec{0}
s=y
|s\rangle
s
A generalization of Bernstein–Vazirani problem has been proposed that involves finding one or more secret keys using a probabilistic oracle. [3] This is an interesting problem for which a quantum algorithm can provide efficient solutions with certainty or with a high degree of confidence, while classical algorithms completely fail to solve the problem in the general case.