There are different ways to achieve that, my favorite is probably this one: The oracle you describe above is just a classical function ("True if my bitstring is 101 or 110") converted to a quantum phase flip. So essentially you only have to build a circuit that implements that classical logic plus some gates to do the phase flip.
Option A: Via classical logic
Step 1: Create the classical logic circuit in Qiskit:
from qiskit.circuit import classical_function, Int1
# define a classical function that can be turned into a circuit
@classical_function
def oracle(x1: Int1, x2: Int1, x3: Int1) -> Int1:
return (x1 and not x2 and x3) or (x1 and x2 and not x3)
bitcircuit = oracle.synth() # turn it into a circuit
Now you have something looking like this:
q_0: ──■────■──
│ │
q_1: ──■────┼──
│ │
q_2: ──┼────■──
┌─┴─┐┌─┴─┐
q_3: ┤ X ├┤ X ├
└───┘└───┘
It flips the output bit (the one at the bottom) if the qubits are in state $|101\rangle$ or $|110\rangle$.
Step 2: To change this into a phaseflip oracle you can sandwich the bottom qubit in between X and H gates:
from qiskit.circuit import QuantumCircuit
phaseoracle = QuantumCircuit(4)
phaseoracle.x(3)
phaseoracle.h(3)
phaseoracle.compose(bitoracle, inplace=True)
phaseoracle.h(3)
phaseoracle.x(3)
to get this circuit, which implements your oracle:
q_0: ────────────■────■────────────
│ │
q_1: ────────────■────┼────────────
│ │
q_2: ────────────┼────■────────────
┌───┐┌───┐┌─┴─┐┌─┴─┐┌───┐┌───┐
q_3: ┤ X ├┤ H ├┤ X ├┤ X ├┤ H ├┤ X ├
└───┘└───┘└───┘└───┘└───┘└───┘
So all together:
from qiskit.circuit import classical_function, Int1, QuantumCircuit
# define a classical function that can be turned into a circuit
@classical_function
def oracle(x1: Int1, x2: Int1, x3: Int1) -> Int1:
return (x1 and not x2 and x3) or (x1 and x2 and not x3)
bitcircuit = oracle.synth() # turn it into a circuit
phaseoracle = QuantumCircuit(4)
phaseoracle.x(3)
phaseoracle.h(3)
phaseoracle.compose(bitoracle, inplace=True)
phaseoracle.h(3)
phaseoracle.x(3)
Option B: Via looking hard
You could see that the oracle is implemented by two controlled Z gates:
from qiskit.circuit import QuantumCircuit
phaseoracle = QuantumCircuit(3)
phaseoracle.cz(0, 2)
phaseoracle.cz(0, 1)