Quantum Algorithms for Graph Connectivity and Formula Evaluation

We give a new upper bound on the quantum query complexity of deciding $st$-connectivity on certain classes of planar graphs, and show the bound is sometimes exponentially better than previous results. We then show Boolean formula evaluation reduces to deciding connectivity on just such a class of graphs. Applying the algorithm for $st$-connectivity to Boolean formula evaluation problems, we match the $O(\sqrt{N})$ bound on the quantum query complexity of evaluating formulas on $N$ variables, give a quadratic speed-up over the classical query complexity of a certain class of promise Boolean formulas, and show this approach can yield superpolynomial quantum/classical separations. These results indicate that this $st$-connectivity-based approach may be the"right"way of looking at quantum algorithms for formula evaluation.


Introduction
Deciding whether two points are connected in a network is a problem of significant practical importance. In this work, we argue that this problem, st-connectivity, is also important as a quantum algorithmic primitive.
Dürr, Heiligman, Høyer, and Mhalla designed a quantum algorithm for deciding stconnectivity that requires O(|V | 3/2 ) queries to the adjacency matrix of a graph on vertex set V [13]. Belovs and Reichardt later discovered an especially elegant span-program-based quantum algorithm for this problem, which is time-efficient and requires only logarithmic space [4]. Belovs and Reichardt's algorithm improves on the query complexity of Dürr et al.'s algorithm when the connecting path is promised to be short (if it exists).
Belovs and Reichardt's st-connectivity algorithm has already been adapted or been used as a subroutine for deciding other graph problems, such as detecting certain subgraphs [4], deciding whether a graph is a forest [8], and deciding whether a graph is bipartite [8].
In this work, we modify the span program algorithm used in [4], inheriting its space and time efficiency, and we restrict to deciding st-connectivity on a class of planar graphs. If the effective resistances of the set of graphs in question (and their planar duals) are small, then we find the quantum algorithm requires far fewer queries than suggested by the analysis in [4]. In fact, we obtain a polynomial to constant improvement in query complexity for some classes of graphs.
from Boolean formula evaluation to st-connectivity could be helpful in the design of new classical algorithms for formulas.
Another open problem concerns span programs in general: when can we view span programs as solving st-connectivity problems? This could be useful for understanding when span programs are time-efficient, since the time-complexity analysis of st-connectivity span programs is straightforward (see Appendix A.1, [4,Section 5.3], [17,Appendix B]).
An important class of st-connectivity-related span programs are those arising from the learning graph framework, which provides a means of designing quantum algorithms that is much simpler and more intuitive than designing a general span program [3]. A limitation of this framework is its one-sidedness with respect to 1-certificates: whereas a learning graph algorithm is designed to detect 1-certificates, a framework capable of giving optimal quantum query algorithms for any decision problem would likely treat 0-and 1-inputs symmetrically. In our analysis of st-connectivity, 1-inputs and 0-inputs are on equal footing. This duality between 1-and 0-inputs in st-connectivity problems could give insights into how to extend the learning graph framework to a more powerful framework, without losing its intuition and relative simplicity.
Organization: Section 2 provides background information. In Section 3, we describe our improved analysis of the span program algorithm for st-connectivity for subgraphs of graphs G such that G ∪ {{s, t}} is planar. In Section 4, we show that every formula evaluation problem is equivalent to an st-connectivity problem. In Section 5, we apply these results to promise nand-trees, for which we are able to prove the most significant classical/quantum separation using our approach. Also in Section 5, we use these ideas to create an improved algorithm for playing the two-player game associated with a nand-tree.

Graph Theory
For an undirected weighted multigraph G, let V (G) and E(G) denote the vertices and edges of G respectively. In this work, we will only consider undirected multigraphs, which we will henceforth often refer to as graphs. To refer to an edge in a multigraph, we will specify the endpoints, as well as a label λ, so that an edge is written ({u, v}, λ). Although the label λ will be assumed to uniquely specify the edge, we include the endpoints for convenience. Let − → E (G) = {(u, v, λ) : ({u, v}, λ) ∈ E(G)} denote the set of directed edges of G. For a planar graph G (with an implicit planar embedding) let F (G) denote the faces of G. We call the infinite face of a planar graph the external face.
For any graph G with connected vertices s and t, we can imagine a fluid flowing into G at s, and traveling through the graph along its edges, until it all finally exits at t. The fluid will spread out along some number of the possible st-paths in G. Such a linear combination of st-paths is called an st-flow. More precisely: Intuitively, R s,t (G) characterizes "how connected" the vertices s and t are. The more, shorter paths connecting s and t, the smaller the effective resistance.
The effective resistance has many applications. In a random walk on G, R s,t (G)|E(G)| is equal to the commute time between s and t, or the expected time a random walker starting from s takes to reach t and then return to s [2,9]. If G models an electrical network in which each edge e of G is a unit resistor and a potential difference is applied between s and t, then R s,t (G) corresponds to the resistance of the network, which determines the ratio of current to voltage in the circuit (see [11]). We can extend these connections further by considering weighted edges. A network consists of a graph G combined with a positive real-valued weight function c : E(G) → R + . In a random walk on a network, which models any reversible Markov chain, a walker at vertex u traverses edge ({u, v}, λ) with probability proportional to c ({u, v}, λ). Then the commute time between s and t is R s,t (N ) e∈E(G) c(e). When N models an electrical network in which each edge e represents a resistor with resistance 1/c(e), then R s,t (N ) corresponds to the resistance of the network.
When G is a single edge e = ({s, t}, λ) with weight c(e), then the resistance R s,t (G) = 1/c(e). When calculating effective resistance, R s,t , we use the rule that for edges in series (i.e., a path), or more generally, graphs connected in series, resistances add. Edges in parallel, or more generally, graphs connected in parallel, follow the rule that conductances in parallel add, where the conductance of a graph is given by one over the resistance. (The conductance of an edge e is equal to c(e), the weight of the edge.) More precisely, it is easy to verify the following: Claim 5. Let two networks N 1 = (G 1 , c 1 ) and N 2 = (G 2 , c 2 ) each have nodes s and t. If we create a new graph G by identifying the s nodes and the t nodes (i.e. connecting the graphs in parallel) and define c : E(G) → R + by c(e) = c 1 (e) if e ∈ E(G 1 ) and c(e) = c 1 (e) if e ∈ E(G 2 ), then (2) However, if we create a new graph G by identifying the t node of G 1 with the s node of G 2 , relabeling this node v ∈ {s, t} (i.e. connecting the graphs in series) and define c as before, then R s,t (G, c) = R s,t (G 1 , c 1 ) + R s,t (G 2 , c 2 ).
In other words, κ defines a subset S ⊂ V (G) such that s ∈ S, t ∈ S, and there is no edge of G with one endpoint in S, and one endpoint in S. An st-cut is a witness that s and t are in different components of G, so no path exists between s and t.
Finally, we consider dual graphs:

Span Programs and Quantum Query Algorithms
Span programs [18] were first introduced to the study of quantum algorithms by Reichardt and Špalek [24]. They have since proven to be immensely important for designing quantum algorithms in the query model.
if there exists a positive witness for x, and w + (x) = ∞ otherwise. Let L(U, R) denote the set of linear maps from U to R. We call a linear map ω ∈ L(U, R) a negative witness for x in P if ωAΠ H(x) = 0 and ωτ = 1. We define the negative witness size of x as: if there exists a negative witness, and w − (x) = ∞ otherwise. If w + (x) is finite, we say that x is positive (wrt. P ), and if w − (x) is finite, we say that x is negative. We let P 1 denote the set of positive inputs, and P 0 the set of negative inputs for P . In this way, the span program defines a partition (P 0 , P 1 ) of [N ].
For a function f : X → {0, 1}, with X ⊆ {0, 1} N , we say P decides f if f −1 (0) ⊆ P 0 and f −1 (1) ⊆ P 1 . We can use P to design a quantum query algorithm that decides f , given access to the input x ∈ X via queries of the form O . Then there is a bounded error quantum algorithm that decides f with quantum query complexity O( W + (f, P )W − (f, P )).

