open-standards/wai/wai-quantum/course/lessons/grover/exercise.json
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

61 lines
2.7 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"schema": "wai.quantum.exercise/1",
"id": "grover",
"translations": { "zh-CN": "machine-assisted: to be reviewed by a fluent reader before it is advertised" },
"title": { "en": "Searching by amplitude", "zh-CN": "靠振幅来搜索" },
"task": {
"en": "Two qubits in uniform superposition, and an oracle that marks 11 with a minus sign. Add the diffusion step so that one round of Grover's search finds 11 every time. No two gates of your program may cancel.",
"zh-CN": "两个处于均匀叠加的量子比特,以及一个用负号标记 11 的预言机。加上扩散(diffusion)步骤,使一轮 Grover 搜索每次都找到 11。程序中不得有相互抵消的门。"
},
"starter": [
"OPENQASM 3.0;",
"include \"stdgates.inc\";",
"qubit[2] q;",
"bit[2] c;",
"h q;",
"// the oracle: a minus sign on 11",
"cz q[0], q[1];",
"// the diffusion: your gates here",
"c = measure q;"
],
"intent": { "distribution": { "11": 1.0 } },
"constraints": { "allow": ["h", "x", "z", "cz"], "counts": { "cz": { "min": 2, "max": 2 } }, "no_smells": ["cancels", "merges", "does_nothing"] },
"hints": {
"en": [
"The oracle's sign is invisible to a measurement: the outcomes are still uniform. The diffusion turns it into amplitude.",
"The diffusion reflects every amplitude about their average. Built from gates, it is a sign on 00 between two layers of Hadamards.",
"To put a sign on 00 with cz, which signs 11, flip both qubits before and after it."
],
"zh-CN": [
"预言机加上的符号在测量中是看不见的:结果仍然是均匀的。扩散步骤把它变成振幅上的差别。",
"扩散步骤把每个振幅关于它们的平均值作反射。用门来搭建时,它就是夹在两层 Hadamard 门之间、加在 00 上的一个符号。",
"cz 给 11 加符号;要用它给 00 加符号,就在它前后把两个量子比特都翻转。"
]
},
"reference": [
"OPENQASM 3.0;",
"include \"stdgates.inc\";",
"qubit[2] q;",
"bit[2] c;",
"h q;",
"cz q[0], q[1];",
"h q;",
"x q;",
"cz q[0], q[1];",
"x q;",
"h q;",
"c = measure q;"
],
"wrong": [
{
"fails": "intent",
"note": "the oracle alone leaves the outcomes uniform",
"qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[2] q;", "bit[2] c;", "h q;", "cz q[0], q[1];", "c = measure q;"]
},
{
"fails": "constraint",
"note": "undoing the oracle and flipping both qubits finds 11 without searching",
"qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[2] q;", "bit[2] c;", "h q;", "cz q[0], q[1];", "cz q[0], q[1];", "h q;", "x q;", "c = measure q;"]
}
]
}