Manuscript Offprint
arXiv:2609.40180Improved Quantum Query Bounds for Boolean Matrix Product Verification
Abstract
We prove the first non-trivial upper bound for the quantum query complexity of Boolean Matrix Product Verification (BMPV), answering a longstanding open question in quantum query complexity. For matrices, our upper bound is , improving on the standard bound obtained using Grover search by Buhrman and Špalek (SODA 2006). We complement this result by showing an lower bound, which improves over the previous best known lower bound of by Childs, Kimmel, and Kothari (ESA 2012).
Our approach centers on a connection with Orthogonal Vectors (OV), which asks whether an indexed list of n Boolean vectors of dimension n contains two vectors with disjoint supports. In particular, we prove equivalences between OV and BMPV and establish the above bounds for OV. We also prove a tight bound for a variant of BMPV that asks whether the product contains a given row vector. Together, these results imply a polynomial separation between the quantum query complexities of deciding whether a graph has radius at most two and whether it has diameter at most two.
*University of Maryland. asgilani@umd.edu
Graduate School of Mathematics, Nagoya University. legall@math.nagoya-u.ac.jp
The University of British Columbia. zxingyu@cs.ubc.ca
Contents
1 Introduction 3
1.1 Background and statement of the main results 3
1.2 Proof overview 4
1.3 Other related work 9
1.4 Open problems 10
2 Preliminaries 10
2.1 Model and problem definitions 10
2.2 Quantum algorithmic tools 12
3 From verification to Orthogonal Vectors 14
3.1 Reductions between verification and Orthogonal Vectors 14
3.2 A lower bound from surjectivity 15
3.3 Equivalence of verification and Orthogonal Vectors 17
3.4 Diameter at Most Two 18
4 An upper bound for Orthogonal Vectors 18
4.1 The promise case 19
4.2 The general case 24
5 An existential analogue of verification 32
5.1 Boolean Matrix Product Row Search 32
5.2 Radius at Most Two 34
Acknowledgements 35
References 36
1.1 Background and statement of the main results
Boolean Matrix Product Verification. Boolean matrix product verification (BMPV ) is one of the central problems in fine-grained complexity [VWW18, Kün18]. Given as input three matrices , this problem asks whether , where denotes the Boolean matrix product, i.e., the matrix product over the Boolean semiring in which addition is OR and multiplication is AND. While over rings Freivalds's randomized linear fingerprint verifies a matrix product classically in quadratic time [Fre79], the same argument does not extend to the Boolean semiring. The best known classical algorithm for Boolean matrix product verification works by reducing it to matrix multiplication, leading to time complexity , where denotes the exponent of matrix multiplication.
Even in the quantum query model, in which the algorithm receives oracle access to A, B, C and only queries to matrix entries are counted, the complexity of verifying a Boolean matrix product remains unresolved. Grover search immediately gives the upper bound , as observed by Buhrman and Špalek [BŠ06], where Q denotes bounded-error quantum query complexity. Whether this upper bound is optimal has remained a longstanding open question in quantum query complexity (see, e.g., [CKK12, JKM12, KN16, LG14b] and [Kot14, Open Problem 4.5]). The best known lower bound is proved by Childs, Kimmel, and Kothari using the read-many formula method [CKK12], leaving a large gap.
The quantum query complexity of Boolean matrix product verification is particularly interesting because of its connection to triangle finding, a central problem that has driven research in quantum query complexity [MSS07, LMS13, LG14a, CLM17]. Although triangle finding reduces to Boolean matrix product verification, successive improvements have led to quantum algorithms for triangle finding in -vertex graphs using queries, well below the bound obtained by Grover search. A significant difference between the two problems lies in their certificate complexities. Whereas triangle finding has constant-size 1-certificates, the 0- and 1-certificate complexities of are and , respectively. This contrast suggests that Boolean matrix product verification may be harder than triangle finding and, prior to this work, could have suggested that its upper bound was optimal. The previously known lower bounds also reflect this contrast: Boolean matrix product verification had a lower bound, whereas the best known lower bound for triangle finding remains the trivial .
In this work, we show the first non-trivial upper bound for Boolean Matrix Product Verification:
Theorem 1.1. . (Note that )
We complement this upper bound by the following new lower bound:
Theorem 1.2. .
Theorem 1.2 significantly improves the lower bound from [CKK12]. Our lower bound holds even when C is the all-ones matrix and .
Diameter and radius. We also study two graph parameters: the diameter (the maximum distance between any pair of vertices) and the radius (the minimum, over all vertices, of the maximum
Boolean matrix product verification is not interesting in the classical query model since its classical query complexity is trivially .
In this paper, the notations , and suppress polylog(n) factors.
distance from that vertex to any other vertex). Throughout, graphs are unweighted and undirected, and n denotes the number of vertices.
Computing and approximating graph diameter and radius have long been studied in classical algorithms and fine-grained complexity [ACIM99, BKM95, RVW13, CLR 14, CGR16, AVWW16, BRS 18]. The special case of deciding whether the diameter is at most two, which we denote DIAM , is closely connected to Boolean matrix product verification: this property holds precisely when is the all-ones matrix, where is the adjacency matrix with ones added on the diagonal. Deciding whether the radius is at most two, which we denote RAD , also has a particularly simple matrix formulation: it asks whether contains an all-ones row. The best known classical algorithms for both problems have time complexity .
We investigate these decision problems in the quantum query model, with oracle access to the graph's adjacency matrix. We apply the techniques developed in this paper and show that the bounds of Theorems 1.1 and 1.2 also hold for deciding whether the diameter is at most two:
Theorem 1.3. and .
We then give bounds, tight up to polylogarithmic factors, for the quantum query complexity of radius at most two:
Theorem 1.4.
These results give a polynomial separation between the quantum query complexities of deciding whether the radius is at most two and whether the diameter is at most two. Interestingly, such a separation is not known in the classical time complexity setting. Note that the main difference between the two problems is a change of quantifier. While corresponds to with the all-ones target matrix, corresponds to the all-ones-target case of Boolean Matrix Product Row Search ( ), which asks whether some row of equals a given vector . For , this becomes
Our results also show that BMPRS has quantum query complexity , yielding the same polynomial separation from BMPV.
1.2 Proof overview
Figure 1 summarizes our results.
1.2.1 Reductions and the lower bound
Reductions to Orthogonal Vectors. Our central connection is with Orthogonal Vectors. The problem asks whether an indexed list of vectors in contains two vectors at distinct positions with disjoint supports.
The inequality
is straightforward. We show
by observing (see also [Kot14, Section 4.3]) that
Pairwise intersection problems