Boolean Formulas
moves by the two players determines a path from the root to a leaf.
A simple inductive argument shows that if x is a 1-instance of nand-tree, then there exists a strategy by which Player A can always win, no matter what strategy B employs; and if x is a 0-instance, there exists a strategy by which Player B can always win. We say an input x is A-winnable if it has value 1 and B-winnable if it has value 0.

Improved Analysis of st-connectivity Algorithm
In this section, we give an improved bound on the runtime of a quantum algorithm for st-connectivity on subgraphs of G, where G ∪ {{s, t}} is planar.
Let st-conn G,D be a problem parameterized by a family of multigraphs G, which takes as input a string The authors of [4] present a quantum query algorithm for st-conn G when G is a complete graph, which is easily extended to any multigraph G. We further generalize their algorithm to depend on some weight function c : E(G) → R + (a similar construction is also implicit in [3]). We call the following span program P G,c : For any choice of weight function c, this span program decides st-conn G , but as we will soon see, the choice of c may impact the complexity of the resulting algorithm.
Using P G,c with c({u, v}, λ) = 1 for all ({u, v}, λ) ∈ E(G), the authors of Ref. [4] show that the query complexity of evaluating st-conn G,D is Their analysis was for the case where G is a complete graph, but it is easily seen to apply to more general multigraphs G. In fact, it is straightforward to show that this bound can be improved to where In particular, when G is a complete graph on vertex set V , with the promise that if an st-path exists, it is of length at most k, Eq. (7) gives a bound of O √ k|V | . In the worst case, when k = |V |, the analysis of [4] does not improve on the previous quantum algorithm of [13], which gives a bound of O(|V | 3/2 ). In this paper, we consider in particular multigraphs that are planar even when an additional st-edge is added (equivalently, there exists a planar embedding in which s and t are on the same face), as in graph G in Figure 1. (In the case of Figure 1, s and t are both on the external face.) Given such a graph G, we define three other related graphs, which we denote by G, G † , and G .
We first define the graph G, which is the same as G, but with an extra edge labeled by ∅ connecting s and t. We then denote by G † the planar dual of G. Because every planar dual has one edge crossing each edge of the original graph, there exists an edge that is dual to ({s, t}, ∅), also labeled by ∅. We denote by s and t the two vertices at the endpoints of ({s, t}, ∅) † = ({s , t }, ∅). Finally, we denote by G the graph G † except with the edge  By construction, G will always have the same number of edges as G. Then as x defines a subgraph G(x) of G by including the edge e if and only if x e = 1, we let G (x) be the subgraph of G where we include the edge e † if and only if x e = 0.
If there is no path from s to t in G(x), there must be a cut between s and t. Note that for any e ∈ E(G), e ∈ E(G(x)) if and only if e † ∈ E(G (x)). Looking at Figure 1, one can convince oneself that any s t -path in G (x) defines an st-cut in G(x): simply define κ(v) = 1 for vertices above the path, and κ(v) = 0 for vertices below the path.
Let c be a weight function on E(G). Then we define a weight function c on E(G ) as c (e † ) = 1/c(e). Then for every x there will be a path either from s to t in G(x) (and hence R s,t (G(x), c)) will be finite), or a path from s to t in G (x) (in which case R s ,t (G (x), c ) will be finite).
We can now state our main lemma: Using Lemma 11 and Theorem 10, we immediately have the following: Theorem 12. Let G be a planar multigraph with s, t ∈ V (G) such that G ∪ {{s, t}} is also planar. Then the bounded error quantum query complexity of evaluating st-conn G,D is where the minimization is over all positive real-valued functions c on E(G).
While it might be difficult in general to find the optimal edge weighting c, any choice of c will at least give an upper bound on the query complexity. However, as we will see, sometimes the structure of the graph will allow us to efficiently find good weight functions.
The proof of Lemma 11 is in Appendix A. The positive witness result follows from generalizing the proof in [4] to weighted multigraphs. The idea is that an st-path witnesses that s and t are connected, as does any linear combination of such paths -i.e. an st-flow. The effective resistance R s,t (G(x), c) characterizes the size of the smallest possible st-flow.
Just as a positive witness is some linear combination of st-paths, similarly, a negative witness turns out to be a linear combination of st-cuts in G(x). But as we've argued, every st-cut corresponds to an s t -path in G (x). Using the correspondence between cuts and paths, we have that a negative witness is a linear combination of s t -paths in G (x). This allows us to show a correspondence between complexity-optimal negative witnesses and minimal s t -flows, connecting w − (x, P G,c ) to R s ,t (G (x), c ).
In Appendix A.1, we show that if a quantum walk step on the network (G, c) can be implemented time efficiently, then this algorithm is not only query efficient, but also time efficient, with only 1 √ δ multiplicative overhead, where δ is the spectral gap of the symmetric normalized Laplacian. For example, if G is a complete graph with unit weights, δ is constant. Let Then we show the following.
In Appendix A.1, we also show that if the space complexity of implementing U G,c in time S G,c is S G,c , the algorithm referred to in Theorem 13 has space complexity at most O(max{log |E(G)|, log |V (G)|} + S G,c + log(1/δ)).

Comparison to Previous Quantum Algorithm
When G ∪ {{s, t}} is planar, our algorithm always matches or improves on the algorithm in [4]. To see this, we compare Eqs. (10) and (8), and choose c to have value 1 on all edges of G. Then the first terms are the same in both bounds, so we only need to analyze the second term. However, using the duality between paths and cuts, we have To obtain the inequality in Eq. (13), we create an s t -flow on G (x) that has value one on edges on the shortest path from s to t and zero on all other edges. Such a flow has unit 1 An earlier version of this work was missing the 1/ √ δ term in the complexity, due to an error in the proof. We thank Arjan Cornelissen and Alvaro Piedrafita for finding this error and bringing it to our attention.
flow energy equal to the shortest path. However, the true effective resistance can only be smaller than this, because it is the minimum energy over all possible s t -flows.
We now present two simple examples where our algorithm and analysis do better than that of [4]. In the first example, we highlight how the change from C s,t (G(x)) to R s ,t (G(x)) in the complexity gives us an advantage for some graphs. In the second example, we show that being able to choose a non-trivial weight function c can give us an advantage for some graphs.
Let G be an st-path of length N : i.e., N + 1 vertices arranged in a line so that each vertex is connected to its neighbors to the left and right by a single edge, and s and t are the vertices on either end of the line, as in Figure   Then, choosing c to have value 1 on all edges of G, we have because the only x ∈ D such that s and t are connected in G(x) is x = 1 N , in which case the only unit flow has value 1 on each edge. This flow has energy N . However because when s and t are not connected in G(x), G(x) has at most N − h edges, so G (x) has at least h edges. Thus we can define a unit flow with value 1/h on each of h parallel edges in G (x), giving an energy of 1/h. On the other hand In fact, since C s,t (G(x)) counts the minimum number of edges ({u, v}, λ) across any cut (i.e. such that κ(u) = 1 and κ(v) = 0), it is always at least 1, for any G(x) in which an st-cut exists, whereas R s ,t (G (x)) can be as small as 1/N for some G. Choosing h = √ N in our example, and applying Eqs. (8) and (10), the analysis in [4] gives a query complexity of O(N 1/2 ) while our analysis gives a query complexity of O(N 1/4 ). In Section 4 we will show that this bound is tight. Now consider the graph G in Figure 3. It consists of N edges in a line, connecting vertices s, u 1 , . . . , u N , and then N multi-edges between u N and t. We assign weights c(e) = 1 for edges e on the path from s to u N , and c(e) = N −1 for all other edges. Then, . . . which occurs when only one of the multi-edges between u N and t is present. In that case, the N edges {s, u 1 }, {u 1 , u 2 }, . . . , {u N −1 , u N } each contribute 1 to the effective resistance, and the final edge between u N and t contributes 1 c(e) = N . Also where the maximum occurs when there is only one path from s to t . (If it is the path with N edges, each edge has weight N , and so contributes 1/N to the flow energy.) However for a cut across the multi-edges between u N and t, and which occurs when only one of the multi-edges between u N and t is present. Thus, the analysis in [4] gives a query complexity of O(N ) while our analysis gives a query complexity of O(N 1/2 ).
In Section 5 we will give an example where our analysis provides an exponential improvement over the analysis in [4].

