Simon's algorithm
Simon's algorithm is a quantum query algorithm for a problem known as Simon's problem. This is a promise problem with a flavor similar to the Deutsch-Jozsa and Bernstein-Vazirani problems, but the specifics are different.
Simon's algorithm is significant because it provides an exponential advantage of quantum over classical (including probabilistic) algorithms, and the technique it uses inspired Peter Shor's discovery of an efficient quantum algorithm for integer factorization.
Simon's problem
The input function for Simon's problem takes the form
for positive integers and We could restrict our attention to the case in the interest of simplicity, but there's little to be gained in making this assumption — Simon's algorithm and its analysis are basically the same either way.
Simon's problem
Input: a function
Promise: there exists a string such that for all
Output: the string
We'll unpack the promise to better understand what it says momentarily, but first let's be clear that it requires that has a very special structure — so most functions won't satisfy this promise. It's also fitting to acknowledge that this problem isn't intended to have practical importance. Rather, it's a somewhat artificial problem tailor-made to be easy for quantum computers and hard for classical computers.
There are two main cases: the first case is that is the all-zero string and the second case is that is not the all-zero string.
-
Case 1: If is the all-zero string, then we can simplify the if and only if statement in the promise so that it reads This is equivalent to being a one-to-one function.
-
Case 2: If is not the all-zero string, then the promise being satisfied for this string implies that is two-to-one, meaning that for every possible output string of there are exactly two input strings that cause to output that string. Moreover, these two input strings must take the form and for some string
It's important to recognize that there can only be one string that works if the promise is met, so there's always a unique correct answer for functions that satisfy the promise.
Here's an example of a function taking the form that satisfies the promise for the string
There are different input strings and different output strings, each of which occurs twice — so this is a two-to-one function. Moreover, for any two different input strings that produce the same output string, we see that the bitwise XOR of these two input strings is equal to which is equivalent to saying that either one of them equals the other XORed with
Notice that the only thing that matters about the actual output strings is whether they're the same or different for different choices of input strings. For instance, in the example above, there are four strings and that appear as outputs of We could replace these four strings with different strings, so long as they're all distinct, and the correct solution would not change.
Algorithm description
Here's a quantum circuit diagram representing Simon's algorithm.
To be clear, there are qubits on the top that are acted upon by Hadamard gates and qubits on the bottom that go directly into the query gate. It looks very similar to the algorithms we've already discussed in the lesson, but this time there's no phase kickback; the bottom qubits all go into the query gate in the state
To solve Simon's problem using this circuit will actually require several independent runs of it followed by a classical post-processing step, which will be described later after the behavior of the circuit is analyzed.
Analysis
The analysis of Simon's algorithm begins along similar lines to the Deutsch-Jozsa algorithm. After the first layer of Hadamard gates is performed on the top qubits, the state becomes
When the is performed, the output of the function is XORed onto the all-zero state of the bottom qubits, so the state becomes
When the second layer of Hadamard gates is performed, we obtain the following state by using the same formula for the action of a layer of Hadamard gates as before.
At this point, the analysis diverges from the ones for the previous algorithms in this lesson.
We're interested in the probability for the measurements to result in each possible string Through the rules for analyzing measurements described in the Multiple systems lesson of the Basics of quantum information course, we find that the probability to obtain the string is equal to
To get a better handle on these probabilities, we'll need just a bit more notation and terminology. First, the range of the function is the set containing all of its output strings.
Second, for each string we can express the set of all input strings that cause the function to evaluate to this output string as
The set is known as the preimage of under We can define the preimage under of any set in place of in an analogous way — it's the set of all elements that maps to that set. (This notation should not be confused with the inverse of the function which may not exist. The fact that the argument on the left-hand side is the set rather than the element is the clue that allows us to avoid this confusion.)
Using this notation, we can split up the sum in our expression for the probabilities above to obtain
Every string is represented exactly once by the two summations — we're basically just putting these strings into separate buckets depending on which output string they produce when we evaluate the function and then summing separately over all the buckets.
We can now evaluate the Euclidean norm squared to obtain
To simplify these probabilities further, let's take a look at the value
for an arbitrary selection of
If it happens to be the case that then is a one-to-one function and there's always just a single element for every The value of the expression is in this case.
If, on the other hand, then there are exactly two strings in the set To be precise, if we choose to be any one of these two strings, then the other string must be by the promise in Simon's problem. Using this observation we can simplify as follows.
So, it turns out that the value is independent of the specific choice of in both cases.
We can now finish off the analysis by looking at the same two cases as before separately.
-
Case 1: In this case the function is one-to-one, so there are strings and we obtain
In words, the measurements result in a string chosen uniformly at random.
-
Case 2: In this case is two-to-one, so there are elements in Using the formula from above we conclude that the probability to measure each is
In words, we obtain a string chosen uniformly at random from the set which contains strings. (Because exactly half of the binary strings of length have binary dot product with and the other have binary dot product with as we already observed in the analysis of the Deutsch-Jozsa algorithm for the Bernstein-Vazirani problem.)
Classical post-processing
We now know what the probabilities are for the possible measurement outcomes when we run the quantum circuit for Simon's algorithm. Is this enough information to determine ?
The answer is yes, provided that we're willing to repeat the process several times and accept that it could fail with some probability, which we can make very small by running the circuit enough times. The essential idea is that each execution of the circuit provides us with statistical evidence concerning and we can use that evidence to find with very high probability if we run the circuit sufficiently many times.
Let's suppose that we run the circuit independently times, for There's nothing special about this particular number of iterations — we could take to be larger (or smaller) depending on the probability of failure we're willing to tolerate, as we will see. Choosing will ensure that we have greater than a % chance of recovering
By running the circuit times, we obtain strings To be clear, the superscripts here are part of the names of these strings, not exponents or indexes to their bits, so we have
We now form a matrix having rows and columns by taking the bits of these strings as binary-valued entries.
Now, we don't know what is at this point — our goal is to find this string. But imagine for a moment that we do know the string and we form a column vector from the bits of the string as follows.
If we perform the matrix-vector multiplication modulo — meaning that we perform the multiplication as usual and then take the remainder of the entries of the result after dividing by — we obtain the all-zero vector.
That is, treated as a column vector as just described, the string will always be an element of the null space of the matrix provided that we do the arithmetic modulo This is true in both the case that and To be more precise, the all-zero vector is always in the null space of and it's joined by the vector whose entries are the bits of in case
The question remaining is whether there will be any other vectors in the null space of besides the ones corresponding to and The answer is that this becomes increasingly unlikely as increases — and if we choose the null space of will contain no other vectors in addition to those corresponding to and with greater than a % chance. More generally, if we replace with for an arbitrary choice of a positive integer the probability that the vectors corresponding to and are alone in the null space of is at least
Using linear algebra, it is possible to efficiently calculate a description of the null space of modulo Specifically, it can be done using Gaussian elimination, which works the same way when arithmetic is done modulo as it does with real or complex numbers. So long as the vectors corresponding to and are alone in the null space of which happens with high probability, we can deduce from the results of this computation.
Classical difficulty
How many queries does a classical query algorithm need to solve Simon's problem? The answer is: a lot, in general.
There are different precise statements that can be made about the classical difficulty of this problem, and here's just one of them. If we have any probabilistic query algorithm, and that algorithm makes fewer than queries, which is a number of queries that's exponential in then that algorithm will fail to solve Simon's problem with probability at least
Sometimes, proving impossibility results like this can be very challenging, but this one isn't too difficult to prove through an elementary probabilistic analysis. Here, however, we'll only briefly examine the basic intuition behind it.
We're trying to find the hidden string but so long as we don't query the function on two strings having the same output value, we'll get very limited information about Intuitively speaking, all we'll learn is that the hidden string is not the exclusive-OR of any two distinct strings we've queried. And if we query fewer than strings, then there will still be a lot of choices for that we haven't ruled out because there aren't enough pairs of strings to do this. This isn't a formal proof, it's just the basic idea.
So, in summary, Simon's algorithm provides us with a striking advantage of quantum over classical algorithms within the query model. In particular, Simon's algorithm solves Simon's problem with a number of queries that's linear in the number of input bits of our function, whereas any classical algorithm, even if it's probabilistic, needs to make a number of queries that's exponential in in order to solve Simon's problem with a reasonable probability of success.