CS 294 Recursive Fourier Sampling, Simon’s Algorithm 2/25/2009 Spring 2009 Lecture 3

1 Review

Recall that we can write any classical circuit x → f(x) as a reversible circuit R_{f}. We can view R_{f} as a unitary operation U_{f}, which acts on a quantum superposition using linearity. We will use this representation of a function throughout the lecture.

2 Phase State

We will first see how to set up an interesting state which we will use later in Fourier sampling. Recall the Deutsch-Jozsa procedure which, given a classical circuit for computing a boolean function f : {0,1}^{n} → {0,1}, shows how to transform it into a quantum circuit that produces the quantum state |ϕ⟩ = 1/2^{n/2}∑_{x}(−1)^{f(x)}|x⟩.

The quantum algorithm to carry out this task uses two quantum registers, the first consisting of n qubits, and the second consisting of a single qubit.

• Start with the registers in the state |0^{n}⟩|0⟩

• Compute the Fourier transform on the first register to get ∑_{x∈{0,1}^{n}} |x⟩⊗ |0⟩.

• Compute f to get ∑_{x}|x⟩|f(x)⟩.

• Apply a conditional phase based on f(x) to get ∑_{x}(−1)^{f(x)} |x⟩|f(x)⟩.

• Uncompute f to get ∑_{x}(−1)^{f(x)} |x⟩⊗ |0⟩.

3 Fourier Sampling

Consider a quantum circuit acting on n qubits, which applies a Hadamard gate to each qubit. That is, the circuit applies the unitary transformation H^{⊗n}, or H tensored with itself n times.

Applying the Hadamard transform (or the Fourier transform over Z_{2}^{n}) to the state of all zeros gives an equal superposition over all 2^{n} states

H_{2^{n}}|0··· 0⟩= \frac{1}{\sqrt{2^{n}}} ∑_{x∈\{0,1\}^{n}}|x⟩.

In general, applying the Hadamard transform to the computational basis state |u⟩yields:

H_{2^{n}}|u⟩= \frac{1}{\sqrt{2^{n}}} ∑_{x∈\{0,1\}^{n}}(−1) ^{u·x}|x⟩

We define the Fourier sampling problem as follows: Input an n qubit state |ϕ⟩ = ∑_{x∈{0,1}^{n}} α_{x}|x⟩. Compute H^{⊗n} |ϕ⟩ and measure the resulting state ∑_{y} α̂_{y} |y⟩ to output y with probability |α̂_{y}|^{2}.

Clearly this problem is easy to solve on a quantum computer, but it appears to be hard to solve classically. We will see later by making the procedure recursive that Fourier sampling is indeed difficult in genereal.

4 Extracting n bits with 2 evaluations of Boolean Function

Suppose we are given a black box (or an obfuscated classical circuit) that computes the function function f_{s} : {0,1}^{n} → {1,−1}, where f(x) = s · x, where s · x denotes the dot product s_{1}x_{1} + ··· + s_{n}x_{n}mod2. The challenge is to use this black box to efficiently determine s.

It is easy to see how to perform this task with n queries to the black box: simply input in turn the n inputs x of Hamming weight 1. The outputs of the black box are the bits of s. Since each query reveals only one bit of information, it is clear that n queries are necessary.

Remarkably there is a quantum algorithm that requires only two (quantum) queries to the black box:

• Use the black box to set up the phase state |ϕ⟩ = 1/2^{n/2}∑_{x}(−1)^{f(x)}|x⟩.

• Apply the Fourier transform H^{⊗n} and measure. The outcome of the measurement is s.

To see that the outcome of the measurement is s, recall that H^{⊗n} |s⟩ = 1/2^{n/2}∑_{x}(−1)^{s·x}|x⟩ = |ϕ⟩. Since H^{⊗n} is its own inverse, it follows that H^{⊗n} |ϕ⟩ = |s⟩.

More generally, the transformation H^{⊗n} maps the standard basis |s⟩ to the Fourier basis |ϕ_{s}⟩ = 1/2^{n/2}∑_{x}(−1)^{s·x}|x⟩ and vice-versa.

