2
$\begingroup$

I found some examples of implementing the oracle when the marked state is $|000\rangle$. But how can we know what gate we should use inside of the oracle?

enter image description here

Besides, for the part implementation, the example shows like this:

enter image description here

Mathematically, it should be $2|0\rangle\langle 0|-I$, but how can it be realized by X gates and controlled-Z gate?

$\endgroup$
0
$\begingroup$

The Boolean oracle applies X gates to the three qubits. This way the state |000⟩ becomes |111⟩. Then the multi-CX gate flips the target qubit if the state is |000⟩, from which you then get |0001⟩, or |x,y,z,0⟩ otherwise.

The phase oracle flips the phase of your qubits. So when you apply the X gates on the three qubits, what you are doing is essentially getting the state |111⟩ if it was |000⟩, and then mark it by changing the sign in front to negative, so -|111⟩. Then when you add the X gates again, you change it to -|000⟩.

So basically the phase oracle applies a phase in order to mark your result, whereas a boolean oracle stores the result in an additional qubit, so the choice of gates depends on what you are trying to achieve. For algorithms like Grover's, phase oracles are generally used.

| improve this answer | |
$\endgroup$
0
$\begingroup$

Those two circuits are two different approches in implementing the oracle.

In the first one, the idea is to implement a function $f$ such that $f(x)=1$ iff $x=|000\rangle$. If the input is $|000\rangle$, then a NOT gate is applied to $q_a$ which is the ancilla qubit. If the ancilla qubit is prepared in state $|-\rangle$, then using phase kickback the sign of the amplitude of the state $|000\rangle$ is flipped.

In the second one, the sign of the amplitude of the state $|000\rangle$ is flipped directly through controlled Z gate, which adds an overall of phase of -1 if all control qubits are in state 1.

The reason why we have X gates is to be able to control them. If initially they are all 0, then applying the X gates all of them are in state 1 and we can apply the controlled operations. For instance oracle for 010 would have X gates only on the first and third qubits.

About your other question, think of the effect of that operation on an arbitrary basis state. If you apply it to state $|0\rangle$, then the output is $|0\rangle$ and the output is $-|x\rangle$ for any other input $|x\rangle$. Think about the converse, where you only flip the amplitude of state $|0\rangle$. Those two operations are indistinguihable and therefore the latter is implemented, which is exactly the same as the oracle implementation where $|000\rangle$ is the marked element. (Check this link:Gate corresponding to $-I$)

| improve this answer | |
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.