Simon's problem

From HandWiki
Short description: Problem in computer science

In computational complexity theory and quantum computing, Simon's problem is a computational problem that is proven to be solved exponentially faster on a quantum computer than on a classical (that is, traditional) computer. The quantum algorithm solving Simon's problem, usually called Simon's algorithm, served as the inspiration for Shor's algorithm.[1] Both problems are special cases of the abelian hidden subgroup problem, which is now known to have efficient quantum algorithms.

The problem is set in the model of decision tree complexity or query complexity and was conceived by Daniel R. Simon in 1994.[2] Simon exhibited a quantum algorithm that solves Simon's problem exponentially faster with exponentially fewer queries than the best probabilistic (or deterministic) classical algorithm. In particular, Simon's algorithm uses a linear number of queries and any classical probabilistic algorithm must use an exponential number of queries.

This problem yields an oracle separation between the complexity classes BPP (bounded-error classical query complexity) and BQP (bounded-error quantum query complexity).[3] This is the same separation that the Bernstein–Vazirani algorithm achieves, and different from the separation provided by the Deutsch–Jozsa algorithm, which separates P and EQP. Unlike the Bernstein–Vazirani algorithm, Simon's algorithm's separation is exponential.

Because this problem assumes the existence of a highly-structured "black box" oracle to achieve its speedup, this problem has little practical value.[4] However, without such an oracle, exponential speedups cannot easily be proven, since this would prove that P is different from PSPACE.

Problem description

Given a function (implemented by a black box or oracle) [math]\displaystyle{ f:\{0,1\}^n\rightarrow \{0,1\}^n }[/math] with the promise that, for some unknown [math]\displaystyle{ s\in \{0,1\}^n }[/math], for all [math]\displaystyle{ x, y\in\{0,1\}^n }[/math],

[math]\displaystyle{ f(x)=f(y) }[/math] if and only if [math]\displaystyle{ x \oplus y \in \{0^n, s\} }[/math],

where [math]\displaystyle{ \oplus }[/math] denotes bitwise XOR. The goal is to identify [math]\displaystyle{ s }[/math] by making as few queries to [math]\displaystyle{ f(x) }[/math] as possible. Note that

[math]\displaystyle{ a \oplus b = 0^n }[/math] if and only if [math]\displaystyle{ a = b }[/math]

Furthermore, for some [math]\displaystyle{ x }[/math] and [math]\displaystyle{ s }[/math] in [math]\displaystyle{ x \oplus y = s }[/math], [math]\displaystyle{ y }[/math] is unique (not equal to [math]\displaystyle{ x }[/math]) if and only if [math]\displaystyle{ s \neq 0^n }[/math]. This means that [math]\displaystyle{ f }[/math] is two-to-one when [math]\displaystyle{ s \neq 0^n }[/math], and one-to-one when [math]\displaystyle{ s = 0^n }[/math]. It is also the case that [math]\displaystyle{ x \oplus y = s }[/math] implies [math]\displaystyle{ y = s \oplus x }[/math], meaning that[math]\displaystyle{ f(x) = f(y) = f(x \oplus {s}) }[/math]which shows how [math]\displaystyle{ f }[/math] is periodic.

The associated decision problem formulation of Simon's problem is to distinguish when [math]\displaystyle{ s = 0^n }[/math] ([math]\displaystyle{ f }[/math] is one-to-one), and when [math]\displaystyle{ s \neq 0^n }[/math] ([math]\displaystyle{ f }[/math] is two-to-one).


The following function is an example of a function that satisfies the required property for [math]\displaystyle{ n = 3 }[/math]:

[math]\displaystyle{ x }[/math] [math]\displaystyle{ f(x) }[/math]
000 101
001 010
010 000
011 110
100 000
101 110
110 101
111 010

In this case, [math]\displaystyle{ s = 110 }[/math] (i.e. the solution). Every output of [math]\displaystyle{ f }[/math] occurs twice, and the two input strings corresponding to any one given output have bitwise XOR equal to [math]\displaystyle{ s = 110 }[/math].

For example, the input strings [math]\displaystyle{ 010 }[/math] and [math]\displaystyle{ 100 }[/math] are both mapped (by [math]\displaystyle{ f }[/math]) to the same output string [math]\displaystyle{ 000 }[/math]. That is, [math]\displaystyle{ {\displaystyle f(010)=000} }[/math] and [math]\displaystyle{ {\displaystyle f(100)=000} }[/math]. Applying XOR to 010 and 100 obtains 110, that is [math]\displaystyle{ {\displaystyle 010\oplus 100=110=s}. }[/math]