AND-OR Formulas and st-Connectivity
In this section, we present a useful relationship between and-or formula evaluation problems and st-connectivity problems on certain graphs. As mentioned in Section 2, for simplicity we will restrict our analysis to read-once formulas, but the algorithm extends simply to "read-many" formulas. In this case, we will primarily be concerned with the query complexity: the input x = (x 1 , . . . , x N ) to a formula will be given via a standard Given an and-or formula φ with N variables, we will recursively construct a planar multigraph G φ , such that G φ has two distinguished vertices labeled by s and t respectively, and every edge of G φ is uniquely labeled by a variable {x i } i∈ [N ] . If φ = x i is just a single variable, then G φ is just a single edge with vertices labeled by s and t, and edge label Otherwise, suppose φ = φ 1 ∧ · · · ∧ φ l . Then G φ is the graph obtained from the graphs G φ 1 , . . . , G φ l by identifying the vertex labeled t in G φ i with the vertex labeled s in G φ i+1 , for all i = 1, . . . , l − 1, and labeling the vertex labeled s in G φ 1 by s, and the vertex labeled t in G φ l by t. That is, we connect the graphs G φ 1 , . . . , G φ l in series, as in Figure 4. (For a formal definition of G φ , see Appendix B).
The only other possibility is that φ = φ 1 ∨ · · · ∨ φ l . In that case, we construct G φ by starting with G φ 1 , . . . , G φ l and identifying all vertices labeled by s, and labeling the resulting vertex with s, and identifying all vertices labeled by t, and labeling the resulting vertex by t. That is, we connect G φ 1 , . . . , G φ l in parallel (see Figure 4). We note that graphs constructed in this way are exactly the set of series-parallel graphs with two terminals (see e.g. [27,Def. 3]), and are equivalent to graphs without a K 4 minor [10,12].
Then we obtain G φ1∧φ2∧φ3 by connecting G φ1 , G φ2 , and G φ3 in series, and G φ1∨φ2∨φ3 by connecting them in parallel.
Note that for any φ, G φ is planar, and furthermore, both s and t are always on the same face. Thus, we can define G φ , G φ (x) and G φ (x) as in Section 3. Then we can show the following: We give a formal proof of Lemma 14 in Appendix B, but the intuition is that an or of subformulas, φ 1 ∨ · · · ∨ φ l evaluates to true if any of the subformulas evaluates to true, and likewise, if two vertices are connected by multiple subgraphs in parallel, the vertices are connected if there is a path in any of the subgraphs. An and of subformulas φ 1 ∧ · · · ∧ φ l evaluates to true only if every subformula evaluates to true, and likewise, if two vertices are connected by multiple subgraphs in series, the vertices are only connected if there is a path through every subgraph. Thus, we can show by induction that s and t are connected To see that s and t are connected in G φ (x) if and only if φ(x) = 0, we can use a similar argument, and make use of the fact that an s t -path in Lemma 14 implies that we can solve a formula evaluation problem Eval φ by solving the associated st-connectivity problem, in which the input is a subgraph of G φ . By our construction, G φ will always be a planar graph with s and t on the external face, so moreover, we can apply Theorem 12 to obtain the following.

Theorem 15. For any family φ of and-or formulas, the bounded error quantum query complexity of Eval φ when the input is promised to come from a set D is
where the minimization is over all positive real-valued functions c on E(G φ ).
Proof. By Lemma 14, the query complexity of Eval φ on D is at most the query complexity of st-conn G φ ,D . Since G φ is planar, and has s and t on the same face, we can apply Theorem 12, which immediately implies the result.

