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]>
11 lines
934 B
Markdown
11 lines
934 B
Markdown
A function f from n bits to one bit is *constant* if it gives the same answer on every input, and *balanced* if it gives 0 on exactly half of them. Told that f is one or the other, a classical program must, in the worst case, ask about more than half the inputs.
|
||
|
||
The Deutsch–Jozsa algorithm asks once. The function is given as an *oracle*, a circuit that adds f(x) to an extra qubit. The algorithm:
|
||
|
||
1. puts every input qubit in superposition with `h`;
|
||
2. prepares the extra qubit in |−⟩, so that the oracle kicks f(x) back as the sign (−1)^f(x) on |x⟩;
|
||
3. interferes the inputs with `h` again and measures them.
|
||
|
||
For a constant f every sign is the same, the paths add up on |0…0⟩, and the outcome is all zeros. For a balanced f the paths to |0…0⟩ cancel exactly, so the outcome is never all zeros. One query decides.
|
||
|
||
The engine checks the outcome distribution exactly: "every time" means probability 1, by proof.
|