{ "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];"] } ] }