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.2 KiB
1.2 KiB
经典比特靠重复来保护:用 111 发送 1,单次翻转之后多数仍然正确。量子比特不能简单地复制(没有哪个门能复制一个未知的状态),但它在计算基下的取值可以被铺开:两个受控非门把 a|0⟩ + b|1⟩ 变成 a|000⟩ + b|111⟩。这就是三量子比特的比特翻转码,最小的纠错码。
某一个量子比特被翻转之后,同样的两个受控非门可以解码:它们让 q[0] 保存数据(如果被击中的是 q[0],则数据已被翻转),让 q[1]、q[2] 分别保存它是否与 q[0] 不一致。之后由多数表决来纠正 q[0]。
这道练习是一个生成器(generator):input uint err; 让程序成为一族线路,每个取值对应一条。检查在 err = 0、1 和 2 上运行你的程序,每种情况都有自己的判定,三种情况都通过才算通过。在命令行中,每个命令都接受 --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