open-standards/wai/wai-quantum/course/lessons/bernstein-vazirani/lesson.en.md
Transaction Science fb230d8a62 wai-quantum: the circuits course as data, each exercise checked by the engine, and wai-quantum learn in English and Chinese
engine::course reads the course from wai-quantum/course/: 21 lessons from a
first circuit through superposition, entanglement, interference, the standard
algorithms, noise and mitigation, error correction and fault tolerance to
resource estimates, each a Markdown text in English and Simplified Chinese and
an exercise.json with a schema. A check runs each case of an exercise (a
generator's inputs) with its intent and the verdict, measures its constraints
(the gates allowed, counts, the T count, the critique's smells, the resource
estimate's counts), and says what went wrong from the diagnostics, the verdict
and the critique, never from the solution. The tests hold every solution to
pass by proof, every known wrong answer to fail for its stated reason, and
every locale to every text and message.

wai-quantum learn shows, starts, checks, hints and explains a lesson, keeps
progress only on this machine, and speaks the language --lang or LANG names;
the command summaries and docs topics have Chinese translations held to the
English they came from. The verdict gains of_diagnostic for a generator's
refusal. llms.txt names the course.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 08:42:54 -04:00

731 B
Raw Permalink Blame History

Suppose f(x) = s · x mod 2, the parity of the bits that x shares with a hidden string s. Classically, each query of f reveals one bit of s at best: asking about x = 100 gives the first bit, and so on, n queries for n bits.

The Bernstein–Vazirani algorithm finds all of s with one query, with the circuit of Deutsch–Jozsa: inputs in superposition, the target in |−⟩, the oracle, and Hadamards on the inputs. The oracle leaves the state

Σₓ (−1)^(s·x) |x⟩ / √2ⁿ,

and that pattern of signs is exactly what n Hadamards turn into the single basis state |s⟩.

Remember the bit order: the outcome is written c[2] c[1] c[0], the highest bit first. An oracle that reads q[0] and q[2] has the hidden string 101.