DOKK Library

Span Programs and Quantum Space Complexity

Authors Stacey Jeffery,

License CC-BY-3.0

Plaintext
                          T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49
                                       www.theoryofcomputing.org




       Span Programs and Quantum Space
                  Complexity
                                                   Stacey Jefferyโˆ—
                 Received October 7, 2020; Revised November 3, 2021; Published May 24, 2022




       Abstract. While quantum computers hold the promise of significant computational
       speedups, the limited size of early quantum machines motivates the study of
       space-bounded quantum computation. We relate the quantum space complexity of
       computing a function ๐‘“ with one-sided error to the logarithm of its span program size
       over the reals, a classical quantity that is well-studied in attempts to prove formula
       size lower bounds.
           In the more natural bounded error model, we show that the amount of space needed
       for a unitary quantum algorithm (i. e., an algorithm that makes no measurements
       until the final step) to compute ๐‘“ with bounded (two-sided) error is at least the
       logarithm of its approximate span program size. Approximate span programs have been
       introduced in the field of quantum algorithms but not studied classically. However,
       the approximate span program size of a function is a natural generalization of its
       span program size.

     A conference version of this paper appeared in the Proceedings of the 11th Innovations in Theoretical Computer
Science Conference, 2020 [17].
   โˆ— Supported by an NWO WISE Fellowship, an NWO Veni Innovational Research Grant under project number
639.021.752, and QuantERA project QuantAlgo 680-91-03. SJ is a CIFAR Fellow in the Quantum Information Science
Program.


ACM Classification: F.1.1, F.1.3
AMS Classification: 81P68
Key words and phrases: quantum computing, quantum space complexity, span programs


ยฉ 2022 Stacey Jeffery
c b Licensed under a Creative Commons Attribution License (CC-BY)                      DOI: 10.4086/toc.2022.v018.a011
                                                S TACEY J EFFERY

          While no non-trivial lower bound is known on the span program size (or
      approximate span program size) of any explicit function, a number of lower bounds
      are known on the monotone span program size. We show that the approximate
      monotone span program size of ๐‘“ is a lower bound on the space needed by quantum
      algorithms of a particular form, called monotone phase estimation algorithms, to compute
      ๐‘“ . We then give the first non-trivial lower bound on the approximate monotone span
      program size of an explicit function.


1    Introduction
While quantum computers hold the promise of significant speedups for a number of problems,
building them is a serious technological challenge, and it is expected that early quantum
computers will have quantum memories of very limited size. This motivates the theoretical
question: what problems could we solve faster on a quantum computer with limited space?
Or similarly, what is the minimum number of qubits needed to solve a given problem (and
hopefully still get a speedup)?
     We take a modest step towards answering such questions, by relating the space complexity
of a function ๐‘“ to its span program size (see Definition 3.3), which is a measure that has received
significant attention in theoretical computer science over the past few decades. Span programs
are a model of computation introduced by Karchmer and Wigderson [20] in an entirely classical
setting; they defined the span program size of a function in order to lower bound the size of
counting branching programs. Some time later, Reichardt and ล palek [28] related span programs
to quantum algorithms, and introduced the new measure of span program complexity (see
Definition 3.4). The importance of span programs in quantum algorithms stems from the ability
to compile any span program for a function ๐‘“ into a bounded error quantum algorithm for ๐‘“
[27]. In particular, there is a tight correspondence between the span program complexity of ๐‘“ ,
and its quantum query complexityโ€”a rather surprising and beautiful connection for a model
originally introduced outside the realm of quantum computing. In contrast, the classical notion
of span program size had received no attention in the quantum computing literature before now.
     Ref. [15] defined the notion of an approximate span program for a function ๐‘“ , and showed
that even an approximate span program for ๐‘“ can be compiled into a bounded error quantum
algorithm for ๐‘“ . In this paper, we further relax the definition of an approximate span program
for ๐‘“ , making analysis of such algorithms significantly easier (see Definition 3.6).
     Let S๐‘ˆ ( ๐‘“ ) denote the bounded error unitary space complexity of ๐‘“ , or the minimum space needed
by a unitary quantum algorithmโ€”i. e., an algorithm that makes no measurements until the final
stepโ€”that computes ๐‘“ with bounded error (see Definition 2.3). In [10] and [12], independently,
it was shown that S๐‘ˆ ( ๐‘“ ) = S( ๐‘“ ) (up to constants), where S( ๐‘“ ) denotes the bounded error space
complexity of ๐‘“ , without the restriction to algorithms that are unitary. Our results are proven for
S๐‘ˆ ( ๐‘“ ), but the results of [10, 12] imply that they also apply to S( ๐‘“ ). A similar statement is not
known for the one-sided error unitary quantum space complexity, S๐‘ˆ          1
                                                                              ( ๐‘“ ), though we suspect that
it also holds, and a proof of this would strengthen our results about S๐‘ˆ        1
                                                                                   ( ๐‘“ ) to also hold for S1 ( ๐‘“ ).
                                ๐‘›
     For a function ๐‘“ : {0, 1} โ†’ {0, 1}, we can assume that the input is accessed by queries, so

                         T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                   2
                            S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

that we do not need to store the full ๐‘›-bit input in working memory, but we need at least log ๐‘›
bits of memory to store an index into the input. Thus, a lower bound of ๐œ”(log ๐‘›) on S( ๐‘“ ) for
some ๐‘“ would be considered non-trivial.
    Letting SP( ๐‘“ ) denote the minimum size of a span program deciding ๐‘“ , and SP    f ( ๐‘“ ) the
minimum size of a span program approximating ๐‘“ (see Definition 3.7), we have the following
(see Theorem 4.1):

Theorem 1.1 (Informal). For any Boolean function ๐‘“ , if S( ๐‘“ ) denotes its bounded error quantum space
                f ( ๐‘“ ) its approximate span program size, then
complexity, and SP

                                                S( ๐‘“ ) โ‰ฅ log SP
                                                             f ( ๐‘“ ).

Similarly, if S๐‘ˆ
               1
                 ( ๐‘“ ) denotes its one-sided error unitary space complexity, and SP( ๐‘“ ) its span program size,
then
                                                1
                                               S๐‘ˆ ( ๐‘“ ) โ‰ฅ log SP( ๐‘“ ).

    In the case of bounded (two-sided) error, this lower bound is tight in the following sense
(corollary of Theorem 3.1 and 3.2):

Theorem 1.2 (Informal). The class of languages decidable in bounded error by a quantum algorithm
with space ๐‘‚(๐‘†) and 2๐‘‚(๐‘†) queries1 is equal to the class of languages approximated by a span program of
size and complexity 2๐‘‚(๐‘†) .

     The relationship between span program size and quantum space complexity is rather natural,
as the span program size of ๐‘“ is known to lower bound the minimum size of a symmetric
branching program for ๐‘“ , and the logarithm of the branching program size of a function ๐‘“
characterizes its classical deterministic space complexity.
     The inequality S๐‘ˆ  1
                          ( ๐‘“ ) โ‰ฅ log SP( ๐‘“ ) in Theorem 1.1 follows from a construction of [27] for
converting a one-sided error quantum algorithm for ๐‘“ into a span program for ๐‘“ . We adapt this
construction to show how to convert a bounded (two-sided) error unitary quantum algorithm
for ๐‘“ with query complexity ๐‘‡ and space complexity ๐‘† โ‰ฅ log ๐‘‡ into an approximate span
program for ๐‘“ with complexity ฮ˜(๐‘‡) and size 2ฮ˜(๐‘†) , proving S๐‘ˆ ( ๐‘“ ) โ‰ฅ ฮฉ(log SP      f ( ๐‘“ )), and thus
S( ๐‘“ ) โ‰ฅ ฮฉ(log SP( ๐‘“ )). The connection between S( ๐‘“ ) and log SP( ๐‘“ ) is tight up to an additive term
                f                                                 f
of the logarithm of the minimum complexity of any span program for ๐‘“ with optimal size,
yielding Theorem 1.2. This follows from the fact that an approximate span program can be
compiled into a quantum algorithm in a way that similarly preserves the correspondence between
space complexity and (logarithm of) span program size, as well as the correspondence between
query complexity and span program complexity (see Theorem 3.1). While the preservation of
   1Depending on the precise model of computation, it is without loss of generality to assume that the space is at
least logarithmic in the number of queries. In our model of unitary quantum algorithms (see Section 2), this is a
reasonable assumption since we would need to use a counter of size at least logarithmic in the query complexity to
know which unitary to apply. In the case of a quantum Turing machine that halts absolutely, if there is ever a pair of
time steps ๐‘ก โ‰  ๐‘ก 0 such that the state of the machine at step ๐‘ก and the state at step ๐‘ก 0 are non-orthogonal, then some
(exponentially decreasing) branch of the computation will run forever, which is a contradiction.


                         T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                       3
                                                 S TACEY J EFFERY

the correspondence between query complexity and span program complexity (in both directions)
is not necessary for our results, it may be useful in future work for studying lower bounds on
time and space simultaneously.
    The significance of Theorem 1.1 is that span program size has received extensive attention in
theoretical computer science. Using results from [5], the connection in Theorem 1.1 immediately
implies the following (Theorem 4.2):

Theorem 1.3. For almost all Boolean functions ๐‘“ on ๐‘› bits, S๐‘ˆ
                                                            1
                                                              ( ๐‘“ ) = ฮฉ(๐‘›).

    If we make a uniformity assumption that the quantum space complexity of an algorithm is at
least the logarithm of its time complexity, then Theorem 1.3 would follow from a lower bound of
ฮฉ(2๐‘› ) on the quantum time complexity of almost all ๐‘›-bit Boolean functions. Notwithstanding,
the proof via span program size is evidence of the power of the technique.
    In the pursuit of lower bounds on span program size of explicit functions, several nice
expressions lower bounding SP( ๐‘“ ) have been derived. By adapting one such lower bound on
SP( ๐‘“ ) to SP
           f ( ๐‘“ ), we get the following (see Lemma 4.6):

Theorem 1.4 (Informal). For any Boolean function ๐‘“ , and partial matrix2 ๐‘€ โˆˆ (โ„ โˆช {โ˜…}) ๐‘“
                                                                                           โˆ’1 (0)ร— ๐‘“ โˆ’1 (1)


with k๐‘€ k โˆž โ‰ค 1:                                                   !!
                                                 1
                                                   -rank(๐‘€)
                          S( ๐‘“ ) โ‰ฅ ฮฉ log         2
                                                                      ,
                                           max๐‘–โˆˆ[๐‘›] rank(๐‘€ โ—ฆ ฮ”๐‘– )

where โ—ฆ denotes the entrywise product, and ฮ”๐‘– [๐‘ฅ, ๐‘ฆ] = 1 if ๐‘ฅ ๐‘– โ‰  ๐‘ฆ ๐‘– and 0 else.

    Above, 12 -rank denotes the approximate rank, or the minimum rank of any matrix ๐‘€        e such
that |๐‘€[๐‘ฅ, ๐‘ฆ] โˆ’ ๐‘€[๐‘ฅ,
                  e ๐‘ฆ]| โ‰ค for each ๐‘ฅ, ๐‘ฆ such that ๐‘€[๐‘ฅ, ๐‘ฆ] โ‰  โ˜…. If we replace -rank(๐‘€) with
                              1
                              2
                                                                                     1
                                                                                     2
rank(๐‘€), we get the logarithm of an expression called the rank measure, introduced by Razborov
[25]. The rank measure was shown by Gร l to be a lower bound on span program size, SP [11],
and thus, our results imply that the log of the rank measure is a lower bound on S๐‘ˆ          1
                                                                                               . It is
straightforward to extend this proof to the approximate case to get Theorem 1.4.
    Theorem 1.4 seems to give some hope of proving a non-trivialโ€”that is, ๐œ”(log ๐‘›)โ€”lower
bound on the quantum space complexity of some explicit ๐‘“ , by exhibiting a matrix ๐‘€ for which
the (approximate) rank measure is 2๐œ”(log ๐‘›) . In [25], Razborov showed that the rank measure is a
lower bound on the Boolean formula size of ๐‘“ , motivating significant attempts to prove lower
bounds on the rank measure of explicit functions. The bad news is, circuit lower bounds have
been described as โ€œComplexity theoryโ€™s Waterlooโ€ [4]. Despite significant effort, no non-trivial
lower bound on span program size for any ๐‘“ is known.
    Due to the difficulty of proving explicit lower bounds on span program size, earlier work has
considered the easier problem of lower bounding monotone span program size, mSP( ๐‘“ ). For a
monotone function ๐‘“ , the monotone span program size of ๐‘“ , mSP( ๐‘“ ) is the minimum size of any
monotone span program for ๐‘“ (see Definition 5.1). We can similarly define the approximate monotone
span program size of ๐‘“ , mSP
                           f ( ๐‘“ ) (see Definition 5.1). Although log mSP
                                                                       f ( ๐‘“ ) is not a lower bound

   2Note that ๐‘€ depends on ๐‘“ in that it is indexed by the 0- and 1-inputs of ๐‘“ .


                         T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                           4
                        S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

on S( ๐‘“ ), even for monotone ๐‘“ , it is a lower bound on the space complexity of any algorithm
obtained by compiling a monotone span program. We show that such algorithms are equivalent
to a more natural class of algorithms called monotone phase estimation algorithms. Informally, a
phase estimation algorithm is an algorithm that works by performing phase estimation of some
unitary that makes one query to the input, and estimating the amplitude on a 0 in the phase
register (see Definition 5.12). Any quantum algorithm can be put into this form in a way that
preserves its space, query, and even time complexity. A monotone phase estimation algorithm
is a phase estimation algorithm where, loosely speaking, adding 0s to the input can only make
the algorithm more likely to reject (see Definition 5.13). This includes, for example, the phase
estimation variant of Groverโ€™s algorithm. We can then prove the following (see Theorem 5.14):

Theorem 1.5 (Informal). For any Boolean function ๐‘“ , any bounded error monotone phase estimation
algorithm for ๐‘“ has space complexity at least log mSP f ( ๐‘“ ), and any one-sided error monotone phase
estimation algorithm for ๐‘“ has space complexity at least log mSP( ๐‘“ ).

    Fortunately, non-trivial lower bounds for the monotone span program complexity are
known for explicit functions. In Ref. [5], Babai, Gร l and Wigderson showed a lower bound
of mSP( ๐‘“ ) โ‰ฅ 2ฮฉ(log (๐‘›)/log log(๐‘›)) for some explicit function ๐‘“ , which was later improved to
                      2

                                                                                                ๐œ–
mSP( ๐‘“ ) โ‰ฅ 2ฮฉ(log (๐‘›)) by Gร l [11]. In Ref. [29], a function ๐‘“ was exhibited with mSP( ๐‘“ ) โ‰ฅ 2๐‘›
                  2


for some constant ๐œ– โˆˆ (0, 1), and in the strongest known result, Pitassi and Robere exhibited a
function ๐‘“ with mSP( ๐‘“ ) โ‰ฅ 2ฮฉ(๐‘›) [24]. Combined with our results, each of these implies a lower
bound on the space complexity of one-sided error monotone phase estimation algorithms. For
example, the result of [24] implies a lower bound of ฮฉ(๐‘›) on the space complexity of one-sided
error monotone phase estimation algorithms for a certain satisfiability problem ๐‘“ . This lower
bound, and also the one in [29], are proven by choosing ๐‘“ based on a constraint satisfaction
problem with high refutation width, which is a measure related to the space complexity of certain
classes of SAT solvers, so it is intuitively not surprising that these problems should require a
large amount of space to solve with one-sided error.
    For the case of bounded error space complexity, we also prove the following (see Theorem 5.3,
Corollary 5.15):

Theorem 1.6 (Informal). There exists a function ๐‘“ : {0, 1} ๐‘› โ†’ {0, 1} such that any bounded error
monotone phase estimation algorithm for ๐‘“ has space complexity (log ๐‘›)2โˆ’๐‘œ(1) .

   This lower bound is non-trivial, although much less so than the best known lower bound
of ฮฉ(๐‘›) for the one-sided case. The approximate monotone span program lower bound
from which Theorem 1.6 follows also implies a new lower bound of 2(log ๐‘›)
                                                                           2โˆ’๐‘œ(1)
                                                                                  on the (non-
approximate) monotone span program size of the function ๐‘“ in Theorem 1.6 (although, as
previously mentioned, there are much better lower bounds for monotone span program size of
other explicit functions).
   To prove the lower bound in Theorem 1.6, we apply a new technique that leverages the
best possible gap between the certificate complexity and approximate polynomial degree of a

                      T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                        5
                                              S TACEY J EFFERY

function, employing a function ๐‘” : {0, 1} ๐‘š
                                                 2+๐‘œ(1)
                                                 โ†’ {0, 1} from [8],3 whose certificate complexity
is ๐‘š 1+๐‘œ(1) , and whose approximate degree is ๐‘š 2โˆ’๐‘œ(1) . Following a strategy of [29], we use this ๐‘”
to construct a pattern matrix [30] (see Definition 5.8) and use this matrix in a monotone version
of Theorem 1.4 (see Theorem 5.4). The fact that certificate complexity and approximate degree
                                  g (๐‘”) โ‰ค ๐ถ(๐‘”)2 for all ๐‘” is a barrier to proving a lower bound
of total functions are related by deg 1/3
better than (log ๐‘›)2 using this technique, but we also give a generalization that has the potential
to prove significantly better lower bounds (see Lemma 5.11).


Discussion and open problems The most conspicuous open problem of this work is to prove
a lower bound of ๐œ”(log ๐‘›) on S( ๐‘“ ) or even S๐‘ˆ    1
                                                     ( ๐‘“ ) for some explicit decision function ๐‘“ . It is
known that any space ๐‘† quantum Turing machine can be simulated by a deterministic classical
algorithm in space ๐‘† 2 [31], so a lower bound of ๐œ”(log2 ๐‘›) on classical space complexity would
also give a non-trivial lower bound on quantum space complexity. If anything, the relationship
to span program size is evidence that this task is extremely difficult.
     We have shown a lower bound of 2(log ๐‘›)
                                                2โˆ’๐‘œ(1)
                                                       on the approximate monotone span program
complexity of an explicit monotone function ๐‘“ , which gives a lower bound of (log ๐‘›)2โˆ’๐‘œ(1) on
the bounded error space complexity needed by a quantum algorithm of a very specific form: a
monotone phase estimation algorithm. This is much worse than the best bound we can get in
the one-sided case: a lower bound of ฮฉ(๐‘›) for some explicit function. An obvious open problem
is to try to get a better lower bound on the approximate monotone span program complexity of
some explicit function.
     Our lower bound of (log ๐‘›)2โˆ’๐‘œ(1) only applies to the space complexity of monotone phase
estimation algorithms and does not preclude the existence of a more space-efficient algorithm
of a different form for ๐‘“ . We do know that phase estimation algorithms are fully general, in
the sense that every function has a space-optimal phase estimation algorithm. Does something
similar hold for monotone functions and monotone phase estimation algorithms? This would
imply that log mSP f ( ๐‘“ ) is a lower bound on S( ๐‘“ ) for all monotone functions ๐‘“ .
     In this paper, we define an approximate version of the rank method, and monotone rank
method, and in case of the monotone rank method, give an explicit non-trivial lower bound. The
rank method is known to give lower bounds on formula size, and the monotone rank method
on monotone formula size. An interesting question is whether the approximate rank method
also gives lower bounds on some complexity theoretic quantity related to (classical) formulas.
     Our results are a modest first step towards understanding unitary quantum space complexity,
but even if we could lower bound the unitary quantum space complexity of an explicit function,
there are several obstacles limiting the practical consequences of such a result. First, while an
early quantum computer will have a small quantum memory, it is simple to augment it with
a much larger classical memory. Thus, in order to achieve results with practical implications,
we would need to study computational models that make a distinction between quantum and
classical memories. We leave this as an important challenge for future work.

   3An earlier version of this paper used a function described in [1] with a 7/6-separation between certificate
complexity and approximate degree. We thank Robin Kothari for pointing us to the improved result of [8].


                        T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                6
                             S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

    Second, we are generally only interested in running quantum algorithms when we get an
advantage over classical computers in the time complexity, so results that give a lower bound on
the quantum space required if we wish to keep the time complexity small, such as time-space
lower bounds, are especially interesting. While we do not address time-space lower bounds in
this paper, one advantage of the proposed quantum space lower bound technique, via span
programs, is that span programs are also known to characterize quantum query complexity,
which is a lower bound on time complexity. We leave exploration of this connection for future
work.
    We mention two previous characterizations of S( ๐‘“ ). Ref. [19] showed that S( ๐‘“ ) is equal to
the logarithm of the minimum width of a matchgate circuit computing ๐‘“ , and thus our results
imply that this minimum matchgate width is approximately equal to the approximate span
program size of ๐‘“ . Separately, in Ref. [9], Fefferman and Lin showed that for every function
๐‘˜, inverting 2 ๐‘˜(๐‘›) ร— 2 ๐‘˜(๐‘›) matrices is complete for the class of problems ๐‘“ such that S( ๐‘“ ) โ‰ค ๐‘˜(๐‘›).
Our results imply that evaluating an approximate span program of size 2 ๐‘˜(๐‘›) (for some suitable
definition of the problem) is similarly complete for this class. Evaluating an approximate span
program boils down to deciding if k๐ด(๐‘ฅ)+ |๐‘ค0 ik, for some matrix ๐ด(๐‘ฅ) partially determined by
the input ๐‘ฅ, and some initial state |๐‘ค 0 i, is below a certain threshold, so these results are not
unrelated.4 We leave exploring these connections as future work.

Organization The remainder of this paper is organized as follows. In Section 2, we present
the necessary notation and quantum algorithmic preliminaries, and define quantum space
complexity. In Section 3, we define span programs, and describe how they correspond to
quantum algorithms. In particular, we describe how a span program can be โ€œcompiledโ€ into
a quantum algorithm (Section 3.2), and how a quantum algorithm can be turned into a span
program (Section 3.3), with both transformations more or less preserving the relationships
between span program size and algorithmic space, and between span program complexity and
query complexity. From this correspondence, we obtain, in Section 4, expressions that lower
bound the quantum space complexity of a function. While we do not know how to instantiate
any of these expressions to get a non-trivial lower bound for an explicit function, in Section 5, we
consider to what extent monotone span program lower bounds are meaningful lower bounds
on variants of quantum space complexity, and give the first non-trivial lower bound on the
approximate monotone span program size of a function.


2     Preliminaries
We begin with some miscellaneous notation. For a vector |๐‘ฃi, we let k|๐‘ฃik denote its โ„“2 -norm. In
the following, let ๐ด be a matrix with ๐‘– and ๐‘— indexing its rows and columns. Define:
                      k๐ดk โˆž = max |๐ด ๐‘–,๐‘— |,      and     k๐ดk = max{k๐ด|๐‘ฃik : k|๐‘ฃik = 1}.
                                  ๐‘–,๐‘—

    4Here, ๐ด(๐‘ฅ) = ๐ดฮ ๐ป(๐‘ฅ) , where ๐ด is as in Definition 3.3, |๐‘ค 0 i = ๐ด+ |๐œi for |๐œi as in Definition 3.3, and ๐ป(๐‘ฅ) is as
in Definition 3.4. ๐ด(๐‘ฅ)+ denotes the pseudo-inverse of ๐ด(๐‘ฅ). Then one can verify that ๐‘ค + (๐‘ฅ) = k๐ด(๐‘ฅ)+ |๐‘ค 0 ik 2 (see
Definition 3.4).


                          T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                       7
                                            S TACEY J EFFERY

Following [2], define the ๐œ€-rank of a matrix ๐ด as the minimum rank of any matrix ๐ต such that
k๐ด โˆ’ ๐ตk โˆž โ‰ค ๐œ€. For a matrix ๐ด with singular value decomposition ๐ด = ๐‘˜ ๐œŽ ๐‘˜ |๐‘ฃ ๐‘˜ ih๐‘ข ๐‘˜ |, where we
                                                                    ร
assume โˆ€๐‘˜, ๐œŽ ๐‘˜ > 0, define:
                                                                                        ร• 1
 col(๐ด) = span{|๐‘ฃ ๐‘˜ i} ๐‘˜ ,   row(๐ด) = span{|๐‘ข ๐‘˜ i} ๐‘˜ ,   ker(๐ด) = row(๐ด)โŠฅ ,      ๐ด+ =             |๐‘ข ๐‘˜ ih๐‘ฃ ๐‘˜ |.
                                                                                             ๐œŽ๐‘˜
                                                                                         ๐‘˜

The following lemma, from [22], is useful in the analysis of quantum algorithms.

Lemma 2.1 (Effective spectral gap lemma). Fix orthogonal projectors ฮ ๐ด and ฮ ๐ต . Let ๐‘ˆ =
(2ฮ ๐ด โˆ’ ๐ผ)(2ฮ ๐ต โˆ’ ๐ผ), and let ฮ ฮ˜ be the orthogonal projector onto the e๐‘–๐œƒ -eigenspaces of ๐‘ˆ such that
|๐œƒ| โ‰ค ฮ˜. Then if ฮ ๐ด |๐‘ขi = 0, then kฮ ฮ˜ ฮ ๐ต |๐‘ขik โ‰ค ฮ˜2 k|๐‘ขik.

In general, we will let ฮ ๐‘‰ denote the orthogonal projector onto ๐‘‰, for a subspace ๐‘‰.

Unitary quantum algorithms and space complexity A unitary quantum algorithm ๐’œ = {๐’œ ๐‘› } ๐‘›โˆˆโ„•
                                                                                         (๐‘›)       (๐‘›)
is a family (parametrized by ๐‘›) of sequences of 2๐‘ (๐‘›) -dimensional unitaries ๐‘ˆ1 , . . . , ๐‘ˆ๐‘‡(๐‘›) , for
some ๐‘ (๐‘›) โ‰ฅ log ๐‘› and ๐‘‡(๐‘›). (We will generally dispense with the explicit parametrization by ๐‘›).
For ๐‘ฅ โˆˆ {0, 1} ๐‘› , let ๐’ช๐‘ฅ be the unitary that acts as ๐’ช๐‘ฅ | ๐‘—i = (โˆ’1)๐‘ฅ ๐‘— | ๐‘—i for ๐‘— โˆˆ [๐‘›], and ๐’ช๐‘ฅ |0i = |0i.
We let ๐’œ(๐‘ฅ) denote the random variable obtained from measuring

                                        ๐‘ˆ๐‘‡ ๐’ช๐‘ฅ ๐‘ˆ๐‘‡โˆ’1 . . . ๐’ช๐‘ฅ ๐‘ˆ1 |0i

with some two-outcome measurement that should be clear from context. We call ๐‘‡(๐‘›) the
query complexity of the algorithm, and ๐‘†(๐‘›) = ๐‘ (๐‘›) + log ๐‘‡(๐‘›) the space complexity. By including
a log ๐‘‡(๐‘›) term in the space complexity, we are implicitly assuming that the algorithm must
maintain a counter to know which unitary to apply next. This is a fairly mild uniformity
assumption (that is, any uniformly generated algorithm uses ฮฉ(log ๐‘‡) space), and it will make
the statement of our results much simpler. The requirement that ๐‘ (๐‘›) โ‰ฅ log ๐‘› is to ensure that
the algorithm has enough space to store an index ๐‘– โˆˆ [๐‘›] into the input.

Remark 2.2. Since ๐‘‡ is the number of queries made by the algorithm, we may be tempted to
assume that it is at most ๐‘›, however, while every ๐‘›-bit function can be computed in ๐‘› queries,
this may not be the case when space is restricted. For example, it is difficult to imagine an
algorithm that uses ๐‘‚(log ๐‘›) space and ๐‘œ(๐‘› 3/2 ) quantum queries to solve the following problem
on [๐‘ž]๐‘› โ‰ก {0, 1} ๐‘› log ๐‘ž : Decide whether there exist distinct ๐‘–, ๐‘—, ๐‘˜ โˆˆ [๐‘›] such that ๐‘ฅ ๐‘– + ๐‘ฅ ๐‘— + ๐‘ฅ ๐‘˜ = 0
mod ๐‘ž.

   For a (partial) function ๐‘“ : ๐ท โ†’ {0, 1} for ๐ท โІ {0, 1} ๐‘› , we say that ๐’œ computes ๐‘“ with
bounded error if for all ๐‘ฅ โˆˆ ๐ท, ๐’œ(๐‘ฅ) = ๐‘“ (๐‘ฅ) with probability at least 2/3. We say that ๐’œ
computes ๐‘“ with one-sided error if in addition, for all ๐‘ฅ such that ๐‘“ (๐‘ฅ) = 1, ๐’œ(๐‘ฅ) = ๐‘“ (๐‘ฅ) with
probability 1.

Definition 2.3 (Unitary Quantum Space). For a family of functions ๐‘“ : ๐ท โ†’ {0, 1} for ๐ท โІ {0, 1} ๐‘› ,
the unitary space complexity of ๐‘“ , S๐‘ˆ ( ๐‘“ ), is the minimum ๐‘†(๐‘›) such that there is a family of

                       T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                      8
                        S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

unitary quantum algorithms with space complexity ๐‘†(๐‘›) that computes ๐‘“ with bounded error.
Similarly, S๐‘ˆ
            1
              ( ๐‘“ ) is the minimum ๐‘†(๐‘›) such that there is a family of unitary quantum algorithms
with space complexity ๐‘†(๐‘›) that computes ๐‘“ with one-sided error.
    In general, quantum algorithms need not be of the strict unitary form described above, as a
