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]>
935 B
935 B
Hadamard 门 h 把 |0⟩ 变成 (|0⟩ + |1⟩)/√2:两个振幅都是 1/√2,因此测量以各自 (1/√2)² = 1/2 的概率给出 0 或 1。
这就是叠加:它不是一个暗中为 0 或暗中为 1 的量子比特,而是一个对每种结果各有一个振幅的状态。这种区别在单次测量中看不出来,而干涉那几课正是要用到它。
引擎检查分布时并不采样。它精确地计算状态并从中读出概率,所以“恰好二分之一”就是二分之一,而不是一千次采样得到的 0.497。带采样次数的运行仍然会采样,其计数会在精确值附近波动:
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