Faster quantum algorithm for evaluating game trees
Abstract
We give an query quantum algorithm for evaluating size ANDOR formulas. Its running time is polylogarithmically greater after efficient preprocessing. Unlike previous approaches, the algorithm is based on a quantum walk on a graph that is not a tree. Instead, the algorithm is based on a hybrid of directsum span program composition, which generates treelike graphs, and a novel tensorproduct span program composition method, which generates graphs with vertices corresponding to minimal zerocertificates.
For comparison, by the general adversary bound, the quantum query complexity for evaluating a size readonce ANDOR formula is at least , and at most . However, this algorithm is not necessarily time efficient; the number of elementary quantum gates applied between input queries could be much larger. Ambainis et al. have given a quantum algorithm that uses queries, with a polylogarithmically greater running time.
1 Introduction
An ANDOR formula is a rooted tree in which the internal nodes correspond to AND or OR gates. The size of the formula is the number of leaves. To a formula of size and a numbering of the leaves from to corresponds a function . This function is defined on input by placing bit on the th leaf, for , and evaluating the gates toward the root. Evaluating an ANDOR formula solves the decision version of a MINMAX tree, also known as a twoplayer game tree.
Let be the quantum query complexity for evaluating the size ANDOR formula . Quantum query complexity is the generalization of classical decision tree complexity to quantum algorithms. Now the general adversary bound of is [BS04, HLŠ07], and thus . Since the general adversary bound is nearly tight for any boolean function, in particular [Rei09a]. (Interpreted in a different way, this says that the square of the quantum query complexity of evaluating a boolean function is almost a lower bound on the readonce formula size for that function [LLS06].) However, the algorithm from [Rei09a] is not necessarily even time efficient. That is, even though the number of queries to the input is nearly optimal, the number of elementary quantum gates applied between input queries could be much larger.
Ambainis et al. [ACR07] have given a quantum algorithm that evaluates using queries, with a running time only polylogarithmically larger after efficient preprocessing. We reduce the query overhead from to only , with the same preprocessing assumption.
Theorem 1.1.
Let be an ANDOR formula of size . Then can be evaluated with error at most by a quantum algorithm that uses input queries. After polynomialtime classical preprocessing independent of the input, and assuming unittime coherent access to the preprocessed string, the running time of the algorithm is .
An improvement from to overhead may not be significant for eventual practical applications. Additionally, the algorithm does not obviously bring us closer to knowing whether the general adversary bound is tight for quantum query complexity, because its overhead is larger than the overhead of the query algorithm from [Rei09a]. (It may be that the analysis used to prove Theorem 1.1 is somewhat loose.)
However, the idea behind the algorithm is still of interest, as it provides a new solution to the problem of evaluating ANDOR formulas with large depth. If is a formula on variables, with depth , then the [ACR07] algorithm, applied directly, evaluates using queries.^{1}^{1}1Actually, [ACR07, Sec. 7] only shows a bound of queries, but this can be improved to using the bounds on below [ACR07, Def. 1]. The improved analysis of the same algorithm in [Rei09b] tightens this to , which is also the depthdependence found by [Amb07]. Thus for a highly unbalanced formula, with depth , the quantum algorithm performs no better asymptotically than the trivial query classical algorithm. Fortunately, Bshouty et al. have given a “rebalancing” procedure that takes ANDOR formula as input and outputs an equivalent ANDOR formula with depth and size [BCE91, BB94]. Appealing to this result, [ACR07] evaluates using queries.
The algorithm behind Theorem 1.1 gets around the largedepth problem without using formula rebalancing. Instead, the algorithm is based on a novel method for constructing bipartite graphs with certain useful spectral properties. Ambainis et al. run a quantum walk on a graph that matches the formula tree, except with certain edge weights and boundary conditions at the leaves. This tree comes from glueing together elementary graphs for each gate. We term this composition method “directsum” composition, because the graph’s adjacency matrix acts on a space that is the direct sum of spaces for each individual gate. Directsum composition incurs severe overhead on highly unbalanced formulas, making the query complexity at least proportional to the formula depth.
The new algorithm begins with the same elementary graphs, with even the same edge weights. However, it composes them using a kind of “tensorproduct” graph composition method. Overall, this results in graphs that have much lower depth, although they are not trees. By carefully combining this method with directsum composition, we obtain a graph on which the algorithm runs a quantum walk. The two approaches are summarized in more detail in Section 1.1 below.
The general formulaevaluation problem is an ideal example of a recursively defined problem. The evaluation of a formula is the evaluation of a function, the inputs of which are themselves independent formulas. As argued in a companion paper [Rei09b], quantum computers are particularly well suited for evaluating formulas. Unlike the situation for classical algorithms, for a large class of formulas the optimal quantum algorithm can work following the formula’s recursive structure. Since Theorem 1.1 does not require ANDOR formula rebalancing, it extends this quantum recursion paradigm. Besides its conceptual appeal, this may also be important because the effect of rebalancing on the general quantum adversary bound appears to be less tractable for formulas over gate sets beyond AND and OR. Therefore the rebalancing step that aids [ACR07] might not be useful to solve the largedepth problem on more general formulas. The hybrid graph composition method is another tool that might generalize more easily.
Our algorithm is developed and analyzed using the framework relating span programs and quantum algorithms from [Rei09a]. The connection to timeefficient quantum algorithms, especially for evaluating unbalanced formulas over arbitrary fixed, finite gate sets, has been developed further in [Rei09b]. Table 1 summarizes some results for the formulaevaluation problem in the classical and quantum models; for a more detailed and inclusive review, see [Rei09b]. Section 1.2 below will go over only the history of quantum algorithms for evaluating ANDOR formulas.
Randomized, zeroerror  Quantum boundederror  
Formula  query complexity  query complexity  
[Gro96, BBBV97]  
Balanced   [SW86]  [FGG07, ACR07]  
Wellbalanced ANDOR  tight recursion  [SW86]  
Approx.balanced ANDOR  [ACR07, Rei09b]  
Arbitrary ANDOR  [HW91]  [BS04] (Thm. 1.1)  
Balanced ()  ,  [JKS03]  [RŠ08]  
Balanced over  [Rei09a]  
Almostbalanced over  [Rei09b] 
1.1 Idea of the algorithm
As an example to illustrate the main idea of our algorithm, consider the ANDOR formula , where and denote and , respectively. In Figure 1, this formula is represented as a tree.
The [ACR07] algorithm starts with the graph in Figure 1, essentially the same as the formula tree, except with extra edges attached to the root and some leaves. The edges should be weighted, but for this intuitive discussion take every edge’s weight to be one.
Consider an input . Modify the graph by attached a dangling edge to vertex if , for . Then it is simple to see that the resulting graph has an eigenvaluezero eigenvector supported on vertex (or rather its adjacency matrix does) if and only if . If we added an edge off vertex , then the resulting graph would have an eigenvaluezero eigenvector supported on the new root if and only if .
The [ACR07] algorithm takes advantage of this property by running (phase estimation on) a quantum walk that starts at the root vertex. The algorithm detects the eigenvaluezero eigenvector in order to evaluate the formula.
This algorithm does not work well on formulas with large depth. For example, consider the maximally unbalanced formula on inputs, a skew tree. The corresponding graph is nearly the length line graph. It will still have an eigenvaluezero eigenvector supported on the root if and only if the formula evaluates to zero. However, the algorithm will require time to detect this eigenvector, because its squared support on the root is only after normalization, and because the spectral gap around zero will also be . (The spectral gap determines the precision of the phase estimation procedure, and hence its running time. It corresponds to the squared support of eigenvaluezero eigenvectors by [Rei09a, Theorem 8.7].) Alternatively, one can argue that the algorithm requires time because it takes that long even to reach the deepest leaf vertices.
Now consider the graph in Figure 2. Again modify the graph according to an input by attaching dangling edges to those vertices with . Considering a few examples should convince the reader that the resulting graph has an eigenvaluezero eigenvector supported on vertex if and only if . Note, though, that the distance from “output” vertex to any of the “input” vertices to is at most two. The graph is also far from being a tree. Its main feature is that the “constraint” vertices—the vertices aside from —are in onetoone correspondence with minimal zerocertificates to . For example, for , , but flipping any bit of from to changes the formula evaluation from to . The corresponding constraint vertex is connected to exactly those input vertices for which .
The graphs in Figures 1 and 2 represent two extremes of a family of graphs that evaluate in the same manner. The graph in Figure 1 can be seen (essentially) as coming from plugging together along the individual graphs in Figures 3(a) and 3(b) that evaluate single OR and AND gates in the same manner. We term this “directsum” composition. The graph in Figure 2 comes from a certain “tensorproduct” composition of the graphs from Figures 3(a) and 3(b). (Figure 3 shows several other examples of tensorproduct graph composition.)
With the correct choice of edge weights, tensorproduct composition leads to graphs for which the squared support of the unitnormalized eigenvaluezero eigenvector on the root is for a formula of size . This implies by [Rei09a, Theorem 9.1] a quantum algorithm that uses queries to evaluate the formula. There is no issue with deep formulas. However, the algorithm will not be time efficient. Essentially, the problem is that the number of vertices can be exponentially large in , as can be their degrees, which makes it difficult to implement a quantum walk efficiently.
Theorem 1.1 gets around this problem by using a combination of the two methods of composing graphs. For example, the graph in Figure 2 also evaluates the formula in the same manner. One can think of the vertex as evaluating the subformula . The subgraph it cuts off has been composed in a directsum manner with a tensorproductcomposed graph for the formula . By combining the two composition methods, we can manage the tradeoffs, controlling the maximum degree and norm of the graph, while also avoiding the formula depth problem.
Although our algorithm can be presented and analyzed entirely in terms of graphs, we will present it in terms of span programs. Span programs are part of a framework for designing and analyzing quantum algorithms [Rei09a], for which Section 2 gives some necessary background. Eigenvaluezero eigenvectors correspond to span program witnesses and the squared support on the root corresponds to a complexity measure known as the full witness size [Rei09b]. The two graph composition techniques described above correspond to different ways of composing general span programs.
1.2 Review of quantum algorithms for evaluating ANDOR formulas
Research on the formulaevaluation problem in the quantum model began with the simple bit OR function, . Grover gave a quantum algorithm for evaluating with bounded onesided error using oracle queries and time [Gro96, Gro02].
Grover’s algorithm, together with repetition for reducing errors, can be applied recursively to speed up the evaluation of more general ANDOR formulas. For example, the size ANDOR formula can be evaluated in queries. Here the extra logarithmic factor comes from using repetition to reduce the error probability of the inner evaluation procedure from a constant to be polynomially small. Call a formula layered if the gates at the same depth are the same. Buhrman, Cleve and Wigderson show that the above argument can be applied to evaluate a layered, depth ANDOR formula on inputs using queries [BCW98, Theorem 1.15].
Høyer, Mosca and de Wolf [HMW03] consider the case of a unitary input oracle that maps
(1.1) 
where , are pure states with . Such an oracle can be implemented when the function is computed by a boundederror, randomized subroutine [NC00]. Høyer et al. allow access to and , both at unit cost, and show that can still be evaluated using queries. This robustness result implies that the steps of repetition used by [BCW98] are not necessary, and a depth layered ANDOR formula can be computed in queries, for some constant . This gives an query quantum algorithm for the case that the depth is constant, but is not sufficient to cover, e.g., the complete, binary ANDOR formula, for which .
A breakthrough for the formulaevaluation problem came in 2007, when Farhi, Goldstone and Gutmann presented a quantum algorithm for evaluating complete, binary ANDOR formulas [FGG07]. Their algorithm is not based on iterating Grover’s algorithm in any way, but instead runs a quantum walk—analogous to a classical random walk—on a graph derived from the ANDOR formula graph as in Figure 1. The algorithm runs in time in a certain continuoustime query model.
Ambainis et al. discretized the [FGG07] algorithm by reinterpreting a correspondence between discretetime random and quantum walks due to Szegedy [Sze04] as a correspondence between continuoustime and discretetime quantum walks [ACR07]. Applying this correspondence to quantum walks on certain weighted graphs, they gave an query quantum algorithm for evaluating “approximately balanced” formulas, extended in [Rei09b]. Using the formula rebalancing procedure of [BCE91, BB94], the [ACR07] algorithm uses queries in general. This is nearly optimal, since the adversary bound gives an lower bound [BS04].
This author has given an query quantum algorithm for evaluating arbitrary size ANDOR formulas [Rei09a]. In fact, the result is more general, stating that the general adversary bound is nearly tight for every boolean function. However, unlike the earlier ANDOR formulaevaluation algorithms, the algorithm is not necessarily time efficient.
2 Span programs
In this section, we will briefly recall some of the definitions and results on span programs from [Rei09a, Rei09b]. This section is essentially an abbreviated version of [Rei09b, Sec. 2].
For a natural number , let . For a finite set , let be the inner product space with orthonormal basis . For vector spaces and over , let be the set of linear transformations from into , and let . For , is its operator norm. Let . For a string , let denote its bitwise complement.
2.1 Span program full witness size
The full witness size is a span program complexity measure that is important for developing quantum algorithms that are time efficient as well as query efficient.
Definition 2.1 (Span program [Kw93]).
A span program consists of a natural number , a finitedimensional inner product space over , a “target” vector , disjoint sets and for , , and “input vectors” for .
To corresponds a function , defined on by
(2.1) 
Some additional notation is convenient. Fix a span program . Let . Let be given by . For , let and . Then if . A vector is said to be a witness for if and . A vector is said to be a witness for if and .
Definition 2.2 (Witness size).
Consider a span program , and a vector of nonnegative “costs.” Let . For each input , define the witness size of on with costs , , as follows:
(2.2) 
The witness size of with costs is
(2.3) 
Define the full witness size by letting and
(2.4)  
(2.5) 
When the subscript is omitted, the costs are taken to be uniform, , e.g., . The witness size is defined in [RŠ08]. The full witness size is defined in [Rei09a, Sec. 8], but is not named there. A strict span program has , so , and a monotone span program has for all [Rei09a, Def. 4.9].
Theorem 2.3 ([Rei09a, Theorem 9.3], [Rei09b, Theorem 2.3]).
Let be a span program. Then can be evaluated using
(2.6) 
quantum queries, with error probability at most . Moreover, if the maximum degree of a vertex in is , then the time complexity of the algorithm for evaluating is at most a factor of worse, after classical preprocessing and assuming constanttime coherent access to the preprocessed string.
2.2 Directsum span program composition
Let be a boolean function. Let . For , let be a natural number, with for . For , let . Define by
(2.7) 
Define by . Given span programs for the individual functions and for , we will construct a span program for .
Let be a span program computing . Let have inner product space , target vector and input vectors indexed by and for and .
For , let be a vector of costs, and let be the concatenation of the vectors . For , let and be span programs computing and , with . For , let have inner product space with target vector and input vectors indexed by and for , . For , let .
Let . Define by if . The idea is that maps to the input span program that must evaluate to true in order for to be available for .
Definition 2.4 ([Rei09a, Def. 4.5]).
The directsumcomposed span program is defined by:

