A quantum combination lock
To learn how quantum algorithms differ from classical ones, we need a problem that allows us to compare a quantum algorithm to its classical counterpart. The problem, we want to look at, is the problem of finding out the secret code that is behind a quantum "combination lock".
Let's imagine a black box where we can set a code, and for every 1 that occurs in the same same position as in the secret code, the answer changes (0 becomes 1, 1 becomes 0).
So in the case of the secret code 110, we would have the following two-qubit gates between guess and answer qubits:
-
A
\(\ket{0}\)
-
B
\(\ket{1}\)
Exactly! The first operator is applied as the first digit is guessed correctly. The second one is not applied.
Not quite! The first operator is applied as the first digit is guessed correctly. The second one is not applied.
Cracking the black box open
Normally, we are not provided with the circuit itself and we are tasked to find out what the secret code is by guessing and looking at the answer.
Let's go for a classical solution first. Without further ado, can you figure out the secret code without opening the blackbox?
Measurements
-
A
1001
-
B
0101
-
C
1100
-
D
1101
That's right! The secret code is 1101.
You can now also open the black box to take a look inside.
Not quite! The secret code is actually 1101.
You can now also open the black box to take a look
inside.
-
A
1
-
B
2
-
C
3
-
D
4
Exactly! In general, it takes at least 4 tries to figure out the secret code. You will find out how on the next page.
Close, but not quite! In general, it takes at least 4 tries to figure out the secret code. You will find out how on the next page.
A quantum solution for the quantum combination lock
For a classical solution to the quantum combination lock we always needed to perform at least as much guesses as we had digits in the secret code. This is not bad. But can we get better using the properties of qubits, namely superposition and entanglement? It turns out, we can! Let's explore how.
Investigating another black box
A common way to work with quantum algorithm is to prepare an equal superposition and use it for calculation. This is also used in the Bernstein-Vazirani algorithm we want to look into now.
Afterward, open the black box and check how you can retrieve the secret code from the measurement outcomes.
Measurements
Hints
- To prepare an equal superposition of multiple qubits, apply a H gate to every qubit involved.
- The output qubit is the last qubit.
-
A
1001
-
B
0101
-
C
0110
-
D
1101
That's right! The secret code is 0110.
You can now also open the black box to take a look
inside.
Not quite! The secret code is actually 0110.
You can now also open the black box to take a
look
inside.
-
A
1
-
B
2
-
C
3
-
D
4
That’s correct! Strange, how we just needed one guess and actually the controlling qubits changed.
Not quite! It is actually only one guess needed.