open-standards/wai/wai-quantum/course/lessons/first-circuit/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.6 KiB
Raw Permalink Blame History

OpenQASM 3 编写的量子程序先声明量子比特和经典比特,然后作用门,最后测量:

OPENQASM 3.0;
include "stdgates.inc";
qubit[1] q;
bit[1] c;
c = measure q;

每个量子比特都从状态 |0⟩ 开始。门改变状态;测量从被测的每个量子比特读出一个比特。这个程序没有作用任何门,所以每次测量都读出 0。

一个量子比特的状态是两个数,即 |0⟩ 和 |1⟩ 的振幅。测量以振幅大小的平方为概率给出 0 或 1。状态 |0⟩ 的振幅是 1 和 0,所以测得 0 的概率是 1。

检查是怎样进行的。 练习会说明你的程序必须做什么,这里是被测比特的一个精确分布。引擎精确地计算出你的程序的分布并加以比较;它的判定(verdict)说明它是怎样检查的(分布被精确计算时,就是由证明检查),以及程序是否做到了所要求的事。不做采样,也不做猜测。

在命令行中:

wai-quantum learn start first-circuit first-circuit.qasm --lang zh-CN   # 起始程序,供你编辑
wai-quantum learn check first-circuit first-circuit.qasm --lang zh-CN   # exits 1:程序通过之前,退出状态为 1
wai-quantum learn hint first-circuit first-circuit.qasm --lang zh-CN    # 下一条提示
wai-quantum learn why first-circuit first-circuit.qasm --lang zh-CN     # 哪里出了问题,来自引擎的判定

在 Studio 中,课程里的 检查、提示 和 哪里出了问题? 对编辑器中的程序做同样的事。