The inner product space is . Any vector in can be uniquely expressed as , where and .

The target vector is .

The free input vectors are indexed by with, for ,
(2.8) 
The other input vectors are indexed by for , , . For , , with for . For , let . For and , let
(2.9)
By [Rei09a, Theorem 4.3], and . Moreover, we can bound how quickly the full witness size can grow relative to the witness size:
Lemma 2.5 ([Rei09b, Lemma 2.5]).
Under the above conditions, for each input , with ,

If , let be a witness to with . Then
(2.10) 
If , let be a witness to such that . Then
(2.11)
If , then and should each be taken to be in the above equations.
Lemma 2.6 ([Rei09b, Lemma 3.4]).
If is the directsum composition along a formula of span programs and , then
(2.12) 
If the span programs are monotone, then .
3 Evaluation of arbitrary ANDOR formulas
Let be an ANDOR formula. In this section, we will prove Theorem 1.1 by applying Theorem 2.3 to a certain composed span program . The construction of has three steps that we will explain in detail below.

Eliminate any AND or OR gates with fanin one, and expand out AND and OR gates with higher fanins into gates of fanin exactly two.

Mark a certain subset of the edges of the formula. We call marked edges “checkpoints.”

Starting with the span programs for and , compose them for the subformulas cut off by checkpointed edges using a version of tensorproduct composition. Compose the resulting span programs across checkpoints using directsum composition to yield .
Directsum span program composition keeps the norm of the corresponding graph’s adjacency matrix under control, as well as the maximum degree of a vertex in the graph. However, it makes the full witness size grow much larger than the witness size, especially for highly unbalanced formulas. Reduced tensorproduct composition generates strict span programs, for which the full witness size stays close to the witness size. However, it allows the norm and the maximum degree of the corresponding graph to grow exponentially quickly. By using both techniques in careful combination, we are able to manage this tradeoff so that Theorem 2.3 can be applied.
Section 3.1 presents the span programs we use for fanintwo AND and OR gates.
In Section 3.2, we study reduced tensorproduct composition for the span programs for AND and OR gates. Reduced tensorproduct composition is a version of tensorproduct composition that parsimoniously uses fewer dimensions when possible. For ANDOR formulas, it has the advantage that the output span program’s inner product space bears a close connection to false inputs of the formula , similarly to canonical span programs. In order to motivate the checkpointing idea, we explain the problems of a scheme based only on reduced tensorproduct composition.
Section 3.3 then presents our full construction of , based on a combination of directsum and reduced tensorproduct composition.
Section 3.4 contains the analysis of the graphs required to apply Theorem 2.3.
3.1 Span programs for AND and OR
We will use the following strict, monotone span programs for fanintwo AND and OR gates:
Definition 3.1 ([Rei09b, Def. 4.1]).
For , define span programs and computing and , , respectively, by
(3.1)  
(3.2) 
Both span programs have , and . Here the parameters , for , are given by
(3.3)  
(3.4) 
where . Let and .
Note that . They are largest when .
Claim 3.2 ([Rei09b, Claim 4.2]).
The span programs and satisfy:
(3.5) 
3.2 Reduced tensorproduct span program composition for ANDOR formulas
Reduced tensorproduct composition of span programs is introduced in [Rei09a, Def. 4.6]. We repeat the definition here, specializing to the case of monotone, strict span programs acting on disjoint inputs. Also, for simplicity we consider the case of composing on one span program at a time. After stating the definition, we specialize further to ANDOR formulas, and characterize the reduced tensorproduct span program composition of the AND and OR span programs from Definition 3.1.
Consider monotone functions and . Let be defined by
(3.6) 
for , . Let be a span program computing and let be a span program computing . Assume that and are both monotone, strict span programs.
Let span program be in inner product space , with target vector and input vectors indexed by for . Let be in the inner product space with target vector and input vectors indexed by for . Since and are both monotone, .
Definition 3.3 ([Rei09a]).
The tensorproductcomposed span program, reduced with respect to the basis for , is , defined by:

