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]>
1.2 KiB
1.2 KiB
Grover 算法在 N 个项目中搜索被标记的一个,只需大约 √N 次查询。它的预言机用一个负号标记该项目。单单一个符号不会改变任何结果,所以每一轮都在预言机之后接一个扩散(diffusion)步骤:把每个振幅关于全部振幅的平均值作反射。
预言机之后,被标记的振幅为负,平均值略低于其他振幅。关于平均值作反射,会把被标记的振幅抬到远高于其余振幅的位置。重复大约 (π/4)√N 次后,被标记的项目会以接近 1 的概率出现。当 N = 4 时,一轮就是精确的:每次的结果都是被标记的项目。
扩散步骤是夹在两层 Hadamard 门之间、加在 |0…0⟩ 上的一个符号。Studio 的示例“Grover search, 3 qubits”在 N = 8 上运行两轮:被标记的项目以 121/128 的概率出现。
这道练习要求没有相互抵消的门:评析(critique)发现的问题模式也是检查的一部分。wai-quantum critique 会列出它们及其所在的行,哪里出了问题? 会引用它们。