The Grover algorithm deals with sorting in an unstructured database and we can build an oracle (target function f) to achieve this. The oracle returns 1 if the element we search is founded otherwise 0. Now my question is whether it is possible to add a condition into the oracle such as I'm looking odd element from a list l where l = [0,1,2,3,4,5]. As far as I know, the Grover algorithm can't do a search under a specific condition, correct? Thank you for your answer.
Yes, it's possible. In Grover, or more generally amplitude amplification, you perform the following repeatedly:
- Reflect on the good space
- Reflect on the initial state
During the reflection about the good space, you must mark the good space and during this marking process, you can add any condition you like including checking whether or not the "data part" of your state is in a certain list. What would this "condition checking" look like in a circuit? Exactly as it would look like in a classical computer.
See this tutorial of Microsoft . Refer to the SAT oracle tutorials, where you can implement a very general oracle.