Grover's algorithm is used, among other things, to search an item $\mathbf{y}$ in an unordered list of items $[\mathbf{x}_0, \mathbf{x}_1, ..., \mathbf{x}_{n-1}]$ of length $n$. Even though there are plenty of questions here regarding this topic, I still miss the point.
Searching in a list, the classical way
Normally, I would design a search function this way $$ \mathrm{search}([\mathbf{x}_0, \mathbf{x}_1, ..., \mathbf{x}_{n-1}], \mathbf{y}) = i \in \mathbb{N} \quad \text{such that } \mathbf{x}_i = \mathbf{y} $$ So I give the list and the wanted item as inputs, and I receive the position of the item in the list as output. I think I have understood that the information about $\mathbf{y}$ is embedded in the algorithm through the oracle gate $O$, so our function becomes $$ \mathrm{search}_\mathbf{y}([\mathbf{x}_1, \mathbf{x}_2, ..., \mathbf{x}_n] ) = i \in \mathbb{N} \quad \text{such that } \mathbf{x}_i = \mathbf{y} $$ Let's make a practical example. Consider searching the ace of spades $1\spadesuit$ in a sequence of 8 cards from a standard 52-card deck:
The list of length $8$ is $[ \mathbf{x}_0 = J\clubsuit,$ $ \mathbf{x}_1 = 10\diamondsuit,$ $ \mathbf{x}_2 = 4\heartsuit,$ $ \mathbf{x}_3 = Q\clubsuit,$ $ \mathbf{x}_4 = 3\spadesuit,$ $ \mathbf{x}_5 = 1\spadesuit,$ $ \mathbf{x}_6 = 6\spadesuit, $ $ \mathbf{x}_7 = 6\clubsuit]$.
The wanted element is $\mathbf{x}_5$. I should obtain $\mathrm{search}_{\spadesuit}(cards) = 5$. Each card can be encoded with $\lceil{\log_2 52}\rceil = 6$bits, the list has $8$ elements so we need $6\times 8 = 48$ bits to encode the list. In this case, the oracle $O$ will implement the function: $$f(\mathbf{x}) = \begin{cases} 1, & \mathbf{x} = 1\spadesuit \\ 0, & \text{otherwise} \end{cases}$$
However, the input of Grover's algorithm is not a state of $48$qubits.
(NB: Image of shuffled deck is taken from here)
Grover and its oracle
Several sources (eg. here - graphically explained) say that the input of the algorithm is different: the input is a state taken from the search space $S = \{ 0, 1, 2, ..., N \} = \{0, 1, 2, ..., 7 \} $ where $N$ is the number of elements of the list. Each number corresponds to the position of an element in the list.
The input of $\mathrm{search}_{\spadesuit}(\cdot)$ is now a $\lceil \log_2 8 \rceil = 3$qubit vector $|\psi\rangle$, which must be a superposition of all the items in the search space $S$.
We know
- $|0_{3\text{qubits}}\rangle = |000\rangle$ corresponds to $J\clubsuit$;
- $|1_{3\text{qubits}}\rangle = |001\rangle$ corresponds to $10\diamondsuit$;
- $|2_{3\text{qubits}}\rangle = |010\rangle$ corresponds to $4\heartsuit$;
- $|5_{3\text{qubits}}\rangle = |101\rangle$ corresponds to $1\spadesuit$ which is the wanted element;
- and so on...
In this case we have $$\mathrm{search}_{\spadesuit}(|\psi\rangle) = |5_{3\text{qubits}}\rangle$$ But in this case, our oracle would have to implement the function $$f(|\psi\rangle) = \begin{cases} 1, & |\psi\rangle = |5_{3\text{qubits}}\rangle \\ 0, & \text{otherwise} \end{cases}$$
Building the oracle requires us to know that $\spadesuit$ is at position 5. What's the point to execute the algorithm if we have already searched for the element in order to build the oracle?