{ "schema": "wai.quantum.exercise/1", "id": "deutsch-jozsa", "translations": { "zh-CN": "machine-assisted: to be reviewed by a fluent reader before it is advertised" }, "title": { "en": "Constant or balanced, in one query", "zh-CN": "常数还是平衡,一次查询见分晓" }, "task": { "en": "The oracle computes f(x₀, x₁) = x₀ ⊕ x₁ into q[2]: a balanced function. Around it, write the Deutsch–Jozsa circuit so that the measured inputs read 11 every time. Keep the oracle's two cx gates as they are.", "zh-CN": "预言机(oracle)把 f(x₀, x₁) = x₀ ⊕ x₁ 计算到 q[2] 中:这是一个平衡函数。在它周围写出 Deutsch–Jozsa 线路,使测得的输入每次都读出 11。保持预言机的两个 cx 门不变。" }, "starter": [ "OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[3] q;", "bit[2] c;", "// before the oracle: your gates here", "// the oracle: f(x) = x0 xor x1, into q[2]", "cx q[0], q[2];", "cx q[1], q[2];", "// after the oracle: your gates here", "c[0] = measure q[0];", "c[1] = measure q[1];" ], "intent": { "distribution": { "11": 1.0 } }, "constraints": { "allow": ["h", "x", "cx"], "counts": { "cx": { "min": 2, "max": 2 }, "x": { "max": 1 } } }, "hints": { "en": [ "Put the inputs in superposition, so that the oracle is asked about every input at once.", "Prepare q[2] in |−⟩ before the oracle: then f(x) comes back as a sign on |x⟩, by phase kickback.", "After the oracle, interfere the inputs again. A constant function would bring them back to 00." ], "zh-CN": [ "让输入处于叠加,这样一次就同时向预言机询问了所有输入。", "在预言机之前把 q[2] 制备到 |−⟩:这样 f(x) 会通过相位反冲,以 |x⟩ 上的符号返回。", "预言机之后,再让输入发生一次干涉。如果函数是常数,输入会回到 00。" ] }, "reference": [ "OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[3] q;", "bit[2] c;", "x q[2];", "h q[0];", "h q[1];", "h q[2];", "cx q[0], q[2];", "cx q[1], q[2];", "h q[0];", "h q[1];", "c[0] = measure q[0];", "c[1] = measure q[1];" ], "wrong": [ { "fails": "intent", "note": "with q[2] left in |0⟩ the answer never comes back as a phase", "qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[3] q;", "bit[2] c;", "h q[0];", "h q[1];", "cx q[0], q[2];", "cx q[1], q[2];", "h q[0];", "h q[1];", "c[0] = measure q[0];", "c[1] = measure q[1];"] }, { "fails": "constraint", "note": "an oracle with one cx removed is a different function", "qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[3] q;", "bit[2] c;", "x q[2];", "h q[0];", "h q[1];", "h q[2];", "cx q[0], q[2];", "h q[0];", "h q[1];", "c[0] = measure q[0];", "c[1] = measure q[1];"] } ] }