quantum computer is not restricted to only measure at the end of the algorithm. If one only cares
about time complexity, then it is without loss of generality to assume that all measurements
happen in the final step of the algorithm, because one can simply set aside any register that
is to be measured, to be used as a โ€œread-onlyโ€ register (that is, strictly as a control) for the
remainder of the computation. However, it is not obvious that this would not increase the space
complexity, since any register that should have been measured is not available for re-use. It
was recently shown that, in fact, even for space complexity, there is no loss of generality in
considering unitary quantum algorithms [10, 12]; if we let S( ๐‘“ ) denote the minimum space
complexity of any quantum algorithm that computes ๐‘“ with bounded error, S( ๐‘“ ) = S๐‘ˆ ( ๐‘“ ). Thus,
we can restrict our attention to unitary quantum algorithms for the remainder of this article but
all of our results in the bounded error setting also hold for non-unitary algorithms [10, 12]. At
the time of writing, there is no analogous result for S๐‘ˆ
                                                       1
                                                         ( ๐‘“ ), but we suspect it holds along similar
lines.

Phase estimation For a unitary ๐‘ˆ acting on ๐ป and a state |๐œ“i โˆˆ ๐ป, we will say we perform ๐‘‡
steps of phase estimation of ๐‘ˆ on |๐œ“i when we compute
                                             ๐‘‡โˆ’1
                                          1 ร•
                                         โˆš       |๐‘กi๐‘ˆ ๐‘ก |๐œ“i,
                                           ๐‘‡ ๐‘ก=0

and then perform a quantum Fourier transform over โ„ค/๐‘‡ โ„ค on the first register, called the phase
register. This procedure was introduced in [21]. It is easy to see that the complexity (either query
or time) of phase estimation is ๐‘‚(๐‘‡) times the complexity of implementing a controlled call to
๐‘ˆ. The space complexity of phase estimation is log ๐‘‡ + log dim(๐ป).
    Informally: we will use the fact that if ๐‘ˆ |๐œ“i = |๐œ“i, then performing ๐‘‡ steps of phase
estimation of ๐‘ˆ on |๐œ“i and measuring the phase register results in outcome 0 with probability
1; and if ๐‘ˆ |๐œ“i = e๐‘–๐œƒ |๐œ“i for some ๐œƒ โˆˆ (โˆ’๐œ‹, ๐œ‹] with |๐œƒ| > 0, then performing sufficiently large
๐‘‡ = ฮฉ(1/|๐œƒ|) steps of phase estimation results in outcome 0 with probability bounded by a
constant below 1. Formally: for the results in Section 3.2, we refer to the proof of [15, Lemma
3.2] where formal results about phase estimation are exploited; for the results in Section 5.2,
we prove the specific properties of phase estimation needed for our purposes in Lemma 5.18
and 5.19.
    We note that we can increase the success probability to any constant by adding some constant
number ๐‘˜ of phase registers, and doing phase estimation ๐‘˜ times in parallel, still using a single
register for ๐‘ˆ, and taking the majority. This still has space complexity log dim ๐ป + ๐‘‚(log ๐‘‡).

Amplitude estimation For a unitary ๐‘ˆ acting on ๐ป, a state |๐œ“i โˆˆ ๐ป, and an orthogonal
projector ฮ  on ๐ป, we will say we perform ๐‘€ steps of amplitude estimation of ๐‘ˆ on |๐œ“i with respect

                      T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                        9
                                                S TACEY J EFFERY

to ฮ  when we perform ๐‘€ steps of phase estimation of

                                          ๐‘ˆ(2|๐œ“ih๐œ“| โˆ’ ๐ผ)๐‘ˆ โ€  (2ฮ  โˆ’ ๐ผ)
                                                                                              ๐œ‹๐‘ก
on ๐‘ˆ |๐œ“i, then, if the phase register contains some ๐‘ก โˆˆ {0, . . . , ๐‘€ โˆ’ 1}, compute ๐‘หœ = sin2 2๐‘€ ,
                                  2
which is an estimate of kฮ ๐‘ˆ |๐œ“ik in a new register. The (time or query) complexity of this is
๐‘‚(๐‘€) times the complexity of implementing a controlled call to ๐‘ˆ, implementing a controlled
call to 2ฮ  โˆ’ ๐ผ, and generating |๐œ“i. The space complexity is log ๐‘‡ + log dim ๐ป + ๐‘‚(1). We have
the following guarantee [7]:

Lemma 2.4. Let ๐‘ = kฮ ๐‘ˆ |๐œ“ik 2 . There exists ฮ” = ฮ˜(1/๐‘€) such that when ๐‘หœ is obtained as above from
๐‘€ steps of amplitude estimation, with probability at least 1/2, | ๐‘หœ โˆ’ ๐‘| โ‰ค ฮ”.

We will thus also refer to ๐‘€ steps of amplitude estimation as amplitude estimation to precision 1/๐‘€.


3     Span programs and quantum algorithms
In Section 3.1, we will define a span program, its size and complexity, and what it means for a
span program to approximate a function ๐‘“ . In Section 3.2, we will prove the following, which
implies that the first part of Theorem 1.1 is essentially tight.

Theorem 3.1. Let ๐‘“ : ๐ท โ†’ {0, 1} for ๐ท โІ {0, 1} ๐‘› , and let ๐‘ƒ be a span program that ๐œ…-approximates
๐‘“ with size ๐พ and complexity ๐ถ, for some constant ๐œ… โˆˆ (0, 1). Then there exists a unitary quantum
algorithm ๐’œ ๐‘ƒ that decides ๐‘“ with bounded error in space ๐‘† = ๐‘‚(log ๐พ + log ๐ถ) using ๐‘‡ = ๐‘‚(๐ถ) queries
to ๐‘ฅ.

    Finally, in Section 3.3, we prove the following theorem, which implies Theorem 1.1:

Theorem 3.2. Let ๐‘“ : ๐ท โ†’ {0, 1} for ๐ท โІ {0, 1} ๐‘› and let ๐’œ be a unitary quantum algorithm using ๐‘‡
queries, and space ๐‘† to compute ๐‘“ with bounded error. Then for any constant ๐œ… โˆˆ (0, 1), there is a span
program ๐‘ƒ๐’œ with size ๐‘ (๐‘ƒ๐’œ ) โ‰ค 2๐‘‚(๐‘†) that ๐œ…-approximates ๐‘“ with complexity ๐ถ๐œ… โ‰ค ๐‘‚(๐‘‡). If ๐’œ decides
๐‘“ with one-sided error, then ๐‘ƒ๐’œ decides ๐‘“ .

    A statement similar to Theorem 3.1 for the case of exact (๐œ… = 1) span programs5 was proven in
[27]. Later this was generalized to the case of approximate span program [15], but a slightly more
constrained notion of approximation was used, which would not allow us to prove Theorem 3.2.
Neither of these works explicitly mentioned space complexity, although the analysis of the space
complexity follows easily.
    Theorem 3.2 is proven by exhibiting a construction that maps a bounded-error quantum
algorithm for ๐‘“ to a span program that approximates it. This is based on a similar construction
in [27] that maps a one-sided error quantum algorithm for ๐‘“ to a span program that decides
it exactly. Interestingly, the fact that span program complexity is a lower bound on query
complexity was known even without a mapping from bounded-error quantum algorithms to
    5See Section 3.1 for definitions of exact and approximate span programs.


                        T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                       10
                             S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

span programs. This was proven by showing [27] that the semidefinite minimization problem
whose solution is the minimum span program complexity of a span program that decides ๐‘“ is
the dual of a semidefinite program that was known to be a lower bound on quantum query
complexity [3, 6, 14].

3.1     Span programs
Span programs were first introduced in the context of classical complexity theory in [20], where
they were used to study counting classes for nondeterministic logspace machines. While span
programs can be defined with respect to any field, we will consider span programs over โ„ (or
equivalently, โ„‚, when convenient, see Remark 3.10). We use the following definition, slightly
modified from [20]:

Definition 3.3 (Span Program and Size). A span program on {0, 1} ๐‘› consists of:

      โ€ข Finite inner product spaces {๐ป ๐‘—,๐‘ } ๐‘—โˆˆ[๐‘›],๐‘โˆˆ{0,1} โˆช {๐ปtrue , ๐ปfalse }. We define ๐ป =                 ๐‘—,๐‘ ๐ป ๐‘—,๐‘ โŠ•
                                                                                                          ร‰

        ๐ปtrue โŠ• ๐ปfalse , and for every ๐‘ฅ โˆˆ {0, 1} ๐‘› , ๐ป(๐‘ฅ) = ๐ป1,๐‘ฅ1 โŠ• ยท ยท ยท โŠ• ๐ป๐‘›,๐‘ฅ ๐‘› โŠ• ๐ปtrue .6

      โ€ข A vector space ๐‘‰.

      โ€ข A target vector |๐œi โˆˆ ๐‘‰.7

      โ€ข A linear map ๐ด : ๐ป โ†’ ๐‘‰.

We specify this span program by ๐‘ƒ = (๐ป, ๐‘‰ , |๐œi, ๐ด), and leave the decomposition of ๐ป implicit.
The size of the span program is ๐‘ (๐‘ƒ) = dim ๐ป.

    To recover the classical definition from [20], we can view ๐ด as a matrix, with each of its
columns labelled by some (๐‘—, ๐‘) โˆˆ [๐‘›] ร— {0, 1} (or โ€œtrueโ€ or โ€œfalseโ€).
    Span programs were introduced to the study of quantum query complexity in [28]. In the
context of quantum query complexity, ๐‘ (๐‘ƒ) is no longer the relevant measure of the complexity
of a span program. Instead, [28] introduce the following measures:

Definition 3.4 (Span Program Complexity and Witnesses). For a span program ๐‘ƒ = (๐ป, ๐‘‰ , |๐œi, ๐ด)
on {0, 1} ๐‘› and input ๐‘ฅ โˆˆ {0, 1} ๐‘› , we say ๐‘ฅ is accepted by the span program if there exists |๐‘คi โˆˆ ๐ป(๐‘ฅ)
such that ๐ด|๐‘คi = |๐œi, and otherwise we say ๐‘ฅ is rejected by the span program. Let ๐‘ƒ0 and ๐‘ƒ1 be
respectively the set of rejected and accepted inputs to ๐‘ƒ. For ๐‘ฅ โˆˆ ๐‘ƒ1 , define the positive witness
complexity of ๐‘ฅ as:

                       ๐‘ค + (๐‘ฅ, ๐‘ƒ) = ๐‘ค+ (๐‘ฅ) = min{k|๐‘คik 2 : |๐‘คi โˆˆ ๐ป(๐‘ฅ), ๐ด|๐‘คi = |๐œi}.
    6We remark that while ๐ปtrue and ๐ปfalse may be convenient in constructing a span program, they are not necessary.
We can always consider a partial function ๐‘“ 0 defined on (๐‘› + 1)-bit strings of the form (๐‘ฅ, 1) for ๐‘ฅ in the domain of ๐‘“ ,
as ๐‘“ (๐‘ฅ), and let ๐ป๐‘›+1,1 = ๐ปtrue and ๐ป๐‘›+1,0 = ๐ปfalse .
    7Although ๐‘‰ has no meaningful inner product, we use Dirac notation, such as |๐œi and h๐œ”| for the sake of our
fellow quantum computing researchers.


                         T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                        11
                                                 S TACEY J EFFERY

Such a |๐‘คi is called a positive witness for ๐‘ฅ. For a domain ๐ท โІ {0, 1} ๐‘› , we define the positive
complexity of ๐‘ƒ (with respect to ๐ท) as:

                                    ๐‘Š+ (๐‘ƒ, ๐ท) = ๐‘Š+ = max ๐‘ค + (๐‘ฅ, ๐‘ƒ).
                                                          ๐‘ฅโˆˆ๐‘ƒ1 โˆฉ๐ท

    For ๐‘ฅ โˆˆ ๐‘ƒ0 , define the negative witness complexity of ๐‘ฅ as:

         ๐‘ค โˆ’ (๐‘ฅ, ๐‘ƒ) = ๐‘ค โˆ’ (๐‘ฅ) = min{kh๐œ”|๐ดk 2 : h๐œ”| โˆˆ โ„’(๐‘‰ , โ„), h๐œ”|๐œi = 1, h๐œ”|๐ดฮ ๐ป(๐‘ฅ) = 0}.

Above, โ„’(๐‘‰ , โ„) denotes the set of linear functions from ๐‘‰ to โ„. Such an h๐œ”| is called a negative
witness for ๐‘ฅ. We define the negative complexity of ๐‘ƒ (with respect to ๐ท) as:

                                    ๐‘Šโˆ’ (๐‘ƒ, ๐ท) = ๐‘Šโˆ’ = max ๐‘คโˆ’ (๐‘ฅ, ๐‘ƒ).
                                                          ๐‘ฅโˆˆ๐‘ƒ0 โˆฉ๐ท

                                                                           โˆš
    Finally, we define the complexity of ๐‘ƒ (with respect to ๐ท) by ๐ถ(๐‘ƒ, ๐ท) = ๐‘Š+๐‘Šโˆ’ .

    For ๐‘“ : ๐ท โ†’ {0, 1}, we say a span program ๐‘ƒ decides ๐‘“ if ๐‘“ โˆ’1 (0) โІ ๐‘ƒ0 and ๐‘“ โˆ’1 (1) โІ ๐‘ƒ1 .

Definition 3.5. We define the span program size of a function ๐‘“ , denoted SP( ๐‘“ ), as the minimum
๐‘ (๐‘ƒ) over families of span programs that decide ๐‘“ .

    We note that originally, in [20], span program size was defined
                                   ร•                            ร•
                        ๐‘  0(๐‘ƒ) =         dim(col(๐ดฮ ๐ป ๐‘—,๐‘ )) =         dim(row(๐ดฮ ๐ป ๐‘—,๐‘ )).
                                   ๐‘—,๐‘                          ๐‘—,๐‘


This could differ from ๐‘ (๐‘ƒ) = dim(๐ป) = ๐‘—,๐‘ dim(๐ป ๐‘—,๐‘ ), because dim(๐ป ๐‘—,๐‘ ) might be much larger
                                                ร
than dim(row(๐ดฮ ๐ป ๐‘—,๐‘ )). However, if a span program has dim(๐ป ๐‘—,๐‘ ) > dim(row(๐ดฮ ๐ป ๐‘—,๐‘ )) for
some ๐‘—, ๐‘, then it is a simple exercise to show that the dimension of dim(๐ป ๐‘—,๐‘ ) can be reduced
without altering the witness size of any ๐‘ฅ โˆˆ {0, 1} ๐‘› , so the definition of SP( ๐‘“ ) is the same as
if we had used ๐‘  0(๐‘ƒ) instead of ๐‘ (๐‘ƒ). In any case, we will not be relying on previous results
about the span program size as a black-box, and will rather prove all required statements, so
this difference has no impact on our results.
    While span program size has only previously been relevant outside the realm of quantum
algorithms, the complexity of a span program deciding ๐‘“ has a fundamental correspondence
with the quantum query complexity of ๐‘“ . Specifically, a span program ๐‘ƒ can be turned into a
quantum algorithm for ๐‘“ with query complexity ๐ถ(๐‘ƒ, ๐ท), and moreover, for every ๐‘“ , there exists
a span program such that the algorithm constructed in this way is optimal [27]. This second
direction is not constructive: there is no known method for converting a quantum algorithm with
query complexity ๐‘‡ to a span program with complexity ๐ถ(๐‘ƒ, ๐ท) = ฮ˜(๐‘‡). However, if we relax
the definition of which functions are decided by a span program, then such a construction is
possible, as we will show in Section 3.3. The following is a slight relaxation of [15, Definition 2.6].8
   8Which was already a relaxation of the notion of a span program deciding a function.


                       T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                         12
                         S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

Definition 3.6 (A Span Program that Approximately Decides a Function). Let ๐‘“ : ๐ท โ†’ {0, 1}
for ๐ท โІ {0, 1} ๐‘› and ๐œ… โˆˆ (0, 1). We say that a span program ๐‘ƒ on {0, 1} ๐‘› ๐œ…-approximates ๐‘“ if
๐‘“ โˆ’1 (0) โІ ๐‘ƒ0 , and for every ๐‘ฅ โˆˆ ๐‘“ โˆ’1 (1), there exists an approximate positive witness | ๐‘คi
                                                                                           ห† such that
                                     ๐œ…
๐ด| ๐‘คi
    ห† = |๐œi, and ฮ ๐ป(๐‘ฅ)โŠฅ | ๐‘คi
                               2
                            ห†    โ‰ค ๐‘Šโˆ’ . We define the approximate positive complexity as

                                                                           ๐œ…
                                                                            
                  ๐œ…
           ๐‘Š+ = ๐‘Š+ (๐‘ƒ, ๐ท) = max min k| ๐‘คik   : ๐ด| ๐‘คi
                                                  ห† = |๐œi, ฮ ๐ป(๐‘ฅ)โŠฅ | ๐‘คi         .
                                           2                           2
           b    b                      ห†                            ห†    โ‰ค
                                 ๐‘ฅโˆˆ ๐‘“ โˆ’1 (1)                                                       ๐‘Šโˆ’
                                                                                                          q
If ๐‘ƒ ๐œ…-approximates ๐‘“ , we define the complexity of ๐‘ƒ (wrt. ๐ท and ๐œ…) as ๐ถ๐œ… (๐‘ƒ, ๐ท) =                         ๐‘Š
                                                                                                            b+๐‘Šโˆ’ .

   If ๐œ… = 0, the span program in Definition 3.6 decides ๐‘“ (exactly), and ๐‘Š
                                                                         b+ = ๐‘Š+ . By [15,
Theorem 2.10], for any ๐‘ฅ,
                                     n                                         o      1
                                         ฮ ๐ป(๐‘ฅ)โŠฅ | ๐‘คi        : ๐ด| ๐‘คi                        .
                                                        2
                             min                  ห†              ห† = |๐œi =
                                                                                    ๐‘คโˆ’ (๐‘ฅ)
Thus, since ๐‘Šโˆ’ = max๐‘ฅโˆˆ ๐‘“ โˆ’1 (0) ๐‘ค โˆ’ (๐‘ฅ), for every ๐‘ฅ โˆˆ ๐‘“ โˆ’1 (0), there does not exist an approximate
positive witness with ฮ ๐ป(๐‘ฅ)โŠฅ | ๐‘คi             < ๐‘Š1โˆ’ . Thus, when a span program ๐œ…-approximates ๐‘“ , there
                                          2
                               ห†

                 ๐‘Šโˆ’ between the smallest positive witness error ฮ ๐ป(๐‘ฅ) | ๐‘คi                         of ๐‘ฅ โˆˆ ๐‘“ โˆ’1 (1), the
                                                                                               2
is a gap of size 1โˆ’๐œ…                                                 โŠฅ ห†

smallest positive witness error of ๐‘ฅ โˆˆ ๐‘“ (0).
                                        โˆ’1


Definition 3.7. We define the ๐œ…-approximate span program size of a function ๐‘“ , denoted SPf ๐œ… ( ๐‘“ ), as
the minimum ๐‘ (๐‘ƒ) over families of span programs that ๐œ…-approximate ๐‘“ . We let SP f ( ๐‘“ ) = SP
                                                                                           f 1/4 ( ๐‘“ ).

    We note that the choice of ๐œ… = 1/4 in SPf ( ๐‘“ ) is arbitrary, as it is possible to modify a span
program to reduce any constant ๐œ… to any other constant without changing the complexity or the
logarithm of the size asymptotically. This convenient observation is formalized in the following
claim.
Claim 3.8. Let ๐‘ƒ be a span program that ๐œ…-approximates ๐‘“ : ๐ท โ†’ {0, 1} for some constant ๐œ…. For any
constant ๐œ…0 โ‰ค ๐œ…, there exists a span program ๐‘ƒ 0 that ๐œ…0-approximates ๐‘“ with
                                                                       log(1/๐œ…0 )
                                              ๐‘ (๐‘ƒ 0) = (๐‘ (๐‘ƒ) + 2) log(1/๐œ…) ,
                                                                   2
                                                                                                                 (3.1)
and ๐ถ๐œ…0 (๐‘ƒ 0 , ๐ท) โ‰ค ๐‘‚ (๐ถ๐œ… (๐‘ƒ, ๐ท)).
   We prove Claim 3.8 shortly in Section 3.1.1. We have the following corollary that will be
                     f ๐œ… is the monotone approximate span program size, defined in Definition 5.1:
useful later, where mSP
Corollary 3.9. For any ๐œ…, ๐œ…0 โˆˆ (0, 1) with ๐œ…0 < ๐œ…, and any Boolean function ๐‘“ ,
                                                                 1 log(1/๐œ…)
                                         f ๐œ… ( ๐‘“ ) โ‰ฅ SP
                                         SP          f ๐œ…0 ( ๐‘“ ) 2 log(1/๐œ…0) โˆ’ 2.

If ๐‘“ is monotone, we also have
                                                                   1 log(1/๐œ…)
                                      f ๐œ… ( ๐‘“ ) โ‰ฅ mSP
                                     mSP           f ๐œ…0 ( ๐‘“ ) 2 log(1/๐œ…0) โˆ’ 2.

                      T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                         13
                                                    S TACEY J EFFERY

Remark 3.10. It can sometimes be useful to construct a span program over โ„‚. However, for
any span program over โ„‚, ๐‘ƒ, there is a span program over โ„, ๐‘ƒ 0, such that for all ๐‘ฅ โˆˆ ๐‘ƒ0 ,
๐‘ค โˆ’ (๐‘ฅ, ๐‘ƒ 0) โ‰ค ๐‘คโˆ’ (๐‘ฅ, ๐‘ƒ), for all ๐‘ฅ โˆˆ ๐‘ƒ1 , ๐‘ค + (๐‘ฅ, ๐‘ƒ 0) โ‰ค ๐‘ค + (๐‘ฅ, ๐‘ƒ), and ๐‘ (๐‘ƒ 0) โ‰ค 2๐‘ (๐‘ƒ). We define ๐‘ƒ 0
as follows. Without loss of generality, suppose ๐ป ๐‘—,๐‘ = spanโ„‚ {| ๐‘—, ๐‘, ๐‘˜i : ๐‘˜ โˆˆ ๐‘† ๐‘—,๐‘ }. Define
๐ป 0๐‘—,๐‘ = spanโ„ {| ๐‘—, ๐‘, ๐‘˜, ๐‘Ži : ๐‘˜ โˆˆ ๐‘† ๐‘—,๐‘ , ๐‘Ž โˆˆ {0, 1}}. Define

                              ๐ด0 | ๐‘—, ๐‘, ๐‘˜, 0i = Re (๐ด| ๐‘—, ๐‘, ๐‘˜i) |0i + Im (๐ด| ๐‘—, ๐‘, ๐‘˜i) |1i

                              ๐ด0 | ๐‘—, ๐‘, ๐‘˜, 1i = Re (๐ด| ๐‘—, ๐‘, ๐‘˜i) |1i โˆ’ Im (๐ด| ๐‘—, ๐‘, ๐‘˜i) |0i.

Finally, let |๐œ0i = |๐œi|0i.
   Suppose |๐‘คi is a witness in ๐‘ƒ. Then

              |๐œi = ๐ด|๐‘คi = ๐ดRe(|๐‘คi) + ๐‘–๐ดIm(|๐‘คi)
                  = Re(๐ดRe(|๐‘คi)) + ๐‘–Im(๐ดRe(|๐‘คi)) + ๐‘–Re(๐ดIm(|๐‘คi)) โˆ’ Im(๐ดIm(|๐‘คi)).

Since we can assume |๐œi is real, we have

         |๐œi = Re(๐ดRe(|๐‘คi)) โˆ’ Im(๐ดIm(|๐‘คi)) and                     Im(๐ดRe(|๐‘คi)) + Re(๐ดIm(|๐‘คi)) = 0.

Define |๐‘ค 0i = Re(|๐‘คi)|0i + Im(|๐‘คi)|1i. Then

๐ด0 |๐‘ค 0i = Re(๐ดRe(|๐‘คi))|0i+Im(๐ดRe(|๐‘คi))|1i+Re(๐ดIm(|๐‘คi))|1iโˆ’Im(๐ดIm(|๐‘คi))|0i = |๐œi|0i = |๐œ0i.

Note that we have k|๐‘คik = k|๐‘ค 0ik. A similar argument holds for negative witnesses.
   Thus, we will restrict our attention to real span programs, but still allow constructions of
span programs over โ„‚ (in particular, in Section 3.3 and Section 5.2.1).

3.1.1   Proof of Claim 3.8

In this section, we prove Claim 3.8. The proof is somewhat technical, and may be skipped
without compromising the readerโ€™s understanding of the remainder of the paper. We restate
Claim 3.8 below.

Claim 3.8. Let ๐‘ƒ be a span program that ๐œ…-approximates ๐‘“ : ๐ท โ†’ {0, 1} for some constant
๐œ…. For any constant ๐œ…0 โ‰ค ๐œ…, there exists a span program ๐‘ƒ 0 that ๐œ…0-approximates ๐‘“ with
                       log(1/๐œ…0 )
๐‘ (๐‘ƒ 0) = (๐‘ (๐‘ƒ) + 2) log(1/๐œ…) , and ๐ถ๐œ…0 (๐‘ƒ 0 , ๐ท) โ‰ค ๐‘‚ (๐ถ๐œ… (๐‘ƒ, ๐ท)).
                   2


    Let |๐‘ค0 i = ๐ด+ |๐œi. We say a span program is normalized if k|๐‘ค 0 ik = 1. A span program can
easily be normalized by scaling |๐œi, which also scales all positive witnesses and inverse scales
all negative witnesses. However, we sometimes want to normalize a span program, while also
keeping all negative witness sizes bounded by a constant. We can accomplish this using the
following construction, from [15].

                          T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                       14
                                  S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

Theorem 3.11. Let ๐‘ƒ = (๐ป, ๐‘‰ , |๐œi, ๐ด) be a span program on {0, 1} ๐‘› , and let ๐‘ = k|๐‘ค0 ik 2 . For a
positive real number ๐›ฝ, define a span program ๐‘ƒ ๐›ฝ = (๐ป ๐›ฝ , ๐‘‰ ๐›ฝ , |๐œ๐›ฝ i, ๐ด๐›ฝ ) as follows, where | 0i
                                                                                                 ห† and | 1i
                                                                                                         ห† are
not in ๐ป or ๐‘‰:
                    ๐›ฝ                   ๐›ฝ                ห†                 ๐›ฝ           ห†
                  ๐ป ๐‘—,๐‘ = ๐ป ๐‘—,๐‘ , ๐ปtrue = ๐ปtrue โŠ• span{| 1i}, ๐ปfalse = ๐ปfalse โŠ• span{| 0i}

                                                                    p
              ๐›ฝ                                 ๐›ฝ                       ๐›ฝ2 + ๐‘
                           ห†
            ๐‘‰ = ๐‘‰ โŠ• span{| 1i},              ห† +
                                ๐ด = ๐›ฝ๐ด + |๐œih0|                                | 1ih ห† |๐œ๐›ฝ i = |๐œi + | 1i.
                                                                                 ห† 1|,                 ห†
                                                                          ๐›ฝ
Then we have the following:

   โ€ข (๐ด๐›ฝ )+ |๐œ๐›ฝ i = 1;

   โ€ข for all ๐‘ฅ โˆˆ ๐‘ƒ1 , ๐‘ค + (๐‘ฅ, ๐‘ƒ ๐›ฝ ) = ๐›ฝ12 ๐‘ค + (๐‘ฅ, ๐‘ƒ) + 2;

   โ€ข for all ๐‘ฅ โˆˆ ๐‘ƒ0 , ๐‘ค โˆ’ (๐‘ฅ, ๐‘ƒ ๐›ฝ ) = ๐›ฝ 2 ๐‘ค โˆ’ (๐‘ฅ, ๐‘ƒ) + 1.

Corollary 3.12. Let ๐‘ƒ be a span program on {0, 1} ๐‘› , and ๐‘ƒ ๐›ฝ be defined as above for ๐›ฝ = โˆš 1 . If ๐‘ƒ
                                                                                           ๐‘Šโˆ’ (๐‘ƒ)
                          ๐›ฝ
                            โˆš                               ๐›ฝ              ๐›ฝ
๐œ…-approximates ๐‘“ , then ๐‘ƒ     ๐œ…-approximates ๐‘“ , with ๐‘Šโˆ’ (๐‘ƒ ) โ‰ค 2, ๐‘Š+ (๐‘ƒ ) โ‰ค ๐‘Šโˆ’ (๐‘ƒ)๐‘Š+ (๐‘ƒ) + 2 and
                                                                     b                  b
   ๐›ฝ
๐‘ (๐‘ƒ ) โ‰ค ๐‘ (๐‘ƒ) + 2.

Proof. First note that by Theorem 3.11, ๐‘Šโˆ’ (๐‘ƒ ๐›ฝ ) โ‰ค 2. Let |๐‘คi be an approximate positive witness
for ๐‘ฅ in ๐‘ƒ, with ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi โ‰ค ๐‘Šโˆ’๐œ…(๐‘ƒ) and k|๐‘คik 2 โ‰ค ๐‘Š
                             2
                                                       b+ (๐‘ƒ). Define

                                                                 ๐›ฝ
                                    |๐‘ค 0i =
                                                 1
                                                       |๐‘คi + p        ห† + ๐œ… | 0i.
                                                                    | 1i      ห†
                                              ๐›ฝ(1 + ๐œ…)         ๐›ฝ +๐‘
                                                                2        1+๐œ…