Comparison to Existing Boolean Formula Algorithms
Reichardt proved that the quantum query complexity of evaluating any formula on N variables is O( We need the following claim, which we prove in Appendix B: The intuition behind Claim 17 is the following. Although G φ is defined via the dual of G φ , which is constructed through a sequence of series and parallel compositions, G φ itself can also be built up through a sequence of series and parallel compositions. For any and-or formula φ on N variables, we can define a formula φ on N variables by replacing all ∨-nodes in φ with ∧-nodes, and all ∧-nodes in φ with ∨-nodes. By de Morgan's law, for Proof of Theorem 16. We will make use of the following fact: for any network (G, c), and any positive real number W : We now proceed with the proof. For any formula φ in {∧, ∨, ¬}, by repeated applications of de Morgan's law, we can push all not-gates to distance-1 from a leaf. Since x i and ¬x i can both be learned in one query, we can restrict our attention to and-or formulas.
If φ has only N = 1 variable, it's easy to see that W + (P G φ ,c )W − (P G φ ,c ) ≤ N for c taking value 1 on the single edge in G φ . We will prove by induction that this is true for any φ, for some choice of c, completing the proof, since the complexity of our algorithm is an edge originating from the graph G φ i . That is, our new weight function is the same as combining all of the old weight functions, up to scaling factors Using Lemma 11, Claim 5, and Eq. (22), for any 1-instance x, Thus Recall that for a weight function c on G φ , we define a weight function c on G φ by c (e † ) = 1/c(e). Then for an edge e ∈ E( . By Claim 17, G φ is formed by composing {G φ i } i in parallel, so by Lemma 11, Claim 5, and Eq. (22): Continuing from above, we have: The proof for the case φ = φ 1 ∨ · · · ∨ φ l is similar.
An immediate corollary of Theorem 16 is the following. As with many results in this field, characterizing classical complexity seems to be more difficult than quantum complexity. However, we show we can lower bound the classical query complexity of a class of Boolean formulas in terms of the effective resistance of their corresponding graphs, achieving a quadratic quantum/classical speed-up in query complexity.
We consider and-or formulas on restricted domains. For We will analyze and-or formulas such that the input to every gate in the formula comes from D N,h (in the case of and), which we denote and| D N,h and D N,h (in the case of or), which we denote or| D N,h . These promises on the domains make it easier to evaluate both functions. For example, if or evaluates to 1, we are promised that there will not be just one input with value 1, but at least h.
Then using sabotage complexity [5] to bound the classical query complexity, we have the following theorem, whose (somewhat long, but not technical) proof can be found in Appendix C: Note that in the above theorem, when we compose formulas with promises on the input, we implicitly assume a promise on the input to the composed formula. More precisely, for and using sabotage complexity to show that this is a lower bound on the randomized query complexity of φ. This gives us a quadratic separation between the randomized and quantum query complexities of this class of formulas. For details, see Appendix C.
Using the composition lower bound for promise Boolean functions of [19], and the lower bound for Grover's search with multiple marked items [6], we have that the quantum query complexity of Theorem 19 is tight. Additionally, in light of our reduction from Boolean formula evaluation to st-connectivity, we see that our example from Figure 2 in Section 3 is equivalent to the problem of and| D N,h , so our query bound in that example is also tight.
Based on Theorem 19, one might guess that when evaluating formulas using the stconnectivity reduction, one can obtain at most a quadratic speed-up over classical randomized query complexity. However, it is in fact possible to obtain a superpolynomial speed-up for certain promise problems using this approach, as we will discuss in Section 5.1.

Query Separations
In this section, we prove two query separations that are stronger than our previous results. These query separations rely on the nand-tree formula with a promise on the inputs. This restriction, the k-fault promise, will be defined shortly. Let F d k be the set of inputs to nand d that satisfy the k-fault condition. Then the two results are the following: Theorem 20. Using the st-connectivity approach to formula evaluation (Theorem 15), one can solve Eval nand d when the input is promised to be from F d log d with O(d) queries, while any classical algorithm requires Ω(d log log(d) ) queries.
For a different choice of k, this example demonstrates the dramatic improvement our st-connectivity algorithm can give over the analysis of [4] -in this case, an exponential (or more precisely, a polynomial to constant) improvement: The analysis of [4] gives a bound of O(N 1/4 ) quantum queries to decide this problem (where N = 2 d is the number of edges in G nand d ), while our analysis shows this problem can be decided with O(1) quantum queries.
We now define what we mean by k-fault nand-trees. In [28], Zhan et al. find a relationship between the difficulty of playing the two-player game associated with a nand-tree, and the witness size of a particular span program for nand d . They find that trees with fewer faults, or critical decisions for a player playing the associated two-player game, are easier to evaluate on a quantum computer. We show that our algorithm does at least as well as the algorithm of Zhan et al. for evaluating k-fault trees. To see this, we relate fault complexity to effective resistances of Consider a nand d instance x ∈ {0, 1} 2 d , and recall the relationship between a nandtree instance and the two-player nand-tree game described in Section 2.3. We call the sequence of nodes that Player A and Player B choose during the course of a game a path p -this is just a path from the root of the nand-tree to a leaf node. If x is Z-winnable, we call P Z (x) the set of paths where Player Z wins, and Player Z never makes a move that would allow her opponent to win. That is, a path in P A (x) (resp. P B (x)) only encounters nodes that are themselves the roots of A-winnable (resp. B-winnable) subtrees and never passes through a node where Player B (resp. Player A) could make a decision to move to a B-winnable (resp. A-winnable) subtree. Whether a node in the tree is the root of an A-winnable or B-winnable subtree can be determined by evaluating the subformula corresponding to that subtree. See Figure 5 for an example of P A . Let ν Z (p) be the set of nodes along a path p at which it is Player Z's turn. Thus, ν A (p) (resp. ν B (p)) contains those nodes in p at even (resp. odd) distance > 0 from the leaves.
Zhan et al. call a node v a fault if one child is the root of an A-winnable tree, while the other child is the root of a B-winnable tree. Such a node constitutes a critical decision point.
If we let f Z (p) denote the number of faults in ν Z (p), we can define the fault complexity For k = 0, . . . , d/2, the set of k-fault trees, F d k , are those instances x ∈ {0, 1} 2 d with log F(x) ≤ k. In these trees, the winning player will encounter at most k fault nodes on their path to a leaf. Kimmel [19] shows there exists a span program for evaluating nand-trees whose witness size for an instance x is at most the fault complexity F(x).
We first show a relationship between effective resistance of G nand d (x) or G nand d (x) and F(x): The proof of Lemma 22 can be found in Appendix D. An immediate corollary of Lemma 22 and Theorem 15 is the following.
Player B's Second Turn Proof of Theorem 20. Theorem 20 is now an immediate consequence of Corollary 23, with k set to log(d), along with the fact from [28] that the classical query complexity of evaluating such formulas is Ω(d log log(d) ).
We will use Corollary 23, along with the following claim, to prove Theorem 21: Claim 24. Let two graphs G 1 and G 2 each have nodes s and t and let . Suppose we create a new graph G by identifying the s nodes and the t nodes (i.e. connecting the graphs in parallel), then If we create a new graph G by identifying the t node of G 1 with the s node of G 2 and relabeling this node v ∈ {s, t} (i.e. connecting the graphs in series), then We now prove that for every x ∈ {0, 1} 2 d such that nand d (x) = 0, C s,t (G nand d (x)) = 2 d/2 . Thus, for any promise D on the input, as long as there exists some x ∈ D such that nand d (x) = 0, we have max x∈D:nand d (x)=0 C s,t (G nand d (x)) = 2 d/2 . Intuitively, this is because every st-cut on any subgraph of G nand d cuts across 2 d/2 edges of G nand d .
The proof is by induction on d. For the base even case, d = 0 and G nand 0 is a single edge connecting s and t. The only input x ∈ {0, 1} 2 0 such that nand d (x) = 0 is x = 0, in which case, the st-cut is κ(s) = 1 and κ(t) = 0, so the cut is across the unique edge in G nand 0 , so C s,t (G nand 0 (x)) = 1.
For the induction step, we treat even and odd separately. Suppose d > 0 is odd. −1 +1 , . . . , x 2 d ). Thus G nand d (x) involves composing two graphs G nand d−1 (x 0 ) and G nand d−1 (x 1 ) in series. Since we are assuming s and t are not connected in G nand d (x), at least one of G nand d−1 (x 0 ) and G nand d−1 (x 1 ) must not be connected. Without loss of generality, suppose G nand d−1 (x 0 ) is not connected and C s,t (G nand d−1 (x 0 )) ≤ C s,t (G nand d−1 (x 1 )). By induction, C s,t (G nand d−1 (x 0 )) = 2 (d−1)/2 . Thus using Eq. (30) in Claim 24, Now suppose d > 0 is even.
Since we are assuming s and t are not connected in G nand d (x), both of G nand d−1 (x 0 ) and G nand d−1 (x 1 ) must not be connected, and so by induction, we have C s,t (G nand d−1 (x 0 )) = C s,t (G nand d−1 (x 1 )) = 2 (d−1)/2 = 2 d/2−1 , since d is even. Thus using Eq. (29) in Claim 24, Therefore, using Eq. (8), we have that the analysis of [4] for d-depth nand-trees with inputs in