We have shown that a quantum algorithm can be more efficient than any probabilistic algorithm in terms of the number of queries. One way to use this difference in the number of queries in order to demonstrate a gap between quantum and probabilistic algorithms is to make the queries very expensive. Then the quantum algorithm would be n/2 times faster than any probabilistic algorithm for the given task. It turns out that we can increase this gap substantially, as we will see next. The idea is to make each query itself be the answer to a Fourier sampling problem, so each query itself is much easier for the quantum algorithm than for any probabilistic algorithm. Carrying this out recursively for logn levels leads to the superpolynomial speedup for quantum algorithms.

5 Recursive Fourier Sampling

Our goal is to give a superpolynomial separation between quantum computation and classical probabilistic computation. The idea is to define a recursive version of the Fourier sampling problem, where each query to the function (on an input of length n) is itself the answer to a recursive Fourier sampling problem (on an input of length n/2). Intuitively a classical algorithm would need to solve n subproblems to solve a problem on an input of length n (since it must make n queries). Thus its running time satisfies the recurrence T (n) ≥ nT (n/2) + O(n) which has solution T (n) = Ω(n^{logn}). The quantum algorithm needs to make only two queries and thus its running time satisfies the recurrence T (n) = 2T (n/2) + O(n), which solves to T (n) = O(nlogn).

Recall that for one level we have an oracle for f(x) with the promise that f(x) = s · x. For two levels, we are given functions f(x) and f′(x,y) with the promise that for some g(x) we have f(x) = s · g(x) and f′(x,y) = g(x) · y. To compute s we must know a few values of g(x), and to compute each of these values we sample y and use f′. More generally, we are given oracles to f_{1},...,f_{k} and g_{k} with the promise that f_{i}(x_{1},...,x_{i}) = g_{i−1} (x_{1},...,x_{i−1} ) · g_{i}(x_{1},...,x_{i}) and we wish to compute g_{0} ≡ s. Illustrated below is level three:

1. To find s, sample enough values from g_{1}(·) and use the promise f_{1}(x_{1}) = s · g_{1}(x_{1}).

2. To sample g_{1}(x_{1}) for some particular x_{1}, sample enough values from g_{2}(x_{1},·) and use the promise f_{2}(x_{1},x_{2}) = g_{1}(x_{1}) · g_{2}(x_{1},x_{2}).

3. To sample g_{2}(x_{1},x_{2}) for some particular x_{1},x_{2}, use the oracle for g_{3}(x_{1},x_{2},·) and the promise f_{3}(x_{1},x_{2},x_{3}) = g_{2}(x_{1},x_{2}) · g_{3}(x_{1},x_{2},x_{3}).

It should be clear now why this is the procedure we want. For the lengths to scale appropriately, we must have 2|x_{i}| = |x_{i−1} | and k = logn.

The proof that no classical probabilistic algorithm can reconstruct s is somewhat technical, and establishes that for a random g satisfying the promise, any algorithm (deterministic or probabilistic) that makes n^{o(logn)} queries to g must give the wrong answer on at least 1/2−o(1) fraction of g’s. This lemma continues to hold even if the actual queries are chosen by a helpful(but untrusted) genie who knows the answer.

This establishes that relative to an oracle BQP ⊈ MA. MA is the probabilistic generalization of NP. It is conjectured that recursive Fourier sampling does not lie in the polynomial hierarchy. In particular, it is an open question to show that, relative to an oracle, recusive Fourier sampling does not lie AM or in BPP^{NP}. The latter class is particularly important since it includes approximate counting.

6 BQP ⊆ PSPACE

To put this gap result in context, we give an important complexity result relating BQP to PSPACE.

