Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

1 Introduction

The concept of a span program as a linear-algebraic model of computation is not new. It was introduced by Karchmer and Wigderson in 1993 [9] and has many applications in classical complexity theory. Span programs can be used to evaluate decision problems. In 2008 Reichardt and Spalek [12] introduced a new complexity measure for span programs – witness size, which, as Reichardt showed later in [10, 11], has strong connection with the quantum query complexity. There is a quantum algorithm for evaluating span programs [10] and these two complexity measures are essentially equivalent. The difficulty is to come up with a span program with a good witness size complexity.

In [12] authors dealt with bounded-size span programs evaluating Boolean functions each on O(1) bits and posed an open question – do there exist interesting quantum algorithms based directly on asymptotically large span program? Belovs used span programs to construct learning graphs [3, 4]. He also used span program approach for the matrix rank problem [2]. In [1] Ambainis et al. came up with a simple yet powerful span program for the graph collision problem.

In this paper, we extend the family of algorithms based on span programs. We present two new span-program-based quantum algorithms – an \(O(n\sqrt{n})\) algorithm for the graph bipartiteness problem and an \(O(n\sqrt{n})\) algorithm for the graph connectivity problem. Both algorithms in the quantum query sense are optimal because the witness sizes match the quantum query complexity lower bounds [6, 7] for these problems. Thus we demonstrate that span programs can be useful also for the problems with an asymptotically large input and possibly our algorithms could be building blocks for bigger span programs in the future.

The graph connectivity problem has been studied before [7] and there already exists a \(O(n\sqrt{n})\) quantum query algorithm which requires O(n) qubits of quantum memory. The advantage of our algorithm is that it uses only \(O(\log n)\) qubits of quantum memory because the span program \(P_2\) uses a vector space with \(O(n^2)\) dimensions. Similarly for the graph bipartiteness problem. It can be solved with the breadth-first search method [8] which uses O(n) qubits of quantum memory, but our approach with a span program requires \(O(\log n)\) qubits of quantum memory.

2 Preliminaries

In this paper, we present algorithms which work on simple graphs, given in adjacency model. If the given graph has n vertices then the input size for an algorithm is \(n \times n\) and we assume that the input variable \(x_{i,j}\) corresponds to the value of entry in i-th row and j-th column of the adjacency matrix.

2.1 Span Programs

Definition 1

[1]. A span program P is a tuple \(P=\left( H, \left| t \right\rangle , V\right) \), where H is a finite-dimensional Hilbert space, \(\left| t \right\rangle \in H\) is called the target vector, and \(V=\{V_{i,b}|i \in [n], b \in \{0,1\}\}\), where each \(V_{i,b} \subseteq H\) is a finite set of vectors.

Denote by \(V(x) = \bigcup {\{V_{i,b}|i\in [n], x_i=b\}}\). The span program is said to compute function \(f:D \rightarrow \{0,1\}\), where the domain \(D \subseteq \{0,1\}^n\), if for all \(x\in D\),

$$\begin{aligned} f(x)=1 \iff \left| t \right\rangle \in {\text {span}}(V(x)). \end{aligned}$$

Basically, what this definition says is that for each input variable \(x_i\) we have two sets of vectors (as the span program authors, we define these vectors in advance) – \(V_{i,0}\) and \(V_{i,1}\). If \(x_i=b\) then we say that vectors from the set \(V_{i,b}\) are available and vectors from the set \(V_{i,1-b}\) are not available. If some vector is included in both sets \(V_{i,0}\) and \(V_{i,1}\) then we say that it is a free vector – it is always available.

The function returns 1 iff the target vector can be expressed as a linear combination of the available vectors, otherwise it returns 0.

Definition 2