[math]\displaystyle{ s=110 }[/math] can also be verified using input strings 001 and 111 that are both mapped (by f) to the same output string 010. Applying XOR to 001 and 111 obtains 110, that is [math]\displaystyle{ 001\oplus111=110=s }[/math]. This gives the same solution [math]\displaystyle{ s=110 }[/math] as before.

In this example the function f is indeed a two-to-one function where [math]\displaystyle{ {\displaystyle s\neq 0^{n}} }[/math].

Problem hardness

Intuitively, this is a hard problem to solve in a "classical" way, even if one uses randomness and accepts a small probability of error. The intuition behind the hardness is reasonably simple: if you want to solve the problem classically, you need to find two different inputs [math]\displaystyle{ x }[/math] and [math]\displaystyle{ y }[/math] for which [math]\displaystyle{ f(x)=f(y) }[/math]. There is not necessarily any structure in the function [math]\displaystyle{ f }[/math] that would help us to find two such inputs: more specifically, we can discover something about [math]\displaystyle{ f }[/math] (or what it does) only when, for two different inputs, we obtain the same output. In any case, we would need to guess [math]\displaystyle{ {\displaystyle \Omega ({\sqrt {2^{n}}})} }[/math] different inputs before being likely to find a pair on which [math]\displaystyle{ f }[/math] takes the same output, as per the birthday problem. Since, classically to find s with a 100% certainty it would require checking [math]\displaystyle{ {\displaystyle \Theta ({\sqrt {2^{n}}})} }[/math] inputs, Simon's problem seeks to find s using fewer queries than this classical method.

Simon's algorithm

Quantum circuit representing/implementing Simon's algorithm

The algorithm as a whole uses a subroutine to execute the following two steps:

  1. Run the quantum subroutine an expected [math]\displaystyle{ O(n) }[/math] times to get a list of linearly independent bitstrings [math]\displaystyle{ y_1, ..., y_{n - 1} }[/math].
  2. Each [math]\displaystyle{ y_k }[/math] satisfies [math]\displaystyle{ y_k \cdot s = 0 }[/math], so we can solve the system of equations this produces to get [math]\displaystyle{ s }[/math].

Quantum subroutine

The quantum circuit (see the picture) is the implementation of the quantum part of Simon's algorithm. The quantum subroutine of the algorithm makes use of the Hadamard transform[math]\displaystyle{ H^{\otimes n}|k\rangle = \frac{1}{\sqrt{2^n}} \sum_{j = 0}^{2^n - 1} (-1)^{k \cdot j} |j\rangle }[/math]where [math]\displaystyle{ k \cdot j = k_1 j_1 \oplus \ldots \oplus k_n j_n }[/math], where [math]\displaystyle{ \oplus }[/math] denotes XOR.

First, the algorithm starts with two registers, initialized to [math]\displaystyle{ |0\rangle^{\otimes n}|0\rangle^{\otimes n} }[/math]. Then, we apply the Hadamard transform to the first register, which gives the state

[math]\displaystyle{ \frac{1}{\sqrt{2^n}} \sum_{k = 0}^{2^n - 1} |k\rangle |0\rangle^{\otimes n}. }[/math]

Query the oracle [math]\displaystyle{ U_f }[/math] to get the state

[math]\displaystyle{ \frac{1}{\sqrt{2^n}} \sum_{k = 0}^{2^n - 1} |k\rangle |f(k)\rangle }[/math].

Apply another Hadamard transform to the first register. This will produce the state

[math]\displaystyle{ \frac{1}{\sqrt{2^n}} \sum_{k = 0}^{2^n - 1} \left[\frac{1}{\sqrt{2^n}} \sum_{j = 0}^{2^n - 1} (-1)^{j \cdot k} |j\rangle \right] |f(k)\rangle = \sum_{j = 0}^{2^n - 1} |j\rangle \left[\frac{1}{2^n} \sum_{k = 0}^{2^n - 1} (-1)^{j \cdot k} |f(k)\rangle \right]. }[/math]

Finally, we measure the first register (the algorithm also works if the second register is measured before the first, but this is unnecessary). The probability of measuring a state [math]\displaystyle{ |j\rangle }[/math] is[math]\displaystyle{ \left|\left| \frac{1}{2^n} \sum_{k = 0}^{2^n - 1} (-1)^{j \cdot k} |f(k)\rangle \right|\right|^2 }[/math]This is due to the fact that taking the magnitude of this vector and squaring it sums up all the probabilities of all the possible measurements of the second register that must have the first register as [math]\displaystyle{ |j\rangle }[/math]. There are two cases for our measurement:

  1. [math]\displaystyle{ s = 0^n }[/math] and [math]\displaystyle{ f }[/math] is one-to-one.
  2. [math]\displaystyle{ s \neq 0^n }[/math] and [math]\displaystyle{ f }[/math] is two-to-one.

