5.2.1 Deutsch’s algorithm
It is late on Sunday evening. Alice and Bob have just finished their homework assignments for the quantum computing class and are about to watch a 3D movie. When they turn on their holographic television set, they discover that the movie screening has been postponed due to unexpected dramatic news coverage coming from the International Transgalactic Station. There has been a terrible accident and a module containing two crew members, Hila and Iman, has separated from the main mothership. The last message received from the module was that Iman has been injured and is heavily bleeding – he is in need of an urgent blood transfer. What makes the situation complicated is that Hila and Iman are somewhat in shock and forgot their own blood type – they can only remember that they each had blood type A or B. The news presenter is appealing to the general public for help with suggesting a way for Hila and Iman to determine if they have the same blood type, because if that was the case Hila could transfer her blood to Iman to save his life. This is because the medical kit in Hila and Iman’s module includes a lympho-transcoder that is able to convert either of the two blood types to the opposite one. Hence, even if it turns out that their blood types are mismatching, Hila can convert her’s to the opposite one using the lympho-transcoder.
Upon hearing these news, Alice and Bob immediately abandon their plan to watch a movie and start to ponder what could be done to help Hila and Iman.
The news coverage continues with some additional information.
Luckily, it turns out that the module involved in the accident contains a database chip that stores Hila and Iman’s blood type.
We can model this by a function
What needs to be determined is whether
The solution seems at hand: Hila and Iman simply need to query the database twice to read out their respective blood types,
Our two protagonists are at an impasse.
Clearly, any classical algorithm needs to evaluate
After flipping through some manuals, Bob discovers that the database chip can be switched into quantum mode.
When enabled, the database chip no longer evaluates the function classically but instead implements the sign oracle
-
1.
Prepare a qubit in state
. -
2.
Use the database chip in quantum mode to apply the operation
. -
3.
Apply the Hadamard gate
to the output qubit and measure it. -
4.
If the outcome is
then Hila and Iman have the same blood type and otherwise they have different blood types.
Note that in this procedure Hila and Iman only query the database chip once to determine if they have the same blood type. Here is an implementation of the algorithm in Quirky:
The picture shows that the outcome is
But why does Deutsch’s algorithm work?
Let us analyze it step by step.
The first Hadamard gate creates the state
After applying the second Hadamard, we obtain the following state:
Note that the two signs
It is a good exercise to verify this explicitly:
Exercise 5.3 (Verifying Deutsch’s algorithm).
Solution.
We evaluate Eq. 5.7 for all four functions.-
•
For
: -
•
For
: -
•
For the all-zeros function:
-
•
For the all-ones function:
Eq. 5.8 shows that the final measurement yields outcome 0 if and only if
Another way to interpret Deutsch’s algorithm is that it computes the sum of the two bits
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
This is also why the sum modulo two is known as the XOR (short for ‘exclusive OR’) of the two bits, since it is one if exactly one of the two bits is set.