[1].

  1. (1)

    A positive witness for \(x\in f^{-1}(1)\) is a vector \(w=(w_v),v\in V(x)\), such that \(\left| t \right\rangle =\sum _{v\in V(x)}{w_v v}\). The positive witness size is

    $$\begin{aligned} {\text {wsize}}_1(P):=\max _{x\in f^{-1}(1)}{\min _{w:\text {witness of }x}{\Vert w\Vert ^2}}. \end{aligned}$$
  2. (2)

    A negative witness for \(x\in f^{-1}(0)\) is a vector \(w\in H\), such that \(\left\langle t | w \right\rangle =1\) and for all \(v\in V(x)\): \(\left\langle v | w \right\rangle =0\). The negative witness size is

    $$\begin{aligned} {\text {wsize}}_0(P):=\max _{x\in f^{-1}(0)}{\min _{w:\text {witness of }x}{\sum _{v\in V}{{\left\langle v | w \right\rangle }^2}}}. \end{aligned}$$
  3. (3)

    The witness size of a program P is

    $$\begin{aligned} {\text {wsize}}(P):=\sqrt{{\text {wsize}}_0(P)\cdot {\text {wsize}}_1(P)}. \end{aligned}$$
  4. (4)

    The witness size of a function f denoted by \({\text {wsize}}(f)\) is the minimum witness size of a span program that computes f.

Theorem 1

[10, 11]. Q(f) and \({\text {wsize}}(f)\) coincide up to a constant factor. That is, there exists a constant \(c > 1\) which does not depend on n or f such that \(\frac{1}{c}{\text {wsize}}(f) \le Q(f) \le c \cdot {\text {wsize}}(f)\).

3 Span Program for Testing Graph Bipartiteness

A bipartite graph is a graph whose vertices can be divided into two disjoint sets such that there is no edge that connects vertices of the same set. An undirected graph is bipartite iff it has no odd cycles.

Algorithm 1

There exists a span program P which for a graph with n vertices detects if the graph is bipartite with \(wsize(P) = O(n\sqrt{n})\).

Proof

We will make a span program which detects if a graph has an odd cycle.

Let \(n=|G|\) be a number of vertices in the given graph G. Then the span program is as follows:

figure afigure a

The states in the span program \(P_1\) are mostly in the form \(\left| v_{k,b} \right\rangle \) where v is vertex index, k represents vertex from which we started our search for an odd length cycle and b represents the parity of the current path length. The first subindex k in state \(\left| v_{k,b} \right\rangle \) can also be considered as the subspace index for the subspace \(V_k = {\text {span}}(\{\left| v_{k,b} \right\rangle | v \in [1..n], b\in \{0,1\}\})\). Vectors corresponding to edges are in the form \(\left| u_{k,b} \right\rangle +\left| v_{k,1-b} \right\rangle \) consisting from sum of two states which both belong to same subspace \(V_k\).

In the span program \(P_1\) the target vector \(\left| 0 \right\rangle \) can only be expressed as a linear combination of the available vectors if at least one of the vectors in the form \(\left| k_{k,0} \right\rangle +\left| k_{k,1} \right\rangle \) can be expressed. Without loss of generality, if there is an odd length cycle \(v_1-v_2-\dots -v_{(2j+1)}-v_1\) then the target vector can be expressed by taking the vectors corresponding to the edges of this cycle, alternatingly with plus and minus sign

$$\left| 0 \right\rangle =\left( \left| 0 \right\rangle +\left| 1_{1,0} \right\rangle +\left| 1_{1,1} \right\rangle \right) -\left( \left| 1_{1,0} \right\rangle +\left| 2_{1,1} \right\rangle \right) +\dots -\left( \left| (2j+1)_{1,0} \right\rangle +\left| 1_{1,1} \right\rangle \right) $$

therefore the span program \(P_1\) will always return 1 when the given graph is not bipartite.

From the other side, if there is no odd length cycle then none of the vectors in the form of \(\left| k_{k,0} \right\rangle +\left| k_{k,1} \right\rangle \) can be expressed using the available vectors from \(P_1\). To cancel out the state \(\left| k_{k,0} \right\rangle \) we should be using a vector \(\left| k_{k,0} \right\rangle +\left| v_{k,1} \right\rangle \) corresponding to some edge \(k-v\) where v is some vertex adjacent to k because no other vector contains the state \(\left| k_{k,0} \right\rangle \). By doing so we move from the state \(\left| k_{k,0} \right\rangle \) to the state \(\left| v_{k,1} \right\rangle \) (possibly with some coefficient other than 1) which has the parity bit flipped. Similarly, to cancel out the state \(\left| v_{k,1} \right\rangle \) we should be using a vector corresponding to some edge going out from vertex v. To stop this process we need to reach the state \(\left| k_{k,1} \right\rangle \). It can be done only if there is an odd cycle because the path must be closed and the parity bit restricts it to odd length. When there is no odd cycle, span program \(P_1\) will always return 0.