Winning the NAND-tree Game
In this section, we describe a quantum algorithm that can be used to help a player make decisions while playing the nand-tree game. In particular, we consider the number of queries to x needed by Player A to make decisions throughout the course of the game in order to win with probability ≥ 2/3. (In this section, we focus on A-winnable trees, but the case of B-winnable trees is similar.) We first describe a naive strategy, which uses a quantum algorithm [21,23] that decides if a depth-d tree is winnable with bounded error in O(2 d/2 log d) queries. If Player A must decide to move to node v 0 or v 1 , she evaluates each subtree rooted at v 0 and v 1 , amplifying the success probability to Ω(1/d) by using O(log d) repetitions, and moves to one that evaluates to 1. Since Player A has O(d) decisions to make, this strategy succeeds with bounded error, and since evaluating a nand-tree of depth r costs O(2 r/2 ) quantum queries, the total query complexity is: This strategy does not use the fact that some subtrees may be easier to win than others. For example, if one choice leads to a subtree with all leaves labeled by 1, whereas the other subtree has all leaves labeled by 0, the player just needs to distinguish these two disparate cases. More generally, one of the subtrees might have a small positive witness size -i.e., it is very winnable -whereas the other has a large positive witness size -i.e., is not very winnable.
Our strategy will be to move to the subtree whose formula corresponds to a graph with smaller effective resistance, unless the two subtrees are very close in effective resistance, in which case it doesn't matter which one we choose. For a depth d game on instance x, we show if R s,t (G nand d (x)) is small and Player B plays randomly, this strategy does better than the naive strategy, on average.
We estimate the effective resistance of both subtrees of the current node using the witness size estimation algorithm of [17]. In particular, in Appendix D.2 we prove: Lemma 25 (Est Algorithm). Let φ be an and-or formula with constant fan-in l, ∨-depth d ∨ and ∧-depth d ∧ . Then the quantum query complexity of estimating R s,t (G φ (x)) (resp. Let Est(x) be the algorithm from Lemma 25 with ε = 1 3 , and φ = nand d , so l = 2, and both d ∨ and d ∧ are at most d/2 . While estimating the effective resistance of two subtrees, we only care about which of the subtrees has the smaller effective resistance, so we do not want to wait for both iterations of Est to terminate. Let p(d) be some polynomial function in d such that Est(x) always terminates after at most p(d) R s,t (G φ (x))2 d/4 queries, for all x ∈ {0, 1} 2 d . We define a subroutine, Select(x 0 , x 1 ), that takes two instances, In Appendix D.3, we prove the following lemma.
Using Lemma 26, we can prove the following (the inductive proof is in Appendix D.

A Analysis of the Span Program for st-Connectivity
In this section, we analyze the complexity of our span-program-based algorithms, proving Lemma 11, first stated in Section 3, which relates witness sizes of the span program P G,c to the effective resistance of graphs related to G. We need the concept of a circulation, which is like a flow but with no source and no sink.

Definition 28 (Circulation). A circulation on a graph G is a function θ :
The following easily verified observations will be useful in several of the remaining proofs in this section.
Claim 29. Let θ be a unit st-flow in some multigraph G. We can consider the corresponding vector |θ = (u,v,λ)∈ − → E (G) θ(u, v, λ)|u, v, λ . Then |θ can be written as a linear combination of vectors corresponding to self-avoiding st-paths and cycles that are edge-disjoint from these paths.
Let σ be a circulation on G. Then |σ can be written as a linear combination of cycles in G. Furthermore, |σ can be written as a linear combination of cycles such that each cycle goes around a face of G.
The next claim shows a direct correspondence between positive witnesses, and st-flows.

Claim 30. Fix a span program P G,c as in (6). Call |w ∈ H a positive witness in P G,c if A|w = τ (note that such a |w is not necessarily a positive witness for any particular input x). Then if θ is a unit st-flow in
is a positive witness in P G,c , and furthermore, if |w is a positive witness in P G,c , then Proof. The proof is a straightforward calculation. Let θ be a unit st-flow on G. Then Above we have used that θ(u, v, λ) = −θ(v, u, λ), and v,λ:(u,v,λ)∈ − → E (G) θ(u, v, λ) = 0 when u ∈ {s, t}, 1 when u = s, and −1 when u = t.
To prove the second half of the claim, let |w be such that A|w = τ , and define θ(u, v, λ) = c({u, v}, λ)( w|u, v, λ − w|v, u, λ ). We immediately see that θ(u, v, λ) = −θ(v, u, λ) for all (u, v, λ). Furthermore, we have: Thus, for all u ∈ V (G(x))\{s, t}, (u The next claim shows a direct correspondence between negative witnesses, and s t -flows. Claim 31. For a planar graph G, fix a span program P G,c as in (6). Call a linear function

) is a unit s t -flow on G , and furthermore, for every s t -flow θ on G there is a negative witness
. Proof. When we consider the edges of G as directed edges, we assign edge directions to the dual by orienting each dual edge π/2 radians counter-clockwise from the primal edge.
Note that without loss of generality, if ω is a negative witness, we can assume ω(s) = 1 and ω(t) = 0. This is because ωA and ωAΠ H(x) are invariant under affine transformations of ω.
We first show that if ω is a negative witness in P G,c , then θ : Next, every v ∈ V (G † ) corresponds to a face f v of G, and the edges coming out of v are dual to edges going clockwise around the face f v (see Figure 6). If (w 1 , w 2 , λ 1 ), . . . , (w k , w k+1 , λ k ), for w k+1 = w 1 , are the directed edges going clockwise around f v , then we have: Thus, θ is a circulation. Then, since θ (s , t , ∅) = 1, if we remove the flow on this edge, which recovers θ, we get a unit s t -flow on G .
Next we will show that if θ is a unit s t -flow on G , then there exists a negative witness ω in P G,c such that for all (u There is a one-to-one correspondance between vertices in V (G) = V (G) and faces in F (G † ), so we can define ω : . This edge is part of a clockwise cycle around one face in G † , call it f , and a counter clockwise cycle around one face in G † , call it g. Since these are the only two faces containing the edge (u , v , λ), we must have In particular, this means that ω(s) − ω(t) = θ ((s, t, ∅) † ) = θ (s , t , ∅) = 1, so ω is a negative witness, and for all (u, v, λ) |u, v, λ is a positive witness in P G,c , and since θ is supported on − → E (G(x)), |w ∈ H(x), and so |w is a positive witness for x in P G,c . Thus On the other hand, let |w be an optimal positive witness for x. By Claim 30, θ(u, v, λ) = c({u, v}, λ)( u, v, λ|w − v, u, λ|w ) is a unit st-flow on G, and since |w ∈ H(x), θ (u, v, λ) is only non-zero on − → E (G(x)), so θ is a unit st-flow on G(x). Thus, where the last inequality is by Cauchy-Schwarz. Thus, w + (x, P G,c ) = 1 2 R s,t (G(x)). Now we prove that w − (x, P G,c ) = 2R s ,t (G (x), c ). Let x ∈ {0, 1} E(G) be such that s and t are not connected in G(x). Fix an optimal negative witness ω for x. By Claim 31 the linear function θ : Since ω is a negative witness for x, we also have:

and so it is a unit s t -flow on G (x). Thus
For the other direction, let θ be an s t -flow in G (x) with minimal energy. By Claim 31, there is a negative witness ω such that θ ((u, v, λ) so ω is a negative witness for x in P G,c . Thus: completing the proof.

A.1 Time and Space Analysis of the Span Program Algorithm for st-Connectivity
In this section, we will give an upper bound on the time complexity of st-conn G in terms of the time complexity of implementing a step of a discrete-time quantum walk on G. At the end of this section, we discuss the space complexity of the algorithm. We first describe the algorithm that can be derived from a span program, following the conventions of [17]. Throughout this section, we will let Π S denote the orthogonal projector onto an inner product space S. For a span program P = (H, U, A, τ ), the corresponding algorithm performs phase estimation on the unitary (2Π H(x) − I)(2Π ker A − I) applied to initial state |w 0 = A + τ , where Π H(x) denotes the orthogonal projector onto H(x), and Π ker A denotes the orthogonal projector onto the kernel of A, and A + denotes the pseudo-inverse of A. To decide a function f on domain D, it is sufficient to perform phase estimation to precision O . In case of the st-connectivity span program P G,c in (6), it is a simple exercise to see that 2Π H(x) − I can be implemented in O(1) quantum operations, including 2 queries to x. The reflection 2Π ker A − I is independent of x, and so requires 0 queries to implement, however, it could still require a number of gates that grows quickly with the size of G. We will show that implementing 2Π ker A − I can be reduced to implementing a discrete-time quantum walk on G, a task which could be quite easy, depending on the structure of G (for example, in the case that G is a complete graph on n vertices, this can be done in O(log n) gates [4]).
For a multigraph G and weight function c, we define a quantum walk step on G to be a unitary U G,c that acts as follows for any u ∈ V (G): This theorem follows from Lemma 32, stated below, and Lemma 33, which deals with the construction of the algorithm's initial state.
Lemma 32. Let A be defined as in (6). Proof. This analysis follows [4] (see also [17]). Let Define spaces Z and Y as follows.
Define isometries whose column-spaces are Z and Y respectively: Now we note that for any ({u, v}, λ) ∈ E(G), we have the following: Thus, we can calculate: While AA † = 2L is twice the Laplacian of G, A A † is half the symmetric normalized Laplacian of G, L sym : We can define the discriminant of W by D(W ) = M † Z M Y = A, and let {cos θ j } j for θ j ∈ [0, π/2] enumerate its singular values. By [26], , and the remaining eigenvalues of W are {e ±2iθ j } j . Thus if δ is the smallest nonzero eigenvalue of L sym , then δ/2 is the smallest nonzero singular value of A. Let τ ∈ [0, π/2] be such that cos τ = δ/2. Then the smallest non-zero phase of −W is ±|π − 2τ |. Using the identity cos τ ≤ π 2 − τ for any τ ∈ [0, π/2], we have phase gap at least Thus, using phase estimation to precision Θ( √ δ), we can implement a reflection around the (−1)-eigenspace of W to constant precision. Let R W denote this reflection. We now argue Thus M Y maps ker A to the (−1)-eigenspace of W , and (ker A) ⊥ to its orthogonal complement.
It only remains to argue that each of M Y , 2Π Z − I and 2Π Y − I can be implemented in time complexity at most O(S G,c ).
We first show that we can implement the isometry M Y , or rather a unitary U Y that acts as |0 |0 |u, v, λ → M Y |u, v, λ = |y u,v,λ . First, use HX on the first qubit to perform the map: Conditioned on the value of the first register, copy either u or v into the second register to get: Thus, we can implement U Y in the time it takes to write down a vertex of G, O(log |V (G)|), which is at most O(S G,c ). Using the ability to implement U Y , we can implement 2Π where R Y is the reflection that acts as the identity on computational basis states of the form |0 |0 |u, v, λ , and reflects computational basis states without this form.
Next, we implement a unitary U Z that acts as |0 |u |0 → M Z |u = |z u . First, use the quantum walk step U G,c , which can be implemented in time S G,c , to perform: Conditioned on the bit in the first register, swap the third and fourth registers, to get: The total cost of implementing U Z is O(S G,c + log |V (G)|) = O(S G,c ). Thus, we can implement 2Π Z − I in O(S G,c ) quantum gates.
Lemma 33. Let A and τ be defined as in (6). Let S G,c be an upper bound on the complexity of implementing U G,c . Then the initial state of the algorithm, |w 0 |w 0 Proof. Without loss of generality, we can assume that G includes the edge ({s, t}, ∅) (we can simply not include it in any subgraph). Furthermore, we set c({s, t}, ∅) = 1/r, for some positive r to be specified later, so that A|s, t, ∅ = r −1/2 τ . This has no effect on other edges in G. Note that so |s, t, for some |w ⊥ 0 ∈ ker A. Thus, constant precision phase estimation on 2Π ker A − I maps |s, t, ∅ to Using quantum amplitude amplification [7], we can amplify the amplitude on the |0 |w 0 part of this arbitrarily close to 1 using a number of calls to 2Π ker A − I proportional to In fact, it is straightforward to show that for any |µ ∈ rowA, the vector |ν with smallest norm that satisfies A|ν = |µ , is A + |µ [17]. Using this fact along with Claim 30 and Definition 9, we have |w 0 2 = R s,t (G, c).
Finally, we note that the space required by the algorithm, in addition to whatever auxiliary space we need to implement U G,c , is O(max{log |E(G)|, log |V (G)|}). U Y and U G,c each act on a Hilbert space of dimension less than 4|V (G)| 2 |E(G)|, so can in principle be implemented on O(max{log |E(G)|, log |V (G)|} + log(1/δ)) qubits, where the log(1/δ) term accounts for the phase register in the O( √ δ)-precision phase estimation. However, a time-efficient implementation of U G,c may also make use of some number S G,c of auxiliary qubits. We use these unitaries to perform phase estimation on (2Π Thus we need O(log(|E(G)|) qubits to store the output of the phase estimation. Putting everything together gives the claimed space complexity.

B Formula Evaluation and st-Connectivity
In this section, we prove the correspondence between evaluating the formula φ, and solving st-connectivity on the graph G φ . We first give a formal definition of G φ . , s 2 , . . . , s l , t} and, letting s 1 = s and s l+1 = t, define: In order to prove Lemma 14, we will first prove Lemma 35: Lemma 35. For an and-or formula φ on {0, 1} N , define φ to be the formula obtained by replacing ∨-nodes with ∧-nodes and ∧-nodes with ∨-nodes in φ. Then for all x ∈ {0, 1} N , ifx denotes the bitwise complement of x, then φ (x) = ¬φ(x). Furthermore up to an isomorphism that maps s to s , t to t , and an edge labeled by any label λ to an edge labeled by λ, Proof. The first part of the proof is by induction. Suppose φ has depth 0, so φ = x i for some variable Then by the induction hypothesis, where the second to last equality is de Morgan's law. The case φ = φ 1 ∨ · · · ∨ φ l is similar. We will now prove that G † φ = G φ , and furthermore, dual edges have the same label, by induction on the depth of φ, from which the result follows immediately.
If φ = x i is a depth-0 formula, then φ = x i . In that case, G φ is just an edge from s to t, labeled by x i , and G φ is just an edge from s to t labeled For the inductive step, to show that G φ and G φ are dual, and therefore G φ = G φ . It suffices to exhibit a bijection ζ : if and only if the faces ζ(u) and ζ(v) are separated by an edge in E(G φ ) with the label x j . We first consider the case that φ = φ 1 ∧ · · · ∧ φ l , so φ = φ 1 ∨ · · · ∨ φ l . Then, G φ consists of the graphs G φ 1 , . . . , G φ l , chained together in series as in Figure 7, with an additional edge from s to t, so the faces of G φ are exactly all the interior faces of each G φ i , as well as the two faces on either side of the st-edge ({s, t}, ∅), which we will denote by f s and f t . That is, adding an i to the label of each internal face of G φ i : where we will use the labels s and t in anticipation of the isometry between G φ and G φ . By the induction hypothesis, for each i ∈ [l], there exists a bijection ζ i : and ζ i (v) are faces separated by an edge with the label x j . We define ζ by ζ(i, v) = (i, ζ i (v)) for all i ∈ [l] and v ∈ V (G φ i ) \ {s, t}, ζ(s ) = f s , and ζ(t ) = f t . By the induction hypothesis, we can see that for any edge ({u, v}, x j ) ∈ E(G φ ) \ ({s , t }, ∅), ζ(u) and ζ(v) are separated by an edge labeled x j . This is because this edge is in one of the G φ i , and so it has a dual edge in G φ i , by the induction hypothesis (see Figure 7). The only other edge in G φ is the edge ({s , t }, ∅), and ζ(s ) and ζ(t ) are exactly those faces on either side of ({s, t}, ∅) in G φ , completing the proof that G † φ = G φ . If φ = φ 1 ∨ · · · ∨ φ l , then φ = φ 1 ∧ · · · ∧ φ l , and a nearly identical proof shows that Now that we have shown an isomorphism between G φ and G φ , note that G φ (x) is the subgraph of G φ that includes all those edges where x e = 0. On the other hand G φ (x) is the graph that includes all those edges where x e = 1. Taking the bitwise negation of x, we find that G φ (x) = G φ (x).
Lemma 35 allows us to prove Claim 17: Proof. If φ = φ 1 ∨ · · · ∨ φ l , then φ = φ 1 ∧ · · · ∧ φ l . From Lemma 35, G φ (x) = G φ (x), which using Definition 34 is composed of {G φ i (x)} l i=1 in series. But using the isomorphism of Lemma 35 again, this is just {G φ i (x)} l i=1 composed in series. The proof for φ = φ 1 ∧ · · · ∧ φ l is similar. Proof. We will prove the statement by induction on the depth of φ. If φ = x j has depth 0, then G φ is just an edge ({s, t}, x j ), and G φ is just an edge ({s , t }, x j ). Thus s and t are connected in G φ (x) if and only if x j = 1, in which case φ evaluates to 1, and s and t are connected in G φ if and only if x j = 0, in which case φ evaluates to 0.
If φ = φ 1 ∧ · · · ∧ φ l , then G φ consists of G φ 1 , . . . , G φ l connected in series from s to t, and moreover, G φ (x) consists of G φ 1 (x), . . . , G φ l (x) connected in series from s to t. Thus an st-path in G φ (x) consists of an st-path in G φ 1 (x), followed by an st-path in G φ 2 (x), etc., up to an st-path in G φ l (x). Thus, s and t are connected in G φ (x) if and only if s and t are connected in each G φ 1 (x), . . . , G φ l (x), which happens if and only if φ 1 (x) ∧ · · · ∧ φ l (x) = 1.
On the other hand, by Claim 17, G φ consists of G φ 1 , . . . , G φ l connected in parallel between s and t . So any s t -path in G φ (x) is an s t -path in one of the G φ i (x), which is equivalent to an st-path in one of G φ i (x). Thus, by Lemma 35 s and t are connected in G φ (x) if and only if φ 1 (x) ∨ · · · ∨ φ l (x) = ¬φ 1 (x) ∨ · · · ∨ ¬φ l (x) = 1. By de Morgan's law is true if and only if φ(x) = φ 1 (x) ∧ · · · ∧ φ l (x) = 0. The case when φ = φ 1 ∨ · · · ∨ φ l is similar.

C Classical Lower Bound on Class of Promise Boolean Formulas
In this section, we consider the query complexity of classical algorithms for and-or formulas, proving Theorem 19. To do this, we use a recent tool from Ben-David and Kothari [5]. They show that the bounded-error classical randomized query complexity of a function f , denoted R(f ), satisfies R(f ) = Ω(RS(f )), where RS(f ) is the randomized sabotage complexity, defined presently. Furthermore, they prove that for a composed function f • g, We say Finally, the randomized sabotage complexity is given by Proof. For x ∈ [D N,h ] sab to be consistent with y, y ∈ D N,h such that or(y) = or(y ), we must have that x ∈ {0, * } N ∪ {0, †} N . Furthermore, the number of * 's or †'s in x must be at least h. Thus the sabotaged problem reduces to finding at least one marked item out of n, promised there are at least h marked items. The randomized bounded-error query complexity of this task is Ω(N/h), and so by Theorem 3 in [5], The proof for and is similar.
The next corollary follows immediately from Lemma 36 and the composition property of sabotage complexity: Now that we understand the query complexity of symmetric composed and-or formulas, we can look at how this compares to the quantum query complexity of evaluating such functions. We now prove the following lemma.
Proof. The proof follows by induction on the number of compositions. First suppose that φ = or| D N,h . Then G φ consists of N edges connected in parallel between s and t, and G φ consists of N edges connected in series. The only input x such that φ(x) = 0 is the all zeros input. Therefore max x∈D:φ(x)=0 R s,t (G φ (x)) = N. Now notice (using Claim 5) that R s,t (G φ (x)) = 1/|x|. However because of the domain of A similar analysis holds for the base case φ = and| D N,h . Now for the inductive step, Let D ξ be the domain of ξ and let x j ∈ D ξ denote the bits of x that are input to the j th copy of ξ. Suppose first that φ 1 = or| D N 1 ,h 1 . G φ is formed by taking the N 1 graphs G ξ and connecting them in series. The only way φ(x) = 0 is if the input x j ∈ D ξ to each of the ξ functions satisfies ξ(x j ) = 0, so by Claim 5 On the other hand, G φ is formed by taking N 1 graphs G ξ and connecting them in parallel. Using Claim 5, if x j ∈ D ξ is the input to j th function ξ, we have Thus larger values for R s,t (G φ (x)) come from cases where R s,t (G ξ (x j )) are large. Now which occurs when ξ(y) = 0. Because of the promise on the domain of φ 1 , there must be at least h 1 of the N 1 subformulas ξ that evaluate to 1. On each of those subformulas, we want to have an input x j ∈ D ξ that maximizes the effective resistance of that subformula. Therefore, we have Therefore, using the inductive assumption, The inductive step for φ 1 = and| D N,h is similar.

D.1 Relationship Between Faults and Effective Resistance
In this section, we prove Lemma 22: Proof. We will give a proof for F A (x); the case of F B (x) is similar. First, R s,t (G nand d (x)) = ∞ if and only if s and t are not connected in G nand d (x), which, by Lemma 14, occurs if and only if x is a 0-instance. This means exactly that x is not A-winnable, which, by Eq. (28), holds if and only if F A (x) = ∞. Thus, suppose this is not the case, so F A (x) < ∞.
The rest of the proof is by induction. We need to look at both odd and even cases. For the case of d = 0, the only A-winnable input in {0, 1} 2 0 is x = 1. In that case, using Eq. (28), F A (x) = 1, since there are no decision nodes for Player A, and since G nand 0 (x) is just a single edge from s to t, R s,t (G nand 0 (x)) = 1.
Let x ∈ {0, 1} 2 d be any A-winnable input with d > 1. We let x 0 be the first 2 d−1 bits of x and x 1 be the last 2 d−1 bits of x, so x = (x 0 , x 1 ).
We first consider odd d > 1. Using the definition of G φ from Section 4, and the fact that for d odd, the root node is an ∧-node, we see that G nand d (x) consists of G nand d−1 (x 0 ) and G nand d−1 (x 1 ) connected in series, so by Claim 5 Now the root can not be a fault, because it is a decision node for Player B, but we know the tree is A-winnable, so no choice Player B makes would allow her to win the game. Therefore, both subtrees connected to the root node must be A-winnable. Using Eq. (28) we have Combining Eqs. (77) and (78) and the inductive assumption for even depth trees, we have for odd d, Now we consider the case that d is even, so the root is a decision node for Player A. Consequently, the root node is a ∨-node, so by Claim 5 Suppose the root is a fault. Without loss of generality, let's assume the subtree with input x 0 is not A-winnable. Then R s,t (G nand d−1 (x 0 )) = ∞ so Eq. (80) becomes Using the inductive assumption for odd depth trees, Eq. (28), and the fact that the root is a fault, we have If the root is not a fault, then both R s,t (G nand d−1 (x 0 )) and R s,t (G nand d−1 (x 1 )) are finite, so from (80), and using the inductive assumption, we have A similar analysis for F B (x) completes the proof.

D.2 Estimating Effective Resistances
In this section, we will prove Lemma 25, which bounds the query complexity of estimating the effective resistance of a graph corresponding to a Boolean formula. In [17], Ito and Jeffery describe a quantum query algorithm to estimate the positive or negative witness size of a span program given access to O x . We will describe how to use this algorithm to estimate the effective resistance of graphs G φ (x) or G φ (x).
Ref. [17] define the approximate positive and negative witness sizes,w + (x, P ) and w − (x, P ). These are similar to the positive and negative witness sizes, but with the conditions |w ∈ H(x) and ωAΠ H(x) = 0 relaxed.
If x ∈ P 1 , then e + (x) = 0. In that case, an approximate positive witness for x is a positive witness, andw + (x) = w + (x). For negative inputs, the positive error is larger than 0. We can define a similar notion of approximate negative witnesses: Definition 40 (Approximate Negative Witness). For any span program P on {0, 1} N and x ∈ {0, 1} N , we define the negative error of x in P as: : ω ∈ L(U, R), ωτ = 1 .
Any ω such that ωAΠ H(x) 2 = e − (x, P ) is called an approximate negative witness for x in P . We define the approximate negative witness size as If x ∈ P 0 , then e − (x) = 0. In that case, an approximate negative witness for x is a negative witness, andw − (x) = w − (x). For positive inputs, the negative error is larger than 0.
There exists a quantum algorithm that estimates f to relative error ε and that uses Similarly, let P be a span program such that for all x ∈ X, f (x) = w − (x, P ) and define W + = W + (P, f ) = max x∈Xw+ (x, P ). Then there exists a quantum algorithm that estimates f to accuracy ε and that uses O 1 ε 3/2 w − (x) W + queries.
We will apply Theorem 41 to the span program P G,c defined in Eq. (6), with G = G φ . Throughout this section, we will always set the weight function c to take value one on all edges of the graph G. In this, case, to simplify notation, we will denote the span program P G,c as P G . To apply Theorem 41, we need bounds on W + (P G φ ) and W − (P G φ ). We will prove: Lemma 42. For any formula φ, its ∧-depth is the largest number of ∧-labeled nodes on any path from the root to a leaf. Let φ be any and-or formula with maximum fan-in l, and G φ consists of G φ 1 , . . . , G φ l , connected in parallel. Any self-avoiding st-path must include exactly one edge adjacent to s and one edge adjacent to t. However, any path that includes an edge from G φ i and G φ j for i = j must go through s or t, so it must have more than one edge adjacent to s, or more than one edge adjacent to t, so such a path can never be a self-avoiding st-path. Thus, any self-avoiding st-path must be contained completely in one of the G φ i . The longest such path is thus the longest self-avoiding st-path in any of the G φ i , which, by induction, is max i l d∧(φ i ) = l d∧ .

Now we can prove Lemma 42:
Proof of Lemma 42. To begin, we will prove the upper bound on W + . Suppose |w is an optimal approximate positive witness for x. By Claim 30, if |w is an approximate positive witness, then since A|w = τ , and c has unit value on all edges of G, θ(u, v, λ) = u, v, λ|w − v, u, λ|w is a unit flow on G. Since |w is an approximate positive witness for x, it has minimal error for x, so it minimizes Π H(x) ⊥ |w 2 , and since it is optimal, it minimizes |w 2 over all approximate positive witnesses. Define |θ = (u,v,λ)∈ − → E (G) θ(u, v, λ)|u, v, λ , so we know that 1 2 |θ also maps to τ under A, so is also a positive witness in P G φ .Then we have where the last inequality uses Cauchy-Schwarz, so 1 2 |θ is also an approximate positive witness for x. Similarly, so 1 2 |θ is optimal. By Claim 29, we can consider a decomposition of |θ into self-avoiding paths p i and cycles c i such that all cycles are disjoint from all paths, |θ = r i=1 α i |p i + r i=1 β i |c i , where for each i, where v (i) It's easy to see (in the case of unit edge weights) that A|c i = 0 for all i, so Let |θ = r i=1 α i |p i . Then since c i and p j have no common edges, we have c i |p j = 0, and also c i |(I − Π H(x) )|p j = 0, so the error of 1 2 |θ is 1 so 1 2 |θ also has minimal error. Furthermore, |θ 2 ≤ |θ 2 , with equality if and only if there are no cycles in the decomposition. By the optimality of 1 2 |θ as an approximate positive witness for x, we can conclude that |θ = r i=1 α i |p i , and since A|p i = 2τ for all i, and A|θ = 2τ , we have r i=1 α i = 1. Then Since the longest self-avoiding st-path in G φ has length at most l d∧ , and each L i is the length of a self-avoiding path in G φ , we havew + (x, P G φ ) ≤ 1 4 2l d∧ = 1 2 l d∧ . Thus W + (P G φ ) ≤ 1 2 l d∧ . Next we prove the bound on W − . A min-error approximate negative witness for x in 2 is minimized. By Claim 31, since ωτ = 1, the function θ : is a unit s t -flow on G φ = G φ , and the witness complexity is where we create |θ from θ in the usual way. By an argument similar to the previous argument, if ω is an optimal approximate negative witness for x, then |θ 2 is upper bounded by twice the length of the longest self-avoiding s t -path in G φ = G φ . By Lemma 35 and Claim 43, this is upper bounded by 2l

D.3 Winning the NAND-tree
We now analyze the algorithm for winning the game associated with a nand-tree, proving Lemma 26 and Theorem 27. Select(x 0 , x 1 ) terminates after O N 1/4 √ w min queries to (x 0 , x 1 ) and outputs b such that R s,t (G nand d (x b )) ≤ 2R s,t (G nand d (xb)) with bounded error.
Proof. Since at least one of x 0 and x 1 is a 1-instance, using the description of Select in Section 5.2, at least one of the programs will terminate. Suppose without loss of generality that Est(x 0 ) is the first to terminate, outputting w 0 . Then there are two possibilities: Est(x 1 ) does not terminate after p(d) √ w 0 N 1/4 steps, in which case, R s,t (G nand d (x 0 )) ≤ 2R s,t (G nand d (x 1 )), and Select outputs 0; or Est(x 1 ) outputs w 1 before p(d) √ w 0 N 1/4 steps have passed and Select outputs b such that w b ≤ wb. We will prove the first case by contradiction. Suppose 2R s,t (G nand d (x 1 )) < R s,t (G nand d (x 0 )).
Thus, R s,t (G nand d (x 0 )) ≤ 2R s,t (G nand d (x 1 )), so outputting 0 is correct. Furthermore, since we terminate after p(d) √ w 0 N 1/4 = O( R s,t (G nand d (x 0 ))N 1/4 ) steps, and since R s,t (G nand d (x 0 )) = O(R s,t (G nand d (x 1 ))), the running time is at most O N 1/4 √ w min . We now consider the second case, in which both programs output estimates w 0 and w 1 , such that |w b − R s,t (G nand d (x b ))| ≤ εR s,t (G nand d (x b )) for b = 0, 1. Suppose w b ≤ wb. We then have Thus R s,t (G nand d (x b )) ≤ 2R s,t (G nand d (xb)), as required. Furthermore, the running time of the algorithm is bounded by the running time of Est(x 1 ), the second to terminate. We know that Est(x 1 ) has running time at most O R s,t (G nand d (x 1 ))N 1/4 steps, and by assumption, Est(x 1 ) terminated after less than p(d) steps, so the total running time is at most O N 1/4 √ w min . Proof. First note that Player A must make O(d) choices over the course of the game. We amplify Player A's probability of success by repeating Select at each decision node O(log d) times and taking the majority. Then the probability that Player A chooses the wrong direction at any node is O(1/d), and we ensure that her probability of choosing the wrong direction over the course of the algorithm is < 1/3. From here on, we analyze the error free case. Let p(d) be a non-decreasing polynomial function in d such that Select, on inputs x 0 , x 1 ∈ {0, 1} 2 d , terminates in at most p(d)2 d/4 min{R s,t (G nand d (x 0 )), R s,t (G nand d (x 1 ))} queries. Then we will prove that for trees of odd depth d, the expected number of queries by Player A over the course of the game is at most p(d)2 d/4+5 R s,t (G nand d (x)), while for even depth trees, it is at most p(d)2 d/4+11/2 R s,t (G nand d (x)), thus proving the main result.
We prove the result by induction on the depth of the tree. For depth zero trees, there are no decisions, N = R s,t G nand 0 (x) = 1, so the result holds.
For the inductive case, we treat odd and even depth cases separately. First consider an instance of nand d with d > 0, d odd. Thus nand d (x) = nand d−1 (x 0 ) ∧ nand d−1 (x 1 ), where x = (x 0 , x 1 ). Because the root is at odd distance from the leaves, the root is a decision node for Player B. Because we are in an A-winnable tree, no matter which choice Player B makes, we will end up at an A-winnable subtree of depth d − 1, so the inductive assumption holds for those trees. That is, the expected number of queries for Player A must make to win the subtree with input x b (for b ∈ {0, 1}) averaged over Player B's choices is at most We are assuming that Player B chooses left and right with equal probability. Thus, the expected number of queries that Player A must make over Player B's choices throughout the game is at most ) by Jensen's ineq., = p(d − 1)2 (d−1)/4+11/2 1 2 R s,t (G nand d (x)) by Claim 5, proving the case for odd d. Now consider an instance of nand d with d > 0, d even. Thus nand d (x) = nand d−1 (x 0 )∨ nand d−1 (x 1 ), where x = (x 0 , x 1 ). Because the root is at even distance from the leaves, the root is a decision node for Player A. Player A runs Select(x 0 , x 1 ), which returns b ∈ {0, 1} such that (by Lemma 26) which requires at most queries.
After making the choice to move to the subtree with input x b , by the inductive assumption, the expected number of queries that Player A need to make throughout the rest of the game (averaged over Player B's choices) is There are two cases to consider. If R s,t (G nand d−1 (x b )) ≤ R s,t (G nand d−1 (xb)), then combining Eq. (104) and Eq. (105), we have that the total number of queries averaged over Player B's choices is where we've used R s,t (G nand d (x)) = R s,t (G nand d−1 (x 0 )) −1 + R s,t (G nand d−1 (x 1 )) −1 −1 from Claim 5 and the fact that R s,t (G nand d−1 (x b )) ≤ R s,t (G nand d−1 (xb)) to bound the value R s,t (G nand d−1 (x b )) by 2R s,t (G nand d (x)). This proves the even induction step for this case.
The other case is if R s,t (G nand d−1 (x b )) > R s,t (G nand d−1 (xb)). In that case, again using the fact that R s,t (G nand d (x)) = R s,t (G nand d−1 (x 0 )) −1 + R s,t (G nand d−1 (x 1 )) This proves the induction step for the other case.