Let . For , define and by
(3.7) 
The inner product space of is . Any vector can be uniquely expressed as , where .

The target vector is
(3.8) 
is strict and monotone, thus for all .

The input vectors are indexed by
(3.9) and given by
(3.10)
The intuition behind this construction is to compose the span programs in a tensorproduct manner somewhat similar to Definition 2.4. From [Rei09a, Def. 4.4], this would give a span program with target vector and input vectors either for or otherwise. However, if all the input vectors are zero in a coordinate , then the first type of input vectors are all zero on . The second type of input vectors are all proportional to the same state on that coordinate, so we might as well just keep as in the above definition. The advantage over tensorproduct composition is that the graph associated to the span program potentially has fewer vertices, with lower degrees.
Here we have composed the span program into the first input of . Reduced tensorproduct composition into the other inputs is defined symmetrically.
By [Rei09a, Prop. 4.7], for arbitrary costs and ,
(3.11) 
Now let us study reduced tensorproduct composition for ANDOR formulas. To start with, it will be helpful to give two examples of Definition 3.3, for the cases and . Recall from [Rei09a, Def. 8.1] that the biadjacency matrix for the bipartite graph is given by , where is the matrix whose columns are the input vectors of , as defined in Section 2.1. Assume that is a singleton set, with the first column of . Rearrange the rows so that the nonzero entries of come first (the set from Definition 3.3 comes last), writing , where is nonzero in every entry. Writing , decomposes as
(3.12) 

First consider the case that from Definition 3.1. Let be the composed span program from Definition 3.3. Then
(3.13) For comparison, the tensorproductcomposed span program from [Rei09a, Def. 4.4] would have the biadjacency matrix
(3.14) 
Next consider the case that from Definition 3.1. Let be the composed span program from Definition 3.3. Then
(3.15)
From Eqs. (3.13) and (3.15), we can derive a bound on the growth of the norm of the entrywise absolute value of the biadjacency matrix for a span program, under reduced tensorproduct composition with either or :
Lemma 3.4.
Let be a strict, monotone span program on input bits, with