We can conclude that \(P_1\) indeed computes the expected function. It remains to calculate the witness size of \(P_1\).

For the case when there is an odd cycle we need to calculate the positive witness size. If there is an odd cycle \(v_1-v_2-\dots -v_{d}-v_1\) with length d then the target vector can be expressed in this way

$$\left| 0 \right\rangle =1\cdot \left( \left| 0 \right\rangle +\left| 1_{1,0} \right\rangle +\left| 1_{1,1} \right\rangle \right) +(-1)\cdot \left( \left| 1_{1,0} \right\rangle +\left| 2_{1,1} \right\rangle \right) +\dots +(-1)\cdot \left( \left| d_{1,0} \right\rangle +\left| 1_{1,1} \right\rangle \right) $$

and the positive witness w here consists only from \(d+1\) entries \(\pm 1\) therefore \(\Vert w\Vert ^2=d+1\).

If \(v_1-v_2-\dots -v_{d}-v_1\) is a cycle then also \(v_2-v_3-\dots -v_{d}-v_1-v_2\) is a cycle and therefore the target vector can also be expressed in this way

$$\left| 0 \right\rangle =\left( \left| 0 \right\rangle +\left| 2_{2,0} \right\rangle +\left| 2_{2,1} \right\rangle \right) -\left( \left| 2_{2,0} \right\rangle +\left| 3_{2,1} \right\rangle \right) +\dots -\left( \left| 1_{2,0} \right\rangle +\left| 2_{2,1} \right\rangle \right) $$

the same follows for all d vertices in this cycle and the target vector therefore can be expressed in atleast d different ways. We can combine these d ways each taken with coefficient 1 / d and then we get that the positive witness size

$$\begin{aligned} {\text {wsize}}_1(P_1) \le d*(1/d)^2*(d+1)<2 \end{aligned}$$
(1)

