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]>
67 lines
2.7 KiB
JSON
67 lines
2.7 KiB
JSON
{
|
|
"schema": "wai.quantum.exercise/1",
|
|
"id": "qft",
|
|
"translations": { "zh-CN": "machine-assisted: to be reviewed by a fluent reader before it is advertised" },
|
|
"title": { "en": "The quantum Fourier transform, and back", "zh-CN": "量子傅里叶变换,以及它的逆" },
|
|
"task": {
|
|
"en": "The program applies the three-qubit quantum Fourier transform. After it, write the inverse transform, so that the whole program is the same circuit as doing nothing. Keep the transform's gates as they are.",
|
|
"zh-CN": "这个程序作用了三量子比特的量子傅里叶变换。在它之后写出逆变换,使整个程序与什么也不做是同一条线路。保持变换本身的门不变。"
|
|
},
|
|
"starter": [
|
|
"OPENQASM 3.0;",
|
|
"include \"stdgates.inc\";",
|
|
"qubit[3] q;",
|
|
"// the quantum Fourier transform",
|
|
"h q[0];",
|
|
"cp(pi/2) q[1], q[0];",
|
|
"cp(pi/4) q[2], q[0];",
|
|
"h q[1];",
|
|
"cp(pi/2) q[2], q[1];",
|
|
"h q[2];",
|
|
"swap q[0], q[2];",
|
|
"// its inverse: your gates here"
|
|
],
|
|
"intent": { "equivalent": "OPENQASM 3.0;\ninclude \"stdgates.inc\";\nqubit[3] q;\n" },
|
|
"constraints": { "allow": ["h", "cp", "swap"], "counts": { "h": { "min": 6, "max": 6 }, "cp": { "min": 6, "max": 6 }, "swap": { "min": 2, "max": 2 } } },
|
|
"hints": {
|
|
"en": [
|
|
"The inverse of a sequence of gates is the inverses of the gates, in the reverse order.",
|
|
"h and swap are their own inverses. The inverse of cp(θ) is cp(−θ) on the same qubits."
|
|
],
|
|
"zh-CN": [
|
|
"一串门的逆,就是把每个门换成它的逆,再把顺序倒过来。",
|
|
"h 和 swap 都是自己的逆。cp(θ) 的逆是作用在同样量子比特上的 cp(−θ)。"
|
|
]
|
|
},
|
|
"reference": [
|
|
"OPENQASM 3.0;",
|
|
"include \"stdgates.inc\";",
|
|
"qubit[3] q;",
|
|
"h q[0];",
|
|
"cp(pi/2) q[1], q[0];",
|
|
"cp(pi/4) q[2], q[0];",
|
|
"h q[1];",
|
|
"cp(pi/2) q[2], q[1];",
|
|
"h q[2];",
|
|
"swap q[0], q[2];",
|
|
"swap q[0], q[2];",
|
|
"h q[2];",
|
|
"cp(-pi/2) q[2], q[1];",
|
|
"h q[1];",
|
|
"cp(-pi/4) q[2], q[0];",
|
|
"cp(-pi/2) q[1], q[0];",
|
|
"h q[0];"
|
|
],
|
|
"wrong": [
|
|
{
|
|
"fails": "intent",
|
|
"note": "the gates reversed but the angles not negated",
|
|
"qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[3] q;", "h q[0];", "cp(pi/2) q[1], q[0];", "cp(pi/4) q[2], q[0];", "h q[1];", "cp(pi/2) q[2], q[1];", "h q[2];", "swap q[0], q[2];", "swap q[0], q[2];", "h q[2];", "cp(pi/2) q[2], q[1];", "h q[1];", "cp(pi/4) q[2], q[0];", "cp(pi/2) q[1], q[0];", "h q[0];"]
|
|
},
|
|
{
|
|
"fails": "constraint",
|
|
"note": "deleting the transform does nothing too, but the exercise keeps its gates",
|
|
"qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[3] q;"]
|
|
}
|
|
]
|
|
}
|