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

1.2 KiB
Raw Permalink Blame History

GHZ 态 (|000⟩ + |111⟩)/√2 把 Bell 对推广到三个量子比特:全部一致,要么全为 0,要么全为 1。

两个状态可以给出相同的结果,却依然不同。(|000⟩ − |111⟩)/√2 的测量结果与 GHZ 态完全一样,但这个负号是两部分之间的相对相位,后续的门可以把它变成不同的结果。分布看不到它。

所以这道练习用状态来陈述它的意图(intent):prepares(制备)。引擎从 |0…0⟩ 出发运行你的程序和它自己的参考程序,在相差一个全局相位(作用在整个状态上的相位,任何测量都看不到)的意义下比较两个状态,判定是一个证明。两个程序可以制备同一个状态而仍是不同的线路,所以不止一种答案能够通过。

在命令行中,意图是一个文件:

cat > pair.qasm <<'QASM'
OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q;
bit[2] c;
h q[0];
cx q[0], q[1];
c = measure q;
QASM
echo '{"distribution": {"00": 0.5, "11": 0.5}}' > pair-intent.json
wai-quantum run pair.qasm --intent pair-intent.json --shots 100