Theorem 3.1: P ⊆ BPP ⊆ BQP ⊆ P^{#P} ⊆ PSPACE.

We give a sketch of the proof that BQP ⊆ P^{#P}. We assume without loss of generality that all the transition amplitudes specified in the transition function δ are real (exercise). The action of a quantum circuit may be described by a tree, each node is labelled with a computational basis state, i.e. a bit string. The root of the tree corresponds to the input |x⟩ and applying a gate to any node yields a superposition of basis states represented by the children of that node. We label the edge to each child by the corresponding amplitude. Let us assume that the quantum circuit accepts or rejects depending upon whether the first qubit, when measured in the computational basis is 0 or 1. Thus each leaf of the tree is either an accepting or rejecting node depending on whether the first bit of the string labeling it is 0 or 1. The amplitude of a path p from the root to a leaf of the tree, β_{p}, is just the product of the branching amplitudes along the path, and is computable to within 1/2^{j} in time polynomial in j. Several paths may lead to the same configuration c. Thus the amplitude of c after application of T gates is the following sum over all T length paths p: α_{c} = ∑_{p to c}β_{p}. The probability that quantum circuit accepts is ∑_{accepting c}|α_{c}|^{2}. Let a_{p} = max(β_{p},0) and b_{p} = max(−β_{p},0). Then |α_{c}|^{2} can be written as |α_{c}|^{2} = ∑_{p to c}(a_{p}− b_{p})^{2} = ∑_{p to c}a_{p}^{2}+ b_{p}^{2}− ∑_{p,p′ to c}2a_{p}b_{p}. It follows that the acceptance probability of the quantum circuit can be written as the difference between the two quantities ∑_{accepting c}∑_{p to c}a_{p}^{2}+ b_{p}^{2}, and ∑_{accepting c}∑_{p,p′ to c}2a_{p}b_{p′}. Since each of these quantities is easily seen to be in P^{#P}, it follows that BQP ⊆ P^{#P}.

In view of this theorem, we cannot expect to prove that BQP strictly contains BPP without resolving the long standing open question in computational complexity theory, namely, whether or not P = PSPACE.

6.1 Extended Church-Turing Thesis

The extended Church-Turing thesis is a foundational principle in computer science. It asserts that any ”reasonable” model of computation can be efficiently simulated on a standard model such as a Turing Machine or a Random Access Machine or a cellular automaton. This thesis forms the foundation of complexity theory — for example ensuring that that the class P (polynomial time) is well defined. But what do we mean by ”reasonable”? In this context, reasonable means ”physically realizable in principle”. One constraint that this places is that the model of computation must be digital. Thus analog computers are not reasonable models of computation, since they assume infinite precision arithmetic. In fact, it can be shown that with suitable infinite precision operations, an analog computer can solve NP-Complete problems in polynomial time. And an infinite precision calculator with operations +, x, =0?, can factor numbers in polynomial time.

We first establish that quantum computers are digital:

7 Is Quantum Computation Digital?

There is an issue as to whether or not quantum computing is digital. We need only look at simple gates such as the Hadamard gate or a rotation gate to find real values.

H = ( \frac{1}{\sqrt{2}} −\frac{1}{\sqrt{2}}^{\frac{1}{\sqrt{2}}  \frac{1}{\sqrt{2}}} )  R_{θ} = ( \begin{matrix}cosθ & −sinθ \\ sinθ & cosθ \end{matrix} )  (1)

When we implement a gate, how accurate does it need to be? Do we need infinite precision to build this gate properly? A paper by Shamir, “How To Factor On Your Calculator,” shows that if we assume infinite precision arithmetic, then some NP complete problems can be solved in polynomial time. However, we obviously cannot have infinite precision, so we must digitize quantum computation in order to approximate values such as 1/\sqrt{2}. It turns out that logn bits of precision are necessary.

Suppose we want to build a gate that rotates the input by θ, but the best accuracy we can actually build is rotation by θ ± Δθ (finite precision). Let U_{1},...,U_{m} be a set of ideal gates that implement an exact rotation by θ. Let V_{1},...,V_{m} be a set of actual (constructible) gates that implement rotation by θ ± Δθ. Let |ϕ⟩ be the initial state. Let |ψ⟩ be the ideal output

|ψ⟩ = U_{1}U_{2}··· U_{m}|ϕ⟩, (2)

and let |ψ′⟩ be the actual output

|ψ′⟩ = V_{1}V_{2}··· V_{m}|ϕ⟩. (3)

The closer |ψ⟩ and |ψ′⟩ are to each other, the better the approximation. If we can approximate each gate to within ϵ = O(1/m), then we can approximate the entire circuit with small constant error.

Theorem 3.2: If ∥U_{i}− V_{i}∥ ≤ \frac{ϵ}{4m} for 1 ≤ i ≤ m, then ∥|ψ⟩ − |ψ′⟩∥ ≤ \frac{ϵ}{4}.

Proof:Consider the two hybrid states

|ψ_{k}⟩ = U_{1}··· U_{k−1}V_{k}··· V_{m}|ϕ⟩ , and
|ψ_{k+1}⟩ = U_{1}··· U_{k}V_{k+1} ··· V_{m}|ϕ⟩.

Subtract ψ_{k+1} from ψ_{k} to get

|ψ_{k}⟩ − |ψ_{k+1}⟩ = U_{1}··· U_{k−1}(V_{k}− U_{k})V_{k+1} ··· V_{m}|ϕ⟩ (4)

Since the unitary transformations don’t change the norm of the vector, the only term we need to consider is U_{k+1} − V_{k+1}. But we have an upper bound on this, so we can conclude that

∥|ψ_{k}⟩ − |ψ_{k+1}⟩∥ ≤ \frac{ϵ}{4m}. (5)

Another way to see this is that applying unitary transformations to U_{m}|ϕ⟩ and V_{m}|ϕ⟩ preserves the angle between them, which is defined to be the norm.

We use the triangle inequality to finish to proof.

∥|ψ⟩ − |ψ′⟩∥ = ∥|ψ_{0}⟩ − |ψ_{m}⟩∥
≤ ∑_{i=0}^{m−1}∥|ψ_{i}⟩ − |ψ_{i+1} ⟩∥
≤ m · \frac{ϵ}{4m} ≤ \frac{ϵ}{4}.

We have already seen that quantum computers are digital computers, and therefore a reasonable model of computing. But we also established that P ⊆ BPP ⊆ BQP ⊆ PSPACE. Since we do not know how to separate P from PSPACE, it follows that we cannot unconditionally prove that quantum computers are more powerful than classical computers. Instead there are two ways of establishing that quantum computers are more powerful than classical computers: by an oracle separation, or by giving an efficient quantum algorithm for a problem believed to be hard for classical algorithms. Historically, the first demonstrations that quantum computers are more powerful than classical computers were by proving oracle separations, starting with the recursive Fourier sampling problem, which we will outline below. We will briefly sketch this below and discuss the conjecture that recursive Fourier sampling does not lie in the polynomial hierarchy. The next oracle separation, Simon’s problem, provided the basic template that Shor followed in his quantum algorithm for factoring.

8 Quantum Circuit Implementation

As an aside, let us think about how one might implement a quantum computer. One way to do it would be to have an environment state with n photons. Then for a bit flip operation, the qubit either absorbs an electron or emits one. This scheme unfortunately entangles the qubit with the environment however:

(|0⟩ + |1⟩) ⊗ |n⟩_{e} → |1⟩|n − 1⟩_{e}+ |0⟩|n + 1⟩_{e} (6)

This seems like an unsurmountable problem, but one can imagine that the environment state would have many more electrons than there are qubits. Slightly more precisely, if the environment is in state |ϕ⟩ then after a bit flip it would be in state |ϕ′⟩, where ϕ ≅ ϕ′. In fact, one can show that |ϕ −ϕ′| ≅ 1/\sqrt{n}as n → ∞.

We will think about our quantum computations as an array of n qubits and a classical computer as a controller, which chooses qubits and performs ‘gates’ on them sequentially. It is still not clear though that quantum mechanical theory will hold when there are many qubits.

9 Communication Complexity of Inner Product Function

Suppose Alice has x and Bob has y. Show that it requires at least Ω(n) communications between Alice and Bob to compute x · y. (Hint: use the classical algorithm and the Hadamard gate.)

10 Simon’s Algorithm

Recall that our basic primitive for designing quantum algorithms is Fourier sampling: prepare some quantum state |ψ⟩ = ∑_{x}α_{x}|x⟩ on n qubits; perform a Hadamard transform, resulting in the superposition ∑_{x}β_{x}|x⟩; now measure to sample x with probability |β_{x}|^{2}. The point is that classically it is difficult to simulate the effects of the quantum interference, and therefore to determine for which strings x there is constructive interference and are therefore output with high probability.

We now consider a new way of setting up the initial superposition |ψ⟩ = ∑_{x}α_{x}|x⟩.

10.1 Setting up a random pre-image state

Suppose we’re given a classical circuit for a k − 1 function f : {0,1}^{n} → {0,1}^{n}.

We will show how to set up the quantum state |ϕ⟩ = 1/\sqrt{k}∑_{x:f(x)=a} |x⟩. Here a is uniformly random among all a in the image of f.

The algorithm uses two registers, both with n qubits. The registers are initialized to the basis state |0··· 0⟩|0··· 0⟩. We then perform the Hadamard transform H^{⊗n} on the first register, producing the superposition

\frac{1}{2^{n/2}} ∑_{x∈\{0,1\}^{n}}|x⟩|0··· 0⟩.

Then, we compute f (x)through the oracle C_{f} and store the result in the second register, obtaining the state

\frac{1}{2^{n/2}} ∑_{x∈\{0,1\}^{n}}|x⟩|f (x)⟩.

The second register is not modified after this step. Thus we may invoke the principle of safe storage and assume that the second register is measured at this point.

Let a be the result of measuring of the second register. Then a is a random element in the range of f, and according to rules of partial measurement, the state of the first register is a superposition over exactly those values of x that are consistent with those contents for the second register. i.e.

|ϕ⟩ = 1/\sqrt{k} ∑_{x:f(x)=a} |x⟩

10.2 The Algorithm

Suppose we are given function 2 − 1 f : {0,1}^{n} → {0,1}^{n}, specified by a black box, with the promise that there is an a ∈ {0,1}^{n} with a ≠ 0^{n} such that

• For all x f(x + a) = f(x).
• If f(x) = f(y) then either x = y or y = x + a.

The challenge is to determine a. It is intuitively obvious that this is a difficult task for a classical probabilistic computer. We will show an efficient quantum algorithm.

1. Use f to set up random pre-image state

ϕ = 1/\sqrt{2}|z⟩ + 1/\sqrt{2}|z + a⟩

|0^{n}⟩ |0^{n}⟩H_{2^{n}}C_{f} |f(x)⟩ H_{2^{n}}|y⟩

Figure 1: Simon’s algorithm

where z is a random n-bit string.

2. Perform a Hadamard transform H^{⊗n}.

After step 2 we obtain a superposition

∑_{y∈{0,1}^{n}}α_{y}|y⟩

where

α_{y} = \frac{1}{\sqrt{2}} \frac{1}{2^{n/2}} (−1) ^{y·z}+ \frac{1}{\sqrt{2}} \frac{1}{2^{n/2}} (−1) ^{y·(z⊕a)} = \frac{1}{2^{(n+1) /2}} (−1) ^{y·z}[1 + (−1) ^{y·a}] .

There are now two cases. For each y, if y · a = 1, then α_{y} = 0, whereas if y · a = 0, then

α_{y} = \frac{±1}{2^{(n−1) /2}}.

So when we observe the first register, with certainty we’ll see a y such that y · a = 0. Hence, the output of the measurement is a random y such that y · a = 0. Furthermore, each y such that y · a = 0 has an equal probability of occurring. Therefore what we’ve managed to learn is an equation

y_{1}a_{1}⊕ ··· ⊕ y_{n}a_{n} = 0 (7)

where y = (y_{1},...,y_{n})is chosen uniformly at random from {0,1}^{n}. Now, that isn’t enough information to determine a, but assuming that y ≠ 0, it reduces the number of possibilities for a by half.

It should now be clear how to proceed. We run the algorithm over and over, accumulating more and more equations of the form in (7). Then, once we have enough of these equations, we solve them using Gaussian elimination to obtain a unique value of a. But how many equations is enough? From linear algebra, we know that a is uniquely determined once we have n − 1 linearly independent equations—in other words, n − 1 equations

y^{(1)}· a≡ 0(mod2)
⋮
y^{(n−1)} · a≡ 0(mod2)

such that the set {y^{(1)},...,y^{(n−1)} }is linearly independent in the vector space Z_{2}^{n}. Thus, our strategy will be to lower-bound the probability that any n − 1 equations returned by the algorithm are independent.

Suppose we already have k linearly independent equations, with associated vectors y^{(1)},...,y^{(k)}. The vectors then span a subspace S ⊆ Z_{2}^{n} of size 2^{k}, consisting of all vectors of the form

b_{1}y^{(1)}+ ··· + b_{k}y^{(k)}

with b_{1},...,b_{k}∈ {0,1}. Now suppose we learn a new equation with associated vector y^{(k+1)}. This equation will be independent of all the previous equations provided that y^{(k+1)} lies outside of S, which in turn has probability at least (2^{n}− 2^{k})/2^{n} = 1 − 2^{k−n} of occurring. So the probability that any n equations are independent is exactly the product of those probabilities.

( 1 − \frac{1}{2^{n}}) × ( 1 − \frac{1}{2^{n−1}} ) × ··· × ( 1 − \frac{1}{4}) × ( 1 − \frac{1}{2}) .

Can we lower-bound this expression? Trivially, it’s at least

∏_{k=1}^{∞} ( 1 − \frac{1}{2^{k}}) ≈ 0.28879;

the infinite product here is related to something in analysis called a q-series. Another way to look at the constant 0.28879... is this: it is the limit, as n goes to infinity, of the probability that an n×n random matrix over Z_{2} is invertible.

But we don’t need heavy-duty analysis to show that the product has a constant lower bound. We use the inequality (1 − a)(1 − b) = 1 − a − b + ab > 1 − (a + b), if a,b ∈ (0,1). We just need to multiply the product out, ignore monomials involving two or more \frac{1}{2^{k}} terms multiplied together (which only increase the product), and observe that the product is lower-bounded by

[1 − ( \frac{1}{2^{n}} + \frac{1}{2^{n−1}} + ··· + \frac{1}{4}) ] · \frac{1}{2} ≥ \frac{1}{4}.

We conclude that we can determine a with constant probability of error after repeating the algorithm O(n) times. So the number of queries to f used by Simon’s algorithm is O(n). The number of computation steps, though, is at least the number of steps needed to solve a system of linear equations, and the best known upper bound for this is O(n^{2.376}), due to Coppersmith and Winograd.

10.3 Classical solution

We are going to prove that any probabilistic algorithm needs an exponential time to solve this problem. Suppose that a is chosen uniformly at random from {0,1}^{n}− {0^{n}}. Now consider a classical probabilistic algorithm that’s already made k queries, to inputs x_{1},...,x_{k}. We want to know how much information the algorithm could have obtained about a, given those queried pairs (x_{i},f(x_{i})).

On the one hand, there might be a pair of inputs x_{i},x_{j} (with 1 ≤ i,j ≤ k) such that f (x_{i})= f (x_{j}). In this case, the algorithm already has enough information to determine a: a = x_{i}⊕ x_{j}.

On the other hand, suppose no such pair f(x_{i}),f(x_{j}) exists. Then the queried f(x_{i})’s are distinct and a is

none of \binom{k}{2} values x_{i}⊕ x_{j}.

The probability that the next query will succeed is at most

\frac{k}{2^{n}− 1 − \binom{k}{2}}

because there are at least 2^{n}−1−\binom{k}{2} possible values of u for choosing at the (k+1)-th query. And f(x_{k+1})

should be equal to one of the prior observed f(x_{i}), i ∈ [1,k].

Taking the sum over all k ∈ {1,...,m}. We get

∑_{k=1}^{m} \frac{k}{2^{n}− 1 − \binom{k}{2}} ≤ ∑_{k=1}^{m} \frac{k}{2^{n}− k^{2}} ≤ \frac{m^{2}}{2^{n}− m^{2}}

In order to have an constant probability, we must choose m = Ω(2^{n/2}). Hence, any deterministic algorithm has to run in exponential time to get a correct answer with probability larger than a constant.