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]>
19 lines
1,017 B
Markdown
19 lines
1,017 B
Markdown
<!-- 机器辅助翻译(machine-assisted translation):在对外推广之前,须由熟练的读者审校。 -->
|
||
|
||
由于 T 门主导了容错程序的代价,编译器花了大量功夫去消除它们。有些仅靠代数就能去掉:T·T = S,T⁴ = Z,T·T† = I。一个 T 门也可以穿过与它对易的门,去和它的另一半相遇。
|
||
|
||
引擎的重写(rewrite)每次只做一步,每一步都在它所触及的量子比特上经过检查,所以一连串重写就证明了结果与原线路是同一条线路:
|
||
|
||
```sh runnable
|
||
cat > ts.qasm <<'QASM'
|
||
OPENQASM 3.0;
|
||
include "stdgates.inc";
|
||
qubit[1] q;
|
||
t q[0];
|
||
tdg q[0];
|
||
h q[0];
|
||
QASM
|
||
wai-quantum rewrite simplify ts.qasm
|
||
```
|
||
|
||
编译器走得更远(`wai-quantum compile`):它把相位折叠穿过受控非门、重新综合小的门块,并把每个不是 π/4 整数倍的旋转在误差预算之内写成 Clifford+T 门序列,并为每一遍处理(pass)出具证书。它得到的 T 门数,就是下一课估算的起点。
|