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]>
13 lines
1.1 KiB
Markdown
13 lines
1.1 KiB
Markdown
<!-- 机器辅助翻译(machine-assisted translation):在对外推广之前,须由熟练的读者审校。 -->
|
||
|
||
从 n 个比特到一个比特的函数 f,如果对每个输入都给出同一个答案,就是*常数*函数;如果恰好对一半的输入给出 0,就是*平衡*函数。已知 f 是二者之一,经典程序在最坏情况下必须询问超过一半的输入。
|
||
|
||
Deutsch–Jozsa 算法只询问一次。函数以*预言机*(oracle)的形式给出,即一条把 f(x) 加到一个额外量子比特上的线路。算法:
|
||
|
||
1. 用 `h` 让每个输入量子比特处于叠加;
|
||
2. 把额外的量子比特制备到 |−⟩,使预言机把 f(x) 以符号 (−1)^f(x) 的形式反冲到 |x⟩ 上;
|
||
3. 再用 `h` 让输入发生干涉,然后测量它们。
|
||
|
||
对于常数 f,所有符号都相同,各路径在 |0…0⟩ 上叠加,结果全为零。对于平衡 f,通向 |0…0⟩ 的路径恰好相互抵消,所以结果永远不会全为零。一次查询就能判定。
|
||
|
||
引擎精确地检查结果分布:“每次都”意味着概率为 1,由证明检查。
|