Documentation

LeanPool.LeanQuantumAlg.Algorithms.BernsteinVazirani

Bernstein-Vazirani algorithm #

The Bernstein-Vazirani problem gives oracle access to the inner-product function xx · s mod 2 of an unknown string s, and asks to find s [dW19, qcnotes.tex:1282-1283]. The original problem is due to Bernstein and Vazirani (1997).

The circuit is exactly the Deutsch-Jozsa circuit [dW19, qcnotes.tex:1288]: after one query, the input register holds the phase pattern (1/√N) ∑_x (-1)^{x·s} |x⟩ [dW19, qcnotes.tex:1293-1294], and the second Hadamard layer maps it exactly to the classical state |s⟩ [dW19, qcnotes.tex:1296]. One query therefore recovers the whole hidden string.

This module reuses the shared Walsh-Hadamard pipeline (WalshHadamard.finalJointState applied to the inner-product oracle): the query is the actual XOR-oracle gate, bridged by phase kickback. The new mathematical content is Walsh-character orthogonality, proved by a pair-cancellation involution (flip a bit on which the two characters disagree).

Conventions #

Main results #

The Bernstein-Vazirani oracle for hidden string s: the inner-product function xx · s mod 2 [dW19, qcnotes.tex:1283], queried through Gate.xorOracle like any Deutsch-Jozsa oracle.

Equations
Instances For

    Walsh-sign algebra #

    The bitwise inner-product parity is symmetric.

    The Walsh sign is symmetric.

    A Walsh sign squares to 1.

    Bit-flip involution #

    def QuantumAlg.BernsteinVazirani.flipBit {n : } (x : Fin (2 ^ n)) (k : Fin n) :
    Fin (2 ^ n)

    Flip bit k of a basis label.

    Equations
    Instances For
      theorem QuantumAlg.BernsteinVazirani.bit_flipBit {n : } (x : Fin (2 ^ n)) (k k' : Fin n) :
      theorem QuantumAlg.BernsteinVazirani.flipBit_flipBit {n : } (x : Fin (2 ^ n)) (k : Fin n) :
      flipBit (flipBit x k) k = x
      theorem QuantumAlg.BernsteinVazirani.flipBit_ne {n : } (x : Fin (2 ^ n)) (k : Fin n) :
      flipBit x k x

      Flipping bit k of x toggles the parity x · z exactly when bit k of z is set.

      theorem QuantumAlg.BernsteinVazirani.exists_bit_ne {n : } {y s : Fin (2 ^ n)} (h : y s) :

      Two distinct labels differ at some bit.

      Flipping a bit on which y and s disagree negates the product of their Walsh signs.

      Walsh-character orthogonality: for y ≠ s the signed sum over all basis labels cancels in pairs under the bit-flip involution.

      Circuit correctness #

      Querying the inner-product oracle phases each basis label by its Walsh sign with the hidden string [dW19, qcnotes.tex:1293].

      The second Hadamard layer maps the Bernstein-Vazirani phase pattern exactly to the classical state |s⟩ [dW19, qcnotes.tex:1296].

      noncomputable def QuantumAlg.BernsteinVazirani.timedFinalJointState {n : } (s : Fin (2 ^ n)) :
      Timed (PureState (n + 1))

      The final Bernstein-Vazirani joint state, annotated with one oracle query.

      Equations
      Instances For

        Public resource profile for the Bernstein-Vazirani circuit: one oracle query and two n-qubit Hadamard layers plus the target Hadamard.

        Equations
        Instances For

          The final Bernstein-Vazirani joint state with its public resource profile.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Bernstein-Vazirani correctness: running the Deutsch-Jozsa circuit with the inner-product oracle of hidden string s leaves the joint register in exactly |s⟩ ⊗ |−⟩ [dW19, qcnotes.tex:1296], so a single query recovers the hidden string (Bernstein and Vazirani 1997).

            Bernstein-Vazirani correctness, phrased through the TimeM return value.

            Bernstein-Vazirani supporting theorem for the public statement: the profiled circuit returns |s⟩ ⊗ |-⟩ and records the accepted exact resource counts.