For the first case, [math]\displaystyle{ \left|\left| \frac{1}{2^n} \sum_{k = 0}^{2^n - 1} (-1)^{j \cdot k} |f(k)\rangle \right|\right|^2 = \frac{1}{2^n} }[/math]since in this case, [math]\displaystyle{ f }[/math] is one-to-one, implying that the range of [math]\displaystyle{ f }[/math] is [math]\displaystyle{ \{0, 1\}^n }[/math], meaning that the summation is over every basis vector. For the second case, note that there exist two strings, [math]\displaystyle{ x_1 }[/math] and [math]\displaystyle{ x_2 }[/math], such that [math]\displaystyle{ f(x_1) = f(x_2) = z }[/math], where [math]\displaystyle{ z \in \mathrm{range}(f) }[/math]. Thus, [math]\displaystyle{ \left|\left| \frac{1}{2^n} \sum_{k = 0}^{2^n - 1} (-1)^{j \cdot k} |f(k)\rangle \right|\right|^2 = \left|\left| \frac{1}{2^n} \sum_{z\, \in \,\mathrm{range}(f)} ((-1)^{j \cdot x_1} + (-1)^{j \cdot x_2}) |z\rangle \right|\right|^2 }[/math]Furthermore, since [math]\displaystyle{ x_1 \oplus x_2 = s }[/math], [math]\displaystyle{ x_2 = x_1 \oplus s }[/math], and so[math]\displaystyle{ \begin{align} \left|\left| \frac{1}{2^n} \sum_{z\, \in \,\mathrm{range}(f)} ((-1)^{j \cdot x_1} + (-1)^{j \cdot x_2}) |z\rangle \right|\right|^2 &= \left|\left| \frac{1}{2^n} \sum_{z\, \in \,\mathrm{range}(f)} ((-1)^{j \cdot x_1} + (-1)^{j \cdot (x_1 \oplus s)}) |z\rangle \right|\right|^2 \\ &= \left|\left| \frac{1}{2^n} \sum_{z\, \in \,\mathrm{range}(f)} ((-1)^{j \cdot x_1} + (-1)^{j \cdot x_1 \oplus j \cdot s}) |z\rangle \right|\right|^2 \\ &= \left|\left| \frac{1}{2^n} \sum_{z\, \in \,\mathrm{range}(f)} (-1)^{j \cdot x_1}(1 + (-1)^{j \cdot s}) |z\rangle \right|\right|^2 \end{align} }[/math]This expression is now easy to evaluate. Recall that we are measuring [math]\displaystyle{ j }[/math]. When [math]\displaystyle{ j \cdot s = 1 }[/math], then this expression will evaluate to [math]\displaystyle{ 0 }[/math], and when [math]\displaystyle{ j \cdot s = 0 }[/math], then this expression will be [math]\displaystyle{ 2^{-n + 1} }[/math].

Thus, both when [math]\displaystyle{ s = 0^n }[/math] and when [math]\displaystyle{ s \neq 0^n }[/math], our measured [math]\displaystyle{ j }[/math] satisfies [math]\displaystyle{ j \cdot s = 0 }[/math].

Classical post-processing

We run the quantum part of the algorithm until we have a linearly independent list of bitstrings [math]\displaystyle{ y_1, \ldots, y_{n - 1} }[/math], and each [math]\displaystyle{ y_k }[/math] satisfies [math]\displaystyle{ y_k \cdot s = 0 }[/math]. Thus, we can efficiently solve this system of equations classically to find [math]\displaystyle{ s }[/math].

