Bernstein–Vazirani Algorithm
The Bernstein–Vazirani algorithm recovers an unknown -bit word from a function promised to satisfy , with the dot product evaluated modulo two. A quantum query encodes each bit of as the sign of a single-qubit superposition. Hadamards then turn those signs into the readable word .
One exact quantum query suffices, while matched classical value queries require for worst-case error below . This is a linear query separation in ; it excludes the cost of constructing and implementing the oracle. The unknown-offset variant has the same quantum decoder but a different classical count, derived below.
Helpful background. Phase kickback explains the minus-state answer register. Quantum oracles defines coherent value access, and query complexity distinguishes queries from gates and fixes the error convention.
The hidden linear function
Section titled “The hidden linear function”Fix , write , and let the hidden word be
The oracle is selected from the family
The dot is the mod-two inner product, and the required output is the full -bit label . There are exactly legal functions. Indeed, distinct words give distinct functions because on the th standard basis word .
The intercept is anchored to zero. Linearity is promised by the instance supplier; the algorithm neither tests that promise nor learns an arbitrary -entry truth table. The address length and truth-table size describe different scales, and a comparison stated in one variable must not be silently restated in the other.
One-query recovery of the hidden word
Section titled “One-query recovery of the hidden word”The complete supplied oracle acts on the data register followed by an answer qubit:
Preparing the answer in gives . The target returns unchanged. A rule specified only for target would not suffice to determine this action on a superposition.
The full sequence is
Measure the data qubits to read . It is the same gate sequence as the Deutsch–Jozsa circuit, but now every output bit is used, rather than just testing whether all are zero.
Reading the signs one qubit at a time
Section titled “Reading the signs one qubit at a time”The character state immediately after the oracle factors:
For each , this factor is if and if . Since and , the final Hadamards read all the signs. This makes the exact decoder especially transparent. Measuring before the Hadamards would instead give uniform random data bits.
The character-sum proof
Section titled “The character-sum proof”For , the data transform obeys
The amplitude of after the final layer is therefore
The sum factors coordinate by coordinate:
Each one-bit factor is one when and zero otherwise. Hence the data state is exactly , its norm is one, and measurement returns the full hidden word with probability one.
No zero-query exact algorithm can distinguish the legal outputs. Under the never-wrong fixed-cap convention, a zero-query procedure cannot name any particular without erring on another instance, so it must always declare failure; that violates the allowed inconclusive-probability cap. Consequently, for ,
Across the full bounded-error range, a zero-query output distribution is independent of . Its worst-case success is at most , attained by a uniform guess. Thus exactly when ; otherwise the one-query decoder is necessary and sufficient.
The same circuit has a diagnostic meaning off promise. For an arbitrary Boolean ,
If differs from at exactly truth-table addresses, then the amplitude at is and
This identity diagnoses one Walsh coefficient. It is not a test of linearity, a nearest-codeword theorem, or a guarantee for an unspecified noisy oracle.
Classical queries and the full-word requirement
Section titled “Classical queries and the full-word requirement”Basis queries and the rank lower bound
Section titled “Basis queries and the rank lower bound”Classically, query the standard basis words in order:
The returned values are
so value queries reconstruct the complete word. If the access model permits parallel calls, all addresses can be queried in one round, but the total remains queries. Query count and query-round depth are separate resources.
The matching lower bound survives adaptivity. Fix any branch of a deterministic decision tree after queries, and put its queried address rows into a matrix . Since , there is a nonzero . The two hidden words and give identical answers to every address on the branch:
Inductively they therefore cause the adaptive algorithm to choose the same later addresses and reach the same leaf, yet the leaf cannot output both words. Thus , and the basis schedule attains equality. Thus
Allowing a chance of error
Section titled “Allowing a chance of error”The deterministic rank argument establishes exact recovery. A complete bounded-error comparison follows from the number of distinguishable transcripts.
Choose uniformly from its possibilities and fix a deterministic classical tree with query cap . It has at most answer transcripts and can name at most one hidden word correctly at each leaf. Its average success is therefore at most . By Yao’s minimax principle, no randomized algorithm can have larger worst-case success.
The bound is attainable for every . Query independent standard-basis directions, record those bits of , and guess the remaining bits uniformly. Every hidden word is then recovered with probability . Hence the exact minimax curve is
For every , a cap of queries has optimal error and therefore fails the strict requirement. Thus
while queries suffice at the excluded boundary . In particular,
This is a factor-, or linear, query separation in hidden-word length. Since , it is logarithmic rather than exponential in truth-table size. The theorem says nothing by itself about gate count, total runtime, energy, physical error correction, or a separation of uniform complexity classes.
What changes with an unknown intercept?
Section titled “What changes with an unknown intercept?”Now define a separate family with an unknown intercept,
while continuing to ask only for . Kickback adds the common sign , so the modern circuit ends in
Measurement still returns exactly after one query. The intercept is an unobservable global sign in this circuit and is not part of the reported output.
The matched classical problem has changed. Querying reveals , after which standard-basis queries reveal , for an upper bound of . Equivalently, value equations contain at most independent differences that eliminate the common nuisance intercept.
With no query, exact recovery is plainly impossible. For a deterministic lower bound with , augment each queried address row to . The resulting matrix has a nonzero kernel vector . Its word component must satisfy , because every augmented query row has inner product one with , so is not in the kernel. The parameter pairs and then follow the same adaptive transcript but require different word outputs. Therefore exact recovery needs calls.
The full randomized curve exposes the extra query. With no answers, uniformly guessing succeeds with probability . For , pad every early-stopping branch of a deterministic capped tree with arbitrary queries; this preserves its output and success while giving a nonempty transcript at every leaf. The resulting tree has at most leaves, and at a fixed transcript a proposed word determines at most one consistent intercept, hence at most one parameter pair . Under the uniform distribution on the pairs, average success is at most . Querying , learning independent bits of , and guessing the rest attains that bound. Thus
and
Consequently,
The primary anchored problem has classical cost ; this affine variant has cost under the complete value-query convention. Combining the affine promise with the anchored classical bound would compare different tasks.
Four-bit worked example
Section titled “Four-bit worked example”Take and . In lexicographic address order 0000 through 1111, the affine truth table is 1001100101100110. The post-query data state is
so the final Hadamards give . The common minus sign changes no outcome probability. Equivalently, its unnormalized Walsh coefficients vanish except for .
For comparison, the optimal classical success probabilities are:
| Query cap | Known zero intercept | Unknown intercept |
|---|---|---|
At cap five, the known-intercept procedure can simply stop after four calls. One quantum query succeeds with probability one in either column. Changing whether is known changes the classical information obtainable from an answer; it does not change the required output word.
Implementation and separability
Section titled “Implementation and separability”The ideal circuit uses visible qubits and Hadamards if the answer starts in . An all-zero initialization adds one . Any oracle workspace, oracle gates and output-reading cost must be included in an implementation. Parallel Hadamard layers do not make the entire calculation constant-time.
The displayed data and answer states are products throughout the algorithm’s gate-layer boundaries. This example therefore does not require entangled boundary states. A particular oracle decomposition may create intermediate entanglement; the result makes no general claim about entanglement in quantum computing.
A transparent realization of an affine oracle is
It uses CNOTs and, when , one target . With this minus-state target, every CNOT acts as a local sign change on its control at the gate boundaries. The wiring itself displays the bits of , so a prepared demonstration tests the coherent decoder rather than discovering a secret inaccessible to the circuit designer.
Bernstein and Vazirani introduced the construction in their 1993 complexity work, expanded in 1997. Cleve and collaborators’ 1997 preprint, published in 1998, gives the familiar one-XOR-query refinement. Their broader recursive Fourier-sampling setting must be distinguished from the elementary one-versus- problem here. See quantum complexity classes for the role of oracle separations.
Finally, the transform here is Fourier analysis over , namely . It is not the cyclic transform from the quantum Fourier transform page. The groups have different characters even though their Hilbert spaces have the same dimension.
Exercises
Section titled “Exercises”Count the linear and affine families
Section titled “Count the linear and affine families”Count the anchored linear functions and the affine parameter pairs. Prove that their parameters are unique, and explain which family defines the primary problem.
Solution
Each defines one anchored function . If , evaluating on every gives , so . There are therefore distinct anchored functions.
For the affine family, determines the intercept, and then
determines every word bit. Thus all pairs define distinct functions. The primary Bernstein–Vazirani problem uses only the functions with ; the unknown-intercept family is a separate query problem.
Recover the word with basis queries
Section titled “Recover the word with basis queries”Give the classical basis-query schedule, prove that it recovers , and distinguish total query count from parallel query rounds.
Solution
For , query . The answer is
Writing the returned bits in coordinate order therefore gives after exactly queries. In a sequential model this takes query rounds. If independent simultaneous oracle calls are available, the addresses can be submitted in one round, but the algorithm still consumes calls and returned bits. Parallel depth does not change total query complexity.
Verify Boolean phase kickback
Section titled “Verify Boolean phase kickback”Apply the complete XOR oracle to , prove target return and factorization for a data superposition, and determine the effect of an affine intercept.
Solution
For one basis address,
Linearity gives
The same answer state factors from every term. Replacing the function by multiplies the entire data factor by , so the target still returns and the intercept becomes one unobservable global sign.
Prove character orthogonality
Section titled “Prove character orthogonality”Derive the coordinate product for , prove normalization and exact decoding, and connect the qubitwise factorization to Tensor Products as the general product-space construction.
Solution
Substituting the Hadamard matrix elements gives
Because both the sum and exponent separate by coordinate,
Hence and . The same calculation at the state level is
The tensor product constructs the joint space and distributes the coordinate factors; it does not assert that arbitrary multipartite states factor this way.
Prove the deterministic lower bound
Section titled “Prove the deterministic lower bound”Use rank and a nonzero nullspace word to construct indistinguishable secrets after every adaptive transcript of length .
Solution
Fix the addresses selected along one actual decision-tree branch and form the matrix with these rows. Since , choose with .
For every query already made,
The equal answers force the deterministic algorithm to choose the same next address on both secrets, so induction preserves the common branch. The leaf then sees one transcript for the two distinct required outputs and and must fail on at least one. No exact deterministic tree of depth below exists; combined with basis queries, .
Derive the randomized minimax curve
Section titled “Derive the randomized minimax curve”Prove matching upper and lower bounds for , reproduce the sequence, and obtain for .
Solution
Under uniform , a deterministic depth- tree has at most leaves. Each leaf announces one word and can be correct for at most that one member of the -word family, so its average success is at most . Yao’s principle transfers this bound to the worst-case success of randomized algorithms.
Querying independent basis directions and guessing the remaining bits uniformly attains success on every . Therefore
For and , the successes are
Every cap below four has error at least , whereas four queries give zero error. Hence for , and the same argument gives generally.
Account for an unknown intercept
Section titled “Account for an unknown intercept”Derive the classical schedule and exact affine success curve. Explain why the quantum output is unchanged and why the anchored -query equality no longer applies.
Solution
Query to obtain , then query every and compute
This uses calls. With no query, uniform guessing of succeeds with probability . For , pad early-stopping branches with arbitrary queries so every leaf has a nonempty transcript. There are then at most leaves, and a fixed transcript plus proposed word determines at most one intercept, so it can be correct for at most one parameter pair. The upper bound is attained by learning , then word bits, and guessing the rest. Thus
The quantum character acquires only and still decodes to in one query. The classical oracle returns ordinary values, so it must eliminate the unknown intercept; the anchored equality is therefore inapplicable.
Flip one truth-table value
Section titled “Flip one truth-table value”For , change one value of at address . Calculate the probability of decoding and the probability of each other word. Explain why repeated sampling still does not by itself certify linearity.
Solution
Changing one sign changes every Walsh amplitude by a term of magnitude . More explicitly,
Thus and every other amplitude has magnitude . The correct-word probability is , with probability on each of the other fifteen words; the probabilities sum to one. This is a fixed coherent Boolean-function change, not an independent random bit flip on each invocation. Observing repeatedly can be likely for both this imperfect function and the exact linear one. A statistical test needs a specified alternative, number of trials and tolerated error.
References
Section titled “References”- E. Bernstein and U. Vazirani, “Quantum Complexity Theory,” in Proceedings of the Twenty-Fifth Annual ACM Symposium on Theory of Computing, 11–20 (1993), doi:10.1145/167088.167097.
- E. Bernstein and U. Vazirani, “Quantum Complexity Theory,” SIAM Journal on Computing 26, 1411–1473 (1997), doi:10.1137/S0097539796300921.
- R. Cleve, A. Ekert, C. Macchiavello, and M. Mosca, “Quantum Algorithms Revisited,” Proceedings of the Royal Society A 454, 339–354 (1998), doi:10.1098/rspa.1998.0164.
- D. A. Meyer, “Sophisticated Quantum Search without Entanglement,” Physical Review Letters 85, 2014–2017 (2000), doi:10.1103/PhysRevLett.85.2014.
- M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th Anniversary Edition, Cambridge University Press (2010), doi:10.1017/CBO9780511976667.