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]>
11 lines
878 B
Markdown
11 lines
878 B
Markdown
<!-- 机器辅助翻译(machine-assisted translation):在对外推广之前,须由熟练的读者审校。 -->
|
||
|
||
设 f(x) = s · x mod 2,即 x 与隐藏串 s 共有的那些比特的奇偶性。在经典情形下,每次询问 f 最多只能揭示 s 的一个比特:询问 x = 100 得到第一个比特,以此类推,n 个比特需要 n 次询问。
|
||
|
||
Bernstein–Vazirani 算法只用一次询问就找出整个 s,所用的线路与 Deutsch–Jozsa 相同:输入处于叠加、目标比特处于 |−⟩、预言机,再在输入上作用 Hadamard 门。预言机留下的状态是
|
||
|
||
Σₓ (−1)^(s·x) |x⟩ / √2ⁿ,
|
||
|
||
而这种符号模式恰好就是 n 个 Hadamard 门会变成单一基态 |s⟩ 的那种模式。
|
||
|
||
记住比特的顺序:结果写作 c[2] c[1] c[0],最高位在前。读取 `q[0]` 和 `q[2]` 的预言机,其隐藏串是 101。
|