One can check that ๐ด๐›ฝ |๐‘ค 0i = |๐œ๐›ฝ i.

                                      1                           ๐œ…2            1        ๐œ…        ๐œ…2
        ฮ ๐ป ๐›ฝ (๐‘ฅ)โŠฅ |๐‘ค 0i
                          2                               2
                              =              ฮ  ๐ป(๐‘ฅ) โŠฅ |๐‘คi   +           โ‰ค                       +
                                ๐›ฝ 2 (1 + ๐œ…)2                   (1 + ๐œ…)2   ๐›ฝ 2 (1 + ๐œ…)2 ๐‘Šโˆ’ (๐‘ƒ) (1 + ๐œ…)2
                                                                                       โˆš
                                 ๐œ… + ๐œ…2        2๐œ…(1 + ๐œ…)             1     2๐œ…            ๐œ…
                              =            โ‰ค                    =                 โ‰ค           ,
                                (1 + ๐œ…)  2        ๐›ฝ
                                             ๐‘Šโˆ’ (๐‘ƒ )(1 + ๐œ…)  2    ๐‘Šโˆ’ (๐‘ƒ ) 1 + ๐œ…
                                                                        ๐›ฝ           ๐‘Šโˆ’ (๐‘ƒ ๐›ฝ )

where we have used ๐‘Šโˆ’ (๐‘ƒ ๐›ฝ ) โ‰ค 2. We upper bound ๐‘Š
                                                 b+ (๐‘ƒ ๐›ฝ ) by noting that:

                                                            b+ (๐‘ƒ) + ๐›ฝ        ๐œ…2
                                                                        2
                                                     1
                                  k|๐‘ค 0ik 2 โ‰ค               ๐‘Š             +
                                                ๐›ฝ2 (1 + ๐œ…)2         ๐›ฝ2 + ๐‘ (1 + ๐œ…)2
                                              โ‰ค ๐‘Šโˆ’ (๐‘ƒ)๐‘Š
                                                      b+ (๐‘ƒ) + 2.

Finally, ๐‘ (๐‘ƒ ๐›ฝ ) = ๐‘ (๐‘ƒ) + 2 because of the two extra degrees of freedom | 0i
                                                                          ห† and | 1i.
                                                                                  ห†                          

                          T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                              15
                                                 S TACEY J EFFERY

Proof of Claim 3.8. We will first show how, given a span program ๐‘ƒ such that k|๐‘ค0 ik 2 โ‰ค 1, and ๐‘ƒ
๐œ…-approximates ๐‘“ , we can get a span program ๐‘ƒ 0 such that |๐‘ค 00 i โ‰ค 1, ๐‘Šโˆ’ (๐‘ƒ 0) โ‰ค ๐‘Šโˆ’ (๐‘ƒ)2 , ๐‘ƒ 0
                                                                    2

๐œ…2 -approximates ๐‘“ , ๐‘Š
                     b+ (๐‘ƒ 0) โ‰ค 4๐‘Š
                                 b+ (๐‘ƒ), and ๐‘ (๐‘ƒ 0) = ๐‘ (๐‘ƒ)2 .
    Define ๐‘ƒ as follows, where ๐‘† is a swap operator, which acts as ๐‘†(|๐‘ขi|๐‘ฃi) = |๐‘ฃi|๐‘ขi for all
              0

|๐‘ขi, |๐‘ฃi โˆˆ ๐ป:

                                                        ๐ผ๐ปโŠ—๐ป + ๐‘†
                                                                           
                    ๐ป 0๐‘—,๐‘ = ๐ป ๐‘—,๐‘ โŠ— ๐ป,      0
                                            ๐ด = (๐ด โŠ— ๐ด)          ,                  |๐œ0i = |๐œi|๐œi.
                                                           2

Observe that for any |๐‘ขi, |๐‘ฃi โˆˆ ๐ป, we have

                         ๐ด0(|๐‘ขi|๐‘ฃi โˆ’ |๐‘ฃi|๐‘ขi) = 0,         and       ๐ด0 |๐‘ขi|๐‘ขi = ๐ด|๐‘ขi โŠ— ๐ด|๐‘ขi.

Note that ๐ด0(|๐‘ค0 i|๐‘ค 0 i) = |๐œ0i, so ๐ด0+ |๐œ0i โ‰ค k|๐‘ค 0 i|๐‘ค 0 ik โ‰ค 1.
   If h๐œ”| is a negative witness for ๐‘ฅ in ๐‘ƒ, it is easily verified that h๐œ”0 | = h๐œ”| โŠ— h๐œ”| is a negative
witness in ๐‘ƒ 0, and
                                                                                   2
                                    1                  1
                kh๐œ”0 |๐ด0 k 2 =        (h๐œ”|๐ด) โŠ— (h๐œ”|๐ด) + (h๐œ”|๐ด) โŠ— (h๐œ”|๐ด)                = kh๐œ”|๐ดk 4 ,
                                    2                  2

so ๐‘ค โˆ’ (๐‘ฅ, ๐‘ƒ 0) โ‰ค ๐‘ค โˆ’ (๐‘ฅ, ๐‘ƒ)2 , and ๐‘Šโˆ’ (๐‘ƒ 0) โ‰ค ๐‘Šโˆ’ (๐‘ƒ)2 .
   If |๐‘คi is an approximate positive witness for ๐‘ฅ in ๐‘ƒ, then define

        |๐‘ค 0i = |๐‘คi|๐‘คi โˆ’ ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คiฮ ๐ป(๐‘ฅ) |๐‘คi + ฮ ๐ป(๐‘ฅ) |๐‘คiฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi โˆ’ ฮ ๐ป(๐‘ฅ) |๐‘คiฮ ker(๐ด) |๐‘คi.

We have
                            1
๐ด0 |๐‘ค 0i = ๐ด|๐‘คi๐ด|๐‘คi โˆ’         ๐ดฮ ๐ป(๐‘ฅ) |๐‘คi โŠ— ๐ดฮ ker(๐ด) |๐‘คi + ๐ดฮ ker(๐ด) |๐‘คi โŠ— ๐ดฮ ๐ป(๐‘ฅ) |๐‘คi = |๐œi|๐œi = |๐œ0i.
                                                                                   
                            2

We can bound the error as:

           ฮ ๐ป 0(๐‘ฅ)โŠฅ |๐‘ค 0i       = (ฮ ๐ป(๐‘ฅ)โŠฅ โŠ— ๐ผ)|๐‘ค 0i
                            2                         2                                               2
                                                          = ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi|๐‘คi โˆ’ ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คiฮ ๐ป(๐‘ฅ) |๐‘คi
                                                                     ๐œ…2        ๐œ…2
                                                                                       .
                                                            2
                                = ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คiฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi          โ‰ค           โ‰ค
                                                                    ๐‘Šโˆ’ (๐‘ƒ)2   ๐‘Šโˆ’ (๐‘ƒ 0)

   Next, observe that

                    (ฮ ๐ป(๐‘ฅ) + ฮ ๐ป(๐‘ฅ)โŠฅ ) โŠ— (ฮ ๐ป(๐‘ฅ) + ฮ ๐ป(๐‘ฅ)โŠฅ ) โˆ’ ฮ ๐ป(๐‘ฅ)โŠฅ โŠ— ฮ ๐ป(๐‘ฅ) + ฮ ๐ป(๐‘ฅ) โŠ— ฮ ๐ป(๐‘ฅ)โŠฅ
                     = ฮ ๐ป(๐‘ฅ) โŠ— ฮ ๐ป(๐‘ฅ) + ฮ ๐ป(๐‘ฅ) โŠ— ฮ ๐ป(๐‘ฅ)โŠฅ + ฮ ๐ป(๐‘ฅ)โŠฅ โŠ— ฮ ๐ป(๐‘ฅ)โŠฅ + ฮ ๐ป(๐‘ฅ) โŠ— ฮ ๐ป(๐‘ฅ)โŠฅ
                     = ฮ ๐ป(๐‘ฅ) โŠ— ๐ผ + ๐ผ โŠ— ฮ ๐ป(๐‘ฅ)โŠฅ
                0
          so |๐‘ค i = ฮ ๐ป(๐‘ฅ) |๐‘คi โŠ— |๐‘คi + |๐‘คi โŠ— ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi โˆ’ ฮ ๐ป(๐‘ฅ) |๐‘คi โŠ— ฮ ker(๐ด) |๐‘คi.


                          T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                           16
                               S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

Thus, using the assumption k|๐‘ค 0 ik โ‰ค 1, and the fact that ฮ row(๐ด) |๐‘คi = |๐‘ค0 i:

          k|๐‘ค 0ik 2 = ฮ ๐ป(๐‘ฅ) |๐‘คi|๐‘คi + |๐‘คiฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi โˆ’ ฮ ๐ป(๐‘ฅ) |๐‘คiฮ ker(๐ด) |๐‘คi
                                                                                                 2

                                                                            2
                      = ฮ ๐ป(๐‘ฅ) |๐‘คiฮ row(๐ด) |๐‘คi + |๐‘คiฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi
                                                 2                     2                     2
                      = ฮ ๐ป(๐‘ฅ) |๐‘คi|๐‘ค0 i               + |๐‘คiฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi       + 2 ฮ ๐ป(๐‘ฅ) |๐‘คi      h๐‘ค 0 |ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi
                                                  ๐œ…                      ๐œ…                      โˆš
                                                                    r
                      โ‰ค๐‘Š
                       b+ (๐‘ƒ) + ๐‘Š
                                b+ (๐‘ƒ)                  + 2๐‘Š
                                                           b+ (๐‘ƒ)                   โ‰ค (1 + ๐œ… + 2 ๐œ…)๐‘Š b+ (๐‘ƒ).
                                                 ๐‘Šโˆ’ (๐‘ƒ)                 ๐‘Šโˆ’ (๐‘ƒ)

Note that we could assume that ๐‘Š     bโˆ’ (๐‘ƒ) โ‰ฅ 1 because k๐‘ค0 k โ‰ค 1.
    We complete the proof by extending to the general case. Let ๐‘ƒ be any span program that
๐œ…-approximates ๐‘“ . By applying Theorem 3.11 and Corollary 3.12, we can get a span program, ๐‘ƒ0 ,
                                                                                  โˆš
with k|๐‘ค 0 ik = 1, ๐‘Šโˆ’ (๐‘ƒ0 ) โ‰ค 2, ๐‘Š
                                 b+ (๐‘ƒ0 ) โ‰ค ๐ถ(๐‘ƒ)2 + 2, and ๐‘ (๐‘ƒ0 ) = ๐‘ (๐‘ƒ) + 2, that ๐œ…-approximates ๐‘“ .
We can then apply the construction described above, iteratively, ๐‘‘ times, to get a span program
       โˆš 2๐‘‘        ๐‘‘โˆ’1
๐‘ƒ๐‘‘ that ๐œ… = ๐œ…2 -approximates ๐‘“ , with
                                                              ๐‘‘                 ๐‘‘
                                               ๐‘ (๐‘ƒ๐‘‘ ) = ๐‘ (๐‘ƒ0 )2 = (๐‘ (๐‘ƒ) + 2)2 ,
                                        ๐‘‘
               ๐‘Šโˆ’ (๐‘ƒ๐‘‘ ) โ‰ค 22 ,                 and       b+ (๐‘ƒ๐‘‘ ) โ‰ค 4๐‘‘ ๐‘Š
                                                         ๐‘Š             b+ (๐‘ƒ0 ) โ‰ค 4๐‘‘ ๐ถ(๐‘ƒ)2 + 2 ยท 4๐‘‘ .
                      log(1/๐œ…0 )
                                  
Setting ๐‘‘ = log        log(1/๐œ…)
                                       + 1 gives the desired ๐œ…0.                                                 

3.2   From span programs to quantum algorithms
In this section, we will prove Theorem 3.1, which states that if a span program approximately
decides a function ๐‘“ , then we can compile it to a quantum algorithm for ๐‘“ . While we hope that
Theorem 3.1 will have applications in designing span program algorithms, its only relevance
to the contents of this paper are its implications with respect to the tightness of the first lower
bound expression in Theorem 4.1, and so this section can be safely skipped.
    Theorem 3.1 is similar to [15, Lemma 3.6], the difference here is we let an approximate
positive witness for ๐‘ฅ be any witness with error, ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi , at most ๐œ…/๐‘Šโˆ’ , whereas in [15], it
                                                                2

is required to have error as small as possible. This relaxation could potentially decrease the
positive complexity ๐‘Š b+ , since we now have more freedom in selecting positive witnesses, but
more importantly, it makes it easier to analyze a span program, because we need not find the
approximate positive witness with the smallest possible error. Importantly, this change in how
we define a span program that approximates ๐‘“ does not change the most important property of
such a span program: that it can be compiled into a quantum algorithm for ๐‘“ . To show this,
we now modify the proof of [15, Lemma 3.6] to fit the new definition. We will restrict to span
programs on binary strings {0, 1} ๐‘› , but the proof also works for span programs on [๐‘ž]๐‘› for ๐‘ž > 2.

Proof of Theorem 3.1. For a span program ๐‘ƒ on {0, 1} ๐‘› and ๐‘ฅ โˆˆ {0, 1} ๐‘› , define

                                            ๐‘ˆ(๐‘ƒ, ๐‘ฅ) = (2ฮ ker(๐ด) โˆ’ ๐ผ)(2ฮ ๐ป(๐‘ฅ) โˆ’ ๐ผ),

                           T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                 17
                                               S TACEY J EFFERY

which acts on ๐ป. To prove Theorem 3.1, we will show that by performing phase estimation of
๐‘ˆ(๐‘ƒ, ๐‘ฅ) on initial state |๐‘ค 0 i = ๐ด+ |๐œi, and estimating the amplitude on having |0i in the phase
register, we can distinguish 1- and 0-inputs of ๐‘“ with bounded error.
    By Corollary 3.12 and Claim 3.8, we can assume without loss of generality that ๐‘ƒ has been
scaled so that it ๐œ…-approximates ๐‘“ for some ๐œ… < 1/4, |๐‘ค 0 i = ๐ด+ |๐œi is a unit vector, and ๐‘Šโˆ’ โ‰ค 2.
The scaled span program still has size ๐พ ๐‘‚(1) and complexity ๐‘‚(๐ถ).
    We first modify the proof of [15, Lemma 3.2] to get the following lemma:

Lemma 3.13. Let ๐‘ƒ be a span program that ๐œ…-approximates ๐‘“ , with k|๐‘ค0 ik 2 = 1. Fix any ฮ˜ โˆˆ (0, ๐œ‹),
and let ฮ ฮ˜ be the projector onto the e๐‘–๐œƒ -eigenspaces of ๐‘ˆ(๐‘ƒ, ๐‘ฅ) with |๐œƒ| โ‰ค ฮ˜. For any ๐‘ฅ โˆˆ ๐‘“ โˆ’1 (1),

                                                                    4๐œ…
                                        kฮ ฮ˜ |๐‘ค 0 ik 2 โ‰ค ฮ˜ 2๐‘Š
                                                           b+ +        .
                                                                    ๐‘Šโˆ’

Proof. Suppose ๐‘ฅ โˆˆ ๐‘“ โˆ’1 (1) and let | ๐‘คห† ๐‘ฅ i be an approximate positive witness with ฮ ๐ป(๐‘ฅ)โŠฅ | ๐‘คห† ๐‘ฅ i โ‰ค
                                                                                                           2

 ๐œ…
๐‘Šโˆ’ and k| ๐‘ค
          ห† ๐‘ฅ ik 2 โ‰ค ๐‘Š
                     b+ . Note that since ๐ด| ๐‘คห† ๐‘ฅ i = |๐œi, ฮ row(๐ด) | ๐‘คห† ๐‘ฅ i = ๐ด+ ๐ด| ๐‘คห† ๐‘ฅ i = ๐ด+ |๐œi = |๐‘ค0 i, so

                            ฮ row(๐ด) ฮ ๐ป(๐‘ฅ) | ๐‘คห† ๐‘ฅ i + ฮ row(๐ด) ฮ ๐ป(๐‘ฅ)โŠฅ | ๐‘คห† ๐‘ฅ i = |๐‘ค 0 i.

Since ฮ ๐ป(๐‘ฅ)โŠฅ ฮ ๐ป(๐‘ฅ) | ๐‘คห† ๐‘ฅ i = 0, we have, by the effective spectral gap lemma (Lemma 2.1):

                                                                                    ฮ˜2
                                                          ฮ ฮ˜ ฮ row(๐ด) ฮ ๐ป(๐‘ฅ) | ๐‘คห† ๐‘ฅ i     ฮ ๐ป(๐‘ฅ) | ๐‘คห† ๐‘ฅ i
                                                                                         2             2
                                                                                             โ‰ค
                                                                                    4
                                                                               2 ฮ˜2
                                           ฮ ฮ˜ |๐‘ค0 i โˆ’ ฮ row(๐ด) ฮ ๐ป(๐‘ฅ)โŠฅ | ๐‘คห† ๐‘ฅ i     โ‰ค    k| ๐‘คห† ๐‘ฅ ik
                                                                                                  2
                                                                                    4
                                                                                    ฮ˜2 b
    kฮ ฮ˜ |๐‘ค0 ik 2 + ฮ ฮ˜ ฮ row(๐ด) ฮ ๐ป(๐‘ฅ)โŠฅ | ๐‘คห† ๐‘ฅ i โˆ’ 2h๐‘ค 0 |ฮ ฮ˜ ฮ row(๐ด) ฮ ๐ป(๐‘ฅ)โŠฅ | ๐‘คห† ๐‘ฅ i โ‰ค    ๐‘Š+
                                              2
                                                                                    4
                                                                                    ฮ˜2 b
                                 kฮ ฮ˜ |๐‘ค0 ik 2 โˆ’ 2 kฮ ฮ˜ |๐‘ค0 ik ฮ ๐ป(๐‘ฅ)โŠฅ | ๐‘คห† ๐‘ฅ i โ‰ค         ๐‘Š+
                                                                                    4
                                                                              ๐œ…
                                                                           r
                                                                                    ฮ˜2 b
                                             kฮ ฮ˜ |๐‘ค 0 ik 2 โˆ’ 2 kฮ ฮ˜ |๐‘ค 0 ik        โ‰ค    ๐‘Š+ .
                                                                             ๐‘Šโˆ’     4

This is satisfied only when
                                                 r                       r
                                          ๐œ…     ๐œ…                                   ๐œ…
                                      r
                                                    ฮ˜2 b                     ฮ˜2 b
                       kฮ ฮ˜ |๐‘ค 0 ik โ‰ค         +    +   ๐‘Š+ โ‰ค 2                   ๐‘Š+ +
                                          ๐‘Šโˆ’   ๐‘Šโˆ’   4                        4      ๐‘Šโˆ’
                                        b+ + 4๐œ… .
                      kฮ ฮ˜ |๐‘ค0 ik 2 โ‰ค ฮ˜ 2๐‘Š                                                                      
                                             ๐‘Šโˆ’

    We will let ฮ˜ 2 =    1โˆ’4๐œ…
                               . Then when ๐‘“ (๐‘ฅ) = 0, we have
                        2๐‘Š
                         b+ ๐‘Šโˆ’

                                                        1     1
                                    kฮ 0 |๐‘ค0 ik 2 =          โ‰ฅ   =: ๐‘ž0 ,
                                                     ๐‘ค โˆ’ (๐‘ฅ) ๐‘Šโˆ’

                        T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                  18
                            S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

by [15, Lemma 3.3]. On the other hand, when ๐‘“ (๐‘ฅ) = 1, we have

                                                    ๐œ…    1 โˆ’ 4๐œ…   4๐œ…   1 + 4๐œ…
                      kฮ ฮ˜ |๐‘ค0 ik 2 โ‰ค ฮ˜ 2๐‘Š
                                        b+ + 4         =        +    =        =: ๐‘ž1 .
                                                    ๐‘Šโˆ’    2๐‘Šโˆ’     ๐‘Šโˆ’    2๐‘Šโˆ’
We want to distinguish these two cases using 1/ฮ˜ steps of phase estimation, and then estimating
the amplitude on having an estimate of 0 in the phase register to precision:
                                                    ๐‘ž0 โˆ’ ๐‘ž1 1 โˆ’ 4๐œ…
                                            ฮ”=             =       .
                                                       2     4๐‘Šโˆ’

This will allow us to distinguish between amplitude โ‰ฅ ๐‘ž0 and amplitude โ‰ค ๐‘ž1 . Since ๐œ… < 14
is a constant, ฮ” = ฮฉ(1/๐‘Šโˆ’ ), and thus we use ๐‘‚(1/ฮ”) = ๐‘‚(๐‘Šโˆ’ ) = ๐‘‚(1) (recall that we are
assuming the span program
                            has been scaled) calls to phase estimation, each of which requires
                 q
๐‘‚(1/ฮ˜) = ๐‘‚         ๐‘Š
                   b+๐‘Šโˆ’ = ๐‘‚(๐ถ) controlled calls to ๐‘ˆ (for more details, see the nearly identical
proof of [15, Lemma 3.2]). Since ๐‘ˆ(๐‘ƒ, ๐‘ฅ) can be implemented in cost one query, the query
complexity of this algorithm is ๐‘‚(๐ถ).
    The algorithm needs a single register of dimension dim ๐ป = ๐พ ๐‘‚(1) to apply ๐‘ˆ(๐‘ƒ, ๐‘ฅ), ๐‘‚(1)
registers of dimension 1/ฮ˜ to act as phase registers in phase estimation, and ๐‘‚(1) registers
of dimension ๐‘‚(1/ฮ”) to act as phase registers in the amplitude estimation, for a total space
requirement of
                                                             
                                       1         1
                     log dim ๐ป + ๐‘‚ log   + ๐‘‚ log   = ๐‘‚(log ๐พ) + ๐‘‚(log ๐ถ).
                                       ฮ”         ฮ˜

To complete the proof, we note that the algorithm is unitary, since it consists of phase estimation,
composed unitarily with amplitude estimation.                                                     

3.3   From quantum algorithms to span programs
In this section, we will show how to turn a unitary quantum algorithm into a span program,
proving Theorem 3.2, which implies Theorem 1.1. The construction we use to prove Theorem 3.2
is based on a construction of Reichardt for turning any one-sided error quantum algorithm
into a span program whose complexity matches the algorithmโ€™s query complexity [27, arXiv
version]. We observe that a similar construction also works for two-sided error algorithms,9 but
the resulting span program only approximately decides ๐‘“ .

The algorithm Fix a function ๐‘“ : ๐ท โ†’ {0, 1} for ๐ท โІ {0, 1} ๐‘› , and a unitary quantum algorithm
๐’œ such that on input ๐‘ฅ โˆˆ ๐‘“ โˆ’1 (0), Pr[๐’œ(๐‘ฅ) = 1] โ‰ค 13 , and on input ๐‘ฅ โˆˆ ๐‘“ โˆ’1 (1), Pr[๐’œ(๐‘ฅ) = 1] โ‰ฅ 1โˆ’ ๐œ€,
for ๐œ€ โˆˆ {0, 13 }, depending on whether we want to consider a one-sided error or a bounded error
algorithm. Let ๐‘0 (๐‘ฅ) = Pr[๐’œ(๐‘ฅ) = 0], so if ๐‘“ (๐‘ฅ) = 0, ๐‘0 (๐‘ฅ) โ‰ฅ 2/3, and if ๐‘“ (๐‘ฅ) = 1, ๐‘ 0 (๐‘ฅ) โ‰ค ๐œ€.
  9A preliminary version of this result appeared in [16], but there was an error in the proof, which is fixed by our
new definition of approximate span programs.


                        T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                    19
                                                S TACEY J EFFERY

     We can suppose ๐’œ acts on three registers: a query register span{| ๐‘—i : ๐‘— โˆˆ [๐‘›] โˆช {0}}; a
workspace register span{|๐‘งi : ๐‘ง โˆˆ ๐’ต} for some finite set of symbols ๐’ต that contains 0; and an
answer register span{|๐‘Ži : ๐‘Ž โˆˆ {0, 1}}. The query operator ๐’ช๐‘ฅ acts on the query register as
๐’ช๐‘ฅ | ๐‘—i = (โˆ’1)๐‘ฅ ๐‘— | ๐‘—i if ๐‘— โ‰ฅ 1, and ๐’ช๐‘ฅ |0i = |0i. If ๐’œ makes ๐‘‡ queries, the final state of ๐’œ is:

                              |ฮจ2๐‘‡+1 (๐‘ฅ)i = ๐‘ˆ2๐‘‡+1 ๐’ช๐‘ฅ ๐‘ˆ2๐‘‡โˆ’1 . . . ๐‘ˆ3 ๐’ช๐‘ฅ ๐‘ˆ1 |0, 0, 0i

for some unitaries ๐‘ˆ2๐‘‡+1 , . . . , ๐‘ˆ1 . The output bit of the algorithm, ๐’œ(๐‘ฅ), is obtained by measuring
the answer register of |ฮจ2๐‘‡+1 (๐‘ฅ)i. We have given the input-independent unitaries odd indicies
so that we may refer to the ๐‘ก-th query as ๐‘ˆ2๐‘ก .
    Let |ฮจ0 (๐‘ฅ)i = |ฮจ0 i = |0, 0, 0i denote the starting state, and for ๐‘ก โˆˆ {1, . . . , 2๐‘‡ + 1}, let
|ฮจ๐‘ก (๐‘ฅ)i = ๐‘ˆ๐‘ก . . . ๐‘ˆ1 |ฮจ0 i denote the state after ๐‘ก steps.

The span program We now define a span program ๐‘ƒ๐’œ from ๐’œ. The space ๐ป will represent
all three registers of the algorithm, with an additional time counter register, and an additional
register to represent a query value ๐‘.

    ๐ป = span{|๐‘ก, ๐‘, ๐‘—, ๐‘ง, ๐‘Ži : ๐‘ก โˆˆ {0, . . . , 2๐‘‡ + 1}, ๐‘ โˆˆ {0, 1}, ๐‘— โˆˆ [๐‘›] โˆช {0}, ๐‘ง โˆˆ ๐’ต, ๐‘Ž โˆˆ {0, 1}}.

We define ๐‘‰ and ๐ด as follows, where ๐‘ is some constant to be chosen later:

              ๐‘‰ = span{|๐‘ก, ๐‘—, ๐‘ง, ๐‘Ži : ๐‘ก โˆˆ {0, . . . , 2๐‘‡ + 1}, ๐‘— โˆˆ [๐‘›] โˆช {0}, ๐‘ง โˆˆ ๐’ต, ๐‘Ž โˆˆ {0, 1}}
                      ๏ฃฑ
                      ๏ฃด |๐‘ก, ๐‘—, ๐‘ง, ๐‘Ži โˆ’ |๐‘ก + 1i๐‘ˆ๐‘ก+1 | ๐‘—, ๐‘ง, ๐‘Ži if ๐‘ก โˆˆ {0, . . . , 2๐‘‡} is even
                      ๏ฃด |๐‘ก, ๐‘—, ๐‘ง, ๐‘Ži โˆ’ (โˆ’1)๐‘ |๐‘ก + 1, ๐‘—, ๐‘ง, ๐‘Ži if ๐‘ก โˆˆ {0, . . . , 2๐‘‡} is odd (i. e., ๐‘ˆ๐‘ก+1 = ๐’ช๐‘ฅ )
                      ๏ฃด
                      ๏ฃด
                      ๏ฃด
                         |๐‘ก, ๐‘—, ๐‘ง, ๐‘Ži                         if ๐‘ก = 2๐‘‡ + 1, ๐‘Ž = 1, and ๐‘ = 0
                      ๏ฃฒ
                      ๏ฃด
 ๐ด|๐‘ก, ๐‘, ๐‘—, ๐‘ง, ๐‘Ži =     โˆš
                          ๐‘๐‘‡ |๐‘ก, ๐‘—, ๐‘ง, ๐‘Ži                     if ๐‘ก = 2๐‘‡ + 1, ๐‘Ž = 0, and ๐‘ = 0
                      ๏ฃด
                      ๏ฃด
                      ๏ฃด
                      ๏ฃด
                                                              if ๐‘ก = 2๐‘‡ + 1 and ๐‘ = 1.
                      ๏ฃด
                      ๏ฃด 0
                      ๏ฃณ
For ๐‘ก โ‰ค 2๐‘‡, ๐ด|๐‘ก, ๐‘, ๐‘—, ๐‘ง, ๐‘Ži should be intuitively understood as applying ๐‘ˆ๐‘ก+1 to | ๐‘—, ๐‘ง, ๐‘Ži, and
incrementing the counter register from |๐‘กi to |๐‘ก + 1i. When ๐‘ก is even, this correspondence is
clear (in that case, the value of ๐‘ is ignored). When ๐‘ก is odd, so ๐‘ˆ๐‘ก+1 = ๐’ช๐‘ฅ , then as long as ๐‘ = ๐‘ฅ ๐‘— ,
(โˆ’1)๐‘ |๐‘ก + 1, ๐‘—, ๐‘ง, ๐‘Ži = |๐‘ก + 1i๐‘ˆ๐‘ก+1 | ๐‘—, ๐‘ง, ๐‘Ži. We thus define

               ๐ป ๐‘—,๐‘ = span{|๐‘ก, ๐‘, ๐‘—, ๐‘ง, ๐‘Ži : ๐‘ก โˆˆ {0, . . . , 2๐‘‡} is odd, ๐‘ง โˆˆ ๐’ต, ๐‘Ž โˆˆ {0, 1}}.

