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

54 lines
2.5 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": "estimate",
"translations": { "zh-CN": "machine-assisted: to be reviewed by a fluent reader before it is advertised" },
"title": { "en": "What a fault-tolerant machine would need", "zh-CN": "容错机器需要什么" },
"task": {
"en": "This program computes a carry into q[2], copies it into q[3], and uncomputes it: the resource estimate counts two Toffolis. Rewrite it as the same circuit, on the same four qubits, so that the resource estimate counts at most one Toffoli.",
"zh-CN": "这个程序把一个进位计算到 q[2],复制到 q[3],再把它反计算掉:资源估算计入两个 Toffoli 门。把它改写成同一条线路(仍是这四个量子比特),使资源估算至多只计入一个 Toffoli 门。"
},
"starter": [
"OPENQASM 3.0;",
"include \"stdgates.inc\";",
"qubit[4] q;",
"// compute the carry a AND b into q[2]",
"ccx q[0], q[1], q[2];",
"// copy it into q[3]",
"cx q[2], q[3];",
"// uncompute the carry",
"ccx q[0], q[1], q[2];"
],
"intent": {
"equivalent": "OPENQASM 3.0;\ninclude \"stdgates.inc\";\nqubit[4] q;\nccx q[0], q[1], q[2];\ncx q[2], q[3];\nccx q[0], q[1], q[2];\n"
},
"constraints": { "estimate": { "toffolis": { "max": 1 } } },
"hints": {
"en": [
"Follow one basis input through the three gates: what does q[3] end with, in terms of q[0], q[1] and q[2]'s starting value?",
"q[3] ends as q[3] ⊕ (q[0] AND q[1]) ⊕ q[2], and q[2] ends as it began. One Toffoli and one controlled-NOT write that."
],
"zh-CN": [
"让一个基态输入依次经过这三个门:用 q[0]、q[1] 和 q[2] 的初始值来表示,q[3] 最后是什么?",
"q[3] 最后等于 q[3] ⊕ (q[0] AND q[1]) ⊕ q[2],而 q[2] 回到初始值。一个 Toffoli 门加一个受控非门就能写出它。"
]
},
"reference": [
"OPENQASM 3.0;",
"include \"stdgates.inc\";",
"qubit[4] q;",
"ccx q[0], q[1], q[3];",
"cx q[2], q[3];"
],
"wrong": [
{
"fails": "intent",
"note": "dropping the copy of q[2] changes what happens when q[2] starts at 1",
"qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[4] q;", "ccx q[0], q[1], q[3];"]
},
{
"fails": "constraint",
"note": "the same circuit, still at two Toffolis",
"qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[4] q;", "ccx q[0], q[1], q[2];", "cx q[2], q[3];", "ccx q[0], q[1], q[2];"]
}
]
}