open-standards/wai/wai-quantum/course/lessons/kickback/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

59 lines
2.4 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": "kickback",
"translations": { "zh-CN": "machine-assisted: to be reviewed by a fluent reader before it is advertised" },
"title": { "en": "Phase kickback", "zh-CN": "相位反冲" },
"task": {
"en": "q[1] starts in |−⟩, prepared for you. Make q[0] end in |1⟩ with q[1] still in |−⟩, using h and cx, and no x on q[0]. The check compares the whole state.",
"zh-CN": "q[1] 从已为你制备好的 |−⟩ 开始。只用 h 和 cx(不要对 q[0] 作用 x),让 q[0] 最终处于 |1⟩,同时 q[1] 仍处于 |−⟩。检查比较的是整个状态。"
},
"starter": [
"OPENQASM 3.0;",
"include \"stdgates.inc\";",
"qubit[2] q;",
"bit[1] c;",
"// q[1] in |−⟩",
"x q[1];",
"h q[1];",
"// your gates here",
"c[0] = measure q[0];"
],
"intent": {
"prepares": "OPENQASM 3.0;\ninclude \"stdgates.inc\";\nqubit[2] q;\nbit[1] c;\nx q[0];\nx q[1];\nh q[1];\nc[0] = measure q[0];\n"
},
"constraints": { "allow": ["h", "x", "cx"], "counts": { "x": { "max": 1 }, "cx": { "min": 1 } } },
"hints": {
"en": [
"On a target in |−⟩, a controlled-NOT does not change the target: it puts a minus sign on the control's |1⟩ instead.",
"A sign on |1⟩ is invisible until the control goes through a gate that mixes |0⟩ and |1⟩, before and after."
],
"zh-CN": [
"当目标比特处于 |−⟩ 时,受控非门不会改变目标比特,而是在控制比特的 |1⟩ 上加一个负号。",
"|1⟩ 上的符号是看不见的,除非控制比特在此前和此后都经过一个把 |0⟩ 和 |1⟩ 混合起来的门。"
]
},
"reference": [
"OPENQASM 3.0;",
"include \"stdgates.inc\";",
"qubit[2] q;",
"bit[1] c;",
"x q[1];",
"h q[1];",
"h q[0];",
"cx q[0], q[1];",
"h q[0];",
"c[0] = measure q[0];"
],
"wrong": [
{
"fails": "intent",
"note": "without the second Hadamard the kicked phase never becomes an outcome",
"qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[2] q;", "bit[1] c;", "x q[1];", "h q[1];", "h q[0];", "cx q[0], q[1];", "c[0] = measure q[0];"]
},
{
"fails": "constraint",
"note": "flipping q[0] directly uses a second x",
"qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[2] q;", "bit[1] c;", "x q[1];", "h q[1];", "x q[0];", "c[0] = measure q[0];"]
}
]
}