For even ๐‘ก, applying ๐‘ˆ๐‘ก+1 is independent of the input, so we make the corresponding states
available to every input; along with states where the query register is set to ๐‘— = 0, meaning ๐’ช๐‘ฅ
acts input-independently; and accepting states, whose answer register is set to 1 at time 2๐‘‡ + 1:

    ๐ปtrue = span{|๐‘ก, ๐‘, ๐‘—, ๐‘ง, ๐‘Ži : ๐‘ก โˆˆ {0, . . . , 2๐‘‡} is even, ๐‘ โˆˆ {0, 1}, ๐‘— โˆˆ [๐‘›], ๐‘ง โˆˆ ๐’ต, ๐‘Ž โˆˆ {0, 1}}
                       โŠ• span{|๐‘ก, ๐‘, 0, ๐‘ง, ๐‘Ži : ๐‘ก โˆˆ {0, . . . , 2๐‘‡}, ๐‘ โˆˆ {0, 1}, ๐‘ง โˆˆ ๐’ต, ๐‘Ž โˆˆ {0, 1}}
                       โŠ• span{|2๐‘‡ + 1, ๐‘, ๐‘—, ๐‘ง, 1i : ๐‘ โˆˆ {0, 1}, ๐‘— โˆˆ [๐‘›] โˆช {0}, ๐‘ง โˆˆ ๐’ต}.


                         T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                    20
                            S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

The remaining part of ๐ป will be assigned to ๐ปfalse :

                  ๐ปfalse = span{|2๐‘‡ + 1, ๐‘, ๐‘—, ๐‘ง, 0i : ๐‘ โˆˆ {0, 1}, ๐‘— โˆˆ [๐‘›] โˆช {0}, ๐‘ง โˆˆ ๐’ต}.
                                                      โˆš
Note that in defining ๐ด, we have put a large factor of ๐‘๐‘‡ in front of ๐ด|2๐‘‡ + 1, 0, ๐‘—, ๐‘ง, 0i, making
the vectors in ๐ปfalse very โ€œcheapโ€ to use. These vectors are โˆšnever in ๐ป(๐‘ฅ), but will be used as
the error part of approximate positive witnesses, and the ๐‘๐‘‡ ensures they only contribute
relatively small error.
    Finally, we define:

                                            |๐œi = |0, 0, 0, 0i = |0i|ฮจ0 i.

Intuitively, we can construct |๐œi, the initial state, using a final state that has 1 in the answer
register, and using the transitions |๐‘ก, ๐‘—, ๐‘ง, ๐‘Ži โˆ’ |๐‘ก + 1i๐‘ˆ๐‘ก+1 | ๐‘—, ๐‘ง, ๐‘Ži to move from the final state to
the initial state. In the following analysis, we make this idea precise.


Analysis of ๐‘ƒ๐’œ We will first show that for every ๐‘ฅ there is an approximate positive witness
with error depending on its probability of being rejected by ๐’œ, ๐‘0 (๐‘ฅ).

Lemma 3.14. For any ๐‘ฅ โˆˆ {0, 1} ๐‘› , there exists an approximate positive witness |๐‘คi for ๐‘ฅ in ๐‘ƒ๐’œ such
that:
                                                                   ๐‘ 0 (๐‘ฅ)
                                                                           .
                                                              2
                       k|๐‘คik 2 โ‰ค 2๐‘‡ + 2, and ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi โ‰ค
                                                                     ๐‘๐‘‡
In particular, if ๐‘“ (๐‘ฅ) = 1,
                                                                        ๐œ€
                                                                          .
                                                               2
                                                  ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi       โ‰ค
                                                                       ๐‘๐‘‡

Proof. Let ๐‘„ ๐‘ฅ be the linear isometry that acts as

                     ๐‘„ ๐‘ฅ | ๐‘—, ๐‘ง, ๐‘Ži = |๐‘ฅ ๐‘— , ๐‘—, ๐‘ง, ๐‘Ži   โˆ€๐‘— โˆˆ [๐‘›] โˆช {0}, ๐‘ง โˆˆ ๐’ต, ๐‘Ž โˆˆ {0, 1},

where we interpret ๐‘ฅ 0 as 0. Note that for all | ๐‘—, ๐‘ง, ๐‘Ži, and ๐‘ก โˆˆ {0, . . . , 2๐‘‡}, we have

                            ๐ด(|๐‘กi๐‘„ ๐‘ฅ | ๐‘—, ๐‘ง, ๐‘Ži) = |๐‘ก, ๐‘—, ๐‘ง, ๐‘Ži โˆ’ |๐‘ก + 1i๐‘ˆ๐‘ก+1 | ๐‘—, ๐‘ง, ๐‘Ži.

Let ฮ ๐‘Ž = ๐‘—โˆˆ[๐‘›]โˆช{0},๐‘งโˆˆ๐’ต | ๐‘—, ๐‘ง, ๐‘Žih๐‘—, ๐‘ง, ๐‘Ž| be the orthogonal projector onto states of the algorithm
           ร
with answer register set to ๐‘Ž. We will construct a positive witness for ๐‘ฅ from the states of the
algorithm on input ๐‘ฅ, as follows:

                2๐‘‡
                ร•                                                  1
        |๐‘คi =       |๐‘กi๐‘„ ๐‘ฅ |ฮจ๐‘ก (๐‘ฅ)i + |2๐‘‡ + 1i|0iฮ 1 |ฮจ2๐‘‡+1 (๐‘ฅ)i + โˆš |2๐‘‡ + 1i|0iฮ 0 |ฮจ2๐‘‡+1 (๐‘ฅ)i.
                ๐‘ก=0                                                ๐‘๐‘‡

                        T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                         21
                                                       S TACEY J EFFERY

To see that this is a positive witness, we compute ๐ด|๐‘คi, using the fact that ๐‘ˆ๐‘ก+1 |ฮจ๐‘ก (๐‘ฅ)i = |ฮจ๐‘ก+1 (๐‘ฅ)i.
            2๐‘‡
            ร•
  ๐ด|๐‘คi =          (|๐‘กi|ฮจ๐‘ก (๐‘ฅ)i โˆ’ |๐‘ก + 1i๐‘ˆ๐‘ก+1 |ฮจ๐‘ก (๐‘ฅ)i) + |2๐‘‡ + 1iฮ 1 |ฮจ2๐‘‡+1 (๐‘ฅ)i + |2๐‘‡ + 1iฮ 0 |ฮจ2๐‘‡+1 (๐‘ฅ)i
            ๐‘ก=0
            2๐‘‡
            ร•                       2๐‘‡
                                    ร•
        =         |๐‘กi|ฮจ๐‘ก (๐‘ฅ)i โˆ’           |๐‘ก + 1i|ฮจ๐‘ก+1 (๐‘ฅ)i + |2๐‘‡ + 1i|ฮจ2๐‘‡+1 (๐‘ฅ)i
            ๐‘ก=0                     ๐‘ก=0
            2๐‘‡+1
            ร•                       2๐‘‡+1
                                    ร•
        =          |๐‘กi|ฮจ๐‘ก (๐‘ฅ)i โˆ’           |๐‘กi|ฮจ๐‘ก (๐‘ฅ)i = |0i|ฮจ0 (๐‘ฅ)i = |๐œi.
            ๐‘ก=0                      ๐‘ก=1

    We next consider the error of |๐‘คi for ๐‘ฅ, given by ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi . Since ๐‘„ ๐‘ฅ | ๐‘—, ๐‘ง, ๐‘Ži โˆˆ ๐ป(๐‘ฅ) for
                                                                                      2

all ๐‘—, ๐‘ง, ๐‘Ž, and |2๐‘‡ + 1, 0iฮ 1 |ฮจ2๐‘‡+1 (๐‘ฅ)i โˆˆ ๐ปtrue โŠ‚ ๐ป(๐‘ฅ), ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi = โˆš1 |2๐‘‡ + 1i|0iฮ 0 |ฮจ2๐‘‡+1 (๐‘ฅ)i,
                                                                         ๐‘๐‘‡
so
                                                           1                      ๐‘ 0 (๐‘ฅ)
                                                                                          .
                                                  2
                                    ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi        =      kฮ 0 |ฮจ2๐‘‡+1 (๐‘ฅ)ik 2 =
                                                          ๐‘๐‘‡                        ๐‘๐‘‡
    Finally, we compute an upper bound on the positive witness complexity of |๐‘คi.
                              2๐‘‡
                              ร•                                                     1
                  k|๐‘คik 2 =         k๐‘„ ๐‘ฅ |ฮจ๐‘ก (๐‘ฅ)ik 2 + kฮ 1 |ฮจ2๐‘‡+1 (๐‘ฅ)ik 2 +           kฮ 0 |ฮจ2๐‘‡+1 (๐‘ฅ)ik 2
                                                                                   ๐‘๐‘‡
                              ๐‘ก=0
                              2๐‘‡
                              ร•
                          โ‰ค         k|ฮจ๐‘ก (๐‘ฅ)ik 2 + k|ฮจ2๐‘‡+1 (๐‘ฅ)ik 2 = 2๐‘‡ + 2.                               
                              ๐‘ก=0

    Next, we compute an upper bound on ๐‘คโˆ’ (๐‘ฅ) whenever ๐‘“ (๐‘ฅ) = 0.
Lemma 3.15. For any ๐‘ฅ that is rejected by ๐’œ with probability ๐‘ 0 (๐‘ฅ) > 0,
                                                                   (๐‘ + 4)๐‘‡
                                                      ๐‘คโˆ’ (๐‘ฅ) โ‰ค              .
                                                                     ๐‘0 (๐‘ฅ)

In particular, if ๐‘“ (๐‘ฅ) = 0, ๐‘ค โˆ’ (๐‘ฅ) โ‰ค ๐‘+4
                                       2/3
                                           ๐‘‡, so ๐‘Šโˆ’ โ‰ค ๐‘+4
                                                      2/3
                                                          ๐‘‡.

Proof. We will define a negative witness for ๐‘ฅ as follows. First, define

                                              |ฮจ02๐‘‡+1 (๐‘ฅ)i = ฮ 0 |ฮจ2๐‘‡+1 (๐‘ฅ)i,

the rejecting part of the final state. This is non-zero whenever ๐‘ 0 (๐‘ฅ) > 0. Then for ๐‘ก โˆˆ {0, . . . , 2๐‘‡},
define
                                                โ€          โ€ 
                                  |ฮจ0๐‘ก (๐‘ฅ)i = ๐‘ˆ๐‘ก+1 . . . ๐‘ˆ2๐‘‡+1 |ฮจ02๐‘‡+1 (๐‘ฅ)i.
From this we can define
                                                            2๐‘‡+1
                                                            ร•
                                                  h๐œ”| =            h๐‘ก|hฮจ0๐‘ก (๐‘ฅ)|.
                                                             ๐‘ก=0


                         T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                             22
                              S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

We first observe that
     h๐œ”|๐œi = hฮจ00 (๐‘ฅ)|0, 0, 0i = hฮจ02๐‘‡+1 (๐‘ฅ)|๐‘ˆ2๐‘‡+1 . . . ๐‘ˆ1 |0, 0, 0i = hฮจ02๐‘‡+1 (๐‘ฅ)|ฮจ2๐‘‡+1 (๐‘ฅ)i = ๐‘0 (๐‘ฅ).
Thus
                                                                  1
                                                      h ๐œ”|
                                                        ยฏ =            h๐œ”|
                                                               ๐‘ 0 (๐‘ฅ)
is a negative witness. Next, we show that h๐œ”|๐ดฮ ๐ป(๐‘ฅ) = 0. First, for |๐‘ก, ๐‘ฅ ๐‘— , ๐‘—, ๐‘ง, ๐‘Ži โˆˆ ๐ป ๐‘—,๐‘ฅ ๐‘— (so
๐‘ก < 2๐‘‡ is odd), we have
                h๐œ”|๐ด|๐‘ก, ๐‘ฅ ๐‘— , ๐‘—, ๐‘ง, ๐‘Ži = h๐œ”|(|๐‘ก, ๐‘—, ๐‘ง, ๐‘Ži โˆ’ (โˆ’1)๐‘ฅ ๐‘— |๐‘ก + 1i| ๐‘—, ๐‘ง, ๐‘Ži)
                                          = hฮจ0๐‘ก (๐‘ฅ)| ๐‘—, ๐‘ง, ๐‘Ži โˆ’ (โˆ’1)๐‘ฅ ๐‘— hฮจ0๐‘ก+1 (๐‘ฅ)| ๐‘—, ๐‘ง, ๐‘Ži
                                          = hฮจ0๐‘ก+1 (๐‘ฅ)|๐‘ˆ๐‘ก+1 | ๐‘—, ๐‘ง, ๐‘Ži โˆ’ (โˆ’1)๐‘ฅ ๐‘— hฮจ0๐‘ก+1 (๐‘ฅ)| ๐‘—, ๐‘ง, ๐‘Ži
                                          = hฮจ0๐‘ก+1 (๐‘ฅ)|๐’ช๐‘ฅ | ๐‘—, ๐‘ง, ๐‘Ži โˆ’ (โˆ’1)๐‘ฅ ๐‘— hฮจ0๐‘ก+1 (๐‘ฅ)| ๐‘—, ๐‘ง, ๐‘Ži = 0.
The same argument holds for |๐‘ก, 0, 0, ๐‘—, ๐‘ง, ๐‘Ži โˆˆ ๐ปtrue . Similarly, for any |๐‘ก, ๐‘, ๐‘—, ๐‘ง, ๐‘Ži โˆˆ ๐ปtrue with
๐‘ก โ‰ค 2๐‘‡ even, we have
                      h๐œ”|๐ด|๐‘ก, ๐‘, ๐‘—, ๐‘ง, ๐‘Ži = h๐œ”|(|๐‘ก, ๐‘—, ๐‘ง, ๐‘Ži โˆ’ |๐‘ก + 1i๐‘ˆ๐‘ก+1 | ๐‘—, ๐‘ง, ๐‘Ži)
                                               = hฮจ0๐‘ก (๐‘ฅ)| ๐‘—, ๐‘ง, ๐‘Ži โˆ’ hฮจ0๐‘ก+1 (๐‘ฅ)|๐‘ˆ๐‘ก+1 | ๐‘—, ๐‘ง, ๐‘Ži = 0.
Finally, for any |2๐‘‡ + 1, ๐‘, ๐‘—, ๐‘ง, 1i โˆˆ ๐ปtrue , we have
                  h๐œ”|๐ด|2๐‘‡ + 1, ๐‘, ๐‘—, ๐‘ง, 1i = h๐œ”|2๐‘‡ + 1, ๐‘—, ๐‘ง, 1i = hฮจ02๐‘‡+1 (๐‘ฅ)| ๐‘—, ๐‘ง, 1i = 0.
Thus h๐œ”|๐ดฮ ๐ป(๐‘ฅ) = 0 and so h๐œ”|๐ดฮ ยฏ    ๐ป(๐‘ฅ) = 0, and h ๐œ”|
                                                    ยฏ is a negative witness for ๐‘ฅ in ๐‘ƒ. To compute
its witness complexity, first observe that h๐œ”|๐ด = h๐œ”|๐ดฮ ๐ป(๐‘ฅ)โŠฅ , and
                      ๐‘‡
                      ร•            ร•
       ๐ดฮ ๐ป(๐‘ฅ)โŠฅ =                                    (|2๐‘  โˆ’ 1, ๐‘—, ๐‘ง, ๐‘Ži + (โˆ’1)๐‘ฅ ๐‘— |2๐‘ , ๐‘—, ๐‘ง, ๐‘Ži)h2๐‘  โˆ’ 1, ๐‘ฅยฏ ๐‘— , ๐‘—, ๐‘ง, ๐‘Ž|
                      ๐‘ =1 ๐‘—โˆˆ[๐‘›]โˆช{0},๐‘งโˆˆ๐’ต,๐‘Žโˆˆ{0,1}
                              ร•           โˆš
                      +                       ๐‘๐‘‡ |2๐‘‡ + 1, ๐‘—, ๐‘ง, 0ih2๐‘‡ + 1, 0, ๐‘—, ๐‘ง, 0|
                          ๐‘—โˆˆ[๐‘›]โˆช{0},๐‘งโˆˆ๐’ต

so, using hฮจ02๐‘ โˆ’1 (๐‘ฅ)| ๐‘—, ๐‘ง, ๐‘Ži = hฮจ02๐‘  (๐‘ฅ)|๐‘ˆ2๐‘  | ๐‘—, ๐‘ง, ๐‘Ži = (โˆ’1)๐‘ฅ ๐‘— hฮจ02๐‘  (๐‘ฅ)| ๐‘—, ๐‘ง, ๐‘Ži, we have:
                  ๐‘‡
                  ร•              ร•
h๐œ”|๐ดฮ ๐ป(๐‘ฅ)โŠฅ =                                      (hฮจ02๐‘ โˆ’1 (๐‘ฅ)| ๐‘—, ๐‘ง, ๐‘Ži + (โˆ’1)๐‘ฅ ๐‘— hฮจ02๐‘  (๐‘ฅ)| ๐‘—, ๐‘ง, ๐‘Ži)h2๐‘  โˆ’ 1, ๐‘ฅยฏ ๐‘— , ๐‘—, ๐‘ง, ๐‘Ž|
                  ๐‘ =1 ๐‘—โˆˆ[๐‘›]โˆช{0},๐‘งโˆˆ๐’ต,๐‘Žโˆˆ{0,1}
                            ร•         โˆš
                  +                       ๐‘๐‘‡ hฮจ02๐‘‡+1 (๐‘ฅ)| ๐‘—, ๐‘ง, 0ih2๐‘‡ + 1, 0, ๐‘—, ๐‘ง, 0|
                      ๐‘—โˆˆ[๐‘›]โˆช{0},๐‘งโˆˆ๐’ต
                  ๐‘‡
                  ร•              ร•
              =                                   2(โˆ’1)๐‘ฅ ๐‘— hฮจ02๐‘  (๐‘ฅ)| ๐‘—, ๐‘ง, ๐‘Ži)h2๐‘  โˆ’ 1, ๐‘ฅยฏ ๐‘— , ๐‘—, ๐‘ง, ๐‘Ž|
                  ๐‘ =1 ๐‘—โˆˆ[๐‘›]โˆช{0},๐‘งโˆˆ๐’ต,๐‘Žโˆˆ{0,1}
                            ร•         โˆš
                  +                       ๐‘๐‘‡ hฮจ02๐‘‡+1 (๐‘ฅ)| ๐‘—, ๐‘ง, 0ih2๐‘‡ + 1, 0, ๐‘—, ๐‘ง, 0|.
                      ๐‘—โˆˆ[๐‘›]โˆช{0},๐‘งโˆˆ๐’ต


                           T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                            23
                                                    S TACEY J EFFERY

Thus, the complexity of h ๐œ”|
                          ยฏ is:
                     1
   kh๐œ”|๐ดk 2                          2
     ยฏ      =             h๐œ”|๐ดฮ ๐ป(๐‘ฅ)โŠฅ
                 ๐‘ 0 (๐‘ฅ)2
                           ๐‘‡
                     1 ร•          ร•                               2        1        ร•                                     2
             =                               4 hฮจ02๐‘  (๐‘ฅ)| ๐‘—, ๐‘ง, ๐‘Ži +                           ๐‘๐‘‡ hฮจ02๐‘‡+1 (๐‘ฅ)| ๐‘—, ๐‘ง, 0i
                 ๐‘ 0 (๐‘ฅ)2 ๐‘ =1                                          ๐‘ 0 (๐‘ฅ)2
                                ๐‘—โˆˆ[๐‘›]โˆช{0},                                        ๐‘—โˆˆ[๐‘›]โˆช{0},
                                   ๐‘งโˆˆ๐’ต,                                              ๐‘งโˆˆ๐’ต
                                  ๐‘Žโˆˆ{0,1}
                           ๐‘‡
                     4 ร•                2     ๐‘๐‘‡                2
             =                |ฮจ02๐‘  (๐‘ฅ)i +          |ฮจ02๐‘‡+1 (๐‘ฅ)i .
                 ๐‘ 0 (๐‘ฅ)2 ๐‘ =1              ๐‘ 0 (๐‘ฅ)2

Because each ๐‘ˆ๐‘ก is unitary, we have |ฮจ02๐‘  (๐‘ฅ)i                                          = ๐‘ 0 (๐‘ฅ), thus:
                                                            2                       2
                                                                = |ฮจ02๐‘‡+1 (๐‘ฅ)i
                                              4๐‘‡       ๐‘๐‘‡      4+๐‘
                           kh ๐œ”|๐ดk
                              ยฏ    2
                                     =              +        โ‰ค     ๐‘‡ when ๐‘“ (๐‘ฅ) = 0.                                          
                                             ๐‘ 0 (๐‘ฅ) ๐‘ 0 (๐‘ฅ)   2/3
    We conclude the proof of Theorem 3.2 with the following corollary, from which Theorem 3.2
follows immediately, by appealing to Claim 3.8 with ๐œ… = 10
                                                         9
                                                           and ๐œ…0 any constant in (0, 1).
Corollary 3.16. Let ๐‘ = 5, in the definition of ๐‘ƒ๐’œ . Then:
   โ€ข ๐‘ (๐‘ƒ๐’œ ) = 2๐‘†+๐‘‚(1)
   โ€ข If ๐’œ decides ๐‘“ with one-sided error, then ๐‘ƒ๐’œ decides ๐‘“ with complexity ๐ถ โ‰ค ๐‘‚(๐‘‡).
   โ€ข If ๐’œ decides ๐‘“ with bounded error, then ๐‘ƒ๐’œ 10
                                                9
                                                   -approximates ๐‘“ with complexity ๐ถ๐œ… โ‰ค ๐‘‚(๐‘‡).
Proof. We first compute ๐‘ (๐‘ƒ๐’œ ) = dim ๐ป using the fact that the algorithm uses space
                 ๐‘† = log dim span{| ๐‘—, ๐‘ง, ๐‘Ži : ๐‘— โˆˆ [๐‘›] โˆช {0}, ๐‘ง โˆˆ ๐’ต, ๐‘Ž โˆˆ {0, 1}} + log ๐‘‡.
We have:
           dim ๐ป = (dim span{|๐‘ก, ๐‘i : ๐‘ก โˆˆ {0, . . . , 2๐‘‡ + 1}, ๐‘ โˆˆ {0, 1}})2๐‘†โˆ’log ๐‘‡ = 2๐‘†+๐‘‚(1) .
   We prove the third statement, as the second is similar. By Lemma 3.15, using ๐‘ = 5, we have
                                                        5+4    27
                                                 ๐‘Šโˆ’ โ‰ค       ๐‘‡ = ๐‘‡.
                                                        2/3     2
By Lemma 3.14, we can see that for every ๐‘ฅ such that ๐‘“ (๐‘ฅ) = 1, there is an approximate positive
witness |๐‘คi for ๐‘ฅ with error at most

                                         ๐œ€          1 2๐‘‡
                                                       27
                                             1/3             9 1
                                           =     โ‰ค        =       .
                                        ๐‘๐‘‡   5๐‘‡    15๐‘‡ ๐‘Šโˆ’   10 ๐‘Šโˆ’
                                                                                               q              p
Furthermore, k|๐‘คik โ‰ค 2๐‘‡ + 2, so ๐‘Š
                       2        b+ โ‰ค 2๐‘‡ + 2. Observing ๐ถ๐œ… =                                       ๐‘Šโˆ’๐‘Š
                                                                                                    b+ โ‰ค          27๐‘‡(๐‘‡ + 1)
completes the proof.                                                                                                          

                       T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                                  24
                           S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

4    Span programs and space complexity
Using the transformation from algorithms to span programs from Section 3.3, we immediately
have the following connections between span program size and space complexity.

Theorem 4.1. For any ๐‘“ : ๐ท โ†’ {0, 1} for ๐ท โІ {0, 1} ๐‘› , we have
                                              
                     S๐‘ˆ ( ๐‘“ ) โ‰ฅ ฮฉ log SP
                                      f( ๐‘“ )                          ( ๐‘“ ) โ‰ฅ ฮฉ log SP( ๐‘“ ) .
                                                                    1
                                                                                                  
                                                       and         S๐‘ˆ

Theorem 4.1 is a corollary of Theorem 3.2. Theorem 3.1 shows that the lower bound for S๐‘ˆ ( ๐‘“ ) in
Theorem 4.1 is part of a tight correspondence between space complexity and log ๐‘ (๐‘ƒ) + log ๐ถ(๐‘ƒ).
   Theorem 2.9 of [5] gives a lower bound of SP( ๐‘“ ) โ‰ฅ ฮฉ(2๐‘›/3 /(๐‘› log ๐‘›)1/3 ) for almost all ๐‘›-bit
Boolean functions. Combined with Theorem 4.1, we immediately have:

Theorem 4.2. For almost all Boolean functions ๐‘“ : {0, 1} ๐‘› โ†’ {0, 1}, S๐‘ˆ
                                                                      1
                                                                        ( ๐‘“ ) = ฮฉ(๐‘›).

    Ideally, we would like to use the lower bound in Theorem 4.1 to prove a non-trivial lower
bound for S๐‘ˆ ( ๐‘“ ) or S๐‘ˆ
                       1
                         ( ๐‘“ ) for some explicit function ๐‘“ . Fortunately, there are somewhat nice
expressions lower bounding SP( ๐‘“ ) [25, 11], which we extend to lower bounds of SP      f ( ๐‘“ ) in the
remainder of this section. However, on the unfortunate side, there has already been significant
motivation to instantiate these expressions to non-trivial lower bounds for explicit ๐‘“ , with no
success. There has been some success in monotone versions of these lower bounds, which we
discuss more in Section 5.

    For a function ๐‘“ : ๐ท โ†’ {0, 1} for ๐ท โІ {0, 1} ๐‘› , and an index ๐‘— โˆˆ [๐‘›], we let ฮ” ๐‘“ ,๐‘— โˆˆ
{0, 1} ๐‘“ (0)ร— ๐‘“ (1) be defined by ฮ” ๐‘“ ,๐‘— [๐‘ฆ, ๐‘ฅ] = 1 if and only if ๐‘ฅ ๐‘— โ‰  ๐‘ฆ ๐‘— . When ๐‘“ is clear from context,
        โˆ’1     โˆ’1


we simply denote this by ฮ” ๐‘— . The following tight characterization of SP( ๐‘“ ) may be found in, for
example, [23].

Lemma 4.3. For any ๐‘“ : ๐ท โ†’ {0, 1} for ๐ท โІ {0, 1} ๐‘› ,
                                                      ร•
                            SP( ๐‘“ ) = minimize                rank(ฮ› ๐‘— )
                                                      ๐‘—โˆˆ[๐‘›]

                                       subject to โˆ€๐‘— โˆˆ [๐‘›], ฮ› ๐‘— โˆˆ โ„ ๐‘“
                                                                               โˆ’1 (0)ร— ๐‘“ โˆ’1 (1)

                                                      ร•
                                                              ฮ› ๐‘— โ—ฆ ฮ” ๐‘— = ๐ฝ,
                                                      ๐‘—โˆˆ[๐‘›]


where ๐ฝ is the ๐‘“ โˆ’1 (0) ร— ๐‘“ โˆ’1 (1) all-ones matrix.

    By Theorem 4.1, the logarithm of the above is a lower bound on S๐‘ˆ
                                                                    1
                                                                      ( ๐‘“ ). We modify Lemma 4.3
to get the following approximate version, whose logarithm lower bounds S๐‘ˆ ( ๐‘“ ) when ๐œ… = 14 .



                       T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                             25
                                                           S TACEY J EFFERY

Lemma 4.4. For any ๐œ… โˆˆ [0, 1), and ๐‘“ : ๐ท โ†’ {0, 1} for ๐ท โІ {0, 1} ๐‘› ,
                                                                  ร•
                               f ๐œ… ( ๐‘“ ) โ‰ฅ minimize
                               SP                                           rank(ฮ› ๐‘— )                                                      (4.1)
                                                                  ๐‘—โˆˆ[๐‘›]

                                              subject to โˆ€๐‘— โˆˆ [๐‘›], ฮ› ๐‘— โˆˆ โ„ ๐‘“
                                                                                              โˆ’1 (0)ร— ๐‘“ โˆ’1 (1)



                                                                     ร•                                โˆš
                                                                                ฮ›๐‘— โ—ฆ ฮ”๐‘— โˆ’ ๐ฝ       โ‰ค       ๐œ….
                                                                    ๐‘—โˆˆ[๐‘›]
                                                                                              โˆž

Proof. Fix a span program that ๐œ…-approximates ๐‘“ with ๐‘ (๐‘ƒ) = SP   f ๐œ… ( ๐‘“ ), and let {h๐œ” ๐‘ฆ | : ๐‘ฆ โˆˆ ๐‘“ โˆ’1 (0)}
be optimal negative witnesses, and {|๐‘ค ๐‘ฅ i : ๐‘ฅ โˆˆ ๐‘“ (1)} be approximate positive witnesses with
                                                   โˆ’1

 ฮ ๐ป(๐‘ฅ) |๐‘ค ๐‘ฅ i โ‰ค ๐‘Š๐œ…โˆ’ . Letting ฮ  ๐‘—,๐‘ denote the projector onto ๐ป ๐‘—,๐‘ , define
             2

                                                                            !                           !
                                        ร•                                        ร•
                                ฮ›๐‘— =            |๐‘ฆih๐œ” ๐‘ฆ |๐ดฮ  ๐‘—, ๐‘ฆยฏ ๐‘—                   ฮ  ๐‘—,๐‘ฅ ๐‘— |๐‘ค ๐‘ฅ ih๐‘ฅ| ,
                                          ๐‘ฆ                                       ๐‘ฅ


