The Bernstein-Vazirani algorithm identifies the coefficient string of a linear Boolean function with one Boolean quantum oracle call. It contrasts with the calls required by the classical query complexity of linear Boolean function identification. Prepare the data qubits at and an ancilla qubit at , apply a Hadamard gate to every wire, query the function oracle, and apply the Hadamard gates again. The full output is .
The mechanism is Bernstein-Vazirani phase kickback. The Pauli X gate has eigenvector with eigenvalue . Thus the target flips become relative quantum phases on the data, giving
The final Hadamard transform maps this product to , so computational-basis measurement recovers every coefficient with certainty. The ancilla preparation for the Bernstein-Vazirani algorithm ensures the required minus sign, and the Hadamard-conjugated linear oracle gives an exact quantum circuit interpretation. One query is optimal for , since without a query the output cannot depend on the unknown string.
Write and , with the top wire carrying , the middle wire , and the bottom wire the ancilla bit . The binary inner product is , where is exclusive or. Let denote a CNOT gate controlled by wire and targeting . The four linear Boolean functions and their Boolean quantum oracles are:
Reversible circuit for : three unchanged wires
The CNOT gates in the last row commute: their common target acquires the exclusive or of the two controls. Each input wire is preserved, and applying any of these reversible circuits twice restores .
Figure 1.
The four two-bit linear oracles and their exact simplifications after Hadamard gates on all three wires; a filled dot is a control and a circled plus is a target
. Details.
For classical reversible computation, call the unknown function oracle on and . The resulting ancilla bits are respectively and :
Use a fresh zero ancilla bit for each call, or preserve the first result in workspace before restoring the target to zero. Thus two classical calls determine the two-bit string.
For input bits, query the standard basis strings , since . This gives an upper bound of calls. It is also optimal for exact identification: every classical query reveals at most one new bit, since is unchanged and reveals just when is known. A depth- decision tree has at most answer histories, but must distinguish possible hidden strings. Hence , including adaptive strategies. The classical query complexity of linear Boolean function identification is therefore