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]>
1 KiB
A classical bit is protected by repetition: send 111 for 1, and a single flip leaves a majority. A qubit cannot simply be copied (no gate copies an unknown state), but its value in the computational basis can be spread: two controlled-NOTs take a|0⟩ + b|1⟩ to a|000⟩ + b|111⟩. That is the three-qubit bit-flip code, the smallest error-correcting code.
After a flip of one qubit, the same two controlled-NOTs decode: they leave q[0] holding the data (flipped, if q[0] was the one hit) and q[1], q[2] holding whether each disagreed with q[0]. A majority vote then corrects q[0].
This exercise is a generator: input uint err; makes the program a family, one circuit for each value. The check runs your program at err = 0, 1 and 2, each case with its own verdict, and passes only when all three do. On the command line every command takes --input:
cat > flip.qasm <<'QASM'
OPENQASM 3.0;
include "stdgates.inc";
input uint err;
qubit[3] q;
x q[err];
QASM
wai-quantum instance flip.qasm --input err=2