so ฮ› ๐‘— has rank at most dim ๐ป ๐‘— , and so ๐‘—โˆˆ[๐‘›] rank(ฮ› ๐‘— ) โ‰ค ๐‘ (๐‘ƒ) = SP    f ๐œ… ( ๐‘“ ).
                                                      ร
     We now show that {ฮ› ๐‘— } ๐‘— is a feasible solution. Let | err(๐‘ฅ)i be the positive witness error of
|๐‘ค ๐‘ฅ i, | err(๐‘ฅ)i = ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘ค ๐‘ฅ i = ๐‘›๐‘—=1 ฮ  ๐‘—, ๐‘ฅยฏ ๐‘— |๐‘ค ๐‘ฅ i. Then we have:
                                   ร

              ๐‘›
              ร•                                ร•                                                       ร•
        h๐‘ฆ|         ฮ› ๐‘— โ—ฆ ฮ” ๐‘— |๐‘ฅi = h๐œ” ๐‘ฆ |๐ด                ฮ  ๐‘—,๐‘ฅ ๐‘— |๐‘ค ๐‘ฅ i = h๐œ” ๐‘ฆ |๐ด ยญ |๐‘ค ๐‘ฅ i โˆ’                     ฮ  ๐‘—,๐‘ฅ ๐‘— |๐‘ค ๐‘ฅ i โˆ’ | err(๐‘ฅ)i ยฎ
                                                                                          ยฉ                                                  ยช
              ๐‘—=1                             ๐‘—:๐‘ฅ ๐‘— โ‰ ๐‘ฆ ๐‘—                                  ยซ           ๐‘—:๐‘ฅ ๐‘— =๐‘ฆ ๐‘—                             ยฌ
                                                                 ร•
                                = h๐œ” ๐‘ฆ |๐œi โˆ’ h๐œ” ๐‘ฆ |๐ด                        ฮ ๐ป(๐‘ฆ) ฮ  ๐‘—,๐‘ฅ ๐‘— |๐‘ค ๐‘ฅ i โˆ’ h๐œ” ๐‘ฆ |๐ด| err(๐‘ฅ)i
                                                               ๐‘—:๐‘ฅ ๐‘— =๐‘ฆ ๐‘—

                                = 1 โˆ’ 0 โˆ’ h๐œ” ๐‘ฆ |๐ด| err(๐‘ฅ)i
             ๐‘›
                                                                                          ๐œ…   โˆš
             ร•                                                              r
   1 โˆ’ h๐‘ฆ|          ฮ› ๐‘— โ—ฆ ฮ” ๐‘— |๐‘ฅi โ‰ค h๐œ” ๐‘ฆ |๐ด k| err(๐‘ฅ)ik =                       ๐‘ค โˆ’ (๐‘ฆ)      โ‰ค ๐œ….
                                                                                          ๐‘Šโˆ’
              ๐‘—=1

Above we used the fact that h๐œ” ๐‘ฆ |๐ดฮ ๐ป(๐‘ฆ) = 0. Thus, {ฮ› ๐‘— } ๐‘— is a feasible solution with objective
        f ๐œ… ( ๐‘“ ), so the result follows.
value โ‰ค SP                                                                                       
    As a corollary of the above, and the connection between span program size and unitary
quantum space complexity stated in Theorem 4.1, the logarithm of the expression in (4.1) with
๐œ… = 41 is a lower bound on S๐‘ˆ ( ๐‘“ ), and with ๐œ… = 0, it is a lower bound on S๐‘ˆ
                                                                             1
                                                                               ( ๐‘“ ). However, as
stated, it is difficult to use this expression to prove an explicit lower bound, because it is a
minimization problem. We will shortly give a lower bound in terms of a maximization problem,
making it possible to obtain explicit lower bounds by exhibiting a feasible solution.
    A partial matrix is a matrix ๐‘€ โˆˆ (โ„ โˆช {โ˜…}) ๐‘“ (0)ร— ๐‘“ (1) . A completion of ๐‘€ is any ๐‘€ โˆˆ
                                                     โˆ’1    โˆ’1


โ„ ๐‘“ (0)ร— ๐‘“ (1) such that ๐‘€[๐‘ฆ, ๐‘ฅ] = ๐‘€[๐‘ฆ, ๐‘ฅ] whenever ๐‘€[๐‘ฆ, ๐‘ฅ] โ‰  โ˜…. For a partial matrix ๐‘€, define
   โˆ’1     โˆ’1




                          T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                                                   26
                        S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

rank(๐‘€) to be the smallest rank of any completion of ๐‘€, and ๐œ€-rank(๐‘€) to be the smallest rank
of any ๐‘€หœ such that |๐‘€[๐‘ฆ, ๐‘ฅ] โˆ’ ๐‘€[๐‘ฆ,
                               หœ     ๐‘ฅ]| โ‰ค ๐œ€ for all ๐‘ฆ, ๐‘ฅ such that ๐‘€[๐‘ฆ, ๐‘ฅ] โ‰  โ˜…. Let ๐‘€ โ—ฆ ฮ”๐‘– to be
the partial matrix defined:

                                                          ๐‘€[๐‘ฆ, ๐‘ฅ] if ฮ”๐‘– [๐‘ฆ, ๐‘ฅ] = 1
                                                   
                           ๐‘€ โ—ฆ ฮ”๐‘– [๐‘ฆ, ๐‘ฅ] =
                                                          0       if ฮ”๐‘– [๐‘ฆ, ๐‘ฅ] = 0.

Then we have the following corollary of [11, Lemma 3.2, Theorem 3.4] and Theorem 4.1:

Lemma 4.5. For all Boolean functions ๐‘“ : ๐ท โ†’ {0, 1}, with ๐ท โІ {0, 1} ๐‘› , and all partial matrices
๐‘€ โˆˆ (โ„ โˆช {โ˜…}) ๐‘“ (0)ร— ๐‘“ (1) such that max{|๐‘€[๐‘ฆ, ๐‘ฅ]| : ๐‘€[๐‘ฆ, ๐‘ฅ] โ‰  โ˜…} โ‰ค 1:
               โˆ’1     โˆ’1


                                                                                   
                                                           rank(๐‘€)
                            1
                           S๐‘ˆ (๐‘“) โ‰ฅ ฮฉ            log                                      .
                                                     max๐‘–โˆˆ[๐‘›] rank(๐‘€ โ—ฆ ฮ”๐‘– )

    In [25], Razborov showed that the expression on the right-hand side in Lemma 4.5 is a lower
bound on the logarithm of the formula size of ๐‘“ (Ref. [11] related this to SP( ๐‘“ )). Later, in [26],
Razborov noted that when restricted to non-partial matrices, this can never give a better bound
than ๐‘›. Thus, to prove a non-trivial lower bound on S๐‘ˆ1
                                                        ( ๐‘“ ) using this method, one would need
to use a partial matrix. We prove the following generalization to the approximate case.

Lemma 4.6. For all Boolean functions ๐‘“ : ๐ท โ†’ {0, 1}, with ๐ท โІ {0, 1} ๐‘› , and all partial matrices
๐‘€ โˆˆ (โ„ โˆช {โ˜…}) ๐‘“ (0)ร— ๐‘“ (1) such that max{|๐‘€[๐‘ฆ, ๐‘ฅ]| : ๐‘€[๐‘ฆ, ๐‘ฅ] โ‰  โ˜…} โ‰ค 1:
               โˆ’1     โˆ’1


                                                                                     !!
                                                                 2 -rank(๐‘€)
                                                                 1
                           S๐‘ˆ ( ๐‘“ ) โ‰ฅ ฮฉ log                                               .
                                                          max๐‘–โˆˆ[๐‘›] rank(๐‘€ โ—ฆ ฮ”๐‘– )

Proof. Let {ฮ› ๐‘— } ๐‘— be an optimal feasible solution for the expression from Lemma 4.4, so

                                ร•                                   ร•                             โˆš
                   f ๐œ…( ๐‘“ ) โ‰ฅ
                   SP                   rank(ฮ› ๐‘— ),        and              ฮ›๐‘— โ—ฆ ฮ”๐‘— โˆ’ ๐ฝ       โ‰ค    ๐œ….
                                ๐‘—โˆˆ[๐‘›]                               ๐‘—โˆˆ[๐‘›]
                                                                                          โˆž


Let ๐‘€ ๐‘— be a completion of ๐‘€ โ—ฆ ฮ” ๐‘— with rank(๐‘€ โ—ฆ ฮ” ๐‘— ) = rank(๐‘€ ๐‘— ). Then for any ๐‘ฅ, ๐‘ฆ such that
๐‘€[๐‘ฆ, ๐‘ฅ] โ‰  โ˜…:


           ยฉร•                                     ร•
                   ๐‘€ ๐‘— โ—ฆ ฮ› ๐‘— ยฎ [๐‘ฆ, ๐‘ฅ] โˆ’ ๐‘€[๐‘ฆ, ๐‘ฅ] =       ๐‘€[๐‘ฆ, ๐‘ฅ]ฮ” ๐‘— [๐‘ฆ, ๐‘ฅ]ฮ› ๐‘— [๐‘ฆ, ๐‘ฅ] โˆ’ ๐‘€[๐‘ฆ, ๐‘ฅ]
                             ยช
           ยญ
           ยซ ๐‘—โˆˆ[๐‘›]           ยฌ                    ๐‘—โˆˆ[๐‘›]

                                                             ร•                        โˆš
                                                       โ‰ค |๐‘€[๐‘ฆ, ๐‘ฅ]|              ฮ”๐‘— โ—ฆ ฮ›๐‘— โˆ’ ๐ฝ       โ‰ค     ๐œ….
                                                                        ๐‘—โˆˆ[๐‘›]
                                                                                              โˆž


                     T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                   27
                                               S TACEY J EFFERY

Thus

                     โˆš                         ยฉร•                       ร•
                         ๐œ…-rank(๐‘€) โ‰ค rank ยญ              ๐‘€ ๐‘— โ—ฆ ฮ›๐‘— ยฎ โ‰ค           rank(๐‘€ ๐‘— โ—ฆ ฮ› ๐‘— ).
                                                                 ยช

                                               ยซ ๐‘—โˆˆ[๐‘›]           ยฌ      ๐‘—โˆˆ[๐‘›]


Using the fact that for any matrices ๐ต and ๐ถ, rank(๐ต โ—ฆ ๐ถ) โ‰ค rank(๐ต)rank(๐ถ), we have
               โˆš                 ร•
                   ๐œ…-rank(๐‘€) โ‰ค                                  f ๐œ… ( ๐‘“ ) max rank(๐‘€ โ—ฆ ฮ” ๐‘— ).
                                         rank(ฮ› ๐‘— )rank(๐‘€ ๐‘— ) โ‰ค SP
                                                                                 ๐‘—โˆˆ[๐‘›]
                                 ๐‘—โˆˆ[๐‘›]


Setting ๐œ… = 14 , and noting that by Theorem 4.1, S๐‘ˆ ( ๐‘“ ) โ‰ฅ log SP
                                                                f ( ๐‘“ ) = log SP
                                                                              f 1/4 ( ๐‘“ ) completes the
proof.                                                                                                

    Unfortunately, as far as we are aware, nobody has used this lower bound to successfully
prove any explicit, non-trivial formula size lower bound of 2๐œ”(log ๐‘›) , so it seems to be quite
difficult. However, there has been some success proving lower bounds in the monotone span
program case, even without resorting to partial matrices, which we discuss in the next section.


5   Monotone span programs and monotone algorithms
A monotone function is a Boolean function in which ๐‘ฆ โ‰ค ๐‘ฅ implies ๐‘“ (๐‘ฆ) โ‰ค ๐‘“ (๐‘ฅ), where ๐‘ฆ โ‰ค ๐‘ฅ
should be interpreted bitwise. In other words, flipping 0s to 1s either keeps the function value
the same, or changes it from 0 to 1. A monotone span program is a span program in which
๐ป๐‘–,0 = {0} for all ๐‘–, so only 1-valued queries contribute to ๐ป(๐‘ฅ), hence ๐ป(๐‘ฆ) โІ ๐ป(๐‘ฅ) whenever
๐‘ฆ โ‰ค ๐‘ฅ. A monotone span program can only decide or approximate a monotone function.

Definition 5.1. For a monotone function ๐‘“ , define the monotone span program size, denoted mSP( ๐‘“ ),
as the minimum ๐‘ (๐‘ƒ) over (families of) monotone span programs ๐‘ƒ such that ๐‘ƒ decides ๐‘“ ; and
the approximate monotone span program size, denoted mSPf ๐œ… ( ๐‘“ ), as the minimum ๐‘ (๐‘ƒ) over (families
of) monotone span programs ๐‘ƒ such that ๐‘ƒ ๐œ…-approximates ๐‘“ . We let mSP        f ( ๐‘“ ) = mSP
                                                                                         f 1/4 ( ๐‘“ ).

    In contrast to SP( ๐‘“ ), there are non-trivial lower bounds for mSP( ๐‘“ ) for explicit monotone
functions ๐‘“ . However, this does not necessarily give a lower bound on SP( ๐‘“ ), and in particular,
may not be a lower bound on the one-sided error quantum space complexity of ๐‘“ . However, lower
bounds on log mSP( ๐‘“ ) or log mSP f ( ๐‘“ ) do give lower bounds on the space complexity of quantum
algorithms obtained from monotone span programs, and as we will soon see, log mSP( ๐‘“ ) and
      f ( ๐‘“ ) are lower bounds on the space complexity of monotone phase estimation algorithms,
log mSP
described in Section 5.2. The strongest known lower bound on mSP( ๐‘“ ) is the following:

Theorem 5.2 ([24]). There is an explicit Boolean function ๐‘“ : ๐ท โ†’ {0, 1} for ๐ท โІ {0, 1} ๐‘› such that

                                             log mSP( ๐‘“ ) โ‰ฅ ฮฉ(๐‘›).

                      T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                         28
                                  S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

   We will adapt some of the techniques used in existing lower bounds on mSP to show a lower
bound on mSPf ( ๐‘“ ) for some explicit ๐‘“ :

Theorem 5.3. There is an explicit Boolean function ๐‘“ : ๐ท โ†’ {0, 1} for ๐ท โІ {0, 1} ๐‘› such that for any
constant ๐œ…,
                                         f ๐œ… ( ๐‘“ ) โ‰ฅ (log ๐‘›)2โˆ’๐‘œ(1) .
                                   log mSP

    In particular, this implies a lower bound of 2(log ๐‘›)     on mSP( ๐‘“ ) for the function ๐‘“ in
                                                                                          2โˆ’๐‘œ(1)


Theorem 5.3. We prove Theorem 5.3 in Section 5.1. Theorem 5.3 implies that any quantum
algorithm for ๐‘“ obtained from a monotone span program must have space complexity (log ๐‘›)2โˆ’๐‘œ(1) ,
which is slightly better than the trivial lower bound of ฮฉ(log ๐‘›). In Section 5.2, we describe
a more natural class of algorithms called monotone phase estimation algorithms such that
      f ( ๐‘“ ) is a lower bound on the quantum space complexity of any such algorithm computing
log mSP
 ๐‘“ with bounded error. Then for the specific function ๐‘“ from Theorem 5.3, any monotone phase
estimation algorithm for ๐‘“ must use space (log ๐‘›)2โˆ’๐‘œ(1) .

5.1   Monotone span program lower bounds
Our main tool in proving Theorem 5.3 will be the following.

Theorem 5.4. For any Boolean function ๐‘“ : ๐ท โ†’ {0, 1}, ๐ท โІ {0, 1} ๐‘› , and any constant ๐œ… โˆˆ [0, 1):
                                                                                              โˆš
                              f ๐œ…( ๐‘“ ) โ‰ฅ                                           ๐œ…-rank(๐‘€)
                             mSP                              max                                      ,
                                                ๐‘€โˆˆโ„ ๐‘“ (0)ร— ๐‘“ (1) :k๐‘€ k โˆž โ‰ค1 max ๐‘—โˆˆ[๐‘›] rank(๐‘€ โ—ฆ ฮ” ๐‘—,1 )
                                                     โˆ’1     โˆ’1



where ฮ” ๐‘—,1 [๐‘ฆ, ๐‘ฅ] = 1 if ๐‘ฆ ๐‘– = 0 and ๐‘ฅ ๐‘– = 1, and 0 else.

    When, ๐œ… = 0, the right-hand side of the equation in Theorem 5.4 is the (monotone) rank
measure, defined in [25], and shown in [11] to lower bound monotone span program size. We
extend the proof for the ๐œ… = 0 case to get a lower bound on approximate span program size. We
could also allow for partial matrices ๐‘€, as in the non-monotone case (Lemma 4.6) but unlike
the non-monotone case, it is not necessary to consider partial matrices to get non-trivial lower
bounds.

Proof. Fix a monotone span program that ๐œ…-approximates ๐‘“ with size mSP       f ๐œ… ( ๐‘“ ). Let {h๐œ” ๐‘ฆ | :
๐‘ฆ โˆˆ ๐‘“ (0)} be optimal negative witnesses, and let {|๐‘ค ๐‘ฅ i : ๐‘ฅ โˆˆ ๐‘“ (1)} be approximate positive
      โˆ’1                                                         โˆ’1

witnesses with ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘ค ๐‘ฅ i โ‰ค ๐‘Š๐œ…โˆ’ . Letting ฮ  ๐‘—,๐‘ denote the projector onto ๐ป ๐‘—,๐‘ , define
                            2

            ร•                                   ร•                                    ร•                                 ร•
   ฮ›๐‘— =                 |๐‘ฆih๐œ” ๐‘ฆ |๐ดฮ  ๐‘—, ๐‘ฆยฏ ๐‘—                 ฮ  ๐‘—,๐‘ฅ ๐‘— |๐‘ค ๐‘ฅ ih๐‘ฅ| =                   |๐‘ฆih๐œ” ๐‘ฆ |๐ดฮ  ๐‘—,1                  ฮ  ๐‘—,1 |๐‘ค ๐‘ฅ ih๐‘ฅ|,
          ๐‘ฆโˆˆ ๐‘“ โˆ’1 (0)                         ๐‘ฅโˆˆ ๐‘“ โˆ’1 (1)                         ๐‘ฆโˆˆ ๐‘“ โˆ’1 (0):                      ๐‘ฅโˆˆ ๐‘“ โˆ’1 (1):
                                                                                     ๐‘ฆ ๐‘— =0                            ๐‘ฅ ๐‘— =1


so ฮ› ๐‘— has rank at most dim๐ป ๐‘— , and so ๐‘—โˆˆ[๐‘›] rank(ฮ› ๐‘— ) โ‰ค ๐‘ (๐‘ƒ) = mSP  f ๐œ… ( ๐‘“ ). Furthermore, ฮ› ๐‘— is
                                                               ร
only supported on (๐‘ฆ, ๐‘ฅ) such that ๐‘ฆ ๐‘— = 0 and ๐‘ฅ ๐‘— = 1, so ฮ› ๐‘— โ—ฆ ฮ” ๐‘—,1 = ฮ› ๐‘— . Denoting the error of

                              T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                                                   29
                                                               S TACEY J EFFERY

                                                 ร
|๐‘ค ๐‘ฅ i as | err(๐‘ฅ)i = ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘ค ๐‘ฅ i =                ๐‘—:๐‘ฅ ๐‘— =0 ฮ  ๐‘—,1 |๐‘ค ๐‘ฅ i, we have
                       ร•                          ร•                                                     ร•               ร•
                h๐‘ฆ|           ฮ› ๐‘— |๐‘ฅi =                       h๐œ” ๐‘ฆ |๐ดฮ  ๐‘—,1 |๐‘ค ๐‘ฅ i = h๐œ” ๐‘ฆ |๐ด                    ฮ  ๐‘—,1              ฮ  ๐‘—,1 |๐‘ค ๐‘ฅ i
                      ๐‘—โˆˆ[๐‘›]                 ๐‘—:๐‘ฆ ๐‘— =0,๐‘ฅ ๐‘— =1                                         ๐‘—:๐‘ฆ ๐‘— =0           ๐‘—:๐‘ฅ ๐‘— =1

                                         = h๐œ” ๐‘ฆ |๐ด(|๐‘ค ๐‘ฅ i โˆ’ | err(๐‘ฅ)i) = h๐œ” ๐‘ฆ |๐ด|๐‘ค ๐‘ฅ i โˆ’ h๐œ” ๐‘ฆ |๐ด| err(๐‘ฅ)i

                                                                                                            ๐œ…   โˆš
                      ร•                                                                        p        r
           1 โˆ’ h๐‘ฆ|            ฮ› ๐‘— |๐‘ฅi โ‰ค 1 โˆ’ 1 + h๐œ” ๐‘ฆ |๐ด k| err(๐‘ฅ)ik โ‰ค                           ๐‘Šโˆ’             = ๐œ….
                                                                                                            ๐‘Šโˆ’
                      ๐‘—โˆˆ[๐‘›]


Then for any ๐‘€ โˆˆ โ„ ๐‘“
                              โˆ’1 (0)ร— ๐‘“ โˆ’1 (1)
                                                 with k๐‘€ k โˆž โ‰ค 1, we have:

                                                  ร•                                       ร•                     โˆš
                                 ๐‘€โˆ’๐‘€โ—ฆ                     ฮ›๐‘—          โ‰ค k๐‘€ k โˆž ๐ฝ โˆ’                 ฮ›๐‘—       โ‰ค    ๐œ….
                                                  ๐‘—โˆˆ[๐‘›]                                  ๐‘—โˆˆ[๐‘›]
                                                                โˆž                                       โˆž

Thus

               โˆš                                              ร•                ร•
                   ๐œ…-rank(๐‘€) โ‰ค rank ยญ ๐‘€ โ—ฆ                             ฮ›๐‘— ยฎ โ‰ค           rank(๐‘€ โ—ฆ ฮ› ๐‘— )
                                                  ยฉ                     ยช
                                                              ๐‘—โˆˆ[๐‘›]            ๐‘—โˆˆ[๐‘›]
                                          ร• ยซ                           ยฌ              ร•
                                     =            rank(๐‘€ โ—ฆ ฮ” ๐‘—,1 โ—ฆ ฮ› ๐‘— ) โ‰ค                     rank(๐‘€ โ—ฆ ฮ” ๐‘—,1 )rank(ฮ› ๐‘— )
                                         ๐‘—โˆˆ[๐‘›]                                         ๐‘—โˆˆ[๐‘›]
                                        f ๐œ… ( ๐‘“ ) max rank(๐‘€ โ—ฆ ฮ” ๐‘—,1 ).
                                     โ‰ค mSP                                                                                                       
                                                          ๐‘—โˆˆ[๐‘›]


    To show a lower bound on mSP        f ( ๐‘“ ) for some explicit ๐‘“ : {0, 1} ๐‘› โ†’ {0, 1}, it turns out to be
sufficient to find some high approximate rank matrix ๐‘€ โˆˆ โ„๐‘Œร—๐‘‹ for finite sets ๐‘‹ and ๐‘Œ, and
a rectangle cover of ๐‘€, ฮ”1 , . . . , ฮ”๐‘› , where each ฮ”๐‘– โ—ฆ ๐‘€ has low rank. Specifically, we have the
following lemma, which, with rank in place of approximate rank, has been used extensively in
previous monotone span program lower bounds.

Lemma 5.5. Let ๐‘€ โˆˆ โ„๐‘Œร—๐‘‹ with k๐‘€ k โˆž โ‰ค 1, for some finite sets ๐‘‹ and ๐‘Œ and ๐‘‹1 , . . . , ๐‘‹๐‘› โІ ๐‘‹,
๐‘Œ1 , . . . , ๐‘Œ๐‘› โІ ๐‘Œ be such that for all (๐‘ฅ, ๐‘ฆ) โˆˆ ๐‘‹ ร— ๐‘Œ, there exists ๐‘— โˆˆ [๐‘›] such that (๐‘ฅ, ๐‘ฆ) โˆˆ ๐‘‹ ๐‘— ร— ๐‘Œ๐‘— .
Define ฮ” ๐‘— โˆˆ {0, 1}๐‘Œร—๐‘‹ by ฮ” ๐‘— [๐‘ฆ, ๐‘ฅ] = 1 if and only if (๐‘ฆ, ๐‘ฅ) โˆˆ ๐‘Œ๐‘— ร— ๐‘‹ ๐‘— . There exists a monotone function
๐‘“ : ๐ท โ†’ {0, 1} for ๐ท โІ {0, 1} ๐‘› such that for any constant ๐œ… โˆˆ [0, 1):
                                                     โˆš
                                      f ๐œ…( ๐‘“ ) โ‰ฅ        ๐œ…-rank(๐‘€)
                                    mSP                                    .
                                                 max ๐‘—โˆˆ[๐‘›] rank(๐‘€ โ—ฆ ฮ” ๐‘— )

Proof. For each ๐‘ฆ โˆˆ ๐‘Œ, define ๐‘ก ๐‘ฆ โˆˆ {0, 1} ๐‘› by:

                                                                        0 if ๐‘ฆ โˆˆ ๐‘Œ๐‘—
                                                                    
                                                           ๐‘ฆ
                                                          ๐‘ก๐‘— =
                                                                        1 else.


                          T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                                                  30
                          S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

Similarly, for each ๐‘ฅ โˆˆ ๐‘‹, define ๐‘  ๐‘ฅ โˆˆ {0, 1} ๐‘› by

                                                       1 if ๐‘ฅ โˆˆ ๐‘‹ ๐‘—
                                                   
                                          ๐‘  ๐‘—๐‘ฅ =
                                                       0 else.

For every (๐‘ฆ, ๐‘ฅ) โˆˆ ๐‘Œ ร— ๐‘‹, there is some ๐‘— such that ๐‘ฆ ๐‘— โˆˆ ๐‘Œ๐‘— and ๐‘ฅ ๐‘— โˆˆ ๐‘‹ ๐‘— , so it cannot be the case
that ๐‘  ๐‘ฅ โ‰ค ๐‘ก ๐‘ฆ . Thus, we can define ๐‘“ as the unique monotone function such that ๐‘“ (๐‘ ) = 1 for
every ๐‘  โˆˆ {0, 1} ๐‘› such that ๐‘  ๐‘ฅ โ‰ค ๐‘  for some ๐‘ฅ โˆˆ ๐‘‹, and ๐‘“ (๐‘ก) = 0 for all ๐‘ก โˆˆ {0, 1} ๐‘› such that
๐‘ก โ‰ค ๐‘ก ๐‘ฆ for some ๐‘ฆ โˆˆ ๐‘Œ. Then we can define a matrix ๐‘€ 0 โˆˆ โ„ ๐‘“ (0)ร— ๐‘“ (1) by ๐‘€ 0[๐‘ก ๐‘ฆ , ๐‘  ๐‘ฅ ] = ๐‘€[๐‘ฆ, ๐‘ฅ]
                                                                    โˆ’1    โˆ’1


for all (๐‘ฆ, ๐‘ฅ) โˆˆ ๐‘Œ ร— ๐‘‹, and 0 elsewhere. We have ๐œ€-rank(๐‘€ 0) = ๐œ€-rank(๐‘€) for all ๐œ€, and
rank(๐‘€ 0 โ—ฆ ฮ” ๐‘—,1 ) = rank(๐‘€ โ—ฆ ฮ” ๐‘— ) for all ๐‘—. The result then follows from Theorem 5.4.            
    We will prove Theorem 5.3 by constructing an ๐‘€ with high approximate rank, and a good
rectangle cover. Following [29] and [24], we will make use of a technique due to Sherstov for
proving communication lower bounds, called the pattern matrix method [30]. We begin with
some definitions.
Definition 5.6 (Fourier spectrum). For a real-valued function ๐‘ : {0, 1} ๐‘š โ†’ โ„, its Fourier
coefficients are defined, for each ๐‘† โІ [๐‘š]:
                                                1        ร•
                                      ๐‘(๐‘†)
                                      ห†    =                       ๐‘(๐‘ง)๐œ’๐‘† (๐‘ง),
                                               2๐‘š
                                                       ๐‘งโˆˆ{0,1} ๐‘š

where ๐œ’๐‘† (๐‘ง) = (โˆ’1) ๐‘–โˆˆ๐‘† ๐‘ง ๐‘– . It is easily verified that ๐‘ =             ๐‘†โІ[๐‘š] ๐‘(๐‘†)๐œ’
                      ร                                              ร
                                                                               ห†     ๐‘†.

Definition 5.7 (Degree and approximate degree). The degree of a function ๐‘ : {0, 1} ๐‘š โ†’ โ„ is
defined deg(๐‘) = max{|๐‘†| : ๐‘(๐‘†)
                           ห†    โ‰  0}. For any ๐œ€ โ‰ฅ 0, deg
                                                     g (๐‘) = min{deg(๐‘)
                                                         ๐œ€            หœ : k๐‘ โˆ’ ๐‘k
                                                                                หœ โˆž โ‰ค ๐œ€}.
    Pattern matrices, defined by Sherstov in [30], are useful for proving lower bounds in
communication complexity, because their rank and approximate rank are relatively easy to
lower bound. In [29], Robere, Pitassi, Rossman and Cook first used this analysis to give lower
bounds on mSP( ๐‘“ ) for some ๐‘“ . We now state the definition, using the notation from [24], which
differs slightly from [30].
Definition 5.8 (Pattern matrix). For a real-valued function ๐‘ : {0, 1} ๐‘š โ†’ โ„, and a positive integer
                                                           ๐œ†๐‘š     ๐‘š      ๐‘š
๐œ†, the (๐‘š, ๐œ†, ๐‘)-pattern matrix is defined as ๐น โˆˆ โ„ {0,1} ร—([๐œ†] ร—{0,1} ) where for ๐‘ฆ โˆˆ {0, 1}๐œ†๐‘š ,
๐‘ฅ โˆˆ [๐œ†]๐‘š , and ๐‘ค โˆˆ {0, 1} ๐‘š ,
                                    ๐น[๐‘ฆ, (๐‘ฅ, ๐‘ค)] = ๐‘(๐‘ฆ| ๐‘ฅ โŠ• ๐‘ค),
