open-standards/wai/wai-quantum/course/lessons/first-circuit/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

26 lines
1.5 KiB
Markdown

A quantum program in OpenQASM 3 declares its qubits and its classical bits, applies gates, and measures:
```qasm
OPENQASM 3.0;
include "stdgates.inc";
qubit[1] q;
bit[1] c;
c = measure q;
```
Every qubit starts in the state |0⟩. A gate changes the state; a measurement reads one bit from each qubit it measures. This program applies no gate, so its measurement reads 0 every time.
A qubit's state is two numbers, the *amplitudes* of |0⟩ and |1⟩. Measuring gives 0 or 1 with the squares of their sizes as probabilities. The state |0⟩ has amplitudes 1 and 0, so 0 comes up with probability 1.
**How the check works.** The exercise states what your program must do, here an exact distribution of its measured bits. The engine computes your program's distribution exactly and compares; its verdict says how it checked (by proof, when the distribution is computed exactly) and whether the program does what is asked. Nothing is sampled and nothing is guessed.
On the command line:
```sh runnable
wai-quantum learn start first-circuit first-circuit.qasm # the starter program, to edit
wai-quantum learn check first-circuit first-circuit.qasm # exits 1 until the program passes
wai-quantum learn hint first-circuit first-circuit.qasm # the next hint
wai-quantum learn why first-circuit first-circuit.qasm # what went wrong, from the engine's verdict
```
In the Studio, the course's **Check**, **Hint** and **What went wrong?** do the same with the program in the editor.