every vertex versus some vertex
every row versus some row
Figure 1: Query bounds and relationships among the problems. Solid arrows indicate equivalence in quantum query complexity up to constant-factor changes in problem dimension. The lower arrow restricts BMPRS to the all-ones target. Dashed connectors change “every” to “some,” fixing and on the matrix side. Graphs use adjacency matrix queries.
where means that for every , and is defined analogously. A failure of the first inequality supplies a triple with and , and is equivalent to a triangle in a standard tripartite graph, which can be tested in queries [CLM17]. A failure of the second inequality can be encoded as an instance.
Our main technical contribution is showing that and . The lower bound comes from surjectivity, and the upper bound combines variable-time search with a quantum walk for detecting an orthogonal pair. Theorems 1.1 and 1.2 follow by combining these bounds with Equation (1.2) and Equation (1.3).
We also show
which proves Theorem 1.3.
Closed neighborhoods give the reduction from diameter to OV. For the reverse diameter reduction, represent rows by independent vertices and columns by a clique, with incidence edges supplied by the input bits. Two row vertices are within two steps precisely when their supports intersect. This construction has 2n vertices.
A lower bound from surjectivity. The key idea is to encode missing outputs of a function as orthogonal pairs of rows. Consider a surjectivity instance
where, for simplicity, assume is a perfect square. Write . We form a Boolean matrix with rows and columns: for each output component and each possible value, create a row whose entry in column is one exactly when that component of equals that value.
For example, take and the function
| t | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| f(t) | (1,1) | (1,2) | (2,1) | (1,1) | (1,2) | (2,1) |
which misses (2, 2). The corresponding matrix is
| 1 | 2 | 3 | 4 | 5 | 6 | |
|---|---|---|---|---|---|---|
| 1 | 1 | 0 | 1 | 1 | 0 | |
| 0 | 0 | 1 | 0 | 0 | 1 | |
| 1 | 0 | 1 | 1 | 0 | 1 | |
| 0 | 1 | 0 | 0 | 1 | 0 |
A row for and a row for share a one precisely in the columns for which . These two rows are therefore orthogonal exactly when is missing from the image of . In the example, the second and fourth rows form such a pair.
The full reduction in Theorem 3.4 uses this encoding to combine independent surjectivity instances into a single OV instance with rows and columns. By the surjectivity lower bound of Beame and Machmouchi [BM12] and standard adversary composition [LMR11], deciding whether any of these functions is not surjective requires queries. This gives .
Combining Equation (1.3) with this lower bound gives
i.e., the two problems have the same quantum query complexity up to a possible constant-factor change in problem dimension.
1.2.2 An upper bound for Orthogonal Vectors
We first explain the algorithm under an intersection promise that every pair among the input vectors has either or common ones. We describe our quantum walk algorithm for this promise problem under the temporary assumption that every left list is small. We then describe how to remove this assumption and finally describe how to remove the promise.
Preprocessing and combinatorial guarantees. Sampling coordinates and querying them in every vector reveals a common one for every pair with a large intersection, with high probability. We discard these pairs and let be the known graph of surviving candidates, with denoting the neighbors of . Every orthogonal pair survives, and every surviving pair has only common ones.
Choose independent parameters . We sample vector indices independently and uniformly, call the corresponding vectors pivots, and read them completely. We call covered at coordinate if it is a candidate neighbor of some pivot having a one there. Thus, if at a covered coordinate, this one is shared with a sampled pivot. We call heavy at if more than of its candidate neighbors remain uncovered.
The threshold separates two situations. If is not heavy, only a few uncovered partners need attention at this coordinate. If is heavy and , we store this coordinate so that it can be reused across many partner tests. Accordingly, define .
We now argue that sampling makes the total size of the left lists small. Fix a coordinate and consider sampling the pivots one at a time. If many heavy indices with a one remain, the next random pivot is likely to be one of them. Whenever this happens, more than t new indices become covered. But only n indices can become covered altogether.
Quantitatively, the number of heavy indices having a one can only decrease. Each draw therefore covers, in expectation, at least times the expected number of such indices remaining after all draws. This bounds the final expected number by . Summing over coordinates gives , and hence, with constant probability, .
The quantum walk. We will perform a quantum walk on a Johnson graph to find a subset containing an index of a vector with an orthogonal partner. To explain the walk, temporarily assume the stronger statement that every left list has size . We will remove this additional assumption after describing the walk.
The walk maintains a subset of size , together with the left lists of its indices. A walk state is marked if some vector indexed by has an orthogonal partner anywhere in the input. Only one endpoint of an orthogonal pair needs to be in the maintained subset.
An update replaces one index and loads its left list, keeping the information about all other indices. Since heaviness is already known, membership in a left list requires just one input query. Quantum enumeration therefore loads a list in queries. The setup cost, for loading all lists, is , and the update cost, for loading one new list, is .
If an orthogonal pair exists, a random walk state contains a fixed endpoint with probability . By the MNRS bound, with our choice of , the query cost of the quantum walk is , where is the cost of checking a walk state.
We now describe the checking procedure. Fix the maintained subset and a possible partner . We first load the right list , consisting of the coordinates where has a one and is covered. This list is small: every coordinate in it is a common one of and some pivot adjacent to . Each such pair has only common ones, so . Quantum enumeration therefore loads it in queries. The right list can now be reused for every candidate .
For a particular pair, let contain the coordinates where is not heavy and is uncovered. Every common one lies in , , or . Indeed, heaviness puts it in the left list, coverage puts it in the right list, and the remaining set handles the case where neither occurs. Grover search over this union therefore tests orthogonality using queries.
For each , we have . Indeed, at each coordinate where is not heavy, at most candidate neighbors are uncovered; summing over the coordinates gives the bound. Thus the total number of remaining coordinates across candidate pairs involving is at most .
Applying variable-time quantum search over indices and then over partners , we obtain
The first term accounts for loading right lists; the second accounts for searching the sets of coordinates associated with the pairs. Substituting this into the walk bound gives , in addition to reading the pivots.
Removing the list size assumption. We now remove the assumption that every left list is small. The bound on the total size already tells us that large lists cannot occur too often. We make this useful by grouping indices according to approximate list sizes.
Using additional queries, we assign each index a size label . The size labels are powers of two and satisfy . Let the size class contain the indices with size label , and let . The quantity is the sum of the size labels in , so
Consequently, a size class with more expensive lists has fewer indices to search.
We run the same walk on each size class, now maintaining indices. Partners are still searched for throughout the input. The cost of searching a size class is .
There are only size classes. Including preprocessing, the total cost is
Choosing and balances the three walk terms at .
Removing the intersection promise. Without the promise, sampling a few coordinates no longer guarantees that every surviving pair has a small intersection. Consequently, a pivot may contribute many coordinates to a right list, and the bound on the cost of loading these lists fails. We fix this by using only the first common one of each pair: one common one already suffices to rule out orthogonality.
At coordinate , we regard as a candidate neighbor of if and their vectors have no common one before . Coverage is defined using these candidate neighborhoods, which depend on the coordinate. Thus, if and is covered at , then must be the first common one of and some pivot. Each pivot contributes at most one such coordinate, restoring the bound .
The candidate neighborhoods are now implicit, so we cannot determine heaviness from a known graph. Instead, we fully read an independent sample of vectors and use it to estimate the number of uncovered candidate neighbors. We choose the threshold so that, with high probability, every declared heavy index has more than such neighbors, while every index not declared heavy has at most . We use these notions of coverage and heaviness in the same definitions of the left lists, right lists, and remaining sets. The counting argument for pivots still gives , so the same size classes and Johnson walks remain applicable.
To evaluate coverage and heaviness, we store each vector's first common ones with the sampled vectors. These records can be loaded in queries: we search for successive coordinates that determine a previously unknown first intersection, and each successful search resolves at least one sampled vector. There are such searches, and their coordinate intervals have total length at most .
One further change is needed in the checking procedure. The counting argument now bounds only remaining coordinates up to the first common one. Writing first for this coordinate, or if the pair is orthogonal, we have
We search in increasing coordinate order, using successively larger prefixes. Up to logarithmic factors, the squared query cost is bounded by the number of positions through the first common one, or the entire set size plus one if the pair is orthogonal. For each fixed partner , variable-time quantum search over costs the square root of the sum of these squared costs. The displayed inequality bounds the contribution from remaining coordinates, summed over all partners. We estimate the cost of checking each partner , group partners with comparable estimated costs, and apply quantum search separately within each group.
Accounting for these estimates and the additional record loading gives the total query bound
The same choices and give for the general problem.
1.2.3 Boolean Matrix Product Row Search and radius
For BMPRS with , encode the predicate by an intersection of two complemented binary encodings. An all-ones product row then represents a value missing from . Replacing each encoded bit by an OR of variables and applying adversary composition yields queries. For every target , the matching upper bound up to a logarithmic factor follows by robustly evaluating Equation (5.1), using quantum search to compute each product entry.
Closed neighborhoods give the reduction from radius to BMPRS with . For the reverse reduction, a layered incidence construction [AVWW16] makes the possible centers correspond to all-ones rows of . This construction has vertices.
1.3 Other related work
Boolean matrix products. Quantum algorithms for matrix products and verification are surveyed by Kothari and Nayak [KN16] and by Le Gall [LG14b]. Bun, Kothari, and Thaler related stronger lower bounds for linear-size depth-two circuits to improved lower bounds for BMPV [BKT21], and Ding explored polynomial and span program approaches to Boolean matrix problems [Din16]. In classical fine-grained complexity, Vassilevska Williams and Williams relate Boolean matrix multiplication, triangle detection, and product verification through truly subcubic combinatorial reductions [VWW18].
Quantum time-space tradeoffs for computing Boolean matrix products were studied by Klauck, Špalek, and de Wolf [KŠdW07] and strengthened by Beame, Kornerup, and Whitmeyer [BKW26]. These results concern computation with a space constraint; we study decision problems and charge only input queries.
Orthogonal Vectors. Orthogonal Vectors is a central source of classical fine-grained lower bounds, with a broad equivalence class studied by Chen and Williams [CW19]. Much of this classical literature focuses on vectors of dimension . The regime has also been studied: Dalirrooyfard and Kaufmann discuss high-dimensional Orthogonal Vectors, allowing dimension up to , and its connection to distinguishing diameter two from three in dense graphs [DK21].
In the quantum setting, Aaronson, Chia, Lin, Wang, and Zhang studied quantum Orthogonal Vectors with entire-vector queries in polylogarithmic dimension and derived conditional quantum time lower bounds . Our model instead charges for individual entries and uses dimension , so these quantum bounds are not directly comparable. For Orthogonal Vectors in dimension , Buhrman, Patro, and Speelman developed a QSETH framework connecting black-box query lower bounds to conditional quantum time lower bounds, and discussed its application to Orthogonal Vectors with [BPS21]. Van Renterghem obtained an unconditional quantum query lower bound for Orthogonal Vectors with via a reduction from the two-to-one collision problem [VR19]. This lower bound applies, in particular, to the regime considered here.
Graph problems. Wesolowski and Bao study quantum query algorithms and lower bounds for eccentricity, radius, and diameter in the adjacency list model [WB25]. They give -time quantum algorithms for computing the exact diameter and radius, together with corresponding paths, and prove quantum query lower bounds, where m denotes the number of edges. Our results concern unweighted graphs accessed through adjacency matrix queries and the decision problems of testing whether diameter or radius is at most two, so the bounds are not directly comparable.
1.4 Open problems
The main open problem is to close the gap between our lower bound and upper bound for Boolean Matrix Product Verification. Our reductions show that this problem, Orthogonal Vectors, and deciding whether a graph has diameter at most two have equivalent quantum query complexity, up to constant factor changes in instance size. Thus, improvements for any one of these problems will imply an improvement for all of them. In particular, a lower bound of for some constant would establish a polynomial separation from triangle finding, which admits an query algorithm [LG14a, CLM17].
Another direction is to understand the dependence on the vector dimension. What is the quantum query complexity of Orthogonal Vectors on vectors of dimension , as a function of both parameters? Our results address ; it would be interesting to obtain tight bounds when these parameters differ substantially, as well as for verifying rectangular Boolean matrix products.
Our upper bound concerns query complexity and allows unrestricted computation on acquired data. Can a quantum algorithm achieve a running time comparable to our query bound?
Finally, does the polynomial separation between deciding whether a graph has diameter at most two and whether it has radius at most two persist when two is replaced by any larger fixed integer?
Organization. Section 2 fixes the model and notation. Section 3 shows equivalences of Boolean Matrix Product Verification, Orthogonal Vectors and the Diameter at Most Two problems and proves lower bounds for them. Section 4 develops the upper bound, first under an intersection promise and then for general inputs. Section 5 gives lower bounds for Boolean Matrix Product Row Search and Radius at Most Two problems.
2 Preliminaries
2.1 Model and problem definitions
For a positive integer , write . We write and for the all-ones and all-zeros matrices, respectively. We abbreviate , write for the all-ones vector, and write for the identity matrix. For , write for its entrywise complement. For any matrix , write for its -th row. The Boolean product of and is
For a Boolean vector , let . For a proposition , denotes its indicator.
Query model and oracle reductions. A Boolean matrix is accessed through the standard entry oracle
For several input matrices or vector families, an additional register selects the input object. For a (possibly partial) Boolean function , we write for the minimum number of queries to the input oracle made by a quantum algorithm that, for every , outputs with probability at least 2/3. This is its bounded-error quantum query complexity; in particular, .
An oracle reduction has constant query overhead if its target oracle can be simulated coherently using input queries per target query. Unless stated otherwise, every reduction in this paper has this property.
All computation on acquired data and all input-independent unitaries are free in this model; our upper bounds concern query complexity.
Orthogonal Vectors
Definition 2.1 (Orthogonal Vectors). Given an indexed list of vectors in , accepts if there are distinct indices with
We call such a pair orthogonal and abbreviate . Equal bit strings at different positions are distinct choices.
Orthogonal Vectors is also commonly formulated with two lists, asking for one vector from each list with disjoint supports [CW19]. The following elementary reductions relate this convention to Definition 2.1.
Lemma 2.2 (Equivalent formulations of Orthogonal Vectors). Two lists of m vectors in reduce to , and reduces to two lists of m vectors in dimension . Each queried target bit is fixed or copies one input bit.
Proof. View the vectors as rows of a matrix. For the first reduction, combine the two lists and append to every vector in the first list and to every vector in the second. The new columns exclude pairs from the same list and preserve every cross-list intersection test. For the reverse reduction, make two copies of the input list and append the -th unit vector of to position in both copies. The added columns make the two copies of position intersect, and create no intersection between distinct positions.
Hence bounds for list lengths and dimensions within constant factors of n transfer between the formulations. We also use the following padding facts.
Remark 2.3 (Padding). Appending all-zero columns to the matrix of input vectors preserves the answer to OV. So does appending copies of vectors already in the list, provided the list has at least two positions: two copies of the same vector are orthogonal only if that vector is zero, and a zero vector is already orthogonal to every other vector in the list.
For with ,
The off-diagonal product entries express pairwise intersection. If no two distinct rows are orthogonal, every row is nonzero, so the diagonal entries are also one.
Boolean product and graph predicates.
Definition 2.4 (Boolean Matrix Product Verification). For ,
We also use
For a simple undirected n-vertex graph G, let be its zero-diagonal adjacency matrix. Define its closed neighborhood matrix by
where the OR is entrywise. The input oracle supplies the off-diagonal entries of ; symmetry is promised.
For , let be the length of a shortest path between and , or if they lie in different components. For -vertex graphs, define
The basic identity
will be used in both graph applications. In particular,
Finally, Triangle denotes triangle detection in an n-vertex graph under adjacency matrix access.
2.2 Quantum algorithmic tools
Search and access to implicit sets. We collect the search, enumeration, and walk procedures used in the upper bounds. All index sets and numerical bounds below have size polynomial in the input parameter n. Within bounds, subroutines are amplified to inverse polynomial error, implemented coherently, and stopped at their stated query budgets. Grover search and amplitude amplification find a marked element of , or report that none exists, using predicate evaluations [BHMT02]. We use the following standard consequences of amplitude estimation and quantum enumeration [BHMT02, JKM12].
Lemma 2.5 (Access to an implicit set). Let , with , have a membership test costing q input queries. The following tasks can be performed with inverse polynomial error:
-
Distinguish from , and in the latter case obtain , in queries.
-
Given such an estimate for , prepare the uniform superposition over , to inverse polynomial accuracy, in queries.
-
Given , enumerate in queries.
Searching in coordinate order. If the first marked position in an ordered domain of length M is at position g, it can be located in predicate evaluations. Search consecutive intervals of doubling length until one contains a mark, then locate its first mark by binary subdivision. If no position is marked, return an end marker at , with .
Lemma 2.6 (Successive marked positions). Consider a procedure that searches for the next marked position after a cursor in [M], advances the cursor to that position, and stops after at most K marked positions or upon reaching the end marker. The predicate may change after each marked position, provided previously passed positions need not be revisited. If a predicate evaluation uses queries, the entire procedure costs queries.
Proof. If the successive gaps are , then and . The searches cost queries. Since , this gives the claimed bound.
Variable-time search. The cost of testing a candidate may depend on the candidate and on the input. We use the following result of Ambainis, Kokainis, and Vihrovs [AKV23, Sections 2–3], with its bounded-error extension. Only a bound on the sum of squared completion costs is required.
Lemma 2.7 (Search with unknown completion costs). For each candidate , suppose a test with integer allowance costs queries and returns UNFINISHED for , and the correct Boolean answer for , with inverse polynomial error. Given , variable-time quantum search finds an accepting candidate, or reports that none exists, using queries. The individual completion allowances need not be known.
In particular, suppose test costs queries, where is known without further input queries. Taking , and returning UNFINISHED below this allowance, gives a search cost of queries.
MNRS quantum walk search. The framework of Magniez, Nayak, Roland, and Santha expresses the cost of a quantum walk through setup, update, and checking costs [MNRS11]. We state the form used below for a Johnson walk, each of whose steps replaces one uniform member of the maintained subset by a uniform element outside it.
Theorem 2.8 (MNRS search on a Johnson graph). Consider the Johnson walk on the r-subsets of a set of size , where . Suppose that, whenever marked walk states exist, every subset containing a particular element is marked. If preparing a uniform walk state with its data costs S queries, a coherent walk update costs U, and checking whether a walk state is marked costs C, then detecting a marked walk state uses
queries.
The walk has a uniform stationary distribution and spectral gap . When marked walk states exist, their stationary probability is at least , giving the stated bound.
3 From verification to Orthogonal Vectors
A claimed product can differ from in two ways. Entry has a missing-one error if and , and a spurious-one error if and . Thus rejects exactly when some entry has a missing-one error, rejects exactly when some entry has a spurious-one error, and .
The two kinds of error behave very differently. Missing-one errors are triangles in disguise [Kot14, Section 4.3], so they can be detected in queries. Spurious-one errors are orthogonal pairs in disguise, and we show in Section 3.1 that detecting them is equivalent to Orthogonal Vectors. In Section 3.2, we prove an lower bound for Orthogonal Vectors. This lower bound absorbs the cost of triangle detection, so BMPV and OV have the same query complexity up to a constant-factor change in problem dimension (Section 3.3). Section 3.4 proves the same equivalence for Diameter at Most Two. Through these reductions, the algorithm for Orthogonal Vectors in Section 4 also applies to verification and to Diameter at Most Two.
3.1 Reductions between verification and Orthogonal Vectors
A missing-one error at , together with an index satisfying , forms a triangle in a tripartite graph built from , , and . Kothari observed that this correspondence works in both directions.
Proposition 3.1 (Missing-one errors and Triangles [Kot14]). The complement of reduces to triangle detection on 3n vertices, and triangle detection on n vertices reduces to the complement of . Consequently,
Proof. Given , consider the graph on three disjoint vertex sets , , and , each of size , with adjacency matrix
Each adjacency query costs at most one query to A, B, or C. The graph is tripartite, so every triangle has the form , and such a triangle exists exactly when and . Thus the graph contains a triangle if and only if C has a missing-one error.
Conversely, let be the adjacency matrix of an -vertex graph. An entry with and is an edge whose endpoints have a common neighbor, which is exactly a triangle. Diagonal entries cause no violations, because . Hence the graph contains a triangle if and only if is a no-instance of , and each entry of this triple costs one query to .
The final bound is the triangle-finding algorithm of Carette, Laurière, and Magniez [CLM17], which removes the logarithmic factors from Le Gall's algorithm [LG14a].
Spurious-one errors are governed by orthogonality instead: the entry is zero exactly when row of and column of have disjoint supports. A spurious-one error is such an orthogonal pair at a position with . The next lemma encodes this restriction into a single OV instance and shows, conversely, that OV is the special case .
Lemma 3.2 (Spurious-one errors and Orthogonal Vectors). For every ,
Proof. For the second inequality, let Z be the matrix
Let denote the -th standard basis vector. The first rows of are for , and its next rows are for . In the first columns, and share a one exactly when . In the next columns, has a single one, in column , where has the entry ; so they share a one there exactly when . They share no one in the last two columns. Therefore and are orthogonal exactly when entry has a spurious-one error.
No other pair of rows of Z is orthogonal: any two rows share column , any two rows share column , and the last two rows are all ones, while every row of Z is nonzero. These two rows serve only to make the instance square. Hence the rows of Z form a yes-instance of if and only if . Every entry of Z is either fixed or determined by one entry of A, B, or C.
For the first inequality, let be an instance whose rows are the input vectors. Since always holds, Equation (2.1) gives
Queries to are queries to X, and is fixed.
3.2 A lower bound from surjectivity
We now prove that requires queries. The starting point is surjectivity. For even , let be the problem of deciding whether a function
given by an oracle that returns on query , is surjective. Beame and Machmouchi proved that for even [BM12, Corollary 6]. We need the corresponding bound for many independent instances.
Lemma 3.3 (An AND of ONTO instances). For every even and every , deciding whether independently given functions are all surjective requires quantum queries.
Proof. Let denote the negative-weight adversary bound. It characterizes bounded-error quantum query complexity up to a constant factor and is multiplicative under composition, including for functions over finite input alphabets . Hence , and since ,
For intuition, take functions whose values are pairs, with about possibilities for each component. The alphabet then has size . The key observation is that a function misses a value exactly when the set of positions at which the first component of equals is disjoint from the set of positions at which the second component equals . Each such pair of sets becomes a pair of rows, and a few additional columns ensure that no other pair of rows is orthogonal.
Theorem 3.4 (Lower bound for Orthogonal Vectors). For every ,
Proof. Let be even, and consider functions
where a query returns . By Lemma 3.3 with and , deciding whether every is surjective requires queries. We reduce the complementary problem, deciding whether some misses a value, to OV.
The vectors. For , let map a pair to its -th component. The instance consists of the vectors
arranged as the rows of a matrix with three types of columns.
-
Value columns. For each , .
-
Guard columns. For , .
-
Index columns. Let , and let be the binary representation of . For each and , .
Figure 2 shows the complete instance for .
| t | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| (1,1) | (1,2) | (2,1) | (1,1) | (1,2) | (2,1) | |
| (1,1) | (1,2) | (2,1) | (2,2) | (1,1) | (2,2) |
| t | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |||||
| 1 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | |
| 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | |
| 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | |
| 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | |
| 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | |
| 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | |
| 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | |
| 0 | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | |
Figure 2: The construction in the proof of Theorem 3.4 for . The function misses , whereas is surjective. The two vectors with boldface labels have disjoint supports and form the only orthogonal pair. Two vectors with the same intersect in a guard column, and two vectors with different and different intersect in an index column.
Correctness. Vectors with all have a one at , and vectors with all have a one at , so any two vectors with the same intersect. Consider therefore and . These vectors share no one in a guard column. If choose with , and let . Then , and both vectors have a one at . If a common one at would require and , which is impossible, so the two vectors share no one in an index column. In the value columns, they share a one at exactly when . Consequently, the only orthogonal pairs are the pairs with , and the instance contains an orthogonal pair if and only if some is not surjective. Every entry is either fixed or determined by a single value , so each query to the instance can be simulated using queries to the functions.
Size. The instance consists of vectors of dimension
Given a sufficiently large , let be the largest even integer with ; then . Pad the list to vectors by duplicating vectors, and pad the dimension to with all-zero columns. By Remark 2.3, padding preserves the answer. Hence
3.3 Equivalence of verification and Orthogonal Vectors
We now combine the preceding results.
Theorem 3.5 (Verification and Orthogonal Vectors). For every ,
Consequently, .
Proof. For the first inequality, restrict to inputs of the form . By Equation (2.1), this restriction is equivalent to the complement of . Therefore .
For the second relation, decide using Proposition 3.1 and using Lemma 3.2, each with error probability at most 1/6, and accept if both accept. The triangle algorithm detects missing-one errors, and the OV algorithm detects spurious-one errors. This gives
By Theorem 3.4, , so the second term dominates, proving Equation (3.4).
Finally, the lower bound follows from the first inequality in Equation (3.4) and Theorem 3.4.
By Equation (2.1), testing whether is the complement of . Theorem 3.5 therefore shows that this self-product test, a special case of verification with and the all-ones target, is as hard as verifying an arbitrary claimed product, up to replacing by .
3.4 Diameter at Most Two
By Equation (2.2), two vertices are at distance at most two exactly when their closed neighborhoods intersect. A graph therefore has diameter at most two exactly when the rows of , viewed as an OV instance, contain no orthogonal pair. The next proposition turns this observation into reductions in both directions.
Proposition 3.6 (Diameter and Orthogonal Vectors). For every ,
In particular, .
Proof. For the first inequality, let be an -vertex graph, and use the rows of as the input list. The vector for vertex has a one in column if , and otherwise has the adjacency bit . Thus each entry query requires at most one adjacency query. By Equation (2.3) and Equation (2.1), has diameter at most two exactly when the list has no orthogonal pair.
For the second inequality, let be an instance. Define a graph on vertices with two disjoint vertex sets
where represents row of and represents column . The vertices in are independent, and the vertices in form a clique. A vertex is adjacent to exactly when . Each adjacency query can therefore be answered using at most one query to .
Since the vertices in form a clique, every vertex in that has a neighbor is within distance two of every vertex in . Two distinct vertices are within distance two exactly when they have a common neighbor in , so
If row of is zero, then is isolated in . Since , this row forms an orthogonal pair with another row. Hence has diameter at most two exactly when has no orthogonal pair.
For the lower bound, small values of affect only the constant, so assume . Let , and apply the second reduction above to an instance. When is odd, add one more vertex to the clique with no neighbors in . This vertex shortens no distance between row vertices, and it is within distance two of every row vertex that has a neighbor, so the answer is unchanged. Theorem 3.4 now gives .
4 An upper bound for Orthogonal Vectors
Quantum search over pairs, with a further search over coordinates to test each pair, gives an query upper bound for . We improve this bound using combinatorial ideas and standard quantum subroutines such as variable-time quantum search and MNRS quantum walk. For ease of exposition, we consider a promise version of before considering the general version.
We note that the error probabilities of the quantum subroutines from Section 2.2 can be made inverse polynomial with an arbitrarily large fixed exponent with a polylogarithmic overhead so we will suppose that in our following discussion. All samples below are independent uniform draws with replacement, unless their reuse is stated explicitly.
4.1 The promise case
In this section, we formally define the promise version of the orthogonal vectors problem and give an algorithm for it.
Problem (PromOV ). The input consists of query access to Boolean vectors . For fixed positive constants and , every pair of distinct indices is promised to have either at most common ones or at least common ones. The task is to decide whether there are distinct indices such that , that is, whether two distinct input vectors are orthogonal.
Theorem 4.1 (Promise upper bound). There is a bounded-error quantum query algorithm for PromOV using queries.
We now describe the algorithm for . Let be independent integer parameters that we will eventually choose to be and . We begin by describing a useful preprocessing step.
Preprocessing and test sets. Sample a multiset of coordinates from independently and uniformly at random, and query them in every vector. Define the candidate graph on to have an edge between distinct vertices iff none of the sampled coordinates satisfy that , and write for the neighbors of the vertex .
Lemma 4.2 (Candidate pairs). Any orthogonal pair of distinct vectors and satisfies . Moreover, with probability at least 0.99, every distinct pair of vectors and with has at most common ones.
Proof. An orthogonal pair has no common one at any coordinate, so it always survives the sample. A pair with at least common ones is missed by a uniform coordinate with probability at most . Independence of the draws therefore bounds its survival probability by
where the sampling constant is chosen sufficiently large. A union bound over pairs eliminates every pair with many common ones with probability at least 0.99. By the promise, each surviving pair then has at most common ones.
We next sample a multiset Pivots of s indices from [n], independently and uniformly at random, and query all coordinates of the corresponding vectors. For each coordinate k, define
Thus is covered (i.e. ) if some sampled vector has a one at coordinate and , and uncovered otherwise. We call heavy (i.e. ) at coordinate if more than of its candidate neighbors lie outside . These two sets are known after preprocessing, since is known and all sampled vectors have been queried.
We use these sets to restrict the coordinates that must be searched when testing whether and are orthogonal. Define
The set Remaining is known from preprocessing, whereas the lists Left and Right will be enumerated only when needed. The following lemma shows that searching Domain suffices and bounds the sizes of its three parts.
Lemma 4.3 (Coverage and list bounds). For any choice of the sets Covered_k and Heavy_k, every common one of and belongs to Domain_{ij}. With probability at least 0.98, the conclusion of Lemma 4.2 and the following bounds hold simultaneously for all :
Proof. Suppose . If , then . If , then . If neither condition holds, then . In every case, .
To prove the first bound, condition on the coordinate sample, so that is fixed. Fix a coordinate , and pick the pivot draws one at a time. Let be the number of indices for which and more than neighbors of remain uncovered after the first draws. The covered set only grows as more pivots are drawn, so never increases.
Conditioned on the first draws, the next pivot is one of these count indices with probability count . If this happens, more than previously uncovered indices become covered. The conditional expected number of newly covered indices is therefore at least count . Since at most indices can become covered altogether, taking expectations and summing over the draws gives
implying that . The final count is exactly the number of lists containing . Summing over the coordinates, we obtain
Markov's inequality now gives with failure probability at most .
For the second bound, every is a common one of and some sampled vector with . On the event in Lemma 4.2, each sampled vector contributes at most such coordinates. There are pivot draws, so .
For the third bound, count the pairs with and using two different ways:
where the inequality follows by the definition of . Combining the sampling guarantee from Lemma 4.2 with the first bound's failure probability proves that all the conclusions hold with probability at least 0.98.
We next group the vectors according to estimates of their left list sizes. Independently sample a multiset of coordinates and query them in every vector. For each , define to be the least power of two no smaller than
Membership in at a sampled coordinate is determined by the queried bit and the known set . Thus is known for all after these queries. For each power of two with , define
The set contains the indices of vectors with size label a. We will use the same definitions in the general case. The next lemma shows that each size label bounds the corresponding list size, while the sum of the size labels remains small.
Lemma 4.4 (Size labels). Conditioned on , with probability at least the labels in (4.4) satisfy
Moreover, there are nonempty size classes.
Proof. Let . For a fixed vector , let count the sampled coordinates in , with multiplicity. Then is binomial with mean , so estimates . Chernoff bounds give
which is if . For the first inequality, the threshold for is at least twice its mean and exceeds that mean by at least . The second inequality is the usual lower tail bound. Since , choosing the sampling constant sufficiently large makes each failure probability at most . A union bound makes both estimates hold for all vectors with probability at least . On this event, if , the definition of implies . If , the lower estimate gives , so the same conclusion holds. Rounding up to a power of two increases a positive number by at most a factor of two. The upper estimate therefore gives
Summing over all vectors and using the assumed list bound, we obtain
Since every index in has size label , we also have . Finally, all size labels are powers of two between and so there are nonempty size classes.
The checker. Let be an integer parameter that we will eventually choose to be . We now describe a subroutine that, given a set of vectors of size and information about the left lists of elements in this set, checks whether any of them has an orthogonal partner anywhere in the input. Throughout the rest of this subsection, condition on the events in Lemmas 4.3 and 4.4.
Fix a nonempty set , let , and suppose that the lists have been stored. For a fixed , first enumerate . We can then test any candidate by searching for a common one of and . By Lemma 4.3, this test accepts exactly when the two vectors are orthogonal.
We apply the known-cost consequence of Lemma 2.7 first over , and then over . To bound the query costs, we will define
These quantities are known from preprocessing and I. Algorithm 1 provides the checker. Each search returns YES if it finds an accepting test and No otherwise.
Algorithm 1 Promise checker
Input: , , and .
1: function PROMISERIGHT(j)
2: Enumerate Right using Lemma 2.5, part 3.
3: For , search Domain for and accept if no such is found.
4: return search over using Lemma 2.7.
5: end function
6: function PROMISECHECK(I, a)
7: return search over using PROMISERIGHT(j) and Lemma 2.7.
8: end function
Lemma 4.5 (Promise checking cost). Given and the lists , Algorithm 1 decides whether some , with , has an orthogonal partner. Its query cost is
Proof. Fix . Testing whether requires at most one query to , since is known. By Lemma 2.5 and the bound on , enumerating this list costs queries.
Once Right is stored, the domain Domain is known for every . Grover search over this domain uses
queries, where we use .
By Lemma 2.7, searching over the candidate indices i therefore costs .
It remains to search over j. The total budget satisfies
where we use Lemma 4.3 and . Since , the term is at most . A second application of Lemma 2.7 gives
Every orthogonal pair is an edge of , and the test domain contains every common one. Thus the checker accepts exactly when a vector indexed by has an orthogonal partner, up to the error probability of the quantum searches.
The quantum walk. We now use this checker in a quantum walk over each nonempty class . For each such class, let . The states are the -element subsets , and each state stores the lists . A state is marked if some , with , has an orthogonal partner anywhere in the input.
We use the Johnson walk from Section 2.2. Each step replaces one index in and updates its stored list. Let be the query cost of preparing a state with its lists, and let be the query cost of one replacement. The checker has cost from Lemma 4.5. The full algorithm for is given below.
Algorithm 2 Promise algorithm
Input: satisfying the promise of PromOV.
1: , .
2: Query sampled coordinates in all vectors; construct .
3: Pivots samples from ; query all pivot entries.
4: Covered, Heavy for .
5: independent samples from ; query all vectors on .
6: .
7: for with do
8: .
9: Run MNRS on , storing , with checker PROMISECHECK().
10: if the search accepts then
11: return YES.
12: end if
13: end for
14: return No.
Proof of Theorem 4.1. We analyze Algorithm 2, keeping as independent parameters until the final bound. Membership in requires at most one query, since is known for every . By Lemma 2.5, enumerating a left list from class costs queries. Preparing such lists and replacing one of them therefore have respective costs
Suppose a vector with an orthogonal partner has its index in . At least an fraction of the walk states contain that index and are therefore marked. The Johnson walk has spectral gap , so Theorem 2.8 bounds the cost of searching this class by
Substituting the setup, update, and checking costs, and using , gives
For , prepare the lists and run the checker for each walk state, at total cost , within the same bound.
Here we use from Lemma 4.4 and .
The preprocessing uses queries. There are nonempty size classes, so the total query cost is
Choosing and makes this .
Finally, every orthogonal pair survives preprocessing, and each of its indices belongs to a size class. A walk state containing either index is marked, and Lemma 4.5 gives a correct checker. If no orthogonal pair exists, no walk state is marked. The preprocessing and size label events hold with probability at least 0.97; reducing the search errors makes the overall success probability at least 2/3.
4.2 The general case
In this section, we give an algorithm for the orthogonal vectors problem without the promise on pairwise intersections.
Theorem 4.6 (Orthogonal Vectors upper bound). There is a bounded-error quantum query algorithm for using queries.
We now describe the algorithm for . Let be independent integer parameters that we will eventually choose to be and . We use the same test sets, size classes, and quantum walk as in the promise case. The main difference is that candidate neighborhoods now depend on the coordinate: a pair remains a candidate until its first common one. We will also need subroutines to access the test sets and estimate the checking costs, since these are no longer known from preprocessing.
Preprocessing and test sets. For distinct indices , let first be the least coordinate with , or if the two vectors are orthogonal. Define first and
Thus iff and the two vectors have no common one before coordinate . These sets take the place of the fixed neighborhoods in the promise case. We use them implicitly, without computing all pairwise first intersections.
Independently sample multisets Pivots and DegSamp of indices from , uniformly at random, and query all coordinates of the corresponding vectors. The first sample is used for defining the covered sets, while the second is used for estimating the number of uncovered candidate neighbors. As in the promise case, s is the number of pivot draws. We choose
For each coordinate k, define
(4.14)
As before, j is covered at coordinate k if some sampled vector has a one there and has j as a candidate neighbor. We call heavy at k if the estimated number of its uncovered candidate neighbors exceeds 2t. The independent degree sample ensures that this estimate is accurate even though the covered sets depend on Pivots.
Using the covered and heavy sets in , define
Unlike in the promise case, these sets are not known after preprocessing. We first prove their size bounds, and then describe how to access them.
Lemma 4.7 (General preprocessing bounds). For any choice of the sets and , every common one of and belongs to . With probability at least 0.98, the following bounds hold simultaneously for all indices and coordinates:
and
Proof. The coverage statement follows from the same three cases as in Lemma 4.3.
Condition on Pivots, so that every covered set is fixed. For fixed , the number of occurrences in DegSamp belonging to is binomial, with mean
If the true number of uncovered neighbors is at most , a Chernoff bound shows that its estimate exceeds with probability at most . If the true number exceeds , the same bound shows that its estimate is at most with at most this probability. Choosing the sampling constant sufficiently large and taking a union bound over all choices of proves (4.16) with failure probability at most .
For the left list bound, fix a coordinate and pick the pivot draws one at a time. The neighborhoods are fixed, so the counting argument in Lemma 4.3 applies without change: sampling an index with and more than uncovered neighbors covers more than new indices. Consequently,
By Markov’s inequality, this sum is at most with failure probability at most 1/100. On the degree estimation event, every entry in a left list is counted in this sum, proving .
For the right lists, we have the exact identity
Indeed, if , then for some pivot with first . These conditions imply first . Conversely, a first common one with a pivot belongs to . Each pivot contributes at most one coordinate, so .
Finally, since iff and , counting the same pairs in two orders gives
The inequality follows by summing the second bound in (4.16) over coordinates. Combining the two failure probabilities proves the lemma.
We next group the vectors according to estimates of their left list sizes. Independently sample a multiset of coordinates. For each , define to be the least power of two no smaller than
For each power of two with , define
Thus contains the indices of vectors with size label a, and is their number. The sample K is independent of the covered and heavy sets, so Lemma 4.4 applies to these labels as well. We evaluate a label only when needed, rather than querying K in every vector during preprocessing. Throughout the rest of this subsection, condition on the events in Lemmas 4.4 and 4.7.
Access to the test sets. To determine whether belongs to or , it suffices to know its first intersection with every sampled vector. Define the record of by
where concatenates the two multisets, keeping one entry for each occurrence. A left record consists of record(i) together with Left .
We load a record by finding successive common ones between and sampled vectors whose first intersection has not yet been found. Each discovered coordinate determines the first intersection for every such sampled vector having a one there. Algorithm 3 gives the procedure. The set unresolved contains these sample occurrences, and start is the first coordinate still to be searched. Each search for the least coordinate uses Lemma 2.6.
Algorithm 3 Load a record
Input: and the fully read samples Pivots, DegSamp.
1: for .
2: ; start .
3:
4: .
5:
6: .
7:
8: .
9: ; start .
10:
11: .
Lemma 4.8 (Record loading). Algorithm 3 loads record(i) in queries. The record determines membership of i in every and , and determines . For , loading its left record costs queries.
Proof. The search predicate requires at most one query to , since all sampled vectors have been queried. Each successful search determines at least one previously unknown first intersection, so there are at most iterations. Removing resolved occurrences can only remove possible common ones, so no earlier coordinate needs to be searched again. By Lemma 2.6 and (4.13), the total cost is . Each stored value is the earliest common one for its occurrence, and entries left at correspond to orthogonal vectors.
Given record(i), membership in is determined by the comparisons first( and the known bits for . The comparisons needed for membership in are also stored. Moreover, whether a degree sample vector belongs to is known from the fully queried samples. Thus (4.14) can be evaluated without further queries. The right list is determined by (4.18).
Membership in then requires at most one query to . Since , Lemma 2.5, part 3 enumerates this list in queries. Including the record, the cost is
The checker. We now describe a subroutine that, given a set and its left records, checks whether some , with , has an orthogonal partner anywhere in the input. Fix a nonempty such set and let . Once record( ) is loaded, is known for every : the left list is stored, while the right list and remaining set are determined by the records.
In the promise case, we bounded the cost of searching the entire test domain. Here, we search coordinates in increasing order and stop once a common one is found. To bound this cost, define
For an intersecting pair, is the position of its first common one in the increasingly ordered test domain. For an orthogonal pair, it is . The extra coordinate accounts for finishing a search with no common one.
Lemma 4.9 (Total work). The quantities in (4.23) satisfy
Proof. For each pair, the left list, right list, and extra coordinate contribute at most . A remaining coordinate contributes only while . By Lemma 4.7,
The inequality follows from Lemma 4.7; the final equality uses and . Summing over the indices in proves the second bound.
The quantities work_j are not known, so we estimate them before using them as search budgets. For one invocation of the checker, independently sample a multiset Samp of pairs from , uniformly at random. Use this same sample for every budget evaluation within the invocation. A sampled pair is a hit for j if
Define
The term 2ra ensures that the budget remains an upper bound even when the work is small.
Algorithm 4 evaluates this budget and tests a pair with a given allowance. In PAIRTEST, the integer allows a search of the first coordinates of the test domain. The answer UNFINISHED means that no common one was found but the allowance is insufficient to certify orthogonality.
Algorithm 4 Budget evaluation and pair testing
Input: , , its left records, and Samp.
1: function BUDGET(j, I, a, Samp) 2: Load record(j) by Algorithm 3. 3: for with and do 4: Test by Grover search. 5: end for 6: return budget_j from (4.26), counting successful tests as hits. 7: end function 8: function PAIRTEST(i, j, u) 9: Use the stored (record(i), Left_i) and record(j). 10: Search the first min entries of Domain_{ij} for a common one. 11: if a common one is found then 12: return NONORTHOGONAL. 13: else if then 14: return ORTHOGONAL. 15: else 16: return UNFINISHED. 17: end if 18: end function
Lemma 4.10 (Sampled budgets). For each fixed , with probability at least over Samp, for any prescribed constant , the budgets satisfy
Each budget can be evaluated in queries.
Proof. Exactly work of the pairs in satisfy (4.25). Thus the sampled fraction, multiplied by , estimates work . Chernoff bounds, as in Lemma 4.4, give
simultaneously for all , with failure probability at most . Indeed, the additive scale corresponds to a fraction of the sampling domain, and . Substituting these bounds into (4.26) proves the pointwise inequalities. Summing over and applying Lemma 4.9 gives the total budget bound.
Once record(j) is loaded, the first two conditions in (4.25) can be checked without queries. The last condition holds iff the two vectors have no common one before k, which Grover search tests in queries. The record is reused for all sampled pairs, so evaluating the budget costs
Here the term is absorbed by the record loading cost.
We can now describe the checker. For a fixed , apply Lemma 2.7 over , using PAIRTEST. To search over , group the vectors by their sampled budgets:
For , the value bounds work . The groups are accessed through the budget evaluation subroutine. Algorithm 5 gives the checker; each search accepts if it finds an orthogonal pair.
Algorithm 5 General checker
Input: , , and (record(i), Left_i) .
1: function GENERALRIGHT(j, B)
2: Load record(j) by Algorithm 3.
3: Use PAIRTEST(i, j, u) for , accepting ORTHOGONAL.
4: return search using Lemma 2.7 with bound 4B.
5: end function
6: function GENERALCHECK(I, a)
7: Samp samples from .
8: for with do
9: Access using BUDGET(j, I, a, Samp).
10: Estimate using Lemma 2.5, part 1; skip empty groups.
11: Prepare uniform members of using Lemma 2.5, part 2.
12: Search using GENERALRIGHT(j, B).
13: if the search accepts then
14: return YES.
15: end if
16: end for
17: return No.
18: end function
Lemma 4.11 (General checking cost). Given and its left records, Algorithm 5 decides whether some , with , has an orthogonal partner. Its query cost is
Proof. Fix . A call to PAIRTEST costs queries and finishes once . For an intersecting pair, this allowance includes its first common one. For an orthogonal pair, it is enough to exhaust the test domain. Smaller allowances return UNFINISHED. The completion allowances satisfy
On the event in Lemma 4.10, a vector satisfies . Thus Lemma 2.7 applies with bound 4B, and searching over , including the cost of loading record( ), uses queries.
It remains to search over . Membership in costs by Lemma 4.10. By Lemma 2.5, estimating its size costs . If is nonempty, preparing a uniform member costs . Grover search over this group therefore costs
The total budget bound gives
There are groups, so their total search cost is , where the contribution is absorbed by since .
Every budget is positive and, since , its definition gives . Hence every vector belongs to a searched group. The test domains contain every common one, so the checker accepts exactly when a vector indexed by has an orthogonal partner, up to the sampling and quantum search errors. The sample is fixed throughout an invocation, and the error convention in Section 2.2 applies to these subroutines.
The quantum walk. We now use this checker in a quantum walk over each nonempty class . As in the promise case, the states are the -element subsets , and a state is marked if some , with , has an orthogonal partner anywhere in the input. Each state now stores the left records (record( ), Left ) .
The size classes are no longer known explicitly, so preparing and updating a state also requires searching for members of its class. The next lemma bounds this additional cost. As before, S is the query cost of preparing a state with its data, and U is the cost of one replacement in the Johnson walk.
Lemma 4.12 (Access to implicit classes). Class membership costs queries, and estimating within a factor of two costs queries. For a nonempty class and , the setup and update costs are
Proof. To compute , load record and query at the coordinates in . The record determines which of these coordinates belong to , so the label can then be computed from (4.19). The cost is
Testing gives class membership. By Lemma 2.5, parts 1 and 2, estimating the class size costs , and preparing a uniform class member costs .
Preparing a state requires selections without replacement and loading their left records. Since , excluding previously selected indices changes each selection cost by at most a constant factor. An update removes one stored index and its record, selects a new index outside the subset, and loads its left record. Combining the selection cost with Lemma 4.8 gives the stated setup and update costs; the selection cost absorbs the record loading term since .
For each nonempty class, we obtain an estimate and choose . This ensures . The full algorithm for is given below.
Algorithm 6 General algorithm
Input: .
1: , .
2: Sample Pivots, DegSamp as in (4.13); query all their entries.
3: independent samples from [n].
4: Access Covered , Heavy , size , by (4.14), (4.19), (4.20).
5: for powers of two with do
6: Estimate by using Lemma 2.5; skip empty classes.
7: .
8: Store (record , Left ) for each state .
9: Run MNRS with checker GENERALCHECK( ).
10: if the search accepts then
11: return YES.
12: end if
13: end for
14: return No.
Proof of Theorem 4.6. We analyze Algorithm 6, keeping as independent parameters until the final bound. Consider a nonempty class . As in the promise case, if a vector with an orthogonal partner has its index in , at least an fraction of the walk states are marked. The spectral gap is . By Theorem 2.8, together with Lemmas 4.11 and 4.12, searching the class and estimating its size costs
Here we use , , , and . The degree sample contributes at most , which is at most since .
For , prepare the records and run the checker for each walk state, at total cost , within the same bound.
Preprocessing reads the sampled vectors in queries. The coordinates in are queried only when evaluating a class label, and that cost is included above. There are nonempty size classes, so, absorbing into , the total query cost is
Choosing and makes this .
Finally, every index belongs to a size class. If an orthogonal pair exists, a state containing either index is marked, and Lemma 4.11 gives a correct checker. If no orthogonal pair exists, no state is marked. The preprocessing and size label events hold with probability at least 0.97; reducing the search errors makes the overall success probability at least 2/3.
5 An existential analogue of verification
Verification asks whether every row of equals the corresponding row of . We now ask instead whether some row of equals a given vector.
5.1 Boolean Matrix Product Row Search
Definition 5.1 (Boolean Matrix Product Row Search). For and ,
All three inputs are accessed through entry queries. We write for the restriction to the all-ones target, whose input consists of and only.
For the all-ones target, verification and row search differ only in their outermost quantifier:
The first condition is verification with . This special case is as hard as verification up to rescaling (Theorem 3.5 and the discussion following it), and it can be decided with queries by Theorems 3.5 and 4.6. In Section 5.1, we show that the second condition requires queries, while queries suffice for every target . For , the two conditions state that has diameter at most two and radius at most two, respectively, by Equation (2.2). In Section 5.2, we give reductions in both directions between and Radius at Most Two, so the separation carries over to graphs.
Theorem 5.2 (Query bounds for Boolean Matrix Product Row Search). For every ,
The upper bound comes from evaluating Equation (5.1) level by level with quantum search. For fixed and , query and use Grover search over to decide whether equals ; this costs queries. With these bounded-error tests as inputs, a search over for an entry with decides whether row of equals with queries, and a search over decides with queries. The two outer searches use the algorithm of Høyer, Mosca, and de Wolf [HMdW03] for search on bounded-error inputs, which needs no prior error reduction, so no logarithmic factors arise.
The rest of this subsection proves the lower bound. As for Orthogonal Vectors, we start from surjectivity, but the quantifier structure of BMPRS now permits a direct embedding. A function is not surjective exactly when , which matches the two outer quantifiers of BMPRS . The innermost existential quantifier asks whether row of and column of share a one. To make this condition equivalent to , we encode each value by a string of length , let row of mark the zeros of , and let column of hold .
We expand each encoding position into a block of auxiliary indices, repeating the corresponding column of throughout the block. For each column of , the entries in this block are fresh variables whose OR replaces the original encoded bit. This implements composition with OR. Applying adversary composition multiplies the lower bound for surjectivity by . Unlike the proof of Theorem 3.4, which places an AND outside many surjectivity instances, this proof uses a single instance and composes it with ORs at its inputs. The length of the encoding accounts for the factor in Theorem 5.2.
Encoding the predicate . Let be even, and let . For , let be the binary representation of , and define
If , then some satisfies and : take a bit on which and differ, in the first half of the encoding if has a zero there and in the complemented second half otherwise. If , no such exists. Hence, for all ,
For , define
For , let be obtained by replacing each variable with the OR of fresh variables; that is, for ,
Lemma 5.3 (Encoded non-surjectivity). For every even and every integer ,
Proof. We first show that . Given an instance of , set the -th row of to . By Equation (5.2),
that is, exactly when is not surjective. Each bit of depends on a single value , so each query to can be simulated with queries to . Hence , and the lower bound of Beame and Machmouchi [BM12, Corollary 6] gives .
As in the proof of Lemma 3.3, the negative-weight adversary bound characterizes bounded-error quantum query complexity up to a constant factor and is multiplicative under composition , Theorem 1.1 and Lemma 5.2]. Hence , and since ,
Proof of Theorem 5.2. The upper bound was shown above. The middle inequality holds because is a restriction of . For the lower bound, set
with as above. For , the integer is even and at least four, and . Hence and .
We embed into . Index the rows of by and the columns of by , and label of the auxiliary indices, shared by the columns of and the rows of , by the pairs . For , , and , define
All other entries of A and B are zero. For and ,
For and , we have , because has zeros, so row of is nonzero. For , row of , and hence row of , is zero. Comparing with Equation (5.3) gives . Every entry of is fixed, and every entry of is fixed or equal to a single bit of . By Lemma 5.3,
since , , and .
5.2 Radius at Most Two
By Equation (2.2), a graph G has radius at most two exactly when has an all-ones row, which reduces Radius at Most Two to . For the reverse reduction, we use a layered construction of Abboud, Vassilevska Williams, and Wang [AVWW16], stated directly in terms of the matrices A and B. Row, middle, and column indices become three layers of vertices, and auxiliary vertices ensure that only row vertices can be within distance two of every vertex.
Proposition 5.4 (Boolean Matrix Product Row Search and radius). For every ,
Proof. For the first inequality, let be an -vertex graph, and set . Entry of is 1 if and is the adjacency bit otherwise, so it costs at most one query. By Equation (2.2), row of is all ones exactly when every vertex is within distance two of . Hence .
For the second inequality, let be an instance of . The graph has vertices: a vertex for each row index of , a vertex for each middle index , a vertex for each column index of , and three auxiliary vertices , , and . Its edges are
• and for every ;
• for every , and the edge ;
• whenever , and whenever .
Only the edges in the last item depend on the input, and each is answered by a single query to A or B.
We claim that the vertices within distance two of every vertex of are exactly the vertices for which row of is all ones. A vertex is adjacent to and , reaches every other and through , and reaches every through . It is not adjacent to , and their common neighbors are the vertices with , so
It remains to rule out the other vertices. The vertex and every are at distance at least three from each other, because all neighbors of have the form and none of them is adjacent to . The vertex and every vertex or are at distance at least three from each other, because the only neighbor of is , and is adjacent to neither. Hence has radius at most two exactly when .
Corollary 5.5 (Query bounds for Radius at Most Two). For every ,
Proof. The upper bound follows from the first inequality in Proposition 5.4 and Theorem 5.2. For the lower bound, let , so that and . Apply the second reduction of Proposition 5.4 to an instance of , and add further vertices adjacent only to . Each new vertex plays the same role as : it is at distance two from every and at distance three from . Hence the answer is unchanged, and Theorem 5.2 gives
Thus Boolean Matrix Product Row Search, already with the all-ones target, and Radius at Most Two have quantum query complexity , so nested search is optimal for them up to a factor . For their universal counterparts, the condition and Diameter at Most Two, nested search is not optimal: by Theorem 4.6 and the reductions of Section 3, both can be decided with queries. Changing the outermost quantifier from “every” to “some” therefore makes both problems polynomially harder. In particular, Radius at Most Two is polynomially harder than Diameter at Most Two in the adjacency matrix model.
Acknowledgements
We thank Andrew Childs for many helpful discussions. ASG received support from the National Science Foundation (grant 26-17356) and the Department of Energy (grant DE-SC0020264 and the Office of Science, Office of Advanced Scientific Computing Research, Accelerated Research in Quantum Computing program). FLG is supported by JSPS KAKENHI grants JP24H00071 and JP25K24674, MEXT Q-LEAP grant JPMXS0120319794, JST ASPIRE grant JPMJAP2302, and JST CREST grant JPMJCR24I4. XZ is supported by NSERC Grant RGPIN-2024-06493.
Use of generative AI. OpenAI GPT 6 Astra and Anthropic Opus 5.5 were used for literature searches, manuscript drafting and revision, proof development and checking, and LaTeX preparation. The authors retain full responsibility for reviewing the generated material and for all mathematical claims and final text.
In particular, GPT 6 Astra found bottlenecks in authors' earlier arguments for the main upper bound and after significant back-and-forth, suggested a preprocessing step that eventually resulted in the upper bound of for the promise problem considered in Section 4.1. It was then used to improve the exponents and remove the promise. The resulting algorithm was quite complicated, and it was later simplified by the authors resulting in the algorithm presented in Theorem 4.6.
References
[ACIM99] Donald Aingworth, Chandra Chekuri, Piotr Indyk, and Rajeev Motwani. Fast estimation of diameter and shortest paths (without matrix multiplication). SIAM Journal on Computing, 28(4):1167–1181, 1999. doi:10.1137/S0097539796303421.
[ACL 20] Scott Aaronson, Nai-Hui Chia, Han-Hsuan Lin, Chunhao Wang, and Ruizhe Zhang. On the quantum complexity of closest pair and related problems. In 35th Computational Complexity Conference (CCC 2020), volume 169 of Leibniz International Proceedings in Informatics, pages 16:1–16:43. Schloss Dagstuhl–Leibniz-Zentrum für Informatik, 2020. doi:10.4230/LIPIcs.CCC.2020.16.
[AKV23] Andris Ambainis, Martins Kokainis, and Jevgēnijs Vihrovs. Improved algorithm and lower bound for variable time quantum search. In 18th Conference on the Theory of Quantum Computation, Communication and Cryptography (TQC 2023), volume 266 of Leibniz International Proceedings in Informatics, pages 7:1–7:18. Schloss Dagstuhl–Leibniz-Zentrum für Informatik, 2023. doi:10.4230/LIPIcs.TQC.2023.7.
[AVWW16] Amir Abboud, Virginia Vassilevska Williams, and Joshua R. Wang. Approximation and fixed parameter subquadratic algorithms for radius and diameter in sparse graphs. In Proceedings of the Twenty-Seventh Annual ACM-SIAM Symposium on Discrete Algorithms, pages 377–391. SIAM, 2016. doi:10.1137/1.9781611974331.ch28.
[BHMT02] Gilles Brassard, Peter Høyer, Michele Mosca, and Alain Tapp. Quantum amplitude amplification and estimation. In Quantum Computation and Information, volume 305 of Contemporary Mathematics, pages 53–74. American Mathematical Society, 2002. doi:10.1090/conm/305/05215.
[BKM95] Julien Basch, Sanjeev Khanna, and Rajeev Motwani. On diameter verification and Boolean matrix multiplication. Technical Report STAN-CS-95-1544, Department of Computer Science, Stanford University, 1995. URL: https://theory.stanford.edu/~rajeev/postscripts/diamat.ps.gz.
[BKT21] Mark Bun, Robin Kothari, and Justin Thaler. Quantum algorithms and approximating polynomials for composed functions with shared inputs. Quantum, 5:543, 2021. doi:10.22331/q-2021-09-16-543.
[BKW26] Paul Beame, Niels Kornerup, and Michael Whitmeyer. Quantum time-space tradeoffs for matrix problems. SIAM Journal on Computing, 55(3):469–519, 2026. doi:10.1137/24M1710164.
[BM12] Paul Beame and Widad Machmouchi. The quantum query complexity of . Quantum Information & Computation, 12(7–8):670–676, 2012. doi:10.26421/QIC12.7-8-11.
[BPS21] Harry Buhrman, Subhasree Patro, and Florian Speelman. A framework of quantum strong exponential-time hypotheses. In 38th International Symposium on Theoretical Aspects of Computer Science (STACS 2021), volume 187 of Leibniz International Proceedings in Informatics, pages 19:1–19:19. Schloss Dagstuhl–Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPIcs.STACS.2021.19.
[BRS 18] Arturs Backurs, Liam Roditty, Gilad Segal, Virginia Vassilevska Williams, and Nicole Wein. Towards tight approximation bounds for graph diameter and eccentricities. In Proceedings of the 50th Annual ACM SIGACT Symposium on Theory of Computing, pages 267–280. ACM, 2018. doi:10.1145/3188745.3188950.
[BŠ06] Harry Buhrman and Robert Špalek. Quantum verification of matrix products. In Proceedings of the Seventeenth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 880–889, 2006. doi:10.1145/1109557.1109654.
[CGR16] Massimo Cairo, Roberto Grossi, and Romeo Rizzi. New bounds for approximating extremal distances in undirected graphs. In Proceedings of the Twenty-Seventh Annual ACM-SIAM Symposium on Discrete Algorithms, pages 363–376. SIAM, 2016. doi:10.1137/1.9781611974331.ch27.
[CKK12] Andrew M. Childs, Shelby Kimmel, and Robin Kothari. The quantum query complexity of read-many formulas. In Algorithms – ESA 2012, volume 7501 of Lecture Notes in Computer Science, pages 337–348. Springer, 2012. doi:10.1007/978-3-642-33090-2_30.
[CLM17] Titouan Carette, Mathieu Laurière, and Frédéric Magniez. Extended learning graphs for triangle finding. In 34th Symposium on Theoretical Aspects of Computer Science (STACS 2017), volume 66 of Leibniz International Proceedings in Informatics, pages 20:1–20:14. Schloss Dagstuhl–Leibniz-Zentrum für Informatik, 2017. doi:10.4230/LIPIcs.STACS.2017.20.
[CLR 14] Shiri Chechik, Daniel H. Larkin, Liam Roditty, Grant Schoenebeck, Robert E. Tarjan, and Virginia Vassilevska Williams. Better approximation algorithms for the graph diameter. In Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1041–1052. SIAM, 2014. doi:10.1137/1.9781611973402.78.
[CW19] Lijie Chen and Ryan Williams. An equivalence class for orthogonal vectors. In Proceedings of the Thirtieth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 21–40. SIAM, 2019. doi:10.1137/1.9781611975482.2.
[Din16] Yongshan Ding. Quantum algorithms for Boolean matrix product verification, 2016. Undergraduate thesis, Carnegie Mellon University. URL: https://www.yongshanding.com/papers/cmu-ugrad-thesis.pdf.
[DK21] Mina Dalirrooyfard and Jenny Kaufmann. Approximation algorithms for min-distance problems in DAGs. In 48th International Colloquium on Automata, Languages, and Programming (ICALP 2021), volume 198 of Leibniz International Proceedings in Informatics, pages 60:1–60:17. Schloss Dagstuhl–Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPIcs.ICALP.2021.60.
[Fre79] Rüsiņš Freivalds. Fast probabilistic algorithms. In Mathematical Foundations of Computer Science 1979, volume 74 of Lecture Notes in Computer Science, pages 57–69. Springer, 1979. doi:10.1007/3-540-09526-8_5.
[HMdW03] Peter Høyer, Michele Mosca, and Ronald de Wolf. Quantum search on bounded-error inputs. In Automata, Languages and Programming, volume 2719 of Lecture Notes in Computer Science, pages 291–299. Springer, 2003. doi:10.1007/3-540-45061-0_25.
[JKM12] Stacey Jeffery, Robin Kothari, and Frédéric Magniez. Improving quantum query complexity of Boolean matrix multiplication using graph collision. In Automata, Languages, and Programming, volume 7391 of Lecture Notes in Computer Science, pages 522–532. Springer, 2012. doi:10.1007/978-3-642-31594-7_44.
[KN16] Robin Kothari and Ashwin Nayak. Quantum algorithms for matrix multiplication and product verification. In Ming-Yang Kao, editor, Encyclopedia of Algorithms, pages 1673–1677. Springer, 2016. doi:10.1007/978-1-4939-2864-4_303.
[Kot14] Robin Kothari. Efficient Algorithms in Quantum Query Complexity. PhD thesis, University of Waterloo, 2014. URL: https://hdl.handle.net/10012/8625.
[KŠdW07] Hartmut Klauck, Robert Špalek, and Ronald de Wolf. Quantum and classical strong direct product theorems and optimal time-space tradeoffs. SIAM Journal on Computing, 36(5):1472–1493, 2007. doi:10.1137/05063235X.
[Kün18] Marvin Künnemann. On nondeterministic derandomization of Freivalds' algorithm: Consequences, avenues and algorithmic progress. In 26th Annual European Symposium on Algorithms (ESA 2018), volume 112 of Leibniz International Proceedings in Informatics, pages 56:1–56:16. Schloss Dagstuhl–Leibniz-Zentrum für Informatik, 2018. doi:10.4230/LIPIcs.ESA.2018.56.
[LG14a] François Le Gall. Improved quantum algorithm for triangle finding via combinatorial arguments. In 55th IEEE Annual Symposium on Foundations of Computer Science, pages 216–225. IEEE, 2014. doi:10.1109/FOCS.2014.31.
[LG14b] François Le Gall. Quantum complexity of Boolean matrix multiplication and related problems. In Computing with New Resources: Essays Dedicated to Jozef Gruska on the Occasion of His 80th Birthday, volume 8808 of Lecture Notes in Computer Science, pages 176–191. Springer, 2014. doi:10.1007/978-3-319-13350-8_13.
[LMR 11] Troy Lee, Rajat Mittal, Ben W. Reichardt, Robert Špalek, and Mario Szegedy. Quantum query complexity of state conversion. In 52nd IEEE Annual Symposium on Foundations of Computer Science, pages 344–353, 2011. doi:10.1109/FOCS.2011.75.
[LMS13] Troy Lee, Frédéric Magniez, and Miklos Santha. Improved quantum query algorithms for triangle finding and associativity testing. In Proceedings of the Twenty-Fourth Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1486–1502. SIAM, 2013. doi:10.1137/1.9781611973105.107.
[MNRS11] Frédéric Magniez, Ashwin Nayak, Jérémie Roland, and Miklos Santha. Search via quantum walk. SIAM Journal on Computing, 40(1):142–164, 2011. doi:10.1137/090745854.
[MSS07] Frédéric Magniez, Miklos Santha, and Mario Szegedy. Quantum algorithms for the triangle problem. SIAM Journal on Computing, 37(2):413–424, 2007. doi:10.1137/050643684.
[RVW13] Liam Roditty and Virginia Vassilevska Williams. Fast approximation algorithms for the diameter and radius of sparse graphs. In Proceedings of the Forty-Fifth Annual ACM Symposium on Theory of Computing, pages 515–524. ACM, 2013. doi:10.1145/2488608.2488673.
[VR19] Jorg Van Renterghem. The implications of breaking the strong exponential time hypothesis on a quantum computer. Master's thesis, Ghent University, 2019. URL: https://libstore.ugent.be/fulltxt/RUG01/002/787/416/RUG01-002787416_2019_0001_AC.pdf.
[VWW18] Virginia Vassilevska Williams and Ryan Williams. Subcubic equivalences between path, matrix, and triangle problems. Journal of the ACM, 65(5):27:1–27:38, 2018. doi:10.1145/3186893.
[WB25] Adam Wesolowski and Jinge Bao. Quantum algorithms and lower bounds for eccentricity, radius, and diameter in undirected graphs, 2025. arXiv:2502.20148, doi:10.48550/arXiv.2502.20148.