where by ๐‘ฆ| ๐‘ฅ , we mean the ๐‘š-bit string containing one bit from each ๐œ†-sized block of ๐‘ฆ as
                                  (1)    (2)            (๐‘š)
specified by the entries of ๐‘ฅ: (๐‘ฆ ๐‘ฅ1 , ๐‘ฆ ๐‘ฅ2 , . . . , ๐‘ฆ ๐‘ฅ ๐‘š ), where ๐‘ฆ (๐‘–) โˆˆ {0, 1}๐œ† is the ๐‘–-th block of ๐‘ฆ.
     For comparison, what [30] calls an (๐‘›, ๐‘ก, ๐‘)-pattern matrix would be a (๐‘ก, ๐‘›/๐‘ก, ๐‘)-pattern
matrix in our notation. As previously mentioned, a pattern matrix has the nice property that
its rank (or even approximate rank) can be bounded from below in terms of properties of the
Fourier spectrum of ๐‘. In particular, the following is proven in [30]:

                       T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                             31
                                                  S TACEY J EFFERY

Lemma 5.9. Let ๐น be the (๐‘š, ๐œ†, ๐‘)-pattern matrix for ๐‘ : {0, 1} ๐‘š โ†’ {โˆ’1, +1}. Then for any ๐œ€ โˆˆ [0, 1]
and ๐›ฟ โˆˆ [0, ๐œ€], we have:
                                     ร•                                                          (๐œ€ โˆ’ ๐›ฟ)2
                    rank(๐น) =                   ๐œ† |๐‘†|   and   ๐›ฟ-rank(๐น) โ‰ฅ ๐œ†deg๐œ€ (๐‘)                      .
                                                                                  g
                                                                                                (1 + ๐›ฟ)2
                                 ๐‘†โІ[๐‘š]:๐‘(๐‘†)โ‰ 0
                                       ห†

    This shows that we can use functions ๐‘ of high approximate degree to construct pattern
                     ๐œ†๐‘š     ๐‘š    ๐‘š
matrices ๐น โˆˆ โ„ {0,1} ร—([๐œ†] ร—{0,1} ) of high approximate rank. To apply Lemma 5.5, we also need
to find a good rectangle cover of some ๐น.
    A ๐‘-certificate for a function ๐‘ on {0, 1} ๐‘š is an assignment ๐›ผ : ๐‘† โ†’ {0, 1} for some ๐‘† โІ [๐‘š]
such that for any ๐‘ฅ โˆˆ {0, 1} ๐‘š such that ๐‘ฅ ๐‘— = ๐›ผ(๐‘—) for all ๐‘— โˆˆ ๐‘†, ๐‘“ (๐‘ฅ) = ๐‘. The size of a certificate is
|๐‘†|. The following shows how to use the certificates of ๐‘ to construct a rectangle cover of its
pattern matrix.
Lemma 5.10. Let ๐‘ : {0, 1} ๐‘š โ†’ {โˆ’1, +1}, and suppose there is a set of โ„“ certificates for ๐‘ of size at
most ๐ถ such that every input satisfies at least one certificate. Then for any positive integer
                                                                                           โˆš ๐œ†, there exists
                     ๐‘›                           ๐ถ
a function ๐‘“ : {0, 1} โ†’ {0, 1} for ๐‘› = โ„“ (2๐œ†) such that for any ๐œ… โˆˆ (0, 1) and ๐œ€ โˆˆ [ ๐œ…, 1]:
                                                             โˆš               
                                     f ๐œ… ( ๐‘“ ) โ‰ฅ ฮฉ (๐œ€ โˆ’
                                    mSP                           ๐œ…)2 ๐œ†deg๐œ€ (๐‘) .
                                                                       g


Proof. For ๐‘– = 1, . . . , โ„“ , let ๐›ผ ๐‘– : ๐‘† ๐‘– โ†’ {0, 1} for ๐‘† ๐‘– โŠ‚ [๐‘š] of size |๐‘† ๐‘– | โ‰ค ๐ถ be one of the โ„“ certificates.
That is, for each ๐‘–, there is some ๐‘ฃ ๐‘– โˆˆ {โˆ’1, +1} such that for any ๐‘ฅ โˆˆ {0, 1} ๐‘š , if ๐‘ฅ ๐‘— = ๐›ผ ๐‘– (๐‘—) for all
๐‘— โˆˆ ๐‘† ๐‘– , then ๐‘(๐‘ฅ) = ๐‘ฃ ๐‘– (so ๐›ผ ๐‘– is a ๐‘ฃ ๐‘– -certificate).
    We let ๐น be the (๐‘š, ๐œ†, ๐‘)-pattern matrix, which has k๐นk โˆž = 1 since ๐‘ has range {โˆ’1, +1}. We
will define a rectangle cover as follows. For every ๐‘– โˆˆ [โ„“ ], ๐‘˜ โˆˆ [๐œ†]๐‘†๐‘– , and ๐‘ โˆˆ {0, 1} ๐‘†๐‘– , define:

                      ๐‘‹๐‘–,๐‘˜,๐‘ = {(๐‘ฅ, ๐‘ค) โˆˆ [๐œ†]๐‘š ร— {0, 1} ๐‘š : โˆ€๐‘— โˆˆ ๐‘† ๐‘– , ๐‘ค ๐‘— = ๐‘ ๐‘— , ๐‘ฅ ๐‘— = ๐‘˜ ๐‘— }
                                                               (๐‘—)
                      ๐‘Œ๐‘–,๐‘˜,๐‘ = {๐‘ฆ โˆˆ {0, 1}๐œ†๐‘š : โˆ€๐‘— โˆˆ ๐‘† ๐‘– , ๐‘ฆ ๐‘˜ = ๐‘ ๐‘— โŠ• ๐›ผ ๐‘– (๐‘—)}.
                                                                ๐‘—


We first note that this is a rectangle cover. Fix any ๐‘ฆ โˆˆ {0, 1}๐œ†๐‘š , ๐‘ฅ โˆˆ [๐œ†]๐‘š and ๐‘ค โˆˆ {0, 1} ๐‘š . First
note that for any ๐‘–, if we let ๐‘ be the restriction of ๐‘ค to ๐‘† ๐‘– , and ๐‘˜ the restriction of ๐‘ฅ to ๐‘† ๐‘– , we
have (๐‘ฅ, ๐‘ค) โˆˆ ๐‘‹๐‘–,๐‘˜,๐‘ . This holds in particular for ๐‘– such that ๐›ผ ๐‘– is a certificate for ๐‘ฆ| ๐‘ฅ โŠ• ๐‘ค, and by
                                                                                    (๐‘—)
assumption there is at least one such ๐‘–. For such an ๐‘–, we have ๐‘ฆ ๐‘ฅ ๐‘— โŠ• ๐‘ค ๐‘— = ๐›ผ(๐‘—) for all ๐‘— โˆˆ ๐‘† ๐‘– , so
๐‘ฆ โˆˆ ๐‘Œ๐‘–,๐‘˜,๐‘ . Thus, we can apply Lemma 5.5.
                                                                                          (๐‘—)
    Note that if (๐‘ฅ, ๐‘ค) โˆˆ ๐‘‹๐‘–,๐‘˜,๐‘ , and ๐‘ฆ โˆˆ ๐‘Œ๐‘–,๐‘˜,๐‘ , then (๐‘ฆ| ๐‘ฅ โŠ• ๐‘ค)[๐‘—] = ๐‘ฆ ๐‘ฅ ๐‘— โŠ• ๐‘ค ๐‘— = ๐›ผ ๐‘– (๐‘—) for all ๐‘— โˆˆ ๐‘† ๐‘– ,
so ๐‘(๐‘ฆ| ๐‘ฅ โŠ• ๐‘ค) = ๐‘ฃ ๐‘– . Letting ฮ”๐‘–,๐‘˜,๐‘ [๐‘ฆ, (๐‘ฅ, ๐‘ค)] = 1 if ๐‘ฆ โˆˆ ๐‘Œ๐‘–,๐‘˜,๐‘ and (๐‘ฅ, ๐‘ค) โˆˆ ๐‘‹๐‘–,๐‘˜,๐‘ , and 0 else, we
have that if ๐‘ฆ โˆˆ ๐‘Œ๐‘–,๐‘˜,๐‘ and (๐‘ฅ, ๐‘ค) โˆˆ ๐‘‹๐‘–,๐‘˜,๐‘ , (๐น โ—ฆ ฮ”๐‘–,๐‘˜,๐‘ )[๐‘ฆ, (๐‘ฅ, ๐‘ค)] = ๐‘(๐‘ฆ| ๐‘ฅ โŠ• ๐‘ค) = ๐‘ฃ ๐‘– , and otherwise,
(๐น โ—ฆ ฮ”๐‘–,๐‘˜,๐‘ )[๐‘ฆ, (๐‘ฅ, ๐‘ค)] = 0. Thus rank(๐น โ—ฆ ฮ”๐‘–,๐‘˜,๐‘ ) = rank(๐‘ฃ ๐‘– ฮ”๐‘–,๐‘˜,๐‘ ) = 1. Then by Lemma 5.5, there
exists ๐‘“ : {0, 1} ๐‘› โ†’ {0, 1} where ๐‘› = โ„“๐‘–=1 (2๐œ†)|๐‘†๐‘– | โ‰ค โ„“ (2๐œ†)๐ถ such that:
                                           ร
                                          โˆš
                               f ๐œ… ( ๐‘“ ) โ‰ฅ ๐œ…-rank(๐น)
                             mSP
                                                       โˆš 2
                                            g (๐‘) (๐œ€ โˆ’ ๐œ…)
                                         โ‰ฅ๐œ† deg ๐œ€      โˆš      , by Lemma 5.9.                               
                                                  (1 + ๐œ…)2

                        T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                  32
                          S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

    We now prove Theorem 5.3, restated below.

Theorem 5.3. There is an explicit Boolean function ๐‘“ : ๐ท โ†’ {0, 1} for ๐ท โІ {0, 1} ๐‘› such that for
any constant ๐œ…,
                                     f ๐œ… ( ๐‘“ ) โ‰ฅ ฮฉ((log ๐‘›)2โˆ’๐‘œ(1) ).
                               log mSP

Proof. By [8, Theorem 38], there is a function ๐‘ with deg
                                                        g (๐‘) โ‰ฅ ๐ถ(๐‘)2โˆ’๐‘œ(1) , which is, up to the
                                                            1/3
๐‘œ(1) in the exponent, the best possible separation between these two quantities. In particular, this
               g (๐‘) โ‰ฅ ๐‘€ 2โˆ’๐‘œ(1) , and ๐ถ(๐‘) โ‰ค ๐‘€ 1+๐‘œ(1) , where ๐ถ(๐‘) is the certificate complexity
function has deg  1/3
of ๐‘, for some parameter ๐‘€ (see [8] equations (64) and (65), where ๐‘ is referred to as ๐น), and ๐‘ is
a function on ๐‘€ 2+๐‘œ(1) variables (see [8], discussion above equation (64)). Thus, there are at most
 ๐‘€ 2+๐‘œ(1)  ๐‘€ 1+๐‘œ(1)
 ๐‘€ 1+๐‘œ(1) 2          possible certificates of size ๐‘€ 1+๐‘œ(1) such that each input satisfies at least one of
them.
                                                                                                      ๐‘€ 2+๐‘œ(1)  ๐‘€ 1+๐‘œ(1)
Then by Lemma 5.10 there exists a function ๐‘“ : {0, 1} ๐‘› โ†’ {0, 1} for ๐‘› โ‰ค                                                  (2๐œ†)๐‘€
                                                                                                                                1+๐‘œ(1)
                                                                                                      ๐‘€ 1+๐‘œ(1) 2
such that for constant ๐œ… < 1/36 and constant ๐œ†,

                                  f ๐œ… ( ๐‘“ ) โ‰ฅ ฮฉ(deg
                             log mSP            g (๐‘) log ๐œ†) โ‰ฅ ๐‘€ 2โˆ’๐‘œ(1) .
                                                    1/3

Then we have
                   ๐‘€ 2+๐‘œ(1)
                             
       log ๐‘› โ‰ค log          + log 2๐‘€        + ๐‘€ 1+๐‘œ(1) log(2๐œ†) = ๐‘‚(๐‘€ 1+๐‘œ(1) log ๐‘€) = ๐‘€ 1+๐‘œ(1) .
                                     1+๐‘œ(1)

                   ๐‘€ 1+๐‘œ(1)


           f ๐œ… ( ๐‘“ ) โ‰ฅ (log ๐‘›)2โˆ’๐‘œ(1) , and the result for any ๐œ… follows using Corollary 3.9.
Thus, log mSP                                                                                                                       

    Since for all total functions ๐‘, deg
                                     g (๐‘) โ‰ค ๐ถ(๐‘)2 , where ๐ถ(๐‘) is the certificate complexity
                                         1/3
of ๐‘, Lemma 5.10 cannot prove a lower bound better than log mSP f (๐‘) โ‰ฅ (log ๐‘›)2 for any ๐‘›-bit
function. We state a more general version of Lemma 5.10 that might have the potential to prove
a better bound, but we leave this for future work.

Lemma 5.11. Fix ๐‘ : {0, 1} ๐‘š โ†’ {โˆ’1, +1}. For ๐‘– = 1, . . . , โ„“ , let ๐›ผ ๐‘– : ๐‘† ๐‘– โ†’ {0, 1} for ๐‘† ๐‘– โІ [๐‘š] be a
partial assignment such that every ๐‘ง โˆˆ {0, 1} ๐‘š satisfies at least one of the assignments. Let ๐‘ ๐‘– denote the
restriction of ๐‘ to strings ๐‘ง satisfying the assignment ๐›ผ ๐‘– . Then for every positive integer ๐œ†, there
                                                                                                   โˆš exists a
function ๐‘“ : {0, 1} ๐‘› โ†’ {0, 1}, where ๐‘› = โ„“๐‘–=1 (2๐œ†)|๐‘†๐‘– | such that for any ๐œ… โˆˆ (0, 1) and ๐œ€ โˆˆ [ ๐œ…, 1]:
                                              ร

                                                        โˆš                                     !
                                                    (๐œ€ โˆ’ ๐œ…)2 ๐œ†deg๐œ€ (๐‘)
                                                              g
                             f ๐œ…( ๐‘“ ) โ‰ฅ ฮฉ
                            mSP                                                                   .
                                                              ๐‘†โІ[๐‘š]\๐‘† ๐‘– :๐‘ห† ๐‘– (๐‘†)โ‰ 0 ๐œ†
                                                                                        |๐‘†|
                                                          ร
                                              max๐‘–โˆˆ[โ„“ ]

      To make use of this lemma, one needs a function ๐‘ of high approximate degree, such
that for every input, there is a small assignment that lowers the degree to something small.
This generalizes Lemma 5.10 because a certificate is an assignment that lowers the degree
of the remaining sub-function to constant. However, we note that a ๐‘ with these conditions
is necessary but may not be sufficient for proving a non-trivial lower bound, because while
  ๐‘†: ๐‘ห† ๐‘– (๐‘†)โ‰ 0 ๐œ†
ร                 |๐‘†| โ‰ฅ ๐œ†deg(๐‘ ๐‘– ) , it may also be much larger if ๐‘ has a dense Fourier spectrum.
                                                                    ๐‘–


                        T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                                      33
                                                             S TACEY J EFFERY

Proof. Let ๐น be the (๐‘š, ๐œ†, ๐‘)-pattern matrix. Let {๐‘‹๐‘–,๐‘˜,๐‘ ร— ๐‘Œ๐‘–,๐‘˜,๐‘ } ๐‘–,๐‘˜,๐‘ be the same rectangle covered
defined in the proof of Lemma 5.10, with the difference that since the ๐›ผ ๐‘– are no longer certificates,
the resulting submatrices of ๐น may not have constant rank.
    Let ฮ”๐‘–,๐‘˜,๐‘ = ๐‘ฆโˆˆ๐‘Œ๐‘–,๐‘˜,๐‘ |๐‘ฆi (๐‘ฅ,๐‘ค)โˆˆ๐‘‹๐‘–,๐‘˜,๐‘ h๐‘ฅ, ๐‘ค|. Then
                ร            ร

                                                                ร•
                               ๐น โ—ฆ ฮ”๐‘–,๐‘˜,๐‘ =                                       ๐‘(๐‘ฆ| ๐‘ฅ โŠ• ๐‘ค)|๐‘ฆih๐‘ฅ, ๐‘ค|.
                                                     ๐‘ฆโˆˆ๐‘Œ๐‘–,๐‘˜,๐‘ ,(๐‘ฅ,๐‘ค)โˆˆ๐‘‹๐‘–,๐‘˜,๐‘

