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]>
70 lines
3.3 KiB
JSON
70 lines
3.3 KiB
JSON
{
|
||
"schema": "wai.quantum.exercise/1",
|
||
"id": "bit-flip-code",
|
||
"translations": { "zh-CN": "machine-assisted: to be reviewed by a fluent reader before it is advertised" },
|
||
"title": { "en": "Three copies against one flip", "zh-CN": "用三份副本抵御一次翻转" },
|
||
"task": {
|
||
"en": "q[0] holds |1⟩. Encode it into three qubits, let the error flip the qubit q[err] (the check tries err = 0, 1 and 2), then decode and correct so that q[0] reads 1 in every case. Use no x besides the two the program has.",
|
||
"zh-CN": "q[0] 存有 |1⟩。把它编码到三个量子比特中,让错误翻转量子比特 q[err](检查会依次尝试 err = 0、1 和 2),然后解码并纠正,使 q[0] 在每种情况下都读出 1。除了程序中已有的两个 x,不要再使用 x。"
|
||
},
|
||
"starter": [
|
||
"OPENQASM 3.0;",
|
||
"include \"stdgates.inc\";",
|
||
"input uint err;",
|
||
"qubit[3] q;",
|
||
"bit[1] c;",
|
||
"// the state to protect",
|
||
"x q[0];",
|
||
"// encode: your gates here",
|
||
"// the error, on a qubit the check chooses",
|
||
"x q[err];",
|
||
"// decode and correct: your gates here",
|
||
"c[0] = measure q[0];"
|
||
],
|
||
"cases": [
|
||
{ "inputs": { "err": 0 }, "name": { "en": "a flip of q[0]", "zh-CN": "q[0] 被翻转" } },
|
||
{ "inputs": { "err": 1 }, "name": { "en": "a flip of q[1]", "zh-CN": "q[1] 被翻转" } },
|
||
{ "inputs": { "err": 2 }, "name": { "en": "a flip of q[2]", "zh-CN": "q[2] 被翻转" } }
|
||
],
|
||
"intent": { "distribution": { "1": 1.0 } },
|
||
"constraints": { "allow": ["x", "cx", "ccx"], "counts": { "x": { "max": 2 } } },
|
||
"hints": {
|
||
"en": [
|
||
"Encode with two controlled-NOTs from q[0]: |1⟩ becomes |111⟩, and one flip leaves two copies right.",
|
||
"Decoding with the same two controlled-NOTs leaves q[1] and q[2] saying whether each disagrees with q[0].",
|
||
"q[0] is wrong exactly when both other qubits disagree with it. Which gate flips a qubit when two others are both 1?"
|
||
],
|
||
"zh-CN": [
|
||
"用两个以 q[0] 为控制的受控非门编码:|1⟩ 变成 |111⟩,一次翻转之后仍有两份副本是对的。",
|
||
"用同样的两个受控非门解码后,q[1] 和 q[2] 分别表示它是否与 q[0] 不一致。",
|
||
"恰好当另外两个量子比特都与 q[0] 不一致时,q[0] 才是错的。哪个门会在另外两个量子比特都为 1 时翻转一个量子比特?"
|
||
]
|
||
},
|
||
"reference": [
|
||
"OPENQASM 3.0;",
|
||
"include \"stdgates.inc\";",
|
||
"input uint err;",
|
||
"qubit[3] q;",
|
||
"bit[1] c;",
|
||
"x q[0];",
|
||
"cx q[0], q[1];",
|
||
"cx q[0], q[2];",
|
||
"x q[err];",
|
||
"cx q[0], q[1];",
|
||
"cx q[0], q[2];",
|
||
"ccx q[2], q[1], q[0];",
|
||
"c[0] = measure q[0];"
|
||
],
|
||
"wrong": [
|
||
{
|
||
"fails": "intent",
|
||
"note": "without correction a flip of q[0] is read as 0",
|
||
"qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "input uint err;", "qubit[3] q;", "bit[1] c;", "x q[0];", "cx q[0], q[1];", "cx q[0], q[2];", "x q[err];", "cx q[0], q[1];", "cx q[0], q[2];", "c[0] = measure q[0];"]
|
||
},
|
||
{
|
||
"fails": "intent",
|
||
"note": "correcting with one copy fixes some flips and makes others",
|
||
"qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "input uint err;", "qubit[3] q;", "bit[1] c;", "x q[0];", "cx q[0], q[1];", "cx q[0], q[2];", "x q[err];", "cx q[0], q[1];", "cx q[0], q[2];", "cx q[1], q[0];", "c[0] = measure q[0];"]
|
||
}
|
||
]
|
||
}
|