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]>
65 lines
2.9 KiB
JSON
65 lines
2.9 KiB
JSON
{
|
||
"schema": "wai.quantum.exercise/1",
|
||
"id": "deutsch-jozsa",
|
||
"translations": { "zh-CN": "machine-assisted: to be reviewed by a fluent reader before it is advertised" },
|
||
"title": { "en": "Constant or balanced, in one query", "zh-CN": "常数还是平衡,一次查询见分晓" },
|
||
"task": {
|
||
"en": "The oracle computes f(x₀, x₁) = x₀ ⊕ x₁ into q[2]: a balanced function. Around it, write the Deutsch–Jozsa circuit so that the measured inputs read 11 every time. Keep the oracle's two cx gates as they are.",
|
||
"zh-CN": "预言机(oracle)把 f(x₀, x₁) = x₀ ⊕ x₁ 计算到 q[2] 中:这是一个平衡函数。在它周围写出 Deutsch–Jozsa 线路,使测得的输入每次都读出 11。保持预言机的两个 cx 门不变。"
|
||
},
|
||
"starter": [
|
||
"OPENQASM 3.0;",
|
||
"include \"stdgates.inc\";",
|
||
"qubit[3] q;",
|
||
"bit[2] c;",
|
||
"// before the oracle: your gates here",
|
||
"// the oracle: f(x) = x0 xor x1, into q[2]",
|
||
"cx q[0], q[2];",
|
||
"cx q[1], q[2];",
|
||
"// after the oracle: your gates here",
|
||
"c[0] = measure q[0];",
|
||
"c[1] = measure q[1];"
|
||
],
|
||
"intent": { "distribution": { "11": 1.0 } },
|
||
"constraints": { "allow": ["h", "x", "cx"], "counts": { "cx": { "min": 2, "max": 2 }, "x": { "max": 1 } } },
|
||
"hints": {
|
||
"en": [
|
||
"Put the inputs in superposition, so that the oracle is asked about every input at once.",
|
||
"Prepare q[2] in |−⟩ before the oracle: then f(x) comes back as a sign on |x⟩, by phase kickback.",
|
||
"After the oracle, interfere the inputs again. A constant function would bring them back to 00."
|
||
],
|
||
"zh-CN": [
|
||
"让输入处于叠加,这样一次就同时向预言机询问了所有输入。",
|
||
"在预言机之前把 q[2] 制备到 |−⟩:这样 f(x) 会通过相位反冲,以 |x⟩ 上的符号返回。",
|
||
"预言机之后,再让输入发生一次干涉。如果函数是常数,输入会回到 00。"
|
||
]
|
||
},
|
||
"reference": [
|
||
"OPENQASM 3.0;",
|
||
"include \"stdgates.inc\";",
|
||
"qubit[3] q;",
|
||
"bit[2] c;",
|
||
"x q[2];",
|
||
"h q[0];",
|
||
"h q[1];",
|
||
"h q[2];",
|
||
"cx q[0], q[2];",
|
||
"cx q[1], q[2];",
|
||
"h q[0];",
|
||
"h q[1];",
|
||
"c[0] = measure q[0];",
|
||
"c[1] = measure q[1];"
|
||
],
|
||
"wrong": [
|
||
{
|
||
"fails": "intent",
|
||
"note": "with q[2] left in |0⟩ the answer never comes back as a phase",
|
||
"qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[3] q;", "bit[2] c;", "h q[0];", "h q[1];", "cx q[0], q[2];", "cx q[1], q[2];", "h q[0];", "h q[1];", "c[0] = measure q[0];", "c[1] = measure q[1];"]
|
||
},
|
||
{
|
||
"fails": "constraint",
|
||
"note": "an oracle with one cx removed is a different function",
|
||
"qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[3] q;", "bit[2] c;", "x q[2];", "h q[0];", "h q[1];", "h q[2];", "cx q[0], q[2];", "h q[0];", "h q[1];", "c[0] = measure q[0];", "c[1] = measure q[1];"]
|
||
}
|
||
]
|
||
}
|