open-standards/wai/wai-quantum/course/lessons/bit-flip-code/lesson.zh-CN.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

18 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- 机器辅助翻译(machine-assisted translation):在对外推广之前,须由熟练的读者审校。 -->
经典比特靠重复来保护:用 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`:
```sh runnable
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
```