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]>
59 lines
2.4 KiB
JSON
59 lines
2.4 KiB
JSON
{
|
||
"schema": "wai.quantum.exercise/1",
|
||
"id": "bernstein-vazirani",
|
||
"translations": { "zh-CN": "machine-assisted: to be reviewed by a fluent reader before it is advertised" },
|
||
"title": { "en": "A hidden string, in one query", "zh-CN": "一次查询找出隐藏的串" },
|
||
"task": {
|
||
"en": "The oracle computes f(x) = s · x (mod 2) into q[3] for a hidden three-bit string s. Write the Bernstein–Vazirani circuit around it so that the measured inputs read s every time. Keep the oracle's cx gates as they are.",
|
||
"zh-CN": "预言机为一个隐藏的三比特串 s 把 f(x) = s · x (mod 2) 计算到 q[3] 中。在它周围写出 Bernstein–Vazirani 线路,使测得的输入每次都读出 s。保持预言机的 cx 门不变。"
|
||
},
|
||
"starter": [
|
||
"OPENQASM 3.0;",
|
||
"include \"stdgates.inc\";",
|
||
"qubit[4] q;",
|
||
"bit[3] c;",
|
||
"// before the oracle: your gates here",
|
||
"// the oracle: f(x) = s . x, into q[3]",
|
||
"cx q[0], q[3];",
|
||
"cx q[2], q[3];",
|
||
"// after the oracle: your gates here",
|
||
"c[0] = measure q[0];",
|
||
"c[1] = measure q[1];",
|
||
"c[2] = measure q[2];"
|
||
],
|
||
"intent": { "distribution": { "101": 1.0 } },
|
||
"constraints": { "allow": ["h", "x", "cx"], "counts": { "cx": { "min": 2, "max": 2 }, "x": { "max": 1 } } },
|
||
"hints": {
|
||
"en": [
|
||
"The circuit has the same shape as Deutsch–Jozsa's, with one more input.",
|
||
"With every input in superposition and the target in |−⟩, the oracle leaves the sign (−1)^(s·x) on |x⟩; Hadamards turn that pattern of signs into |s⟩."
|
||
],
|
||
"zh-CN": [
|
||
"这条线路与 Deutsch–Jozsa 的形状相同,只是多一个输入。",
|
||
"当每个输入都处于叠加、目标比特处于 |−⟩ 时,预言机在 |x⟩ 上留下符号 (−1)^(s·x);Hadamard 门把这种符号模式变成 |s⟩。"
|
||
]
|
||
},
|
||
"reference": [
|
||
"OPENQASM 3.0;",
|
||
"include \"stdgates.inc\";",
|
||
"qubit[4] q;",
|
||
"bit[3] c;",
|
||
"x q[3];",
|
||
"h q;",
|
||
"cx q[0], q[3];",
|
||
"cx q[2], q[3];",
|
||
"h q[0];",
|
||
"h q[1];",
|
||
"h q[2];",
|
||
"c[0] = measure q[0];",
|
||
"c[1] = measure q[1];",
|
||
"c[2] = measure q[2];"
|
||
],
|
||
"wrong": [
|
||
{
|
||
"fails": "intent",
|
||
"note": "querying one basis input reads one bit of s at most",
|
||
"qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[4] q;", "bit[3] c;", "x q[0];", "cx q[0], q[3];", "cx q[2], q[3];", "c[0] = measure q[0];", "c[1] = measure q[1];", "c[2] = measure q[2];"]
|
||
}
|
||
]
|
||
}
|