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]>
17 lines
820 B
Markdown
17 lines
820 B
Markdown
The Hadamard gate `h` takes |0⟩ to (|0⟩ + |1⟩)/√2: both amplitudes are 1/√2, so a measurement gives 0 or 1, each with probability (1/√2)² = 1/2.
|
|
|
|
That is a *superposition*: not a qubit that is secretly 0 or secretly 1, but a state with an amplitude for each. The difference is invisible to one measurement, and it is what the lessons on interference use.
|
|
|
|
The engine does not sample to check a distribution. It computes the state exactly and reads the probabilities from it, so "exactly one half" means one half, not 0.497 from a thousand shots. A run with shots still samples, and its counts scatter around the exact values:
|
|
|
|
```sh runnable
|
|
cat > coin.qasm <<'QASM'
|
|
OPENQASM 3.0;
|
|
include "stdgates.inc";
|
|
qubit[1] q;
|
|
bit[1] c;
|
|
h q[0];
|
|
c = measure q;
|
|
QASM
|
|
wai-quantum run coin.qasm --shots 1000 --seed 7
|
|
```
|