Note that when ๐‘ฆ โˆˆ ๐‘Œ๐‘–,๐‘˜,๐‘ and (๐‘ฅ, ๐‘ค) โˆˆ ๐‘‹๐‘–,๐‘,๐‘˜ , ๐‘ฆ| ๐‘ฅ โŠ• ๐‘ค satisfies ๐›ผ ๐‘– , so ๐‘(๐‘ฆ| ๐‘ฅ โŠ• ๐‘ค) = ๐‘ ๐‘– (๐‘ฆ 0 | ๐‘ฅ0 โŠ• ๐‘ค 0),
where ๐‘ฆ 0, ๐‘ฅ 0 and ๐‘ค 0 are restrictions of ๐‘ฆ โˆˆ ({0, 1}๐œ† )๐‘š , ๐‘ฅ โˆˆ [๐œ†]๐‘š and ๐‘ค โˆˆ {0, 1} ๐‘š to [๐‘š] \ ๐‘† ๐‘– . Thus,
continuing from above, and rearranging registers, we have:
                              ร•                      ร•                                                             ร•
        ๐น โ—ฆ ฮ”๐‘–,๐‘˜,๐‘ =                                                ๐‘ ๐‘– (๐‘ฆ 0 | ๐‘ฅ0 โŠ• ๐‘ค 0)|๐‘ฆ 0ih๐‘ฅ 0 , ๐‘ค 0 | โŠ—                       | ๐‘ฆih๐‘˜,
                                                                                                                                    ยฏ     ๐‘|
                                                                                                                       ๐œ† )๐‘† ๐‘– :
                       ๐‘ฆ 0 โˆˆ({0,1}๐œ† )[๐‘š]\๐‘† ๐‘–    ๐‘ฅ 0 โˆˆ[๐œ†][๐‘š]\๐‘† ๐‘– ,                                             ๐‘ฆโˆˆ({0,1}
                                                                                                              ยฏ
                                               ๐‘ค 0 โˆˆ{0,1}[๐‘š]\๐‘† ๐‘–                                                ๐‘ฆ|
                                                                                                                ยฏ ๐‘˜ =๐‘โŠ•๐›ผ ๐‘–

                   = ๐น๐‘– โŠ— ๐ฝ2(๐œ†โˆ’1)|๐‘†๐‘– | ,1

where ๐น๐‘– is the (๐‘š, ๐œ†, ๐‘ ๐‘– )-pattern matrix, and ๐ฝ๐‘Ž,๐‘ is the all-ones matrix of dimension ๐‘Ž by ๐‘,
which always has rank 1 for ๐‘Ž, ๐‘ > 0. Thus
                                                                                                                ร•
             rank(๐น โ—ฆ ฮ”๐‘–,๐‘˜,๐‘ ) = rank(๐น๐‘– )rank(๐ฝ2(๐œ†โˆ’1)|๐‘†๐‘– | ,1 ) = rank(๐น๐‘– ) =                                                    ๐œ† |๐‘†| ,
                                                                                                      ๐‘†โІ[๐‘š]\๐‘† ๐‘– :๐‘ห† ๐‘– (๐‘†)โ‰ 0

by [30]. This part of the proof follows [29, Lemma IV.6].
    Then by Lemma 5.5 and Lemma 5.9, we have:
                                                                โˆš 2
                                               โˆš                ๐œ€โˆ’ ๐œ…
                                 
                                   ๐œ…-rank(๐น)             ยฉ        โˆš
                                                                1+ ๐œ…
                                                                      ๐œ†deg๐œ€ (๐‘)
                                                                              
                                                                                          ยช
            mSP๐œ… ( ๐‘“ ) โ‰ฅ ฮฉ
             f                                        โ‰ฅ ฮฉยญ
                                                         ยญ                                ยฎ.                                                   
                           max๐‘–,๐‘˜,๐‘ rank(๐น โ—ฆ ฮ”๐‘–,๐‘˜,๐‘ )      max๐‘– ๐‘†โІ[๐‘š]\๐‘†๐‘– :๐‘ห† ๐‘— (๐‘†)โ‰ 0 ๐œ† ยฎ
                                                                                      |๐‘†|
                                                                ร
                                                         ยซ                                ยฌ

5.2   Monotone algorithms
In Theorem 5.3, we showed a non-trivial lower bound on log mSP       f ( ๐‘“ ) for some explicit monotone
function ๐‘“ . Unlike lower bounds on log SP      f ( ๐‘“ ), this does not give us a lower bound on the
quantum space complexity of ๐‘“ , however, at the very least it gives us a lower bound on the
quantum space complexity of a certain type of quantum algorithm. Of course, this is naturally the
case, since a lower bound on mSP   f ( ๐‘“ ) gives us a lower bound on the quantum space complexity
of any algorithm for ๐‘“ that is obtained from a monotone span program. However, this is not the
most satisfying characterization, as it is difficult to imagine what this class of algorithms looks
like.
    In this section, we will consider a more natural class of algorithms whose space complexity is
shown to be at least mSPf ( ๐‘“ ), and in some cases mSP( ๐‘“ ). We will call a quantum query algorithm
a phase estimation algorithm if it works by estimating the amplitude on |0i in the phase register

                        T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                                                  34
                         S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

after running phase estimation of a unitary that makes one query. We assume that the unitary
for which we perform phase estimation is of the form ๐‘ˆ ๐’ช๐‘ฅ . This is without loss of generality,
because the most general form is a unitary ๐‘ˆ2 ๐’ช๐‘ฅ ๐‘ˆ1 , but we have (๐‘ˆ2 ๐’ช๐‘ฅ ๐‘ˆ1 )๐‘ก |๐œ“0 i = ๐‘ˆ1โ€  (๐‘ˆ ๐’ช๐‘ฅ )๐‘ก |๐œ“00 i
where |๐œ“00 i = ๐‘ˆ1 |๐œ“0 i, and ๐‘ˆ = ๐‘ˆ1๐‘ˆ2 . The weight on a phase of |0i is not affected by this global
(๐‘ก-independent) ๐‘ˆ1โ€  . Thus, we define a phase estimation algorithm as follows:

Definition 5.12. A phase estimation algorithm ๐’œ = (๐‘ˆ , |๐œ“0 i, ๐›ฟ, ๐‘‡, ๐‘€) for ๐‘“ : ๐ท โ†’ {0, 1}, ๐ท โІ
{0, 1} ๐‘› , is defined by (families of):

   โ€ข a unitary ๐‘ˆ acting on โ„‹ = span{| ๐‘—, ๐‘งi : ๐‘— โˆˆ [๐‘›], ๐‘ง โˆˆ ๐’ต} for some finite set ๐’ต;

   โ€ข an initial state |๐œ“0 i โˆˆ โ„‹ ;

   โ€ข a bound ๐›ฟ โˆˆ [0, 1/2);

   โ€ข positive integers ๐‘‡ and ๐‘€ โ‰ค โˆš1 ;
                                        ๐›ฟ

such that for any ๐‘€ 0 โ‰ฅ ๐‘€ and ๐‘‡ 0 โ‰ฅ ๐‘‡, the following procedure computes ๐‘“ with bounded error:

   1. Let ฮฆ(๐‘ฅ) be the algorithm that runs phase estimation of ๐‘ˆ ๐’ช๐‘ฅ on |๐œ“0 i for ๐‘‡ 0 steps, and then
      computes a bit |๐‘i๐ด in a new register ๐ด, such that ๐‘ = 0 if and only if the phase estimate
      is 0.

   2. Run ๐‘€ 0 steps of amplitude estimation to estimate the amplitude on |0i๐ด after application
      of ฮฆ(๐‘ฅ). Output 0 if the amplitude is > ๐›ฟ.

The query complexity of the algorithm is ๐‘‚(๐‘€๐‘‡), and, the space complexity of the algorithm is
log dim โ„‹ + log ๐‘‡ + log ๐‘€ + 1.

    We insist that the algorithm work not only for ๐‘€ and ๐‘‡ but for any larger integers as well,
because we want to ensure that the algorithm is successful because ๐‘€ and ๐‘‡ are large enough,
and not by some quirk of the particular chosen values. When ๐›ฟ = 0, the algorithm has one-sided
error (see Lemma 5.18).
    We remark on the generality of this form of algorithm. Any algorithm can be put into this
form by first converting it to a span program using the construction of Section 3.3 (Theorem 3.2),
and then compiling that into an algorithm using the construction of Section 3.2 (Theorem 3.1),
preserving both the time and space complexity, asymptotically. However, we will consider a
special case of this type of algorithm that is not fully general.

Definition 5.13. A monotone phase estimation algorithm is a phase estimation algorithm such
that if ฮ 0 (๐‘ฅ) denotes the orthogonal projector onto the (+1)-eigenspace of ๐‘ˆ ๐’ช๐‘ฅ , then for any
๐‘ฅ โˆˆ {0, 1} ๐‘› , ฮ 0 (๐‘ฅ)|๐œ“0 i is in the (+1)-eigenspace of ๐’ช๐‘ฅ .

    Let us consider what is โ€œmonotoneโ€ about this definition. The algorithm outputs 0 if |๐œ“0 i
has high overlap with the (+1)-eigenspace of ๐‘ˆ ๐’ช๐‘ฅ , i. e., ฮ 0 (๐‘ฅ)|๐œ“0 i is large. In a monotone phase
estimation algorithm, we know that the only contribution to ฮ 0 (๐‘ฅ)|๐œ“0 i is in the (+1)-eigenspace

                      T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                            35
                                           S TACEY J EFFERY

of ๐’ช๐‘ฅ , which is exactly the span of | ๐‘—, ๐‘งi such that ๐‘ฅ ๐‘— = 0. Thus, only queries that return 0 can
contribute to the algorithm rejecting.
    As a simple example, Groverโ€™s algorithm is a monotone phase estimation algorithm.
Specifically, let |๐œ“0 i = โˆš1๐‘› ๐‘›๐‘—=1 | ๐‘—i and ๐‘ˆ = (2|๐œ“0 ih๐œ“0 | โˆ’ ๐ผ). Then ๐‘ˆ ๐’ช๐‘ฅ is the standard Grover
                             ร

iterate, and |๐œ“0 i is in the span of e๐‘–๐œƒ -eigenvectors of ๐‘ˆ ๐’ช๐‘ฅ with sin |๐œƒ| = |๐‘ฅ|/๐‘›, so phase
                                                                                    p

estimation can be used to distinguish the case |๐‘ฅ| = 0 from |๐‘ฅ| โ‰ฅ 1. So ฮ 0 (๐‘ฅ)|๐œ“0 i is either 0,
when |๐‘ฅ| โ‰  0, or |๐œ“0 i, when |๐‘ฅ| = 0. In both cases, it is in the (+1)-eigenspace of ๐’ช๐‘ฅ .
    It is clear that a monotone phase estimation algorithm can only decide a monotone function.
However, while any quantum algorithm can be converted to a phase estimation algorithm, it is
not necessarily the case that any quantum algorithm for a monotone function can be turned into
a monotone phase estimation algorithm (see Remark 5.17). Thus lower bounds on the quantum
space complexity of any monotone phase estimation algorithm for a monotone ๐‘“ do not imply
lower bounds on S๐‘ˆ ( ๐‘“ ). Nevertheless, if we let mS๐‘ˆ ( ๐‘“ ) represent the minimum quantum space
complexity of any monotone phase estimation algorithm for ๐‘“ , then a lower bound on mS๐‘ˆ ( ๐‘“ )
at least tells us that if we want to compute ๐‘“ with space less than said bound, we must use a
non-monotone phase estimation algorithm.
    Similarly, we let mS๐‘ˆ 1
                            ( ๐‘“ ) denote the minimum quantum space complexity of any monotone
phase estimation algorithm with ๐›ฟ = 0 that computes ๐‘“ (with one-sided error).
    The main theorem of this section states that any monotone phase estimation algorithm for ๐‘“
with space ๐‘† can be converted to a monotone span program of size 2ฮ˜(๐‘†) that approximates ๐‘“ , so
that lower bounds on mSP    f ( ๐‘“ ) imply lower bounds on mS๐‘ˆ ( ๐‘“ ); and that any monotone phase
estimation algorithm with ๐›ฟ = 0 and space ๐‘† can be converted to a monotone span program
of size 2ฮ˜(๐‘†) that decides ๐‘“ (exactly) so that lower bounds on mSP( ๐‘“ ) imply lower bounds on
mS๐‘ˆ 1
      ( ๐‘“ ). These conversions also preserve the query complexity. We now formally state this
main result.
Theorem 5.14. Let ๐’œ = (๐‘ˆ , |๐œ“0 i, ๐›ฟ, ๐‘‡, ๐‘€) be a monotone phase estimation algorithm for ๐‘“ with space
complexity ๐‘† = log dim โ„‹ + log ๐‘‡ + log ๐‘€ + 1 and query complexity ๐‘‚(๐‘‡ ๐‘€). Then there is a monotone
span program with complexity ๐‘‚(๐‘‡ ๐‘€) and size 2 dim โ„‹ โ‰ค 2๐‘† that approximates ๐‘“ . If ๐›ฟ = 0, then this
span program decides ๐‘“ (exactly). Thus

                      mS๐‘ˆ ( ๐‘“ ) โ‰ฅ log mSP
                                       f( ๐‘“ )    and      1
                                                        mS๐‘ˆ ( ๐‘“ ) โ‰ฅ log mSP( ๐‘“ ).

   We prove this theorem in Section 5.2.1. As a corollary, lower bounds on mSP( ๐‘“ ), such as the
one from [24], imply lower bounds on mS๐‘ˆ 1
                                           ( ๐‘“ ); and lower bounds on mSP
                                                                       f ( ๐‘“ ) such as the one in
Theorem 5.3, imply lower bounds on mS๐‘ˆ ( ๐‘“ ). In particular:
Corollary 5.15. Let ๐‘“ : {0, 1} ๐‘› โ†’ {0, 1} be the function described in Theorem 5.3. Then mS๐‘ˆ ( ๐‘“ ) โ‰ฅ
(log ๐‘›)2โˆ’๐‘œ(1) . Let ๐‘” : {0, 1} ๐‘› โ†’ {0, 1} be the function described in Theorem 5.2. Then mS๐‘ˆ
                                                                                           1
                                                                                             (๐‘”) โ‰ฅ ฮฉ(๐‘›).
    We emphasize that while this does not give a lower bound on the quantum space complexity
of ๐‘“ , or the one-sided quantum space complexity of ๐‘”, it does show that any algorithm that uses
(log ๐‘›)๐‘ space to solve ๐‘“ with bounded error, for ๐‘ < 2, or ๐‘œ(๐‘›) space to solve ๐‘” with one-sided
error, must be of a different form than that described in Definition 5.13.

                      T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                          36
                                   S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

    In a certain sense, monotone phase estimation algorithms completely characterize those
that can be derived from monotone span programs, because the algorithm we obtain from
compiling a monotone span program is a monotone phase estimation algorithm, as stated below
in Lemma 5.16. However, not all monotone phase estimation algorithms can be obtained by
compiling monotone span programs, and similarly, we might hope to show that an even larger
class of algorithms can be converted to monotone span programs, in order to give more strength
to lower bounds on mS๐‘ˆ ( ๐‘“ ).

Lemma 5.16. Let ๐‘ƒ be an approximate monotone span program for ๐‘“ with size ๐‘† and complexity ๐ถ. Then
there is a monotone phase estimation algorithm for ๐‘“ with query complexity ๐‘‚(๐ถ) and space complexity
๐‘‚(log ๐‘† + log ๐ถ).

Proof. Fix a monotone span program, and assume it has been appropriately scaled. Without
loss of generality, we can let ๐ป ๐‘— = ๐ป ๐‘—,1 = span{| ๐‘—, ๐‘งi : ๐‘ง โˆˆ ๐’ต๐‘— } for some finite set ๐’ต๐‘— . Then,
๐’ช๐‘ฅ = ๐ผ โˆ’ 2ฮ ๐ป(๐‘ฅ) , which is only true because the span program is monotone. Let ๐‘ˆ = 2ฮ row(๐ด) โˆ’ ๐ผ.
Then ๐‘ˆ ๐’ช๐‘ฅ = (2ฮ ker(๐ด) โˆ’ ๐ผ)(2ฮ ๐ป(๐‘ฅ) โˆ’ ๐ผ) is the span program unitary, described in Section 3.2.
Then it is simple to verify that the algorithm described in [15, Lemma 3.6] (and referred to
in Section 3.2) is a phase estimation algorithm for ๐‘“ with query complexity ๐‘‚(๐ถ) and space
complexity ๐‘‚(log ๐‘† + log ๐ถ).
    The algorithm is a monotone phase estimation algorithm because ๐‘ˆ = 2ฮ row(๐ด) โˆ’ ๐ผ is
a reflection, and |๐œ“0 i = |๐‘ค 0 i = ๐ด+ |๐œi is in the (+1)-eigenspace of ๐‘ˆ, row(๐ด). Since ๐‘ˆ is a
reflection, the (+1)-eigenspace of ๐‘ˆ ๐’ช๐‘ฅ is exactly (ker(๐ด) โˆฉ ๐ป(๐‘ฅ)) โŠ• (row(๐ด) โˆฉ ๐ป(๐‘ฅ)โŠฅ ), and so
ฮ 0 (๐‘ฅ)|๐‘ค 0 i โˆˆ row(๐ด) โˆฉ ๐ป(๐‘ฅ)โŠฅ โŠ‚ ๐ป(๐‘ฅ)โŠฅ .                                                          
Remark 5.17. We mention an example of monotone functions for which the best known quantum
algorithm, in terms of space complexity, is not a monotone phase estimation algorithm. Every
function can be expressed as a Boolean formula, and every monotone function can be expressed
as a monotone Boolean formula (a formula with no negation gates), but this might be much
larger than the smallest (non-monotone) formula for the function. For example, the function
XOR-SAT, defined in [13], can be computed by a circuit of depth ๐‘‚((log ๐‘›)2 ), which means it has
                                                                            ๐œ€
a formula of size 2๐‘‚((log ๐‘›) ) , but its monotone formula complexity is 2ฮฉ(๐‘› ) for some constant ๐œ€.10
                            2



    โˆšFor any Boolean formula of size ๐‘, there exists a quantum algorithm that can evaluate it using
๐‘‚( ๐‘) queries, and ๐‘‚(log ๐‘) space [27, 18]. Since this algorithm is designed via span programs,
it is a phase estimation algorithm, and it is monotone if and only if the formula is monotone. For
a function for which there is a separation between the monotone and non-monotone formula
complexities, the smallest space quantum algorithm of this type will not be monotone. For
example, for XOR-SAT, we could use a quantum algorithm that evaluates a monotone formula
and has space complexity ๐‘› ๐œ€ . This is a monotone phase estimation algorithm, but it is not
optimal. If we instead evaluate the optimal non-monotone formula, we get a quantum algorithm
(that is not monotone) with space complexity (log ๐‘›)2 . Of course, this does not rule out that

   10If we pad XOR-SAT with 0s so that the input length goes from ๐‘› to ๐‘ = 2๐‘(log ๐‘›) for some appropriate constant
                                                                                    2


๐‘, then โˆšthe formula size becomes linear in ๐‘, while the monotone formula size is still superpolynomial in ๐‘, scaling
          ๐œ€ log ๐‘
like 22             . We thank Robert Robere for this observation.


                                T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                             37
                                             S TACEY J EFFERY

there could be some other space-optimal quantum algorithm for this problem that is a monotone
phase estimation algorithm.

5.2.1   Monotone algorithms to (approximate) monotone span programs
In this section, we prove Theorem 5.14. Throughout this section, we fix a phase estimation
algorithm ๐’œ = (๐‘ˆ , |๐œ“0 i, ๐›ฟ, ๐‘‡, ๐‘€) that computes ๐‘“ , with ๐‘ˆ acting on โ„‹ . For any ๐‘ฅ โˆˆ {0, 1} ๐‘› and
ฮ˜ โˆˆ [0, ๐œ‹], we let ฮ ฮ˜ (๐‘ฅ) denote the orthogonal projector onto the span of e๐‘–๐œƒ -eigenvectors of
๐‘ˆ ๐’ช๐‘ฅ for |๐œƒ| โ‰ค ฮ˜. We will let ฮ ๐‘ฅ = ๐‘—โˆˆ[๐‘›],๐‘งโˆˆ๐’ต:๐‘ฅ ๐‘— =1 | ๐‘—, ๐‘งih๐‘—, ๐‘ง|.
                                     ร
    We begin by drawing some conclusions about the necessary relationship between the
eigenspaces of ๐‘ˆ ๐’ช๐‘ฅ and a function ๐‘“ whenever a monotone phase estimation computes ๐‘“ . The
proofs are somewhat dry and are deferred to Section 5.2.2.

Lemma 5.18. Fix a phase estimation algorithm with ๐›ฟ = 0 that solves ๐‘“ with bounded error. Then if
๐‘“ (๐‘ฅ) = 0,
                                                         1
                                       kฮ 0 (๐‘ฅ)|๐œ“0 ik 2 โ‰ฅ 2 ,
                                                        ๐‘€
               โˆš
and for any ๐‘‘ < 8/๐œ‹, if ๐‘“ (๐‘ฅ) = 1, then
                                                                 2
                                           ฮ ๐‘‘๐œ‹/๐‘‡ (๐‘ฅ)|๐œ“0 i            = 0,

and the algorithm always outputs 1, so it has one-sided error.

Lemma 5.19. Fix a phase estimation algorithm with ๐›ฟ โ‰  0 that solves ๐‘“ with bounded error. Then there
is some constant ๐‘ > 0 such that if ๐‘“ (๐‘ฅ) = 0,

                                  kฮ 0 (๐‘ฅ)|๐œ“0 ik 2 โ‰ฅ max{๐›ฟ(1 + ๐‘), 1/๐‘€ 2 }
                                โˆš
and if ๐‘“ (๐‘ฅ) = 1, for any ๐‘‘ <    8/๐œ‹,

                                                                       ๐›ฟ
                                                                                 .
                                                         2
                                        ฮ ๐‘‘๐œ‹/๐‘‡ (๐‘ฅ)|๐œ“0 i       โ‰ค
                                                                 1 โˆ’ ๐‘‘ 8๐œ‹
                                                                           2 2



   To prove Theorem 5.14, we will define a monotone span program ๐‘ƒ๐’œ as follows:

                                  ๐ปtrue = span{| ๐‘—, ๐‘งi : ๐‘— โˆˆ [๐‘›], ๐‘ง โˆˆ ๐’ต} = โ„‹
                                  ๐ป ๐‘—,1 = ๐ป ๐‘— = span{| ๐‘—, ๐‘ง, 1i : ๐‘ง โˆˆ ๐’ต}
                                          1
                            ๐ด| ๐‘—, ๐‘ง, 1i = (| ๐‘—, ๐‘งi โˆ’ (โˆ’1)1 | ๐‘—, ๐‘งi) = | ๐‘—, ๐‘งi
                                          2
                              ๐ด| ๐‘—, ๐‘งi = (๐ผ โˆ’ ๐‘ˆ โ€  )| ๐‘—, ๐‘งi
                                    |๐œi = |๐œ“0 i.                                               (5.1)

   We first show that ฮ 0 (๐‘ฅ)|๐œ“0 i is (up to scaling) a negative witness for ๐‘ฅ, whenever it is
nonzero:

                      T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                      38
                         S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

Lemma 5.20. For any ๐‘ฅ โˆˆ {0, 1} ๐‘› , we have

                                                            1
                                        ๐‘คโˆ’ (๐‘ฅ) =                        .
                                                   kฮ 0 (๐‘ฅ)|๐œ“0 ik 2

In particular, ฮ 0 (๐‘ฅ)|๐œ“0 i/kฮ 0 (๐‘ฅ)|๐œ“0 ik 2 is an optimal negative witness for ๐‘ฅ when ฮ 0 (๐‘ฅ)|๐œ“0 i โ‰  0.

Proof. Suppose ฮ 0 (๐‘ฅ)|๐œ“0 i โ‰  0, and let |๐œ”i = ฮ 0 (๐‘ฅ)|๐œ“0 i/kฮ 0 (๐‘ฅ)|๐œ“0 ik 2 . We will first show that
this is a negative witness, and then show that no negative witness can have better complexity.
First, we notice that
                                                h๐œ“0 |ฮ 0 (๐‘ฅ)|๐œ“0 i
                              h๐œ”|๐œi = h๐œ”|๐œ“0 i =                  = 1.
                                                 kฮ 0 (๐‘ฅ)|๐œ“0 ik 2
Next, we will see that h๐œ”|๐ดฮ ๐ป(๐‘ฅ) = 0. By the monotone phase estimation property, ๐’ช๐‘ฅ ฮ 0 (๐‘ฅ)|๐œ“0 i =
ฮ 0 (๐‘ฅ)|๐œ“0 i, and so ๐’ช๐‘ฅ |๐œ”i = |๐œ”i, and thus ฮ ๐‘ฅ |๐œ”i = 0, where ฮ ๐‘ฅ is the projector onto | ๐‘—, ๐‘งi such
that ๐‘ฅ ๐‘— = 1. Note that ๐ป(๐‘ฅ) = span{| ๐‘—, ๐‘ง, 1i : ๐‘ฅ ๐‘— = 1, ๐‘ง โˆˆ ๐’ต} โŠ• span{| ๐‘—, ๐‘งi : ๐‘— โˆˆ [๐‘›], ๐‘ง โˆˆ ๐’ต}. Thus
ฮ ๐ป(๐‘ฅ) = ฮ ๐ปtrue + ฮ ๐‘ฅ โŠ— |1ih1|. We have:

                                   h๐œ”|๐ด(ฮ ๐‘ฅ โŠ— |1ih1|) = h๐œ”|ฮ ๐‘ฅ = 0.

Since |๐œ”i is in the (+1)-eigenspace of ๐‘ˆ ๐’ช๐‘ฅ , we have ๐‘ˆ ๐’ช๐‘ฅ |๐œ”i = |๐œ”i so since ๐’ช๐‘ฅ |๐œ”i = |๐œ”i,
๐‘ˆ |๐œ”i = |๐œ”i. Thus

                      h๐œ”|๐ดฮ ๐ปtrue = h๐œ”|(๐ผ โˆ’ ๐‘ˆ โ€  ) โŠ— h1| = (h๐œ”| โˆ’ h๐œ”|) โŠ— h1| = 0.

Thus |๐œ”i is a zero-error negative witness for ๐‘ฅ. Next, we argue that it is optimal.
   Suppose |๐œ”i is any optimal negative witness for ๐‘ฅ, with size ๐‘ค โˆ’ (๐‘ฅ). Then since h๐œ”|ฮ ๐‘ฅ =
h๐œ”|๐ด(ฮ ๐‘ฅ โŠ— |1ih1|) must be 0, ๐’ช๐‘ฅ |๐œ”i = (๐ผ โˆ’ 2ฮ ๐‘ฅ )|๐œ”i = |๐œ”i, and since h๐œ”|๐ดฮ ๐ปtrue = h๐œ”|(๐ผ โˆ’ ๐‘ˆ โ€  )
must be 0, ๐‘ˆ |๐œ”i = |๐œ”i. Thus |๐œ”i is a 1-eigenvector of ๐‘ˆ ๐’ช๐‘ฅ , so
                                                            2
                                          |๐œ”ih๐œ”|                    |h๐œ”|๐œ“0 i| 2         1
                                    2
                      kฮ 0 (๐‘ฅ)|๐œ“0 ik โ‰ฅ             2
                                                    |๐œ“0 i       =            2
                                                                                  =             .
                                          k|๐œ”ik                      k|๐œ”ik            k|๐œ”ik 2

We complete the proof by noticing that since h๐œ”|๐ดฮ ๐ปtrue = 0, we have h๐œ”|๐ด = h๐œ”|h1|, and
๐‘ค โˆ’ (๐‘ฅ) = kh๐œ”|๐ดk 2 = k|๐œ”ik 2 .                                                        

   Next we find approximate positive witnesses.

Lemma 5.21. For any ฮ˜ โ‰ฅ 0, the span program ๐‘ƒ๐’œ has approximate positive witnesses for any ๐‘ฅ with
                                                     5๐œ‹2
error at most kฮ ฮ˜ (๐‘ฅ)|๐œ“0 ik 2 and complexity at most 4ฮ˜ 2.


Proof. We first define a vector |๐‘ฃi by:

                                 |๐‘ฃi = (๐ผ โˆ’ (๐‘ˆ ๐’ช๐‘ฅ )โ€  )+ (๐ผ โˆ’ ฮ ฮ˜ (๐‘ฅ))|๐œ“0 i.

                      T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                             39
                                                   S TACEY J EFFERY

Note that ๐ผ โˆ’ (๐‘ˆ ๐’ช๐‘ฅ )โ€  is supported everywhere except the (+1)-eigenvectors of (๐‘ˆ ๐’ช๐‘ฅ )โ€  , which
are exactly the (+1)-eigenvectors of ๐‘ˆ ๐’ช๐‘ฅ . Thus, (๐ผ โˆ’ ฮ ฮ˜ (๐‘ฅ))|๐œ“0 i is contained in this support.
    Next we define                                       
                               |๐‘คi = |๐œ“0 i โˆ’ (๐ผ โˆ’ ๐‘ˆ โ€  )|๐‘ฃi |1i + |๐‘ฃi.

Then we have:

                          ๐ด|๐‘คi = |๐œ“0 i โˆ’ (๐ผ โˆ’ ๐‘ˆ โ€  )|๐‘ฃi + (๐ผ โˆ’ ๐‘ˆ โ€  )|๐‘ฃi = |๐œ“0 i = |๐œi.

So |๐‘คi is a positive witness, and we next compute its error for ๐‘ฅ:
                                                                      2
                                  = ฮ ๐‘ฅยฏ |๐œ“0 i โˆ’ (๐ผ โˆ’ ๐‘ˆ โ€  )|๐‘ฃi
                              2
             ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi
                                                                                                                        2
                                  = ฮ ๐‘ฅยฏ |๐œ“0 i โˆ’ ฮ ๐‘ฅยฏ (๐ผ โˆ’ ๐‘ˆ โ€  )(๐ผ โˆ’ (๐‘ˆ ๐’ช๐‘ฅ )โ€  )+ (๐ผ โˆ’ ฮ ฮ˜ (๐‘ฅ))|๐œ“0 i                            .

Above, ฮ ๐‘ฅยฏ = ๐ผ โˆ’ ฮ ๐‘ฅ . We now observe that
                                                                                 
                        ฮ ๐‘ฅยฏ (๐ผ โˆ’ ๐’ช๐‘ฅ ๐‘ˆ โ€  ) = ฮ ๐‘ฅยฏ ฮ ๐‘ฅยฏ โˆ’ (ฮ ๐‘ฅยฏ โˆ’ ฮ ๐‘ฅ )๐‘ˆ โ€  = ฮ ๐‘ฅยฏ (๐ผ โˆ’ ๐‘ˆ โ€  ).

Thus, continuing from above, we have:
                                                                                                                            2
                                  = ฮ ๐‘ฅยฏ |๐œ“0 i โˆ’ ฮ ๐‘ฅยฏ (๐ผ โˆ’ ๐’ช๐‘ฅ ๐‘ˆ โ€  )(๐ผ โˆ’ ๐’ช๐‘ฅ ๐‘ˆ โ€  )+ (๐ผ โˆ’ ฮ ฮ˜ (๐‘ฅ))|๐œ“0 i
                              2
             ฮ ๐ป(๐‘ฅ)โŠฅ |๐‘คi
                                  = kฮ ๐‘ฅยฏ |๐œ“0 i โˆ’ ฮ ๐‘ฅยฏ (๐ผ โˆ’ ฮ ฮ˜ (๐‘ฅ))|๐œ“0 ik 2 = kฮ ๐‘ฅยฏ ฮ ฮ˜ (๐‘ฅ)|๐œ“0 ik 2
                                  โ‰ค kฮ ฮ˜ (๐‘ฅ)|๐œ“0 ik 2 .

                                                                                                  ๐‘–๐œƒ ๐‘—
   Now we compute the complexity of |๐‘คi. First, let ๐‘ˆ ๐’ช๐‘ฅ =
                                                                                         ร
                                                                                             ๐‘—e          |๐œ† ๐‘— ih๐œ† ๐‘— | be the eigenvalue
decomposition of ๐‘ˆ ๐’ช๐‘ฅ . Then
                                                               ร•            1
                                      (๐ผ โˆ’ (๐‘ˆ ๐’ช๐‘ฅ )โ€  )+ =                              |๐œ† ๐‘— ih๐œ† ๐‘— |
                                                           ๐‘—:๐œƒ ๐‘— โ‰ 0
                                                                      1 โˆ’ eโˆ’๐‘–๐œƒ๐‘—
                                                               ร•
                                  and      ๐ผ โˆ’ ฮ ฮ˜ (๐‘ฅ) =                 |๐œ† ๐‘— ih๐œ† ๐‘— |.
                                                           ๐‘—:|๐œƒ ๐‘— |>ฮ˜


   We can thus bound k|๐‘ฃik 2 :
                                                                                                                                2
                                                                   2
                                                                                ร•              1
          k|๐‘ฃik = (๐ผ โˆ’ (๐‘ˆ ๐’ช๐‘ฅ )โ€  )+ (๐ผ โˆ’ ฮ ฮ˜ (๐‘ฅ))|๐œ“0 i
                2
                                                                        =                                  h๐œ† ๐‘— |๐œ“0 i|๐œ† ๐‘— i
                                                                            ๐‘—:|๐œƒ ๐‘— |>ฮ˜
                                                                                         1 โˆ’ eโˆ’๐‘–๐œƒ๐‘—
                         ร•            1                         ๐œ‹2
                    =                     ๐œƒ
                                            |h๐œ† ๐‘— |๐œ“0 i| 2 โ‰ค        .
                                        2 ๐‘—                    4ฮ˜ 2
                        ๐‘—:|๐œƒ ๐‘— |>ฮ˜ 4 sin 2



                        T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                                       40
                             S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

Next, using ๐’ช๐‘ฅ + 2ฮ ๐‘ฅ = ๐ผ โˆ’ 2ฮ ๐‘ฅ + 2ฮ ๐‘ฅ = ๐ผ, we compute
                             2                                                                                     2
     |๐œ“0 i โˆ’ (๐ผ โˆ’ ๐‘ˆ โ€  )|๐‘ฃi       = |๐œ“0 i โˆ’ (๐ผ โˆ’ ๐’ช๐‘ฅ ๐‘ˆ โ€  โˆ’ 2ฮ ๐‘ฅ ๐‘ˆ โ€  )(๐ผ โˆ’ ๐’ช๐‘ฅ ๐‘ˆ โ€  )+ (๐ผ โˆ’ ฮ ฮ˜ (๐‘ฅ))|๐œ“0 i
                                                                                                                       2
                                 = |๐œ“0 i โˆ’ (๐ผ โˆ’ ฮ ฮ˜ (๐‘ฅ))|๐œ“0 i + 2ฮ ๐‘ฅ ๐‘ˆ โ€  (๐ผ โˆ’ (๐‘ˆ ๐’ช๐‘ฅ )โ€  )+ (๐ผ โˆ’ ฮ ฮ˜ (๐‘ฅ))|๐œ“0 i
                                                                                                               2
                                                                    ร•             1
                                 โ‰ค ยญ kฮ ฮ˜ (๐‘ฅ)|๐œ“0 ik + 2 ฮ ๐‘ฅ ๐‘ˆ โ€                              h๐œ† ๐‘— |๐œ“0 i|๐œ† ๐‘— i ยฎ
                                   ยฉ                                                                       ยช
                                                                                    โˆ’๐‘–๐œƒ ๐‘—
                                                                 ๐‘—:|๐œƒ ๐‘— |>ฮ˜
                                                                             1โˆ’e
                                   ยซ                                                                       ยฌ
                                                      v                                            2
                                                      t ร•
                                                                          1
                                 โ‰ค ยญ kฮ ฮ˜ (๐‘ฅ)|๐œ“0 ik + 2                           |h๐œ† ๐‘— |๐œ“0 i| 2 ยฎ
                                   ยฉ                                                             ยช
                                                                           2 ๐œƒ ๐‘—
                                   ยซ                    ๐‘—:|๐œƒ ๐‘— |>ฮ˜ 4 sin 2                       ยฌ
                                                    ๐œ‹                               2     ๐œ‹   2
                                 โ‰ค kฮ ฮ˜ (๐‘ฅ)|๐œ“0 ik +             k(๐ผ โˆ’ ฮ ฮ˜ (๐‘ฅ))|๐œ“0 ik         โ‰ค        .
                                                          ฮ˜                                    ฮ˜2
Then we have the complexity of |๐‘คi,
                                                                           2
                                    k|๐‘คik 2 = |๐œ“0 i โˆ’ (๐ผ โˆ’ ๐‘ˆ โ€  )|๐‘ฃi            + k|๐‘ฃik 2
                                                  ๐œ‹2   ๐œ‹2   5๐œ‹2
                                              โ‰ค      +    =     .                                                          
                                                  ฮ˜ 2 4ฮ˜ 2 4ฮ˜ 2
   We conclude with the following two corollaries, whose combination gives Theorem 5.14.
Corollary 5.22. Let ๐’œ = (๐‘ˆ , |๐œ“0 i, 0, ๐‘‡, ๐‘€) be a monotone phase estimation algorithm for ๐‘“ with space
complexity ๐‘† = log dim โ„‹ + log ๐‘‡ + log ๐‘€ + 1 and query complexity ๐‘‚(๐‘‡ ๐‘€). Then there is a monotone
span program that decides ๐‘“ (exactly) whose size is 2 dim โ„‹ โ‰ค 2๐‘† and whose complexity is ๐‘‚(๐‘‡ ๐‘€).

Proof. If ๐‘“ (๐‘ฅ) = 0, then by Lemma 5.18, we have kฮ 0 (๐‘ฅ)|๐œ“0 ik 2 โ‰ฅ ๐‘€1 2 , so by Lemma 5.20,
๐‘ค โˆ’ (๐‘ฅ) โ‰ค ๐‘€ 2 . Thus ๐‘Šโˆ’ โ‰ค ๐‘€ 2 .
     If ๐‘“ (๐‘ฅ) = 1, then by Lemma 5.18, we have ฮ 2/๐‘‡ (๐‘ฅ)|๐œ“0 i = 0, so by Lemma 5.21, thereโ€™s an
                                                             2

exact positive witness for ๐‘ฅ with complexity ๐‘‚(๐‘‡ 2 ). Thus ๐‘Š+ โ‰ค ๐‘‚(๐‘‡ 2 ), and so the span program
๐‘ƒ๐’œ from (5.1) has complexity ๐‘‚(๐‘‡ ๐‘€). The size of the span program ๐‘ƒ๐’œ is dim ๐ป = 2 dim โ„‹ . 

Corollary 5.23. Let ๐’œ = (๐‘ˆ , |๐œ“0 i, ๐›ฟ, ๐‘‡, ๐‘€) be a monotone phase estimation algorithm for ๐‘“ with
space complexity ๐‘† = log dim โ„‹ + log ๐‘‡ + log ๐‘€ + 1 and query complexity ๐‘‚(๐‘‡ ๐‘€). Then there is a
constant ๐œ… โˆˆ (0, 1) such that there exists a monotone span program that ๐œ…-approximates ๐‘“ whose size is
2 dim โ„‹ โ‰ค 2๐‘† and whose complexity is ๐‘‚(๐‘‡ ๐‘€).

Proof. If ๐‘“ (๐‘ฅ) = 0, then by Lemma 5.19, we have kฮ 0 (๐‘ฅ)|๐œ“0 ik 2 > ๐›ฟ(1 + ๐‘) for some constant ๐‘ > 0.
Thus, by Lemma 5.20, ๐‘Šโˆ’ โ‰ค (1+๐‘)๐›ฟ1
                                   .
                                                                  ๐‘
   If ๐‘“ (๐‘ฅ) = 1, then by Lemma 5.21, setting ฮ˜ = ๐‘‘๐œ‹/๐‘‡ for ๐‘‘ = ๐œ‹2 1+๐‘ , (where ๐‘ is the constant
                                                                                     p
from above), by Lemma 5.21 there is an approximate positive witness for ๐‘ฅ with error
                                                                               2
                                              ๐‘’ ๐‘ฅ = ฮ 2โˆš ๐‘ /๐‘‡ (๐‘ฅ)|๐œ“0 i
                                                              1+๐‘



                       T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                               41
                                                        S TACEY J EFFERY

and complexity ๐‘‚(๐‘‡ 2 ). By Lemma 5.19, we have
                                      ๐›ฟ                  ๐›ฟ            ๐›ฟ(1 + ๐‘)          1        1
                      ๐‘’๐‘ฅ โ‰ค                    =            ๐‘   =             โ‰ค            .
                                 1 โˆ’ ๐‘‘ 8๐œ‹
                                      2 2
                                                    1 โˆ’ 2(1+๐‘)   1 + ๐‘ โˆ’ ๐‘/2   1 + ๐‘/2 ๐‘Šโˆ’

Thus, letting ๐œ… = 1+๐‘/2
                      1
                         < 1, we have that ๐‘ƒ๐’œ ๐œ…-approximates ๐‘“ . Since the positive witness
complexity is ๐‘‚(๐‘‡ 2 ), and by Lemma 5.19, we also have ๐‘Šโˆ’ โ‰ค ๐‘‚(๐‘€ 2 ), the complexity of ๐‘ƒ๐’œ is
๐‘‚(๐‘‡ ๐‘€). The size of ๐‘ƒ๐’œ is dim ๐ป = 2 dim โ„‹ .                                               

5.2.2   Proofs of Lemma 5.18 and Lemma 5.19
We will prove the lemmas as a collection of claims. Fix ๐‘‡ 0 โ‰ฅ ๐‘‡ and p ๐‘€ 0 โ‰ฅ ๐‘€ with which to
                                                    โˆš
run the algorithm. Suppose ฮฆ(๐‘ฅ) outputs |๐œ“(๐‘ฅ)i = ๐‘ ๐‘ฅ |0i๐ด |ฮฆ0 (๐‘ฅ)i + 1 โˆ’ ๐‘ ๐‘ฅ |1i๐ด |ฮฆ1 (๐‘ฅ)i, and
let ๐‘หœ denote the estimate output by the algorithm. We will let ๐‘ˆ ๐’ช๐‘ฅ = ๐‘— e๐‘–๐œŽ ๐‘— (๐‘ฅ) |๐œ† ๐‘ฅ๐‘— ih๐œ† ๐‘ฅ๐‘— | be an
                                                                      ร

eigenvalue decomposition.

Claim 5.24. If ๐‘“ (๐‘ฅ) = 0 then kฮ 0 (๐‘ฅ)|๐œ“0 ik 2 โ‰ฅ ๐‘€1 2 .
Proof. Since the algorithm computes ๐‘“ with bounded error, the probability of accepting ๐‘ฅ is at
most 1/3, so ๐‘หœ โ‰ค ๐›ฟ with probability at most 1/3.
   Amplitude estimation is just phase estimation of a unitary ๐‘Šฮฆ such that |๐œ“(๐‘ฅ)i is in the
span of eยฑ2๐‘–๐œƒ๐‘ฅ -eigenvectors of ๐‘Šฮฆ , where ๐‘ ๐‘ฅ = sin2 ๐œƒ๐‘ฅ , ๐œƒ๐‘ฅ โˆˆ [0, ๐œ‹/2) [7]. One can show that the
probability of outputting an estimate ๐‘หœ = 0 is sin2 (๐‘€ 0 ๐œƒ๐‘ฅ )/(๐‘€ 02 sin2 (๐œƒ๐‘ฅ )), so

                                                       1   sin2 (๐‘€ 0 ๐œƒ๐‘ฅ )
                                                         โ‰ฅ                 .
                                                       3   ๐‘€ 02 sin2 (๐œƒ๐‘ฅ )
If ๐‘€ 0 ๐œƒ๐‘ฅ โ‰ค ๐œ‹2 , then this would give:

                                                   1   (2๐‘€ 0 ๐œƒ๐‘ฅ /๐œ‹)2   4
                                                     โ‰ฅ               = 2,
                                                   3     ๐‘€ ๐œƒ๐‘ฅ0 2 2    ๐œ‹

which is a contradiction. Thus, we have:
                         ๐œ‹                2๐œƒ๐‘ฅ   1                                 1              โˆš          1
              ๐‘€ 0 ๐œƒ๐‘ฅ >            โ‡’           > 0              โ‡’      sin ๐œƒ๐‘ฅ >          โ‡’            ๐‘๐‘ฅ >      .
                         2                 ๐œ‹   ๐‘€                                  ๐‘€0                        ๐‘€0
    Since ฮฆ(๐‘ฅ) is the result of running phase estimation, we have
                         ร•                         sin2 (๐‘‡ 0 ๐œŽ ๐‘— (๐‘ฅ)/2)                              ๐œ‹2
                  ๐‘๐‘ฅ =           |h๐œ† ๐‘ฅ๐‘— |๐œ“0 i| 2                           โ‰ค kฮ ฮ˜ (๐‘ฅ)|๐œ“0 ik 2 +              ,
                             ๐‘—
                                                   ๐‘‡ 02 sin2 (๐œŽ ๐‘— (๐‘ฅ)/2)                         ๐‘‡ 02 ฮ˜2

for any ฮ˜. In particular, if ฮ” is less than the spectral gap of ๐‘ˆ ๐’ช๐‘ฅ , we have kฮ ฮ” (๐‘ฅ)|๐œ“0 ik =
kฮ 0 (๐‘ฅ)|๐œ“0 ik, so
                                   1                           ๐œ‹2
                                      <  kฮ  0 (๐‘ฅ)|๐œ“ 0 ik 2
                                                           +         .
                                 ๐‘€ 02                        ๐‘‡ 02 ฮ”2

                      T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                        42
                           S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

This is true for any choices ๐‘‡ 0 โ‰ฅ ๐‘‡ and ๐‘€ 0 โ‰ฅ ๐‘€, so we must have:

                                                    1
                                                       โ‰ค kฮ 0 (๐‘ฅ)|๐œ“0 ik 2 .                                               
                                                    ๐‘€2
                                                                             โˆš
Claim 5.25. If ๐‘“ (๐‘ฅ) = 1 and ๐›ฟ = 0, then for any ๐‘‘ < ๐œ‹8 , ฮ ๐‘‘๐œ‹/๐‘‡ (๐‘ฅ)|๐œ“0 i
                                                                                                    2
                                                                                                        = 0.

Proof. Suppose towards a contradiction that ฮ ๐‘‘๐œ‹/๐‘‡ (๐‘ฅ)|๐œ“0 i > 0. Then ๐‘ ๐‘ฅ > 0, and some
                                                                                            2

sufficiently large ๐‘€ 0 โ‰ฅ ๐‘€ would detect this and cause the algorithm to output 0, so we must
actually have ฮ ๐‘‘๐œ‹/๐‘‡ (๐‘ฅ)|๐œ“0 i = 0. In fact, in order to sure that no large enough value ๐‘€ 0 detects
                            2

amplitude > 0 on |0i๐ด , we must have ๐‘ ๐‘ฅ = 0 whenever ๐‘“ (๐‘ฅ) = 1. That means that when ๐‘“ (๐‘ฅ) = 1,
the algorithm never outputs 0, so the algorithm has one-sided error.                            

Claim 5.26. There is some constant ๐‘ such that if ๐‘“ (๐‘ฅ) = 0 and ๐›ฟ > 0 then kฮ 0 (๐‘ฅ)|๐œ“0 ik 2 > ๐›ฟ(1 + ๐‘).

Proof. Recall that ๐‘หœ โˆˆ {sin2 (๐œ‹๐‘š/๐‘€ 0) : ๐‘š = 0, . . . , ๐‘€ 0 โˆ’ 1}. We will restrict our attention to
choices ๐‘€ 0 such that for some integer ๐‘‘,

                                                    ๐‘‘๐œ‹            (๐‘‘ + 1/3)๐œ‹
                                             sin2      โ‰ค ๐›ฟ < sin2            .
                                                    ๐‘€0                ๐‘€0

To see that such a choice exists, let ๐œ be such that ๐›ฟ = sin2 ๐œ, and note that the condition holds as
long as ๐‘‘ โ‰ค ๐œ๐‘€
                  0                                                              3๐œ๐‘€ 0
                 ๐œ‹ < ๐‘‘ + 1/3 for some ๐‘‘, which is equivalent to saying that b ๐œ‹ c = 0 mod 3. If
         ๐œ‹
๐พ = b 21 3๐œ c, then for any ๐‘€ 0 โ‰ฅ ๐‘€, and โ„“ โ‰ฅ 0, define:

                                                             ๐‘€โ„“ = ๐‘€ 0 + โ„“ ๐พ.

Then for any โ„“ > 0,
                                                                                               
                                       3๐œ      3๐œ         3๐œ    1 3๐œ 1
                                          ๐‘€โ„“ โˆ’    ๐‘€โ„“ โˆ’1 =    ๐พโˆˆ   โˆ’  ,  ,
                                       ๐œ‹       ๐œ‹          ๐œ‹     2   ๐œ‹ 2

so there must be one โ„“ โˆˆ {0, . . . , 6} such that b 3๐œ
                                                    ๐œ‹ ๐‘€โ„“ e = 0 mod 3. In particular, there is some
choice ๐‘€โ„“ satisfying the condition such that (using some ๐‘€ 0 โ‰ค โˆš1 ):
                                                                                                ๐›ฟ

                            โˆš                 โˆš          ๐œ‹      ๐œ‹ sin ๐œ
                                                                       
                                                     1
                                  ๐›ฟ๐‘€โ„“ โ‰ค           ๐›ฟ โˆš +6    =1+         โ‰ค 1 + ๐œ‹.                                      (5.2)
                                                      ๐›ฟ  6๐œ        ๐œ

We will use this value as our ๐‘€ 0 for the remainder of this proof.
                                                                                                 ๐œ‹
   Let ๐‘ ๐‘ฅ = sin2 ๐œƒ๐‘ฅ for ๐œƒ๐‘ฅ โˆˆ [0, ๐œ‹/2]. Let ๐‘ง be an integer such that ฮ” = ๐œƒ๐‘ฅ โˆ’ ๐œ‹๐‘ง/๐‘€ 0 has |ฮ”| โ‰ค 2๐‘€ 0.
                            2 ๐œ‹๐‘ง
Then the outcome ๐‘หœ = sin ๐‘€ 0 has probability:

                         ๐‘€ 0 โˆ’1                          2              ๐‘€ 0 โˆ’1         2
                   1     ร•
                                      ๐‘–2๐‘ก(๐œƒ๐‘ฅ โˆ’๐œ‹๐‘ง/๐‘€ 0 )            1     ร•                   sin2 (๐‘€ 0ฮ”)        4
                                  e                          =                    e๐‘–2๐‘กฮ” =                 โ‰ฅ       ,
                 ๐‘€ 02     ๐‘ก=0                                    ๐‘€ 02       ๐‘ก=0             ๐‘€ 02 sin2 ฮ”        ๐œ‹2

                        T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                           43
                                                 S TACEY J EFFERY

since |๐‘€ 0ฮ”| โ‰ค ๐œ‹2 . Thus, by correctness, we must have sin2 (๐œ‹๐‘ง/๐‘€ 0) > ๐›ฟ โ‰ฅ sin2 ๐‘€
                                                                                ๐‘‘๐œ‹
                                                                                  0 . Thus ๐‘ง > ๐‘‘, so



                               (๐‘‘ + 1)๐œ‹  ๐‘ง๐œ‹                  ๐œ‹
                                        โ‰ค 0 = ๐œƒ๐‘ฅ โˆ’ ฮ” โ‰ค ๐œƒ๐‘ฅ +      .
                                  ๐‘€ 0    ๐‘€                  2๐‘€ 0

Thus:

                                                              (๐‘‘ + 1/3)๐œ‹    2๐œ‹            ๐œ‹
                                                                         +       โ‰ค ๐œƒ๐‘ฅ +
                                                                  ๐‘€  0     3๐‘€ 0         2๐‘€ 0
                                                                           ๐œ‹
                                                           
                                                             (๐‘‘ + 1/3)๐œ‹
                                                       sin              +        โ‰ค sin ๐œƒ๐‘ฅ
                                                                 ๐‘€ 0      6๐‘€ 0
                                   ๐œ‹                             ๐œ‹
                                                                             
                   (๐‘‘ + 1/3)๐œ‹                (๐‘‘ + 1/3)๐œ‹               โˆš
               sin            cos      + cos                sin      โ‰ค ๐‘๐‘ฅ
                       ๐‘€ 0        6๐‘€ 0           ๐‘€  0           6๐‘€ 0

                              โˆš              ๐œ‹     โˆš             ๐œ‹
                                  r
                                                                      โˆš
                                ๐›ฟ 1 โˆ’ sin2       +    1 โˆ’ ๐›ฟ sin      โ‰ค ๐‘๐‘ฅ
                                            6๐‘€ 0                6๐‘€ 0


             ๐œ‹                                                                           2 ๐œ‹
When sin2 6๐‘€   0 โ‰ค 1 โˆ’ ๐›ฟ, which we can assume, the above expression is minimized when sin 6๐‘€ 0

is as small as possible. We have, using ๐‘€ 0 โ‰ค 1+๐œ‹
                                               โˆš , from (5.2):
                                                               ๐›ฟ

                                             ๐œ‹       4           ๐›ฟ
                                     sin2        โ‰ฅ         โ‰ฅ           .
                                            6๐‘€ 0
                                                   36๐‘€ 0 2   9(1 + ๐œ‹)2

Thus, continuing from above, letting ๐‘˜ = 9(1+๐œ‹)
                                            1
                                                2 , we have:


                                                   โˆš โˆš        โˆš     โˆš    โˆš
                                                    ๐›ฟ 1 โˆ’ ๐‘˜๐›ฟ + 1 โˆ’ ๐›ฟ ๐‘˜๐›ฟ โ‰ค ๐‘ ๐‘ฅ
                                                                   p
                         ๐›ฟ(1 โˆ’ ๐‘˜๐›ฟ) + (1 โˆ’ ๐›ฟ)๐‘˜๐›ฟ + 2๐›ฟ ๐‘˜(1 โˆ’ ๐›ฟ)(1 โˆ’ ๐‘˜๐›ฟ) โ‰ค ๐‘ ๐‘ฅ



Next, notice that (1 โˆ’ ๐‘˜๐›ฟ)(1 โˆ’ ๐›ฟ) is minimized when ๐›ฟ = 1+๐‘˜
                                                         2๐‘˜ , but ๐›ฟ โ‰ค 2 < 2๐‘˜ , so we have, using
                                                                      1   1+๐‘˜

๐‘˜ < 1 and ๐›ฟ โ‰ค 1/2:
                                             โˆš p
                          ๐›ฟ(1 + ๐‘˜(1 โˆ’ 2๐›ฟ) + 2 ๐‘˜ (1 โˆ’ ๐‘˜/2)(1 โˆ’ 1/2)) โ‰ค ๐‘ ๐‘ฅ
                                                               โˆš
                                                     ๐›ฟ(1 + 0 + ๐‘˜) โ‰ค ๐‘ ๐‘ฅ .

   Since ฮฆ(๐‘ฅ) is the result of running phase estimation of ๐‘ˆ ๐’ช๐‘ฅ for ๐‘‡ 0 โ‰ฅ ๐‘‡ steps, we have:

                                                                         ๐‘‡ 0 ๐œŽ ๐‘— (๐‘ฅ)
                                        ร•                              sin2 ( 2 )
                                 ๐‘๐‘ฅ =           |h๐œ† ๐‘ฅ๐‘— |๐œ“0 i| 2                          ,
                                                                                 ๐œŽ ๐‘— (๐‘ฅ)
                                            ๐‘—                   (๐‘‡ 0)2 sin2 ( 2 )


                       T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                     44
                           S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

so in particular, for any ฮ˜ โˆˆ [0, ๐œ‹), we have
                                                               ร•                                        1
                        ๐‘ ๐‘ฅ โ‰ค kฮ ฮ˜ (๐‘ฅ)|๐œ“0 ik 2 +                             |h๐œ† ๐‘ฅ๐‘— |๐œ“0 i| 2                          .
                                                            ๐‘—:|๐œŽ ๐‘— (๐‘ฅ)|>ฮ˜
                                                                                                (๐‘‡ 0)2 sin2 ( ฮ˜2 )

                                                                                                   ๐œ‹2
                           โ‰ค kฮ ฮ˜ (๐‘ฅ)|๐œ“0 ik 2 + k(๐ผ โˆ’ ฮ ฮ˜ (๐‘ฅ))|๐œ“0 ik 2                                      .
                                                                                                (๐‘‡ 0)2 ฮ˜2

In particular, for any ฮ˜ < ฮ” where ฮ” is the spectral gap of ๐‘ˆ ๐’ช๐‘ฅ , we have kฮ ฮ˜ (๐‘ฅ)|๐œ“0 ik =
kฮ 0 (๐‘ฅ)|๐œ“0 ik, so for any ๐‘‡ 0 โ‰ฅ ๐‘‡, we have

                                                              ๐œ‹2                  โˆš
                                  kฮ 0 (๐‘ฅ)|๐œ“0 ik 2 +           0
                                                                     โ‰ฅ ๐‘ ๐‘ฅ โ‰ฅ ๐›ฟ(1 + ๐‘˜).
                                                            (๐‘‡ ) ฮ”
                                                                2  2


Since this holds for any ๐‘‡ 0 โ‰ฅ ๐‘‡, we get
                                                                                      โˆš
                                          kฮ 0 (๐‘ฅ)|๐œ“0 ik 2 โ‰ฅ ๐›ฟ(1 +                         ๐‘˜).
                                                   โˆš
The proof is completed by letting ๐‘ =                  ๐‘˜.                                                                    

Claim 5.27. If ๐‘“ (๐‘ฅ) = 1 and ๐›ฟ > 0 then ฮ ๐‘‘๐œ‹/๐‘‡ (๐‘ฅ)|๐œ“0 i                              (1 โˆ’ ๐‘‘ 2 ๐œ‹2 /8) โ‰ค ๐›ฟ.
                                                                                2


                                                                  โˆš
Proof. If |๐œ†i is an e๐‘–๐œƒ -eigenvector of ๐‘ˆ ๐’ช๐‘ฅ for some |๐œƒ| โ‰ค ๐‘‘๐œ‹/๐‘‡ < 8/๐‘‡, then the probability of
measuring 0 in the phase register upon performing ๐‘‡ steps of phase estimation is:

                                                             ๐‘‡โˆ’1            2
                                                 1 ร• ๐‘–๐‘ก๐œƒ                             sin2 ๐‘‡๐œƒ
                                      ๐‘ ๐‘ฅ (๐œƒ) := 2    e                         =          2
                                                                                                   .
                                                ๐‘‡ ๐‘ก=0                               ๐‘‡ 2 sin2 ๐œƒ2

Let ๐œ€(๐‘ฅ) = 1 โˆ’ sin๐‘ฅ 2 ๐‘ฅ for any ๐‘ฅ. It is simple to verify that ๐œ€(๐‘ฅ) โ‰ค ๐‘ฅ 2 /2 for any ๐‘ฅ, and ๐œ€(๐‘ฅ) โˆˆ [0, 1]
                  2


for any ๐‘ฅ. So we have:

                                  (๐‘‡๐œƒ/2)2 (1 โˆ’ ๐œ€(๐‘‡๐œƒ/2))                       ๐‘‡ 2 ๐œƒ2
                      ๐‘ ๐‘ฅ (๐œƒ) โ‰ฅ                           โ‰ฅ 1 โˆ’ ๐œ€(๐‘‡๐œƒ/2) โ‰ฅ 1 โˆ’        .
                                  ๐‘‡ 2 (๐œƒ/2)2 (1 โˆ’ ๐œ€(๐œƒ/2))                       8

Thus, we conclude that

                                                     ๐‘‡ 2 ๐‘‘ 2 ๐œ‹2                          ๐‘‘ 2 ๐œ‹2
                                                                                                                      
               ๐‘ ๐‘ฅ โ‰ฅ ฮ ๐‘‘๐œ‹/๐‘‡ (๐‘ฅ)|๐œ“0 i                                                             .
                                          2                                        2
                                                  1โˆ’            = ฮ  ๐‘‘๐œ‹/๐‘‡ (๐‘ฅ)|๐œ“   i   1 โˆ’
                                                     8 ๐‘‡2
                                                                               0
                                                                                            8

If this is > ๐›ฟ, then with some sufficiently large ๐‘€ 0 โ‰ฅ ๐‘€, amplitude estimation would detect this
and cause the algorithm to output 0 with high probability.                                     

                       T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                                                 45
                                         S TACEY J EFFERY

Acknowledgements
I am grateful to Tsuyoshi Ito for discussions that led to the construction of approximate span
programs from two-sided error quantum algorithms presented in Section 3.3, and to Alex
B. Grilo and Mario Szegedy for insightful comments. I am grateful to Robin Kothari for pointing
out the improved separation between certificate complexity and approximate degree in [8],
which led to an improvement in from (log ๐‘›)7/6 (using [1]) to (log ๐‘›)2โˆ’๐‘œ(1) in Theorem 5.3. I thank
Robert Robere for pointing me to a separation between formula size and monotone formula
size for XOR-SAT. Finally, I thank the anonymous reviewers, whose feedback has improved the
presentation of these results.


References
 [1] Scott Aaronson, Shalev Ben-David, and Robin Kothari: Separations in query com-
     plexity using cheat sheets. In Proc. 48th STOC, pp. 863โ€“876. ACM Press, 2016.
     [doi:10.1145/2897518.2897644, arXiv:1511.01937, ECCC:TR15-175] 6, 46

 [2] Noga Alon, Troy Lee, Adi Schraibman, and Santosh Vempala: The approximate rank of a
     matrix and its algorithmic applications. In Proc. 45th STOC, pp. 675โ€“684. ACM Press, 2013.
     [doi:10.1145/2488608.2488694, ECCC:TR12-169] 8

 [3] Andris Ambainis: Quantum lower bounds by quantum arguments. J. Comput. System
     Sci., 64(4):750โ€“767, 2002. Preliminary version in STOCโ€™00. [doi:10.1006/jcss.2002.1826,
     arXiv:quant-ph/0002066] 11

 [4] Sanjeev Arora and Boaz Barak: Computational Complexity: A Modern Approach. Cambridge
     Univ. Press, 2009. Book. 4

 [5] Lรกszlรณ Babai, Anna Gรกl, and Avi Wigderson: Superpolynomial lower bounds for monotone
     span programs. Combinatorica, 19(3):301โ€“319, 1999. [doi:10.1007/s004930050058] 4, 5, 25

 [6] Howard Barnum, Michael E. Saks, and Mario Szegedy: Quantum query complexity and
     semi-definite programming. In Proc. 18th IEEE Conf. on Comput. Complexity (CCCโ€™03), pp.
     179โ€“193. IEEE Comp. Soc., 2003. [doi:10.1109/CCC.2003.1214419] 11

 [7] Gilles Brassard, Peter Hรธyer, Michele Mosca, and Alain Tapp: Quantum amplitude
     amplification and estimation. In Samual J. Lomonaca and Howard E. Brandt, editors,
     Quantum Computation and Quantum Information: A Millennium Volume, pp. 53โ€“74. Amer.
     Math. Soc., 2002. [doi:10.1090/conm/305, arXiv:quant-ph/0005055] 10, 42

 [8] Mark Bun and Justin Thaler: A nearly optimal lower bound on the approximate
     degree of ๐ด๐ถ 0 . SIAM J. Comput., 49(4):59โ€“96, 2020. Preliminary version in FOCSโ€™17.
     [doi:10.1137/17M1161737, arXiv:1703.05784, ECCC:TR17-051] 6, 33, 46

                     T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                      46
                      S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

 [9] Bill Fefferman and Cedric Yen-Yu Lin: A complete characterization of unitary quan-
     tum space. In Proc. 9th Innovations in Theoret. Comp. Sci. Conf. (ITCSโ€™18), pp. 4:1โ€“21.
     Schloss Dagstuhlโ€“Leibniz-Zentrum fuer Informatik, 2018. [doi:10.4230/LIPIcs.ITCS.2018.4,
     arXiv:1604.01384] 7

[10] Bill Fefferman and Zachary Remscrim: Eliminating intermediate measurements in space-
     bounded quantum computation. In Proc. 53rd STOC, pp. 1343โ€“1356. ACM Press, 2021.
     [doi:10.1145/3406325.3451051, arXiv:2006.03530, ECCC:TR20-088] 2, 9

[11] Anna Gรกl: A characterization of span program size and improved lower bounds for
     monotone span programs. Comput. Complexity, 10(4):277โ€“296, 2001. Preliminary version in
     STOCโ€™98. [doi:10.1007/s000370100001] 4, 5, 25, 27, 29

[12] Uma Girish, Ran Raz, and Wei Zhan: Quantum logspace algorithm for powering matrices
     with bounded norm. In Proc. 48th Internat. Colloq. on Automata, Languages, and Program-
     ming (ICALPโ€™21), pp. 73:1โ€“20. Schloss Dagstuhlโ€“Leibniz-Zentrum fuer Informatik, 2021.
     [doi:10.4230/LIPIcs.ICALP.2021.73, arXiv:2006.04880, ECCC:TR20-087] 2, 9

[13] Mika Gรถรถs, Pritish Kamath, Robert Robere, and Dmitry Sokolov: Adventures in
     monotone complexity and TFNP. In Proc. 10th Innovations in Theoret. Comp. Sci.
     Conf. (ITCSโ€™19), pp. 38:1โ€“19. Schloss Dagstuhlโ€“Leibniz-Zentrum fuer Informatik, 2019.
     [doi:10.4230/LIPIcs.ITCS.2019.38, ECCC:TR18-163] 37

[14] Peter Hรธyer, Troy Lee, and Robert ล palek: Negative weights make adversaries stronger.
     In Proc. 39th STOC, pp. 526โ€“535. ACM Press, 2007. [doi:10.1145/1250790.1250867] 11

[15] Tsuyoshi Ito and Stacey Jeffery: Approximate span programs. Algorithmica, 81(6):2158โ€“2195,
     2019. Preliminary version in ICALPโ€™16. [doi:10.1007/s00453-018-0527-1, arXiv:1507.00432]
     2, 9, 10, 12, 13, 14, 17, 18, 19, 37

[16] Stacey Jeffery: Frameworks for Quantum Algorithms. Ph. D. thesis, University of Waterloo,
     2014. Available at http://uwspace.uwaterloo.ca/handle/10012/8710. 19

[17] Stacey Jeffery: Span programs and quantum space complexity. In Proc. 11th Innovations
     in Theoret. Comp. Sci. Conf. (ITCSโ€™20), pp. 4:1โ€“37. Schloss Dagstuhlโ€“Leibniz-Zentrum fuer
     Informatik, 2020. [doi:10.4230/LIPIcs.ITCS.2020.4, arXiv:1908.04232] 1

[18] Stacey Jeffery and Shelby Kimmel: Quantum algorithms for graph connectivity and formula
     evaluation. Quantum, 1:26:1โ€“40, 2017. [doi:10.22331/q-2017-08-17-26, arXiv:1704.00765] 37

[19] Richard Jozsa, Barbara Kraus, Akimasa Miyake, and John Watrous: Matchgate and space-
     bounded quantum computations are equivalent. Proc. Royal Soc. A, 466(2115):809โ€“830, 2010.
     [doi:10.1098/rspa.2009.0433] 7

[20] Mauricio Karchmer and Avi Wigderson: On span programs. In Proc. 8th IEEE
     Conf. Structure in Complexity Theory (SCTโ€™93), pp. 102โ€“111. IEEE Comp. Soc., 1993.
     [doi:10.1109/SCT.1993.336536] 2, 11, 12

                    T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                   47
                                        S TACEY J EFFERY

[21] Alexei Y. Kitaev: Quantum measurements and the Abelian stabilizer problem. Electron.
     Colloq. Comput. Complexity, TR96-003, 1996. [ECCC, arXiv:quant-ph/9511026] 9

[22] Troy Lee, Rajat Mittal, Ben W. Reichardt, Robert ล palek, and Mario Szegedy: Quantum
     query complexity of state conversion. In Proc. 52nd FOCS, pp. 344โ€“353. IEEE Comp. Soc.,
     2011. [doi:10.1109/FOCS.2011.75] 8

[23] Satyanarayana V. Lokam: Complexity lower bounds using linear algebra. Found. Trends
     Theor. Comp. Sci., 4(1โ€“2):1โ€“155, 2009. [doi:10.1561/0400000011] 25

[24] Toniann Pitassi and Robert Robere: Strongly exponential lower bounds for monotone com-
     putation. In Proc. 49th STOC, pp. 1246โ€“1255. ACM Press, 2017. [doi:10.1145/3055399.3055478,
     ECCC:TR16-188] 5, 28, 31, 36

[25] Alexander A. Razborov: Applications of matrix methods to the theory of lower bounds in
     computational complexity. Combinatorica, 10(1):81โ€“93, 1990. [doi:10.1007/BF02122698] 4,
     25, 27, 29

[26] Alexander A. Razborov: On submodular complexity measures. In Proc. London Math. Soc.
     Symposium on Boolean Function Complexity, pp. 76โ€“83, 1992. Authorโ€™s website. 27

[27] Ben W. Reichardt: Span programs and quantum query complexity: The general adversary
     bound is nearly tight for every Boolean function. In Proc. 50th FOCS, pp. 544โ€“551. IEEE
     Comp. Soc., 2009. [doi:10.1109/FOCS.2009.55, arXiv:0904.2759] 2, 3, 10, 11, 12, 19, 37

[28] Ben W. Reichardt and Robert ล palek: Span-program-based quantum algorithm for
     evaluating formulas. Theory of Computing, 8(13):291โ€“319, 2012. Preliminary version in
     STOCโ€™08. [doi:10.4086/toc.2012.v008a013] 2, 11

[29] Robert Robere, Toniann Pitassi, Benjamin Rossman, and Stephen A. Cook: Exponential
     lower bounds for monotone span programs. In Proc. 57th FOCS, pp. 406โ€“415. IEEE Comp.
     Soc., 2016. [doi:10.1109/FOCS.2016.51, ECCC:TR16-064] 5, 6, 31, 34

[30] Alexander A. Sherstov: The pattern matrix method. SIAM J. Comput., 40(6):1969โ€“2000,
     2011. [doi:10.1137/080733644, arXiv:0906.4291] 6, 31, 34

[31] John Watrous: Space-bounded quantum complexity. J. Comput. System Sci., 59(2):281โ€“326,
     1999. [doi:10.1006/jcss.1999.1655] 6




                    T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                    48
                     S PAN P ROGRAMS AND Q UANTUM S PACE C OMPLEXITY

AUTHOR

    Stacey Jeffery
    Senior researcher
    CWI & QuSoft
    Amsterdam
    The Netherlands
    jeffery cwi nl
    https://homepages.cwi.nl/~jeffery/


ABOUT THE AUTHOR

    Stacey Jeffery started her academic career as an undergraduate philosophy student
       at McMaster University, before reading the book Gรถdel, Escher, Bach: An Eternal
       Golden Braid, after which she transfered to a Computer Science program at
       the University of Waterloo. She got her Ph. D. in Computer Science from the
       University of Waterloo under the supervision of Michele Mosca in 2014, before
       spending two and a half years as a postdoc at Caltech at the Insitute for Quantum
       Information and Matter. She now lives in Amsterdam with her husband and
       two-year-old daughter, who enjoys bedtime stories read from Theory of Computing.




                  T HEORY OF C OMPUTING, Volume 18 (11), 2022, pp. 1โ€“49                    49