TransWikia.com

In Grover, how to implement oracle and amplification using Qiskit?

Quantum Computing Asked on May 18, 2021

I found some examples of implementing the oracle when the marked state is $|000rangle$.
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|0ranglelangle 0|-I$, but how can it be realized by X gates and controlled-Z gate?

2 Answers

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.

Answered by At2005 on May 18, 2021

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=|000rangle$. If the input is $|000rangle$, 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 $|000rangle$ is flipped.

In the second one, the sign of the amplitude of the state $|000rangle$ 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 $|0rangle$, then the output is $|0rangle$ and the output is $-|xrangle$ for any other input $|xrangle$. Think about the converse, where you only flip the amplitude of state $|0rangle$. Those two operations are indistinguihable and therefore the latter is implemented, which is exactly the same as the oracle implementation where $|000rangle$ is the marked element. (Check this link:Gate corresponding to $-I$)

Answered by usercs on May 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP