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