To estimate the negative witness size we must find a negative witness \(w'\). We derive \(w'\) by defining how it acts on basis vectors. From definition \({\left\langle w' | 0 \right\rangle }=1\). For every k we must have \(\left\langle w' | \left( \left| 0 \right\rangle +\left| k_{k,0} \right\rangle +\left| k_{k,1} \right\rangle \right) \right\rangle =0\) therefore lets pick \(w'\) in such a way that \(\left\langle w' | k_{k,0} \right\rangle =0\) and \(\left\langle w' | k_{k,1} \right\rangle =-1\). Now repeat the following steps until no changes happen:

  • for every available vector \(\left| u_{k,0} \right\rangle +\left| v_{k,1} \right\rangle \) if \(\left\langle w' | u_{k,0} \right\rangle \) is defined then define \(\left\langle w' | v_{k,1} \right\rangle =-\left\langle w' | u_{k,0} \right\rangle \).

  • for every available vector \(\left| u_{k,1} \right\rangle +\left| v_{k,0} \right\rangle \) if \(\left\langle w' | u_{k,1} \right\rangle \) is defined then define \(\left\langle w' | v_{k,0} \right\rangle =-\left\langle w' | u_{k,1} \right\rangle \).

For all not yet defined \(\left\langle w' | v_{k,b} \right\rangle \) define \(\left\langle w' | v_{k,b} \right\rangle =0\).

For any given vector v in span program \(P_1\) the value \({\left\langle w' | v \right\rangle }^2\le 1\). The total number of vectors does not exceed \(n+n^3\) therefore the negative witness size is

$$\begin{aligned} {\text {wsize}}_0(P_1) \le 1\cdot (n+n^3) \end{aligned}$$
(2)

Combining positive and negative witness sizes we obtain the upper bound for witness size which also corresponds to quantum query complexity

$$\begin{aligned} {\text {wsize}}(P_1) = \sqrt{{\text {wsize}}_0(P_1)\cdot {\text {wsize}}_1(P_1)} = O\left( n\sqrt{n}\right) \end{aligned}$$
(3)

   \(\square \)

4 Span Program for Testing Graph Connectivity

A graph is said to be connected if every pair of vertices in the graph is connected. If in an undirected graph one vertex is connected to all other vertices then by transitivity the graph is connected.

Algorithm 2

There exists a span program P which for a graph with n vertices detects if the graph is connected with \(wsize(P) = O(n\sqrt{n})\).

Proof

Let \(n=|G|\) be a number of vertices in the given graph G. Then the span program is as follows:

figure bfigure b

If all vertices are reachable from vertex with index 1 then the given graph is connected. Here we use Belov’s [5] span program for s-t connectivity as subroutine. This subroutine checks if in a given graph there is a path from the vertex s to the vertex t. The span program for it has the target vector \(\left| s \right\rangle -\left| t \right\rangle \) and for each edge \(i-j\) (input \(x_{i,j}=1\)) we can use the vector \(\left| i \right\rangle -\left| j \right\rangle \).

In span program \(P_2\), by using this subroutine \(n-1\) times, we check if all other vertices are connected to vertex with index 1. We create a separate subspace \(V_k = {\text {span}}(\{\left| v_{k} \right\rangle | v \in [0..n]\})\) for each such subroutine call to avoid any interference between them, which is a common technique [10] how to compose span programs. The span program returns 1 when all vertices are connected, but otherwise it returns 0.

For the case when the given graph is connected we need to calculate the positive witness size. In each s-t subroutine the shortest path length from the vertex s to the vertex t can not be larger than \(n-1\). Threfore each vector from the set \(\left\{ \left| 0_k \right\rangle | k\in [2..n]\right\} \) requires no more than n vectors to express it. There are \(n-1\) such subroutines. The positive witness size is

$$\begin{aligned} wsize_1(P_2)\le n\cdot (n-1) \le n^2 \end{aligned}$$
(4)

To estimate the negative witness size we must find a negative witness \(w'\). We derive \(w'\) by defining how it acts on the basis vectors. From definition \({\left\langle w' | t \right\rangle }=1\). We need to talk about negative witness only when some vertex v is not connected to vertex with index 1. Then the vertex v belongs to different connected component than vertex with index 1. Lets name this connected component \(C_v\) and let the count of vertices in this connected component be \(d_v\). Lets pick \(w'\) in such a way that for each vertex \({v_k}\in {C_v}\) set \(\left\langle w' | 0_k \right\rangle =1/{d_v}\) and for each vertex \({v_z}\notin {C_v}\) set \(\left\langle w' | 0_z \right\rangle =0\).

For \(k\in [2..n]\) we must have \(\left\langle w' | (\left| 0_k \right\rangle +\left| 1_k \right\rangle -\left| k_k \right\rangle ) \right\rangle =0\) therefore set \(\left\langle w' | 1_k \right\rangle =-\left\langle w' | 0_k \right\rangle \) and \(\left\langle w' | k_k \right\rangle =0\). Now repeat the following step until no changes happen: for every available vector \(\left| u_k \right\rangle -\left| v_k \right\rangle \) if \(\left\langle w' | u_k \right\rangle \) is defined then define \(\left\langle w' | v_k \right\rangle =\left\langle w' | u_k \right\rangle \). For all other not yet defined basis vectors \(\left| v_k \right\rangle \) set \(\left\langle w' | v_k \right\rangle =0\).

With such negative witness \(w'\) choice the overall negative witness size will only get increased by vectors which correspond to nonexistent graph edges which connects \(C_v\) with other connected components in graph - i.e. border edges. An edge \(u-v\) is a border edge if \(u\in C_v\) and \(v\notin C_v\). To a border edge \(u-v\) correspond the vectors \(\left| u_k \right\rangle -\left| v_k \right\rangle \) where \(k\in [2..n]\) but only \(d_v\) from these vectors will have \(\left\langle w' | u_k \right\rangle \ne \left\langle w' | v_k \right\rangle \) and each such vector increases the negative witness size by value \((1/d_v)^2\). For \(C_v\) there are at most \(d_v\cdot (n-1)\) border edges therefore the overall negative witness size is

$$\begin{aligned} {\text {wsize}}_0(P_2) \le d_v^2\cdot (n-1)\cdot (1/d_v)^2 \le n \end{aligned}$$
(5)

Combining the positive and negative witness sizes we obtain the upper bound for the witness size which also corresponds to the quantum query complexity

$$\begin{aligned} {\text {wsize}}(P_2) = \sqrt{{\text {wsize}}_0(P_2)\cdot {\text {wsize}}_1(P_2)} = O\left( n\sqrt{n}\right) \end{aligned}$$
(6)

   \(\square \)