The probability that [math]\displaystyle{ y_1, y_2, \dots, y_{n-1} }[/math] are linearly independent is at least[math]\displaystyle{ \prod_{k=1}^\infty \left( 1 - \frac{1}{2^k} \right) = 0.288788\dots }[/math]Once we solve the system of equations, and produce a solution [math]\displaystyle{ s' }[/math], we can test if [math]\displaystyle{ f(0^n) = f(s') }[/math]. If this is true, then we know [math]\displaystyle{ s' = s }[/math], since [math]\displaystyle{ f(0^n) = f(0^n \oplus s) = f(s) }[/math]. If it is the case that [math]\displaystyle{ f(0^n) \neq f(s') }[/math], then that means that [math]\displaystyle{ s = 0^n }[/math], and [math]\displaystyle{ f(0^n) \neq f(s') }[/math] since [math]\displaystyle{ f }[/math] is one-to-one.

We can repeat Simon's algorithm a constant number of times to increase the probability of success arbitrarily, while still having the same time complexity.

Explicit examples of Simon's algorithm for few qubits

One qubit

Consider the simplest instance of the algorithm, with [math]\displaystyle{ n=1 }[/math]. In this case evolving the input state through an Hadamard gate and the oracle results in the state (up to renormalization):

[math]\displaystyle{ |0\rangle |f(0)\rangle + |1\rangle|f(1)\rangle. }[/math]

If [math]\displaystyle{ s=1 }[/math], that is, [math]\displaystyle{ f(0)=f(1) }[/math], then measuring the second register always gives the outcome [math]\displaystyle{ |f(0)\rangle }[/math], and always results in the first register collapsing to the state (up to renormalization):

[math]\displaystyle{ |0\rangle+ |1\rangle. }[/math]

Thus applying an Hadamard and measuring the first register always gives the outcome [math]\displaystyle{ |0\rangle }[/math]. On the other hand, if [math]\displaystyle{ f }[/math] is one-to-one, that is, [math]\displaystyle{ s=0 }[/math], then measuring the first register after the second Hadamard can result in both [math]\displaystyle{ |0\rangle }[/math] and [math]\displaystyle{ |1\rangle }[/math], with equal probability.

We recover [math]\displaystyle{ s }[/math] from the measurement outcomes by looking at whether we measured always [math]\displaystyle{ |0\rangle }[/math], in which case [math]\displaystyle{ s=1 }[/math], or we measured both [math]\displaystyle{ |0\rangle }[/math] and [math]\displaystyle{ |1\rangle }[/math] with equal probability, in which case we infer that [math]\displaystyle{ s=0 }[/math]. This scheme will fail if [math]\displaystyle{ s=0 }[/math] but we nonetheless always found the outcome [math]\displaystyle{ |0\rangle }[/math], but the probability of this event is [math]\displaystyle{ 2^{-N} }[/math] with [math]\displaystyle{ N }[/math] the number of performed measurements, and can thus be made exponentially small by increasing the statistics.

Two qubits

Consider now the case with [math]\displaystyle{ n=2 }[/math]. The initial part of the algorithm results in the state (up to renormalization):[math]\displaystyle{ |00\rangle|f(00)\rangle + |01\rangle|f(01)\rangle + |10\rangle|f(10)\rangle + |11\rangle|f(11)\rangle. }[/math]If [math]\displaystyle{ s=(00) }[/math], meaning [math]\displaystyle{ f }[/math] is injective, then finding [math]\displaystyle{ |f(x)\rangle }[/math] on the second register always collapses the first register to [math]\displaystyle{ |x\rangle }[/math], for all [math]\displaystyle{ x\in\{0,1\}^2 }[/math]. In other words, applying Hadamard gates and measuring the first register the four outcomes [math]\displaystyle{ 00,01,10,11 }[/math] are thus found with equal probability.

Suppose on the other hand [math]\displaystyle{ s\neq(00) }[/math], for example, [math]\displaystyle{ s=(01) }[/math]. Then measuring [math]\displaystyle{ |f(00)\rangle }[/math] on the second register collapses the first register to the state [math]\displaystyle{ |00\rangle+|10\rangle }[/math]. And more generally, measuring [math]\displaystyle{ |f(xy)\rangle }[/math] gives [math]\displaystyle{ |x,y\rangle+|x,y\oplus1\rangle=|x\rangle(|0\rangle+|1\rangle) }[/math] on the first register. Applying Hadamard gates and measuring on the first register can thus result in the outcomes [math]\displaystyle{ 00 }[/math] and [math]\displaystyle{ 10 }[/math] with equal probabilities.

Similar reasoning applies to the other cases: if [math]\displaystyle{ s=(10) }[/math] then the possible outcomes are [math]\displaystyle{ 00 }[/math] and [math]\displaystyle{ 01 }[/math], while if [math]\displaystyle{ s=(11) }[/math] the possible outcomes are [math]\displaystyle{ 00 }[/math] and [math]\displaystyle{ 11 }[/math], compatibly with the [math]\displaystyle{ j\cdot s=0 }[/math] rule discussed in the general case.

To recover [math]\displaystyle{ s }[/math] we thus only need to distinguish between these four cases, collecting enough statistics to ensure that the probability of mistaking one outcome probability distribution for another is sufficiently small.


Simon's algorithm requires [math]\displaystyle{ O(n) }[/math] queries to the black box, whereas a classical algorithm would need at least [math]\displaystyle{ \Omega(2^{n/2}) }[/math] queries. It is also known that Simon's algorithm is optimal in the sense that any quantum algorithm to solve this problem requires [math]\displaystyle{ \Omega(n) }[/math] queries.[5][6]

See also