0
$\begingroup$

I want to build an oracle with multiple state solutions. For example: For n=4 qubits, I want the state solutions to be 1111, 1101, 1110 and 1100. So, as you can see, in all solutions, there are two fixed qubits 11XX.

How can I build an oracle that checks if the 2 most significant qubits are 1, and does not check the state of the other qubits?

Note: I not interested on expanding the circuit, which means, I don't want to build as below:

from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister

qr=QuantumRegister(4)
oracle = QuantumCircuit(qr)
cz_gate = ZGate().control(3)

#for |1100>
oracle.x(0)
oracle.x(1)
oracle.append(cz_gate,qr)
oracle.x(0)
oracle.x(1)


#for |1110>
oracle.x(0)
oracle.append(cz_gate,qr)
oracle.x(0)


#for |1101>
oracle.x(1)
oracle.append(cz_gate,qr)
oracle.x(1)

#for |1111>
oracle.append(cz_gate,qr)

The circuit above can be printed as:not the oracle I want

$\endgroup$
1
  • $\begingroup$ A CCX gate that controls on both the first two qubits should help you? The 0th and the 1st qubit. $\endgroup$ Nov 19 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.