Claude, an AI model developed by Anthropic, discovered the algorithm that refutes the 3SUM, APSP, and Exact Triangle hypotheses. The authors then worked to understand, simplify, strengthen, and extend the algorithm, derive additional consequences, and make the presentation accessible. See “Acknowledgments and Methodology” for how the result was found and shared with the authors. The authors take full responsibility for this paper.

Claude also verified this paper’s main results using the Lean 4 proof assistant with the Mathlib library.

Introduction

Since its inception, algorithms research has sought the fastest possible algorithm for every problem it considers. Powerful techniques have been developed, from variants of dynamic programming to surprising algebraic tools such as the Fast Fourier Transform [65] and fast matrix multiplication [147]. Yet for many problems, these techniques have not sufficed. Some examples include:

  • 3SUM: Given nn numbers, decide whether three of them sum to 0. This is a classical problem with a long history, and it is central to computational geometry (see [92]). Despite many decades of research, the O(n2)O(n^2)-time algorithm taught in algorithms classes has only been sped up by polylogarithmic factors [35, 94, 55].

  • All-Pairs Shortest Paths (APSP): Given an edge-weighted graph on nn vertices with no negative cycles, compute the shortest-path distance between every pair of vertices. Classical algorithms such as Johnson’s [107] and Floyd and Warshall’s [85, 162] solve APSP in O(n3)O(n^3) time. After a long line of work [87, 150, 76, 97, 151, 152, 173, 52, 98, 53, 102], the fastest known algorithm [166] only shaves a subpolynomial, 2Ω(log⁡n)2^{\Omega(\sqrt{\log n})} factor off the cubic running time.

  • Directed Unweighted APSP: The version of APSP in nn-vertex directed unweighted graphs. The fastest known algorithm, by Zwick [172], runs in O(n2.5275)O(n^{2.5275}) time with the current bounds for rectangular matrix multiplication [10], and beyond improvements to the matrix multiplication bounds, it has not been improved for more than two decades. If the exponent ω\omega of matrix multiplication is 2, the best known running time for this problem [14, 172] is still only O~(n2.5)\widetilde{O}(n^{2.5}).

  • Tree Edit Distance: Given two rooted, ordered, labeled trees with nn vertices, and costs for deleting, inserting, and relabeling vertices, find the cheapest sequence of such operations that transforms one tree into the other. Tree Edit Distance is used, for instance, to compare RNA secondary structures and XML documents. The fastest known algorithms for this problem [75, 133] run in cubic time, up to subpolynomial improvements. Only when all costs are equal to 1 are truly subcubic algorithms known [127, 74, 133].

  • Online Set Disjointness: Preprocess sets S1,…,SNS_1,\ldots,S_N and T1,…,TNT_1,\ldots,T_N over a universe of size DD, so that given II and JJ one can quickly decide whether SI∩TJ=∅S_I \cap T_J = \emptyset, or, in the counting version, return ∣SI∩TJ∣\lvert S_I \cap T_J\rvert. Essentially only two straightforward solutions are known: (1) to compute all N2N^2 answers in advance, which fast rectangular matrix multiplication does in N2+o(1)N^{2+o(1)} time when D≤N0.321D \le N^{0.321} [64, 161], and (2) to store the sets and compute each intersection at query time in O(D)O(D) time. Set Disjointness data structures have been studied extensively [50, 116, 89, 155, 119], mostly for sets of small total size over a large universe.

  • CNF-SAT: Given a Boolean formula FF in conjunctive normal form over nn variables and O(n)O(n) clauses, is there an assignment to the variables that satisfies all clauses? The brute-force algorithm solves CNF-SAT in 2npoly⁡(n)2^n\operatorname{poly}(n) time. There are slightly faster algorithms when the width of the clauses is bounded by a constant independent of nn [144, 136, 99]. However, no O(1.99999n)O(1.99999^n)-time algorithm is known.

  • Orthogonal Vectors (OV): Given nn Boolean vectors in d=ω(log⁡n)d = \omega(\log n) dimensions, are two of them orthogonal? The brute-force algorithm solves OV in O(n2d)O(n^2d) time, and only subpolynomial improvements are known: the fastest algorithms [29, 66] run in n2−1/O(log⁡(d/log⁡n))n^{2-1/O(\log(d/\log n))} time.

The apparent lack of progress on problems such as these led to new theories of hardness: NP-completeness [61, 110] for problems with no known polynomial-time algorithm, and fine-grained complexity (FGC) [154, 45] for problems whose best known algorithms were stuck at essentially the straightforward running time. Both theories relate problems via reductions. FGC focuses on improvements in the exponent: a fine-grained reduction from problem AA to problem BB with respect to running times a(n)a(n) and b(n)b(n) implies that an O(b(n)1−ε)O(b(n)^{1-\varepsilon})-time algorithm for BB for some ε>0\varepsilon> 0 can be converted into an O(a(n)1−δ)O(a(n)^{1-\delta})-time algorithm for AA for some δ>0\delta> 0.

Fine-grained complexity took three of the problems from our list above and postulated that the state-of-the-art algorithms cannot be beaten: in the word RAM model of computation with O(log⁡n)O(\log n)-bit words, APSP with polynomially bounded integer weights requires n3−o(1)n^{3-o(1)} time (the “APSP hypothesis” [140, 157, 159, 26]), 3SUM on nn integers of polynomial size requires n2−o(1)n^{2-o(1)} time (the “3SUM hypothesis” [92, 136]), and there is no ε>0\varepsilon> 0 such that CNF-SAT on nn variables and O(n)O(n) clauses can be solved in (2−ε)n(2-\varepsilon)^n time (the “Strong Exponential Time Hypothesis,” SETH [103, 104, 50]).

Through fine-grained reductions, FGC built a web of relations among problems, and within it, classes of problems that are equivalent to each other (see the surveys [154, 45]). For a large variety of problems for which no improved running times had been obtained in decades, FGC pointed to reasons: they are 3SUM-hard, APSP-hard, SETH-hard, or worse. In other words, to improve the known algorithms, one knew which obstacle needed to be overcome.

For instance, many problems are known to be equivalent to APSP under fine-grained reductions. Either all of the following problems are solvable in truly subcubic time, meaning in O(n3−ε)O(n^{3-\varepsilon}) time for some constant ε>0\varepsilon> 0 (truly subquadratic is defined similarly), or none of them is: the (min⁡,+)(\min,+)-product A⋆BA \star B of two n×nn \times n matrices AA and BB (defined by (A⋆B)[i,j]=min⁡k(A[i,k]+B[k,j])(A \star B)[i,j] = \min_k(A[i,k]+B[k,j])) [87, 19]1, Negative Triangle and Second Shortest Simple Path [157, 159], Graph Radius [30, 17], Tree Edit Distance [39, 133], and many other problems [157, 159, 138, 30, 17], more of which are listed below, after Figure 1. Perhaps surprisingly, it is also known [66] that solving APSP in truly subcubic time would give a polynomially faster algorithm for directed unweighted APSP as well, and the corresponding hypotheses are in fact equivalent [82]2 (albeit conditionally2{}^{2}), even though the longstanding running times of the two problems are different: ≈n3\approx n^3 for APSP and ≈n2.5\approx n^{2.5} for directed unweighted APSP (if ω=2\omega= 2).

Diagram of problems affected by the algorithm and their fine-grained reductions

Figure 1. Problems affected by our algorithm, which solves the problem in the orange box (Lopsided All-Edges Sparse Triangle) directly. The problems inside each of the three thick-bordered blue boxes (3SUM class, Exact Triangle, and APSP class) are pairwise equivalent under fine-grained reductions (for MonoConvolution, whose baseline is n1.5n^{1.5}, this means O(n1.5−ε)O(n^{1.5-\varepsilon}) time), and we omit the arrows between them. Problems in gray boxes are reached from 3SUM, APSP, or Exact Triangle only by one-way reductions, so our result gives no faster algorithms for them, but these reductions no longer give evidence of hardness. The new algorithms are deterministic except where marked. Citations are to the reductions; for the problems in the top rows, the cited papers contain many more problems of the same kind.

Similar reductions and equivalences are also known for 3SUM: all nontrivial 3-linear degeneracy tests are equivalent to 3SUM [73], and many other problems are 3SUM-hard (e.g., many problems in computational geometry [92, 36, 146, 18], and some string problems [6, 26, 116]).

CNF-SAT reduces to Orthogonal Vectors [163], so that unless SETH is refuted, OV requires n2−o(1)n^{2-o(1)} time. SETH also implies fine-grained hardness for many exponential-time problems [50].

Both 3SUM and APSP reduce to the Exact Triangle problem (given a tripartite graph with integer edge weights, is there a triangle whose three weights sum to zero?) [158, 157, 159]. Through Exact Triangle, both reduce to online Set Disjointness (from the list above), and even to its offline version, in which the query pairs are given in advance together with the sets [160, 71]; for 3SUM, direct reductions are also known [136, 116, 109, 1]. In graph terms, offline Set Disjointness is the All-Edges Sparse Triangle problem: given a graph with mm edges, decide for every edge whether it lies in a triangle.

All-Edges Sparse Triangle thus inherits the hardness of both 3SUM and APSP, and it is in turn the source of the conditional lower bounds for Set Disjointness data structures, dynamic graph problems, and other problems [136, 26, 116, 90]. Many came to regard it as one of the most reliably hard problems in fine-grained complexity, and the evidence seemed good.

All-Edges Sparse Triangle can be solved in O(m3/2)O(m^{3/2}) time just by listing all triangles [105, 60], and a high-degree/low-degree split combined with matrix multiplication [14] improves this to O(m2ω/(ω+1))O(m^{2\omega/(\omega+1)}), where 2≤ω<2.3722 \le\omega< 2.372 is the matrix multiplication exponent.3 Even if ω=2\omega= 2, this is m4/3m^{4/3}. On the graphs the reductions produce, which have nn vertices of degree about n\sqrt{n}, this equals the brute-force running time n2n^2 conjectured to be optimal. Matrix multiplication only seemed useful for dealing with dense inputs, whereas these instances ask for a sparse set of outputs, and it seemed plausible that no technique could do better.

However, a reduction from AA to BB, proved in order to show that BB is hard, is also an algorithm for AA whenever BB turns out to be easy. In this paper we give a new algorithm for a lopsided version of All-Edges Sparse Triangle, in which the graph is tripartite and one of the three parts is significantly smaller than the other two. Most known reductions to All-Edges Sparse Triangle can be slightly modified to produce such instances.

As a consequence, all of the problems in the list above (and many more), except for CNF-SAT and Orthogonal Vectors, have polynomially faster algorithms than before:

  • 3SUM: deterministic O(n1.9992)O(n^{1.9992}) time for integers of polynomial size (Theorem 22), and for real numbers, a Las Vegas algorithm with O(n1.998)O(n^{1.998}) expected time whose only operations on real numbers are comparisons, additions, and subtractions (Theorem 35).

  • APSP: deterministic O(n2.9995)O(n^{2.9995}) time for polynomially bounded integer weights, and the same bound for the (min⁡,+)(\min,+)-product (Theorem 22), and for real weights, Las Vegas algorithms with O(n2.998)O(n^{2.998}) expected time, again using only comparisons, additions, and subtractions on real numbers (Theorem 35).

  • Directed Unweighted APSP: a deterministic algorithm running in O(n2+μ−ε′′)O(n^{2+\mu-\varepsilon''}) time for some constant ε′′>0\varepsilon'' > 0, where μ<0.5275\mu< 0.5275 is defined by ω(1,μ,1)=1+2μ\omega(1,\mu,1) = 1 + 2\mu, and ω(1,μ,1)\omega(1,\mu,1) is the exponent of multiplying an n×nμn \times n^\mu by an nμ×nn^\mu\times n matrix. Note that O(n2+μ)≤O(n2.5275)O(n^{2+\mu}) \le O(n^{2.5275}) is the longstanding running time of Zwick’s algorithm. This is the first improvement over Zwick’s algorithm that does not come from faster rectangular matrix multiplication, and it refutes the Directed Unweighted APSP hypothesis [66, 68, 84] (Theorem 34).

  • Tree Edit Distance: O(n2.9995)O(n^{2.9995}) time for polynomially bounded integer costs via the tight reduction of [39].

  • Online Set Disjointness: for D≤N0.12D \le N^{0.12}, a deterministic data structure whose preprocessing time is polynomially less than N2N^2 and whose query time is polynomially less

than D\sqrt{D}, and which returns ∣SI∩TJ∣|S_I \cap T_J|, so that it solves the counting version as well. For D≤N1/18D \le N^{1/18}, the preprocessing takes O(N2/D0.063)O(N^2/D^{0.063}) time and the queries take O(D0.437)O(D^{0.437}) time (Theorem 3).

The APSP and 3SUM hypotheses are therefore refuted, and so are several other hypotheses of fine-grained complexity. Figure 1 summarizes the problems affected, and in Section 1.2 below we list many more new algorithmic results. All of these results follow from one algorithm, for computing a given sparse set of entries of the product of two thin matrices, which we describe in the next subsection.

We view this as a great success for fine-grained complexity. The hypotheses were made to be tested. The reductions and connections between problems have always been the focus of fine-grained complexity, and these connections persist whether or not the problems turn out to be hard. The web of reductions that was interpreted to imply hardness is exactly what turns a single new algorithm into faster algorithms for a myriad of problems at once. This also opens a number of research directions in fine-grained complexity, algorithm design, and algebraic complexity; we discuss some in Section 6.

All-Edges Sparse Triangle

In this paper we present a simple algebraic technique that solves All-Edges Sparse Triangle in O(n2−δ)O(n^{2-\delta}) time, for a constant δ>0\delta> 0, on sparse tripartite graphs with two parts of nn vertices and a third part of at most n0.12n^{0.12} vertices. In matrix language it computes a prescribed sparse set of entries of a dense product of thin matrices. We call a product of an N×DN \times D matrix by a D×ND \times N matrix thin when DD is a small power of NN, and, given a set WW of positions of the product, we call these positions, and the entries of the product at them, wanted. Unlike in usual fast matrix multiplication algorithms, the wanted entries are a sparse subset of the full matrix product, and our new algorithm critically exploits this. A matrix multiplication algorithm computes all N2N^2 entries of the product whether they are wanted or not, and thus takes Ω(N2)\Omega(N^2) time, whereas ours is faster than this. Our theorem is as follows.

Theorem 1 (see Corollary 26 and Theorem 25). Let N≥D18N \ge D^{18}, let X∈ZN×DX \in\mathbb{Z}^{N \times D} and Y∈ZD×NY \in\mathbb{Z}^{D \times N} have entries of absolute value NO(1)N^{O(1)}, and let WW be any set of ∣W∣≤N2/D|W| \le N^2/\sqrt{D} positions. The entries (XY)[I,J](XY)[I,J], (I,J)∈W(I,J) \in W, can be computed deterministically in O(N2/D0.063)O(N^2/D^{0.063}) operations on O(log⁡N)O(\log N)-bit integers. More generally, for every ε<0.1204\varepsilon< 0.1204 and every κ>0\kappa> 0 there is a γ>0\gamma> 0 such that, whenever D≤NεD \le N^\varepsilon and ∣W∣≤N2/Dκ|W| \le N^2/D^\kappa, the task takes O(N2/Dγ)O(N^2/D^\gamma) operations.

For comparison, when ∣W∣=N2/D|W| = N^2/\sqrt{D}, computing each wanted entry one by one as an inner product costs N2DN^2\sqrt{D}, and computing the whole product with Coppersmith’s rectangular matrix multiplication algorithm [62] costs N2+o(1)N^{2+o(1)}. Our algorithm is faster than either of these, and uses polynomially less than one operation per entry of the full product.

The algorithm builds on Coppersmith’s algorithm [62] for rectangular matrix multiplication, which makes use of an algebraic identity of Schönhage [143]. The high-level idea is to carefully analyze the inner workings of Coppersmith’s algorithm to see which operations are no longer needed since they are only used to compute output entries outside of WW. This approach would not work effectively for most known matrix multiplication algorithms,4 but it turns out that Schönhage’s identity has sparsity and combinatorial properties we can take advantage of to make this work. See Section 2 for a more detailed overview.

Coppersmith’s paper [62] contains two algorithms. The first algorithm achieves an n2polylog⁡nn^2 \operatorname{polylog} n running time for n×n0.172×nn \times n^{0.172} \times n matrix multiplication (for matrices with polylog⁡n\operatorname{polylog} n bit entries). We do not use this algorithm here, but it has been extensively used before, both in the previous fastest APSP algorithm by Williams [166] and to design the fastest fine-grained algorithms for a number of problems using the polynomial method [164, 30, 29, 66, 16, 8]. Our approach instead builds on the second algorithm in [62], which only achieves an n2+o(1)n^{2+o(1)} running time (and not n2polylog⁡nn^2 \operatorname{polylog} n) for n×nα×nn \times n^\alpha\times n matrix multiplication for some constant α>0\alpha> 0; these no(1)n^{o(1)} factors become insignificant in our setting of polynomial savings. Subsequent work on rectangular matrix multiplication has mostly followed this second approach [63, 120, 124, 161] achieving the current bound α>0.321\alpha> 0.321. In order to take advantage of the wanted set, we will modify Coppersmith’s second algorithm quite differently from prior work, in a way which ultimately achieves the worse bound α>0.12\alpha> 0.12.

Computing the wanted entries of a thin matrix product is equivalent to the counting version of Lopsided All-Edges Sparse Triangle (if XX and YY are the two biadjacency matrices, then (XY)[a,b](XY)[a,b] is the number of middle vertices adjacent to both aa and bb), so it solves the detection variant as well. In a tripartite graph with two parts of nn vertices and a middle part of nεn^\varepsilon vertices, our algorithm counts the triangles through each of ∣W∣|W| prescribed pairs of outer vertices in O(∣W∣n0.437ε+n2−0.063ε)O(|W| n^{0.437\varepsilon} + n^{2-0.063\varepsilon}) time for ε<1/18\varepsilon< 1/18, which is O(n2−0.063ε)O(n^{2-0.063\varepsilon}) for ∣W∣≤n2−ε/2|W| \le n^{2-\varepsilon/2}, and, whenever ∣W∣≤n2−Ω(1)|W| \le n^{2-\Omega(1)}, in truly subquadratic time for every ε<0.1204\varepsilon< 0.1204 (Corollary 16 and Theorem 25).

Known reductions

It is known that 3SUM [136, 116], Exact Triangle and hence APSP [66], and even their real-valued versions [?], all reduce to Lopsided All-Edges Sparse Triangle. In matrix terms, this detection version is a Boolean matrix problem, and it is also known as offline Set Disjointness [116, 66].

The published reductions are mostly randomized, since the hypotheses were stated for randomized algorithms, but some have been derandomized: the reductions from 3SUM [51, 84], including the reduction of [116] to offline Set Disjointness [84], and the reduction from Exact Triangle to the standard balanced case of All-Edges Sparse Triangle, by Chan and Xu [71]. We show that the reduction from Exact Triangle to the lopsided case can also be made deterministic by hashing the weights modulo a prime chosen with fast matrix multiplication and building the instances as Chan and Xu [71] do (Section 3.2), so we refute both hypotheses deterministically.

With randomization, we refute the hypotheses in their most general form, where the inputs are real numbers. The reduction of Chan, Vassilevska Williams, and Xu [?] from the real-valued problems to sparse triangle problems (which was designed as a hardness argument) uses only additions, subtractions, and comparisons (via Fredman’s trick [87]), so combined with our algorithm it gives Las Vegas algorithms for the real-valued versions of 3SUM and APSP (Section 5.2). Unlike the reductions for integer inputs, which need only the detection version, the reduction of [?] that we use is to the counting version of Lopsided All-Edges Sparse Triangle, which asks for the number of triangles through each prescribed pair, and which our Theorem 5 also solves. Chan, Vassilevska Williams, and Xu [?] also give a reduction to the Boolean version of All-Edges Sparse Triangle, but it is tight only from real APSP, not from real 3SUM or Exact Triangle.

Theorem 2 (Theorems 19, 22, and 35). On a word RAM with O(log⁡n)O(\log n)-bit words, deterministic algorithms solve the following problems, where all numbers in the input are integers of absolute value nO(1)n^{O(1)}:

  • Exact Triangle on nn-vertex graphs in O(n2.9983)O(n^{2.9983}) time,

  • APSP on directed nn-vertex graphs with no negative cycles in O(n2.9995)O(n^{2.9995}) time,

  • the (min⁡,+)(\min,+)-product of two n×nn \times n matrices in O(n2.9995)O(n^{2.9995}) time, and

  • 3SUM on nn numbers in O(n1.9992)O(n^{1.9992}) time.

In the real RAM in which the only operations allowed on real numbers are comparisons, additions, and subtractions, Las Vegas algorithms solve the following problems on real inputs:

  • 3SUM on nn numbers in O(n1.998)O(n^{1.998}) expected time,

  • APSP in O(n2.998)O(n^{2.998}) expected time,

  • the (min⁡,+)(\min,+)-product in O(n2.998)O(n^{2.998}) expected time, and

  • Exact Triangle in O(n2.998)O(n^{2.998}) expected time.

Lower bounds are known for the above problems in some restricted models of computation: over the (min⁡,+)(\min,+) semiring, straight-line programs need n3n^3 operations [111] and path-comparison algorithms need Ω(n3)\Omega(n^3) time [112], and 3-linear decision trees for 3SUM need depth Ω(n2)\Omega(n^2) [79], [4].

Our algorithms are not in these restricted models, since the known reductions remove the weights (by hashing, or by Fredman’s trick for real inputs), and we then count triangles in unweighted graphs using integer matrix multiplication.

We remark that there already was some indication that some of these models were too restricted, as for instance recent work [113] showed that 6-linear decision trees of depth O(nlog⁡2n)O(n\log^2 n) suffice to solve 3SUM, and similar strong bounds are known for Exact Triangle. (See the paragraph on unaffected conjectures below for more on this.)

Data structure version, and hinted Online Matrix–Vector. Our algorithm for computing the wanted entries of a thin matrix product can also be converted into a data structure. We strengthen Theorem 1 as follows (Section 4):

Theorem 3 (see Theorem 24 and Corollary 26). Let N≥D18N \ge D^{18}, and let X∈ZN×DX \in\mathbb{Z}^{N \times D}, Y∈ZD×NY \in\mathbb{Z}^{D \times N} have entries of absolute value NO(1)N^{O(1)}. The pair (X,Y)(X,Y) can be preprocessed deterministically in O(N2/D0.063)O(N^2/D^{0.063}) time, polynomially less than the size of the product. After this, any single entry (XY)[I,J](XY)[I,J] can be computed deterministically in O(D0.437)O(D^{0.437}) time, polynomially less than D\sqrt{D}. More generally, for every ε<0.1204\varepsilon< 0.1204 and every q>0q > 0 there is a γ>0\gamma> 0 such that, whenever D≤NεD \le N^\varepsilon, the pair can be preprocessed in O(N2/Dγ)O(N^2/D^\gamma) time, after which any single entry can be computed in O(Dq)O(D^q) time.

The bounds of Theorem 1 follow by asking ∣W∣|W| queries to the data structure. This allows us to refute the hinted Online Matrix–Vector (OMv) conjectures of van den Brand, Nanongkai, and Saranurak [155] in the regime of thin hints, i.e., for very rectangular matrices. In the OMv problem, one is given an n×nn \times n Boolean matrix MM, and then nn vectors arrive one at a time, each of which must be multiplied by MM before the next one arrives. The OMv conjecture [100] asserts that this requires n3−o(1)n^{3-o(1)} total time, and it implies tight lower bounds for many dynamic problems. In the hinted versions, the algorithm gets a hint before the vector arrives. For instance, in vv-hinted Mv, MM is an n×tn \times t matrix and the hint is a t×nt \times n matrix VV, one of whose columns will be the vector. One can then either compute all of MVMV by fast matrix multiplication as soon as the hint arrives, or wait and compute one matrix–vector product in O(nt)O(nt) time, and van den Brand et al. [155] conjecture that no algorithm is polynomially faster than both. Our data structure is faster than both when the hint is thin:

Theorem 4 (Corollary 40). The vv-hinted Mv, Mv-hinted Mv, and uMv-hinted uMv conjectures of [155] (Conjectures 5.2, 5.7, and 5.12 there) are refuted in the regime of thin hints. For hint dimension t=nτt = n^\tau with 0<τ<1/180 < \tau< 1/18, the phase after the hint takes O(n2−0.063τ)O(n^{2-0.063\tau}) time and the phase after the vector O(n1+0.437τ)O(n^{1+0.437\tau}) time, against the conjectured n2−o(1)n^{2-o(1)} and n1+τ−o(1)n^{1+\tau-o(1)}. Correspondingly, the uMv version, whose two hints have dimensions t1=nτ1t_1 = n^{\tau_1} and t2=nτ2t_2 = n^{\tau_2}, fails for τ1<τ2/18\tau_1 < \tau_2/18. All three fail, with smaller savings, for every τ<0.1204\tau< 0.1204 (for the uMv version, τ1<0.1204τ2\tau_1 < 0.1204\tau_2).

The main conditional lower bounds of [155] for dynamic matrix inverse use the conjectures at τ≈0.53\tau\approx0.53, far from the thin regime, and are unaffected. The bounds that are affected are those for the tail end of the update–query trade-offs with the fastest queries. These had established the conditional optimality of the dynamic matrix inverse algorithms of Sankowski [141] and of [155] when queries are fast, and these no longer have a believable conditional lower bound. Neither do other results whose lower bounds were based on this end of the trade-offs, e.g., for partially dynamic distance oracles [HLS24] and dynamic attention [156] (Section 5.4).

More new algorithms. Figure 1 shows the reductions involved. In addition to the results listed above, composing known reductions with our algorithms for Exact Triangle, 3SUM, APSP, and the (min⁡,+)(\min,+)-product ((2)) gives polynomially faster algorithms for many other problems. We next list some examples. Throughout, the numbers in the input are integers of absolute value polynomial in the input size, nn is the number of vertices, matrix rows, or input elements, and our algorithms are deterministic unless stated otherwise.

  • The APSP class. Negative Triangle, which asks whether an edge-weighted graph has a triangle of negative total weight, is arguably the simplest problem of the subcubic equivalence class of APSP [157, 159]; the fact that it is equivalent to APSP made many other reductions possible. The APSP subcubic equivalence class also contains Minimum Weight Cycle (with nonnegative weights) [138, 157, 159], Replacement Paths (for each edge of a shortest ss–tt path, the length of a shortest ss–tt path avoiding it) and Second Shortest Simple Path in directed graphs [157, 159], Radius, Median, and (for unique shortest paths) Betweenness Centrality [14], Metricity (does a given matrix satisfy the triangle inequality?) and (min⁡,+)(\min,+)-Product Verification (is C=A+BC = A + B for given matrices AA, BB, and CC?) [157, 159], Tree Edit Distance [39], Maximum Subarray (the contiguous submatrix of an n×nn \times n matrix with the largest sum of entries) [TT00, BDT16], the Wiener Index (returning the sum of all distances in a graph) [LVW18], computing

the number of witnesses for every entry of the (min, +)-product [68] and a variety of parity versions of many of the mentioned problems [12]. We give the first truly subcubic algorithms for all of these problems, and for Diameter and many other problems which reduce to APSP but may not be known to be equivalent.

  • The 3SUM class. The subquadratic equivalence class of 3SUM contains the variant with three input sets AA, BB, and CC (is there a∈Aa \in A, b∈Bb \in B, c∈Cc \in C with a+b=ca+b=c?) and GeomBase (given nn points with integer coordinates on the three horizontal lines y=0y=0, y=1y=1, and y=2y=2, is there a non-horizontal line through three of them?) [92], All-Numbers 3SUM (for every input number, decide whether it is part of a solution) [157, 159] (the reduction becomes deterministic with the self-reductions of [126, 91], as noted in [84]), Convolution-3SUM (do x0,…,xn−1x_0,\ldots,x_{n-1} satisfy xi+xj=xi+jx_i+x_j=x_{i+j} for some i,ji,j?) [136, 51], and every nontrivial variant of 3-Linear Degeneracy Testing (are there distinct input numbers x1,x2,x3x_1,x_2,x_3 with α1x1+α2x2+α3x3=t\alpha_1x_1+\alpha_2x_2+\alpha_3x_3=t, for fixed integers α1,α2,α3,t\alpha_1,\alpha_2,\alpha_3,t?), such as 3AP, the case x1+x2=2x3x_1+x_2=2x_3 (do three of the numbers form an arithmetic progression?) [73]. The counting version #3SUM is also in the class [68, 83]; see the last item below. We give the first truly subquadratic algorithms for all of these problems.

The 3SUM class also contains MonoConvolution, a “colored” version of Boolean convolution: given three integer sequences a,b,ca,b,c of length nn, determine for every index ii whether there is a j<ij<i with a[j]=b[i−j]=c[i]a[j]=b[i-j]=c[i]. Lincoln, Polak, and Vassilevska Williams [123], Theorems 7 and 8 show that MonoConvolution is (n2,n1.5)(n^2,n^{1.5}) fine-grained equivalent to 3SUM: an O(n2−ε)O(n^{2-\varepsilon})-time algorithm for 3SUM gives an O~(n3/2−ε/(8−2ε))\widetilde{O}(n^{3/2-\varepsilon/(8-2\varepsilon)})-time algorithm for MonoConvolution. Our approach gives O(n1.4999)O(n^{1.4999}) time for MonoConvolution, improving on the previous O~(n1.5)\widetilde{O}(n^{1.5}) time of [123].

  • The (min, +)-convolution class. The (min, +)-convolution of two sequences aa and bb of nn integers is defined as the sequence cc with c[k]=min⁡i+j=k(a[i]+b[j])c[k]=\min_{i+j=k}(a[i]+b[j]) for all kk. This convolution version of APSP is fine-grained reducible to both the (min, +)-product [44] and 3SUM [44, 59]. Problems equivalent to (min, +)-convolution include Superadditivity Testing (is a[i+j]≥a[i]+a[j]a[i+j]\ge a[i]+a[j] for all i,ji,j?), Maximum Consecutive Subsums (for every kk, the largest sum of kk consecutive elements), and Tree Sparsity (a subtree with kk vertices of maximum weight in a vertex-weighted tree) [59]. We give the first truly subquadratic algorithms for all of these problems, refuting the (min, +)-convolution hypothesis [44, 59]. (This would have been possible by refuting either the APSP or the 3SUM hypothesis, and we refute both.)

  • Knapsack and Approximate Subset Sum. Both 0/1 and Unbounded Knapsack, with nn items and capacity tt, reduce to (min, +)-convolution [59]. So does approximating Subset Sum to within a factor 1−ε1-\varepsilon, which is in fact equivalent to it: an algorithm for (min, +)-convolution in time T(n)T(n) gives a randomized approximation scheme in O~(n+T(1/ε))\widetilde{O}(n+T(1/\varepsilon)) time [44]. For 0/1 Knapsack, the best known bound in terms of nn and the largest item weight wmax⁡≤tw_{\max}\le t is O~(n+wmax⁡2)\widetilde{O}(n+w_{\max}^2) [46, 106]. We give the first algorithms running in O~(n+t2−δ)\widetilde{O}(n+t^{2-\delta}) time, and the first approximation scheme running in O~(n+(1/ε)2−δ)\widetilde{O}(n+(1/\varepsilon)^{2-\delta}) time, for a constant δ>0\delta>0. Only the algorithm for Unbounded Knapsack is deterministic.

  • Zero-, Min-, and Max-Weight kk-Clique. For a constant k≥3k\ge3, find kk vertices of an edge-weighted graph whose (k2)\binom{k}{2} edge weights sum to zero, or to the minimum or maximum possible value. Due to the now classical reduction of Nešetřil and Poljak [132]

kk-Clique to triangle detection, our new Exact Triangle algorithm immediately implies the first algorithms running in O(nk−ε)O(n^{k-\varepsilon}) time for an ε>0\varepsilon> 0 (Section 5.3), refuting the weighted kk-Clique hypotheses [7, 125, 36].

  • 3XOR. Given three lists of nn vectors in F2d\mathbb{F}_2^d, where d=O(log⁡n)d = O(\log n), decide whether there are vectors aa, bb, and cc, one from each list, with a⊕b⊕c=0a \oplus b \oplus c = 0, where ⊕\oplus denotes the bitwise XOR. This is a well-studied variant of 3SUM [108, 77]. It is not known to reduce to 3SUM, but the same approach works for it as well, so we give the first truly subquadratic algorithm (Remark 23).

  • Counting versions. Counting the zero-weight triangles of an Exact Triangle instance, or the solutions of a 3SUM instance, is equivalent to the decision problem [68], and for 3SUM the equivalence also holds under deterministic reductions [83]. Similarly, counting the witnesses of each entry of the (min⁡,+)(\min,+)-product is equivalent to computing the (min⁡,+)(\min,+)-product [68]. We give the first truly subcubic algorithms for #Exact Triangle and for counting the witnesses of the (min⁡,+)(\min,+)-product, and the first truly subquadratic algorithm for #3SUM. See [68, 83] for applications.

For problems that are only known to be 3SUM-hard or APSP-hard, such as many of the geometric problems of [92] and the dynamic problems of [135, 26, 116], we get no faster algorithms, since the reductions go the other way. For instance, it is now open whether one can find three collinear points among nn points in the plane in truly subquadratic time.

Relationships to some unaffected conjectures. While we refute various hypotheses, their underlying problems are all similar in nature. We outline how a few other important problems with fine-grained hypotheses differ from 3SUM, Exact Triangle, and APSP, signaling that refuting them might require other techniques.

We begin with CNF-SAT and Orthogonal Vectors (OV). Neither of these problems is known to reduce to All-Edges Sparse Triangle or similar problems. CNF-SAT and Exact Triangle are known to both reduce to certain triangle problems (Matching Triangles and Triangle Collection [28]), but these triangle problems concern the triangles in each of about n3n^3 color triples in dense node-colored graphs, and our techniques do not appear to work there.

Unlike CNF-SAT and Orthogonal Vectors, 3SUM, APSP, and Exact Triangle have long been known to have fast algorithms in certain more powerful models.

3SUM (and more generally kk-SUM) and also Exact Triangle have very efficient linear decision trees. Following a long line of work [130, 79, 15, 93, 97, 98, 53, 118], it is now known [113] that for every k≥3k \ge3, kk-SUM has 2k2k-linear decision trees of depth O(nlog⁡2n)O(n\log^2 n), and Exact Triangle in mm-edge graphs has 6-linear decision trees of depth O(mlog⁡2m)O(m\log^2 m). APSP has decision trees of depth O~(n2.5)\tilde{O}(n^{2.5}) [87]. No such results are known for CNF-SAT and OV.

3SUM, Exact Triangle, and APSP also all have fast nondeterministic and co-nondeterministic algorithms. A nondeterministic algorithm for a decision problem verifies a proof for YES, and a co-nondeterministic algorithm verifies a given proof for NO. Carmosino et al. [50] showed that 3SUM can be solved nondeterministically and co-nondeterministically in O~(n1.5)\tilde{O}(n^{1.5}) time, and Exact Triangle and APSP in O~(n(3+ω)/2)\tilde{O}(n^{(3+\omega)/2}) time. The best known co-nondeterministic algorithms for CNF-SAT and OV are no better than the known deterministic ones, and [50] postulate NSETH, the hypothesis that CNF-SAT requires 2n−o(n)2^{n-o(n)} time even for co-nondeterministic algorithms. They then prove that if NSETH is true, then there cannot be a deterministic (or zero-error randomized) fine-grained reduction from CNF-SAT or OV to 3SUM, APSP, or Exact Triangle. In fact, our algorithm shows that if there were a deterministic fine-grained reduction from CNF-SAT or OV to 3SUM, APSP, or Exact Triangle, then SETH (and not merely NSETH) is false.

Interestingly, the issues posed by co-nondeterminism disappear in the Merlin–Arthur world where randomization is allowed. CNF-SAT [165], 3SUM, and APSP [3] all have vastly improved Merlin–Arthur protocols: the verification time for CNF-SAT (indeed for counting its satisfying assignments) is 2n/2poly⁡(n)2^{n/2}\operatorname{poly}(n), for 3SUM it is O~(n)\widetilde{O}(n), and for APSP it is O~(n2)\widetilde{O}(n^2).

While we obtain a polynomial improvement for 3SUM, we are unable to do so for kk-SUM for k≥4k \ge4. 3SUM reduces to kk-SUM, but no reduction in the other direction is known, and although kk-SUM reduces to exact-weight subgraph problems [21, 23], whose nkn^k baseline we improve (Section 5.3), those reductions can only give kk-SUM algorithms far slower than the n⌈k/2⌉n^{\lceil k/2\rceil} baseline.

The same holds for kk-XOR for k≥4k \ge4 and for the 3SUM-Indexing conjecture [115], [115], [88] . Ultimately, we believe that one good reason for the lack of progress on k≥4k \ge4 is that kk-SUM for k≥4k \ge4 is not known to have fine-grained self-reductions. This has been a major obstacle in designing reductions from kk-SUM and is also a major obstacle in designing algorithms for it. (The same goes for kk-XOR for k≥4k \ge4.)

Combinatorial algorithms. The new algorithms are algebraic and potentially impractical in their current form: the constants hidden in the O(⋅)O(\cdot) are enormous, and the exponents can likely be improved. One might ask whether there are practical or “combinatorial” algorithms for these problems, similar to how one talks about combinatorial Boolean Matrix Multiplication (BMM). The known algorithms for combinatorial BMM, including the Four Russians [9], the n3/polylog⁡nn^3/\operatorname{polylog} n bounds of [34], [54], [169], and the recent n3/2/2Ω((log⁡n)1/7)n^{3/2}/2^{\Omega((\log n)^{1/7})} bound of Abboud, Fischer, Kelley, Lovett, and Meka [11], save only a subpolynomial factor, and no truly subcubic combinatorial algorithm is known. We do not know whether such algorithms exist. Most FGC reductions are combinatorial, so one could refocus the hypotheses to be about combinatorial algorithms [157, 159, 26].

Other parameter regimes. Even without considering combinatorial algorithms, one might also ask whether All-Edges Sparse Triangle can be solved faster in every regime of how large the three parts are. Our technique (due to the identity we use) needs the middle part to have at most n0.12n^{0.12} vertices, whereas prior reductions have focused on different regimes.

For instance, the balanced sparse case of All-Edges Sparse Triangle introduced by Pătraşcu [135] has as input a tripartite graph with roughly equal parts and mm edges overall. Most known fine-grained reductions produce such balanced instances and give conditional lower bounds of m4/3−o(1)m^{4/3-o(1)}.

Another case of interest is where the tripartite graph has two parts of size nn and one part of size n\sqrt{n} and O(n3/2)O(n^{3/2}) edges overall. Solving this version in O(n2−ε)O(n^{2-\varepsilon}) time, even only for triangle detection (and not even for the all-edge version), would have consequences for girth approximation in undirected unweighted graphs [139].

Even faster algorithms. Our focus in this paper is to give the simplest presentation of our new algorithm for thin matrix products, and show how known reductions to All-Edges Sparse Triangle combine with this to give all the polynomial speedups mentioned above. In particular, over the course of this project, with Claude we generated some algorithms whose exponents are slightly better than the ones we present here, but which are significantly more complicated. We intentionally did not include them in this paper. See also the discussion in Section 6 and footnote 10.

Organization. In Section 2 we give the main matrix algorithm. In Section 3 we derive the algorithms for Exact Triangle, 3SUM, and APSP from it, by using or slightly modifying known reductions. In Section 4 we give the data structure version of our matrix algorithm, proving Theorems 1 and 3. In Section 5 we present reductions to achieve the other algorithmic results discussed above. Finally, in Section 6 we discuss future directions.

Quickly computing certain entries of a thin matrix product

We now present our main new algorithm, for computing a subset of the output entries of a thin matrix product. We call such a matrix product thin since the input matrices are highly rectangular. We work in the standard word RAM model with O(log⁡N)O(\log N)-bit words, and thus count operations on O(log⁡N)O(\log N)-bit integers.

Theorem 5. Let D≥4D \ge4 be a power of four and N≥D18N \ge D^{18}. Given as input matrices X∈ZN×DX \in\mathbb{Z}^{N \times D} and Y∈ZD×NY \in\mathbb{Z}^{D \times N}, whose entries are integers of absolute value at most NO(1)N^{O(1)}, as well as a set WW of at most N2/DN^2/\sqrt{D} positions of an N×NN \times N matrix, the entries (XY)[I,J](XY)[I,J], (I,J)∈W(I,J) \in W, can be computed deterministically in time O(N2log⁡2D/D1/18)O(N^2\log^2 D/D^{1/18}).

We call the positions in WW, and the entries of XYXY at them, wanted. We emphasize that XX, YY, and XYXY may be arbitrary dense matrices, and no structure is assumed about the set WW other than its size ∣W∣≤N2/D|W| \le N^2/\sqrt{D}.

We have aimed to present this section in a way that is accessible to nonexperts. Some details in Theorem 5, such as the exponent 18, are chosen to simplify the presentation in this section while still proving a version sufficient to refute the 3SUM and APSP hypotheses. Later, in Section 4, we present a stronger data structure version that has improved parameter trade-offs.

Notably, while the language of tensors and bilinear complexity naturally describes much of our algorithm and the prior work it builds on, we deliberately avoid that language here. This is in part so that a reader unfamiliar with that background may still follow, but also because our arguments here will focus on sparsity and combinatorial properties of our algorithms and algebraic identities that are often intentionally abstracted away in tensor language.

Sections 2.1–2.3 present an exposition of the relevant prior work that we directly build on, especially Strassen [147], Schönhage [143], and Coppersmith [62], and no prior understanding of those works is assumed. The main new idea of this paper is then presented in Section 2.4.

Technique overview. Strassen’s algorithm multiplies matrices by applying a small identity (seven products for multiplying 2×22 \times2 matrices) recursively. In that algorithm, the multiplications happen at the leaves of a recursion tree, and the additions that prepare the leaves (the “encoding phase”) and assemble the result (the “decoding phase”) are comparatively cheap. We do the same with an identity of Schönhage that computes, simultaneously, two small rectangular matrix products. Applied at LL levels of recursion, the identity computes 2L2^L matrix products at once. In order to multiply XX and YY using this, we cut them into smaller blocks, and then simultaneously multiply many pairs of blocks using Schönhage’s identity (Section 2.3).

The new idea (Section 2.4) is to visit only the leaves of the recursion tree that the wanted entries from WW need. A priori, it is not clear that this reduces the number of leaves by much, or that the encoding and decoding phases stay cheap. Both nonetheless turn out to hold, for two reasons.

First, we observe that the additions in the encoding phase that prepare the leaves depend on XX alone or on YY alone (as is the case in all tensor rank decompositions). Since each XX block is multiplied with every YY block, we only need to compute these additions once for each XX block and may share them among many calls to our algorithm (and similarly for YY). One reason for the requirement N≥D18N \ge D^{18} is to ensure that this total cost will be negligible (Section 2.4.1).

Second, we prune the recursion tree, and make a recursive call only when one of its outputs is wanted by WW. This way, the running time is governed by the union of the sets of leaves that the wanted entries need. Most of the analysis goes into bounding this union (Section 2.4.3). We will see that every output entry has a private leaf that no other entry needs, but that all its other leaves are shared by many entries. We will characterize each leaf by how often one needs to pick each of the two matrix products from Schönhage’s identity to get to it in the recursion tree, and find a trade-off: choosing one of the matrix products leads to a relatively small number of leaves, while choosing the other increases how many output entries share each leaf. Balancing the two, we will find that a set of N2D\frac{N^2}{\sqrt{D}} wanted entries only needs about N2D1/18\frac{N^2}{D^{1/18}} leaves in all, and paying O(log⁡2D)O(\log^2 D) operations per leaf gives Theorem 5.

Strassen’s recursive algorithm

We use the recursive approach for multiplying matrices introduced by Strassen [147]. We begin by recalling his algorithm for intuition. The key behind his algorithm is an identity that shows how to multiply two 2×22 \times2 matrices AA and BB using only seven multiplications instead of eight. It forms seven products, each of a linear combination of the entries of AA with a linear combination of the entries of BB, and then obtains each entry of ABAB as a linear combination of those seven products. Recall that, writing A=(aij)A = (a_{ij}) and B=(bij)B = (b_{ij}), the seven products are

S1=(a11+a22)(b11+b22),S5=(a11+a12)b22,S2=(a21+a22)b11,S6=(a21−a11)(b11+b12),S3=a11(b12−b22),S7=(a12−a22)(b21+b22),S4=a22(b21−b11).(1)\begin{aligned} S_1 &= (a_{11} + a_{22})(b_{11} + b_{22}), & S_5 &= (a_{11} + a_{12})b_{22}, \\ S_2 &= (a_{21} + a_{22})b_{11}, & S_6 &= (a_{21} - a_{11})(b_{11} + b_{12}), \\ S_3 &= a_{11}(b_{12} - b_{22}), & S_7 &= (a_{12} - a_{22})(b_{21} + b_{22}), \\ S_4 &= a_{22}(b_{21} - b_{11}). \tag*{(1)} \end{aligned}

and the product is

AB=(S1+S4−S5+S7S3+S5S2+S4S1−S2+S3+S6).AB = \begin{pmatrix} S_1 + S_4 - S_5 + S_7 & S_3 + S_5 \\ S_2 + S_4 & S_1 - S_2 + S_3 + S_6 \end{pmatrix}.

To use this identity to multiply N×NN \times N matrices A,BA,B for larger NN, we interpret AA and BB as 2×22 \times2 block matrices (whose entries are N/2×N/2N/2 \times N/2 matrices), then multiply them as in the identity, i.e., we form seven pairs of linear combinations of the blocks of AA and of BB, recursively multiply each pair, and then assemble the four blocks of ABAB from the seven results. When N=2LN = 2^L, the recursion tree (Figure 2) has LL levels, and 7L7^L leaves, one for each choice of one of the seven products at each level. The multiplications take place at the leaves, meaning there are 7L=Nlog⁡27<N2.817^L = N^{\log_2 7} < N^{2.81} multiplications in total. We call the additions on the way down, which prepare the leaves and are computed from AA alone and from BB alone, the encoding, and those on the way up, which assemble the product, the decoding.

Strassen’s recursion on $N \times N$ matrices

Figure 2. Strassen’s recursion on N×NN \times N matrices, N=2LN = 2^L, showing the first two levels of calls below the root.

To calculate the total cost of Strassen’s algorithm, we also need to count the additions and subtractions at the internal vertices of the recursion tree. At depth kk of the recursion tree, there are 7k7^k internal vertices. Both on the way down and on the way up the tree, the algorithm must compute linear combinations of 2L−k×2L−k2^{L-k} \times2^{L-k} matrices at each of these vertices, which uses O(4L−k)O(4^{L-k}) operations. The total across the whole tree is therefore ∑k=0L−17k4L−k=O(7L)\sum_{k=0}^{L-1} 7^k4^{L-k} = O(7^L), a geometric series dominated by its last term, so the additions only increase the running time by a constant factor. This phenomenon is prevalent in recursive matrix multiplication algorithms, although in the new algorithm we develop in Section 2.4 below, this same argument will no longer apply, and we will need to count the additions and subtractions more carefully.

Schönhage’s identity for an inner product and an outer product

While we will still use Strassen’s recursive approach here, we will replace his identity with another one due to Schönhage [143]. In this subsection we give the notation to introduce this identity and explain its usefulness.

It will be convenient to write such identities as trilinear polynomials.5 As an example, we first show how to write Strassen’s identity from Section 2.1 in this way. Introduce four output variables c11,c12,c21,c22c_{11}, c_{12}, c_{21}, c_{22}, one for each entry of the product ABAB, and multiply each of the seven products S1,…,S7S_1, \ldots, S_7 of Strassen’s identity above by the signed sum of the output variables of the entries where it appeared in the decoding phase. For instance, S1S_1 appears in the formulas for (AB)11(AB)_{11} and (AB)22(AB)_{22}, so it is multiplied by c11+c22c_{11} + c_{22}, and S5S_5 appears in the formula for (AB)11(AB)_{11} with a minus sign and in the formula for (AB)12(AB)_{12}, so it is multiplied by c12−c11c_{12} - c_{11}. Strassen’s identity then reads

S1(c11+c22)+S2(c21−c22)+S3(c12+c22)+S4(c11+c21)+S5(c12−c11)+S6c22+S7c11=∑i,j,k=12aijbjkcik,\begin{aligned} &S_1(c_{11}+c_{22}) + S_2(c_{21}-c_{22}) + S_3(c_{12}+c_{22}) + S_4(c_{11}+c_{21}) \\ &\quad+ S_5(c_{12}-c_{11}) + S_6c_{22} + S_7c_{11} = \sum_{i,j,k=1}^{2} a_{ij}b_{jk}c_{ik}, \end{aligned}

where S1,…,S7S_1, \ldots, S_7 are the products of two linear forms from (1). Now the coefficient of cikc_{ik} on the right-hand side is the entry (AB)ik=ai1b1k+ai2b2k(AB)_{ik} = a_{i1}b_{1k} + a_{i2}b_{2k} that we want, and its coefficient on the left-hand side is the combination of the seven products that computes it, such as $S_1 + S_4 - S_5 + S_7 for c11c_{11}. This polynomial identity thus records the linear combinations and products to be formed, as well as the combinations that assemble the outputs from them.

We will next present Schönhage’s identity in the same way. Recall that the outer product of two vectors (x1,x2,x3)(x_1,x_2,x_3) and (y1,y2,y3)(y_1,y_2,y_3) consists of the nine numbers xiyjx_i y_j, and the inner product of two vectors (p11,p12,p21,p22)(p_{11},p_{12},p_{21},p_{22}) and (q11,q12,q21,q22)(q_{11},q_{12},q_{21},q_{22}) is the single number ∑i,j=12pijqij\sum_{i,j=1}^{2}p_{ij}q_{ij}. These are special cases of matrix products: the outer product is multiplying a 3×13 \times1 matrix times a 1×31 \times3 matrix, and the inner product is multiplying a 1×41 \times4 matrix times a 4×14 \times1 matrix. (We index the pp and qq variables with {1,2}×{1,2}\{1,2\} \times\{1,2\} rather than {1,2,3,4}\{1,2,3,4\} to set up nicer notation for p^\hat{p} and q^\hat{q} in Lemma 6 below.)

Separately computing the inner product and outer product would use 9+4=139+4=13 multiplications. However, Schönhage [143], §6, eq. (6.3), with k=n=3k=n=3 showed that they can be computed (along with some error terms that will turn out to be harmless) using only 10 multiplications. The fact that this is possible even when the inner and outer products are on disjoint sets of variables is surprising, and refuted a border rank version of the “direct sum conjecture for tensor rank” [148].

We call x1,x2,x3,p11,p12,p21,p22x_1,x_2,x_3,p_{11},p_{12},p_{21},p_{22} the seven left variables and y1,y2,y3,q11,q12,q21,q22y_1,y_2,y_3,q_{11},q_{12},q_{21},q_{22} the seven right variables. We will also use ten output variables zijz_{ij} (for 1≤i,j≤31 \leq i,j \leq3) and z0z_0, one for each of the ten quantities we aim to compute, namely, the coefficients of the output variables in the polynomial

G:=∑i,j=13xiyjzij+(∑i,j=12pijqij)z0.G := \sum_{i,j=1}^{3}x_i y_j z_{ij}+\left(\sum_{i,j=1}^{2}p_{ij}q_{ij}\right)z_0.

As a notational helper to state the identity, we introduce two 3×33 \times3 matrices p^\hat{p} and q^\hat{q} of linear forms. These are formed by starting with the 2×22 \times2 matrices of the pp’s and of the qq’s, then extending them to 3×33 \times3 matrices so that every column of p^\hat{p} and every row of q^\hat{q} sums to zero:

p^=(p11p120p21p220−p11−p21−p12−p220),q^=(q11q12−q11−q12q21q22−q21−q22000).\hat{p}= \begin{pmatrix} p_{11} & p_{12} & 0\\ p_{21} & p_{22} & 0\\ -p_{11}-p_{21} & -p_{12}-p_{22} & 0 \end{pmatrix}, \qquad \hat{q}= \begin{pmatrix} q_{11} & q_{12} & -q_{11}-q_{12}\\ q_{21} & q_{22} & -q_{21}-q_{22}\\ 0 & 0 & 0 \end{pmatrix}.

Notice that ∑i,j=13p^ijq^ij=∑i,j=12pijqij\sum_{i,j=1}^{3}\hat{p}_{ij}\hat{q}_{ij}=\sum_{i,j=1}^{2}p_{ij}q_{ij} is the desired inner product.

Schönhage’s identity has ten terms, which we name PijP_{ij} (for 1≤i,j≤31 \leq i,j \leq3, corresponding to the entries of p^\hat{p} and q^\hat{q}) and P0P_0. Each term λ\lambda is the product of a linear form φλ\varphi_\lambda in the left variables, a linear form ψλ\psi_\lambda in the right variables, and a linear form χλ\chi_\lambda in the output variables. These linear forms are as follows:

φPij=xi+p^ij,ψPij=yj+q^ij,χPij=zij+z0,\varphi_{P_{ij}}=x_i+\hat{p}_{ij},\qquad \psi_{P_{ij}}=y_j+\hat{q}_{ij},\qquad \chi_{P_{ij}}=z_{ij}+z_0,
φP0=−(x1+x2+x3),ψP0=y1+y2+y3,χP0=z0.\varphi_{P_0}=-(x_1+x_2+x_3),\qquad \psi_{P_0}=y_1+y_2+y_3,\qquad \chi_{P_0}=z_0.

Lemma 6. Summing over the ten terms,

∑λφλψλχλ=G+E,whereE:=∑i,j=13(xiq^ij+p^ijyj+p^ijq^ij)zij.\sum_{\lambda}\varphi_\lambda\psi_\lambda\chi_\lambda =G+E, \qquad \text{where}\qquad E:=\sum_{i,j=1}^{3}(x_i\hat{q}_{ij}+\hat{p}_{ij}y_j+\hat{p}_{ij}\hat{q}_{ij})z_{ij}.

Proof. We compute the coefficient of each output variable on the left-hand side. The coefficient of zijz_{ij} comes only from the term PijP_{ij}, and it is φPijψPij=(xi+p^ij)(yj+q^ij)=xiyj+(xiq^ij+p^ijyj+p^ijq^ij)\varphi_{P_{ij}}\psi_{P_{ij}}=(x_i+\hat{p}_{ij})(y_j+\hat{q}_{ij})=x_i y_j+(x_i\hat{q}_{ij}+\hat{p}_{ij}y_j+\hat{p}_{ij}\hat{q}_{ij}). The coefficient of z0z_0 is ∑i,j=13(xi+p^ij)(yj+q^ij)−(x1+x2+x3)(y1+y2+y3)\sum_{i,j=1}^{3}(x_i+\hat{p}_{ij})(y_j+\hat{q}_{ij})-(x_1+x_2+x_3)(y_1+y_2+y_3). In this expression, the products xiyix_i y_i cancel, and the cross terms sum to ∑i=13xi∑j=13q^ij+∑j=13yj∑i=13p^ij=0\sum_{i=1}^{3} x_i \sum_{j=1}^{3} \hat{q}_{ij} + \sum_{j=1}^{3} y_j \sum_{i=1}^{3} \hat{p}_{ij} = 0 since the rows of q^\hat{q} and the columns of p^\hat{p} sum to zero. What remains is ∑i,j=13p^ijq^ij=∑i,j=12pijqij\sum_{i,j=1}^{3} \hat{p}_{ij}\hat{q}_{ij} = \sum_{i,j=1}^{2} p_{ij}q_{ij}, as desired.

Lemma 6 is the key identity we will use. It computes our desired GG plus an error polynomial EE. Before moving on to our algorithm, we make two structural observations about the identity that we will use below.

Our first observation will be used to handle the error EE. We call the variables of the inner product, pp, qq, and z0z_0, inner, and those of the outer product, xx, yy, and zijz_{ij}, outer. Notice that every monomial of GG consists only of inner variables (pijqijz0p_{ij}q_{ij}z_0) or only of outer variables (xiyjzijx_i y_j z_{ij}). Meanwhile, every monomial of EE has an outer output variable together with an inner left or right variable. We will use this observation to show that EE is harmless in our algorithm in Lemma 9 below.6

Our second observation concerns the pattern of output variables in our identity, and will be used to take advantage of the sparsity of the set WW of wanted entries in our final algorithm. We say that a term λ\lambda contributes to an output variable zz if zz appears in χλ\chi_\lambda. We see that every term contributes to z0z_0, and only PijP_{ij} contributes to zijz_{ij}. (The decoding layer of Figure 3 below will also illustrate this.) The fact that only one term contributes to each zijz_{ij} will eventually help us to reduce how many products we need to compute when we only need certain output entries. Since the χλ\chi_\lambda forms are all sums of output variables (without any minus signs or other coefficients), it follows that for each output variable zz, its coefficient on the left-hand side of the identity is ∑λφλψλ\sum_\lambda\varphi_\lambda\psi_\lambda, where the sum is over the terms λ\lambda contributing to zz.

One level of the recursion, showing the encoding, recursive multiplication, and decoding steps

Figure 3. One level of the recursion, the analog of one step of Strassen’s algorithm. In step (2), each of the ten terms λ\lambda combines at most three of the seven slices asa_s into Aλ=∑sφλ(s)asA_\lambda= \sum_s \varphi_\lambda(s) a_s (solid lines: ++, dashed: −-). For instance, AP31=ax3−ap11−ap21A_{P31}=a_{x3}-a_{p11}-a_{p21} and AP0=−ax1−ax2−ax3A_{P0}=-a_{x1}-a_{x2}-a_{x3}. The same is done to bb with the forms ψλ\psi_\lambda. In step (3), the ten pairs are multiplied by recursive calls, Cλ=Full⁡(Aλ,Bλ)C_\lambda=\operatorname{Full}(A_\lambda,B_\lambda). In step (4), the slice czijc_{zij} of the output is CPijC_{Pij}, and the slice cz0c_{z0} is the sum of all ten, because every term contributes to z0z_0.

Rectangular matrix multiplication using Schönhage's identity

In this subsection, we apply Schönhage’s identity recursively to derive an algorithm for rectangular matrix multiplication (computing all the output entries, not just a small subset). Our approach is similar to Coppersmith’s algorithm [62], although we will make modifications that worsen some parameters of the algorithm in exchange for preserving some of the combinatorial and structural properties of Schönhage’s identity that we will use below.

The recursion

Schönhage’s identity computes two matrix products, the outer product and the inner product, on disjoint sets of variables. We will see that applying it to LL levels of recursion therefore involves 2L2^L matrix products, one for each way of choosing the outer or the inner product at each level. A choice with the inner product at mm of the levels, and the outer product at the other L−mL-m levels, corresponds to the product of a 3L×4m3^L \times4^m matrix and a 4m×3L−m4^m \times3^{L-m} matrix. (We will focus on a setting of mm much smaller than LL so that these are thin matrix products.) In this subsection, we set up notation for the arrays that the recursion works on and state the recursion, then in Section 2.3.2 we will describe precisely what it computes.

The inputs and outputs of our algorithm will be arrays that contain the entries of many different matrices concatenated together. (Later in Section 2.3.4 we will use this algorithm as a subroutine to multiply a single pair of matrices.) We will index the entries of these arrays by strings of LL variables of Schönhage’s identity. Whether each variable is an inner or outer variable will tell us which of the 2L2^L matrix products the array entry corresponds to, and the specific variables will tell us which entry of the matrix it corresponds to.

A left string of length LL is a string u=u1u2⋯uLu = u_1u_2\cdots u_L of LL left variables, and we call uℓu_\ell its variable at level ℓ\ell. An array aa on the left strings of length LL assigns an integer a[u]a[u] to each uu that is a left string of length LL. The array aa has 7L7^L entries in total (since there are 7 left variables). We define right strings, output strings, and arrays on them in the same way. For instance, an array on the output strings of length LL has 10L10^L entries (since there are 10 output variables).

For a term λ\lambda and a left variable ss, let φλ(s)∈{0,±1}\varphi_\lambda(s) \in\{0,\pm1\} denote the coefficient of ss in φλ\varphi_\lambda, and define ψλ(t)\psi_\lambda(t) similarly for right variables tt. Recall from Schönhage’s identity that, for each term λ\lambda, at most three of the seven values φλ(s)\varphi_\lambda(s) are nonzero since each φλ\varphi_\lambda has at most three monomials, and similarly for the seven values ψλ(t)\psi_\lambda(t).

Just as Strassen’s algorithm cuts matrices into blocks, we cut an array aa on strings of length L≥1L \ge1 into slices according to the variable at level 1: the slice of aa at a left variable ss is the array asa_s on the strings of length L−1L-1 given by as[u′]:=a[su′]a_s[u'] := a[su']. Thus, aa consists of its seven slices, just as a block matrix consists of its blocks. We similarly define the slices btb_t of an array bb on right strings, and czc_z of an array cc on output strings.

The recursion Full(a,b)(a,b), for arrays a,ba,b on the left and right strings of length LL, returns an array on the output strings of length LL:

(1) If L=0L = 0, return the number abab.

(2) For each term λ\lambda of Schönhage’s identity, form Aλ:=∑sφλ(s) asA_\lambda:= \sum_s \varphi_\lambda(s)\,a_s and Bλ:=∑tψλ(t) btB_\lambda:= \sum_t \psi_\lambda(t)\,b_t.

(3) For each term λ\lambda, recursively compute Cλ:=Full⁡(Aλ,Bλ)C_\lambda:= \operatorname{Full}(A_\lambda,B_\lambda).

(4) Return the array cc whose slices are czij:=Cρijc_{z_{ij}} := C_{\rho_{ij}} and cz0:=∑λCλc_{z_0} := \sum_\lambda C_\lambda.

For L=1L = 1, Full is one application of Schönhage’s identity: step (2) evaluates the linear forms φλ\varphi_\lambda and ψλ\psi_\lambda at the seven numbers a[s]a[s] and the seven numbers b[t]b[t], step (3) multiplies the two values for each λ\lambda, and step (4) sums the products into the ten outputs as the forms χλ\chi_\lambda prescribe. In the terms of Section 2.1, step (2) is the encoding and step (4) the decoding.

The calls of Full form a recursion tree. We refer to the call reached by choosing the terms τ1,…,τk\tau_1,\ldots,\tau_k at levels 1,…,k1,\ldots,k as the vertex τ1⋯τk\tau_1\cdots\tau_k, a string of kk terms. It is at depth kk, and its input arrays are on strings of length L−kL-k. The root is the vertex with k=0k = 0, and the leaves, the vertices τ=τ1⋯τL\tau= \tau_1\cdots\tau_L at depth LL, are the 10L10^L multiplications performed in step (1).

Let us now count the operations performed by this algorithm. At depth kk there are 10k10^k vertices (since Schönhage’s identity has 10 terms), each with two input arrays of 7L−k7^{L-k} entries and an output array of 10L−k10^{L-k} entries. Step (2) takes O(7L−k)O(7^{L-k}) operations at a vertex, and step (4) takes O(10L−k)O(10^{L-k}) operations. Hence, Full uses ∑k=0L10k⋅O(7L−k+10L−k)=O(L⋅10L)\sum_{k=0}^{L} 10^k \cdot O(7^{L-k}+10^{L-k}) = O(L\cdot10^L) operations in total, which is not much more than the 10L10^L multiplications. Of this, the encodings, step (2), account for only ∑k=0L10k⋅O(7L−k)=O(10L)\sum_{k=0}^{L} 10^k \cdot O(7^{L-k}) = O(10^L) operations, and the decodings, step (4), for the rest.

Unraveling the recursion computation

In this subsection, we carefully work out which two numbers are multiplied at the leaf τ\tau, and what is returned by Full⁡(a,b)\operatorname{Full}(a,b). For a leaf τ\tau let

Φτ(a):=∑ua[u]∏ℓ=1Lφτℓ(uℓ),Ψτ(b):=∑vb[v]∏ℓ=1Lψτℓ(vℓ),\Phi_\tau(a) := \sum_u a[u] \prod_{\ell=1}^{L} \varphi_{\tau_\ell}(u_\ell), \qquad\Psi_\tau(b) := \sum_v b[v] \prod_{\ell=1}^{L} \psi_{\tau_\ell}(v_\ell),

where the sums are over all left strings uu and all right strings vv of length LL. We extend the relation “contributes to” of Section 2.2 from terms to vertices: a vertex τ1⋯τk\tau_1\cdots\tau_k contributes to an output string ww if τℓ\tau_\ell contributes to wℓw_\ell at every level ℓ≤k\ell\le k. Thus the leaf τ\tau contributes to ww if τℓ=Pij\tau_\ell=P_{ij} at every level ℓ\ell where wℓ=zijw_\ell=z_{ij} (but τℓ\tau_\ell may be arbitrary at the levels where wℓ=z0w_\ell=z_0). Let Mult⁡(a,b)\operatorname{Mult}(a,b) be the array on the output strings of length LL given by

Mult⁡(a,b)[w]:=∑τ contributing to wΦτ(a)Ψτ(b).(2)\operatorname{Mult}(a,b)[w] := \sum_{\tau\ \text{contributing to}\ w} \Phi_\tau(a)\Psi_\tau(b). \tag*{(2)}

Lemma 7. At the leaf τ\tau, Full⁡(a,b)\operatorname{Full}(a,b) multiplies Φτ(a)\Phi_\tau(a) by Ψτ(b)\Psi_\tau(b), and it returns Mult⁡(a,b)\operatorname{Mult}(a,b).

Proof. By induction on LL (see Figure 3). For L=0L=0, the only leaf is the empty string τ\tau, and Φτ(a)=a\Phi_\tau(a)=a and Ψτ(b)=b\Psi_\tau(b)=b, as the products over the levels are empty, so step (1) multiplies them and returns ab=Mult⁡(a,b)ab=\operatorname{Mult}(a,b). For L≥1L\ge1, step (2) is the encoding: since as[u′]=a[su′]a_s[u']=a[su'], for every leaf λτ′\lambda\tau' we have

Φλτ′(a)=∑sφλ(s)Φτ′(as)=Φτ′(Aλ),\Phi_{\lambda\tau'}(a)=\sum_s \varphi_\lambda(s)\Phi_{\tau'}(a_s)=\Phi_{\tau'}(A_\lambda),

and similarly Ψλτ′(b)=Ψτ′(Bλ)\Psi_{\lambda\tau'}(b)=\Psi_{\tau'}(B_\lambda). Thus, by induction, the leaf λτ′\lambda\tau' multiplies Φλτ′(a)\Phi_{\lambda\tau'}(a) by Ψλτ′(b)\Psi_{\lambda\tau'}(b), and Cλ[w′]=∑τ′Φλτ′(a)Ψλτ′(b)C_\lambda[w'] = \sum_{\tau'} \Phi_{\lambda\tau'}(a)\Psi_{\lambda\tau'}(b), summed over the τ′\tau' contributing to w′w'. Step (4) is the decoding: the leaves contributing to zw′zw' are the λτ′\lambda\tau' with λ\lambda contributing to zz and τ′\tau' contributing to w′w', so c[zw′]=∑λ contributing to zCλ[w′]c[zw'] = \sum_{\lambda\text{ contributing to }z} C_\lambda[w'] agrees with (2).

Since one application of the identity computes the coefficients of G+EG+E, we expect that LL recursive applications should compute products of LL such coefficients. For a left variable ss, a right variable tt, and an output variable zz, let

γ(s,t,z):=∑λ contributing to zφλ(s)ψλ(t),(3)\gamma(s,t,z) := \sum_{\lambda\text{ contributing to }z} \varphi_\lambda(s)\psi_\lambda(t), \tag*{(3)}

the coefficient of the monomial stzstz on the left-hand side of the identity. By Lemma 6, it is also the coefficient of stzstz in G+EG+E, and we know that γ(s,t,z)∈{0,±1}\gamma(s,t,z)\in\{0,\pm1\}.

Lemma 8. For all arrays a,ba,b and every output string ww,

Mult⁡(a,b)[w]=∑u,vγ(u1,v1,w1)γ(u2,v2,w2)⋯γ(uL,vL,wL)a[u]b[v],\operatorname{Mult}(a,b)[w] = \sum_{u,v} \gamma(u_1,v_1,w_1)\gamma(u_2,v_2,w_2)\cdots\gamma(u_L,v_L,w_L)a[u]b[v],

the sum over all left strings uu and right strings vv.

Proof. By the definitions of Φτ\Phi_\tau and Ψτ\Psi_\tau, the coefficient of a[u]b[v]a[u]b[v] in (2) is ∑τ∏ℓ=1Lφτℓ(uℓ)ψτℓ(vℓ)\sum_\tau\prod_{\ell=1}^{L}\varphi_{\tau_\ell}(u_\ell)\psi_{\tau_\ell}(v_\ell), summed over the leaves τ\tau contributing to ww. These are the leaves whose term at level ℓ\ell contributes to wℓw_\ell, independently for each ℓ\ell, so this sum of products is the product of sums

∏ℓ=1L∑τℓ contributing to wℓφτℓ(uℓ)ψτℓ(vℓ)=∏ℓ=1Lγ(uℓ,vℓ,wℓ)\prod_{\ell=1}^{L}\sum_{\tau_\ell\text{ contributing to }w_\ell}\varphi_{\tau_\ell}(u_\ell)\psi_{\tau_\ell}(v_\ell)=\prod_{\ell=1}^{L}\gamma(u_\ell,v_\ell,w_\ell)

by (3).

We will use both descriptions of Mult⁡\operatorname{Mult}: Lemma 8 to read matrix products off it (Section 2.3.3), and the sum over leaves in (2) to skip the leaves that do not contribute to the wanted entries (Section 2.4).

Batch computation of multiple matrix products

We now explain the claim from the beginning of Section 2.3.1, that our recursive algorithm is simultaneously computing many matrix products. We will also show that the error EE is harmless, using the fact that each of its monomials uses an outer output variable, but at least one inner input variable.

The inner set of a left string is the set of levels at which it has a pp (as opposed to an xx). It will tell us which of the 2L2^L matrix products the string belongs to. Similarly, the inner set of a right string is the set of levels at which it has a qq (as opposed to a yy), and the inner set of an output string is the set of levels at which it has z0z_0 (as opposed to a zijz_{ij}). The inner part of a string is the string of its variables at the levels of its inner set, in the order of the levels, and its outer part is the string of its variables at the other levels. A string is determined by its inner set, its outer part, and its inner part.

Fix m≥1m\ge1, and let N0:=3L−mN_0:=3^{L-m} and D:=4mD:=4^m. Of the 2L2^L matrix products, one for each set Q⊆{1,…,L}Q\subseteq\{1,\ldots,L\} of levels at which the inner product is chosen, we will use only the (Lm)\binom{L}{m} products with ∣Q∣=m|Q| = m, and set the inputs of the others to zero. As we now make precise, the product for such a QQ multiplies an N0×DN_0 \times D matrix by a D×N0D \times N_0 matrix: the L−mL-m outer levels, with three left and three right outer variables each, give its N0=3L−mN_0 = 3^{L-m} rows and N0N_0 columns, and the mm inner levels, with four left and four right inner variables each, give the D=4mD = 4^m terms of the sum in each of its entries. (To prove Theorem 5, we will ultimately set L=19mL = 19m, a choice we will explain in Section 2.4.3 below.)

We will index the rows and columns of the matrices in these products by strings of variables. For an N0×DN_0 \times D matrix, we index its N0N_0 rows by the N0N_0 strings of L−mL-m outer left variables, and its DD columns by the DD strings of mm inner left variables. Similarly, for a D×N0D \times N_0 matrix, we index its DD rows by the DD strings of mm inner right variables, and its N0N_0 columns by the strings of L−mL-m outer right variables. To multiply an N0×DN_0 \times D matrix AA by a D×N0D \times N_0 matrix BB, we match the column of AA indexed by the string π=pi1j1pi2j2⋯pimjm\pi= p_{i_1j_1}p_{i_2j_2}\cdots p_{i_mj_m} with the row of BB indexed by the string π′=qi1j1qi2j2⋯qimjm\pi' = q_{i_1j_1}q_{i_2j_2}\cdots q_{i_mj_m} with the same indices, so that the entry of ABAB in row rr and column cc is

(AB)[r,c]:=∑πA[r,π]B[π′,c],(AB)[r,c] := \sum_{\pi} A[r,\pi] B[\pi',c],

where the sum is over all the DD strings π\pi of mm inner left variables. Thus, the rows of the product are indexed by the strings of outer left variables and its columns by the strings of outer right variables.

Let QQ be a subset of {1,…,L}\{1,\ldots,L\} of size mm. As above, the outer part of a left string uu with inner set QQ is a row of an N0×DN_0 \times D matrix and its inner part is a column, so the left strings with inner set QQ index the entries of such a matrix. For an N0×DN_0 \times D matrix XQX_Q we write XQ[u]X_Q[u] for its entry at the row and the column of uu. Similarly, the right strings vv with inner set QQ index the entries of a D×N0D \times N_0 matrix YQY_Q, the row given by the inner part of vv and the column by the outer part, and we write YQ[v]Y_Q[v] for this entry. Finally, the output strings with inner set QQ index the entries of the product XQYQX_QY_Q: if the variables of ww at the levels outside QQ are zi1j1,…,ziL−mjL−mz_{i_1j_1},\ldots,z_{i_{L-m}j_{L-m}}, in the order of the levels, then the row of ww is the string xi1⋯xiL−mx_{i_1}\cdots x_{i_{L-m}} and its column is the string yj1⋯yjL−my_{j_1}\cdots y_{j_{L-m}}, and we write (XQYQ)[w](X_QY_Q)[w] for the entry there (Figure 4).

From strings to matrix entries, for $L=6$ and $m=2$

Figure 4. From strings to matrix entries, for L=6L = 6 and m=2m = 2. A string whose inner set is Q={2,5}Q = \{2,5\} has an inner variable (pp, qq, or z0z_0) at the two levels of QQ and an outer one at the other four. One run of Full computes all (62)=15\binom{6}{2} = 15 products XQYQX_QY_Q, one for each subset QQ of size 2.

We can now check that Full, which returns Mult(a,b)(a,b), really computes these products. For each of the K:=(Lm)K := \binom{L}{m} subsets QQ of {1,…,L}\{1,\ldots,L\} of size mm, let XQX_Q be any N0×DN_0 \times D matrix and YQY_Q be any D×N0D \times N_0 matrix. Let the input arrays aa and bb be these matrices laid side by side, by setting

a[u]:=XQ[u],b[v]:=YQ[v]a[u] := X_Q[u], \qquad b[v] := Y_Q[v]

for all the left strings uu and the right strings vv whose inner set QQ has exactly mm elements, and a[u]:=0a[u] := 0, b[v]:=0b[v] := 0 at every other string.

Lemma 9. For the input arrays a,ba,b above and every output string ww whose inner set QQ has exactly mm elements,

Mult⁡(a,b)[w]=(XQYQ)[w].(4)\operatorname{Mult}(a,b)[w] = (X_QY_Q)[w]. \tag*{(4)}

Proof. By Lemma 8, Mult⁡(a,b)[w]\operatorname{Mult}(a,b)[w] is the sum, over all left strings uu and right strings vv, of γ(u1,v1,w1)⋯γ(uL,vL,wL)a[u]b[v]\gamma(u_1,v_1,w_1)\cdots\gamma(u_L,v_L,w_L)a[u]b[v], where γ(s,t,z)\gamma(s,t,z) is the coefficient of stzstz in G+EG+E. We determine which summands can be nonzero. First, a[u]b[v]≠0a[u]b[v]\ne0 requires the inner sets of uu and vv to have exactly mm elements. Next, at a level ℓ∈Q\ell\in Q we have wℓ=z0w_\ell=z_0, and the only monomials of G+EG+E that contain z0z_0 are pijqijz0p_{ij}q_{ij}z_0, with coefficient 11. So γ(uℓ,vℓ)=1\gamma(u_\ell,v_\ell)=1 for some i,ji,j. Thus uu and vv have an inner variable at every level of QQ, and their inner sets are therefore exactly QQ. Finally, at a level ℓ∉Q\ell\notin Q we have wℓ=zijw_\ell=z_{ij} for some i,ji,j, and uℓu_\ell and vℓv_\ell are outer. The left string uu: x1x_1 p11p_{11} x2x_2 x3x_3 p22p_{22} x1x_1

outer part x1x2x3x1x_1x_2x_3x_1: the row of uu in XQX_Q, inner part p11p22p_{11}p_{22}: its column, so uu indexes an entry of XQX_Q

right string vv: y3y_3 q11q_{11} y1y_1 y3y_3 q22q_{22} y2y_2

inner part q11q22q_{11}q_{22}: the row of vv in YQY_Q, outer part y3y1y3y2y_3y_1y_3y_2: its column, so vv indexes an entry of YQY_Q

output string ww: z13z_{13} z0z_0 z21z_{21} z33z_{33} z0z_0 z12z_{12}

row x1x2x3x1x_1x_2x_3x_1 and column y3y1y3y2y_3y_1y_3y_2, read off from its zijz_{ij}, so ww indexes an entry of XQYQX_QY_Q

levels ℓ=1,…,6\ell= 1,\ldots,6 (shaded: the inner set Q={2,5}Q = \{2,5\})

only monomial of G+EG + E that contains zijz_{ij} and no inner variable is xiyjzijx_iy_jz_{ij}, with coefficient 1, so (uℓ,vℓ)=(xi,yj)(u_\ell,v_\ell) = (x_i,y_j).

Hence, the summands that remain are those where uu has inner set QQ, the row rr of ww as its outer part, and some inner part π\pi, and where vv has inner set QQ, the column cc of ww as its outer part, and the inner part π′\pi' with the same indices as π\pi. There is one such summand for each of the DD strings π\pi, and its coefficient is 1. Their sum is ∑πXQ[r,π]YQ[π′,c]=(XQYQ)[w]\sum_\pi X_Q[r,\pi]Y_Q[\pi',c] = (X_QY_Q)[w].

To summarize: one run of Full, which uses 10L10^L multiplications, computes all KK of the products XQYQX_QY_Q. The KK products can be completely independent: we are free to plug in any choices for XQX_Q and YQY_Q and the algorithm will give us all KK products. In the next subsection we will end up plugging in the same matrix for different copies XQX_Q (and YQY_Q).

Tiling the N×D×NN \times D \times N product by products of shape N0×D×N0N_0 \times D \times N_0

We now use our algorithm, which performs KK simultaneous multiplications of an N0×DN_0 \times D matrix with a D×N0D \times N_0 matrix, in order to do a single multiplication of an N×DN \times D matrix XX with a D×ND \times N matrix YY. For our parameter setting, N≫N0N \gg N_0, so we can do this with a simple tiling approach. Tiling enlarges only the outer dimensions, so it handles a smaller inner dimension than Coppersmith’s algorithm from the same identity (at best D≈N0.1204D \approx N^{0.1204} rather than N0.1402N^{0.1402} [62]). We use it because each entry of XYXY is then a single output of a single run of Full, rather than a linear combination of many outputs as in Coppersmith’s algorithm. We will take advantage of this in our algorithm below (Section 2.4).

We cut XX into row blocks of N0N_0 consecutive rows and YY into column blocks of N0N_0 consecutive columns. Thus, XYXY consists of all the products of a row block by a column block, each an N0×DN_0 \times D by D×N0D \times N_0 product, and one run of Full computes KK such products at once. We use each run on a K0×K0K_0 \times K_0 grid of block products, where K0:=⌊K⌋K_0 := \lfloor\sqrt{K}\rfloor: we group the row blocks into bands of K0K_0 consecutive blocks, and similarly the column blocks, and we call a row band together with a column band a tile (Figure 5). Each tile is one run of Full. We fix K02≤KK_0^2 \le K distinct subsets of {1,…,L}\{1,\ldots,L\} of size mm, one for each block product of the grid, the same in every tile. In a tile, let XQX_Q and YQY_Q be the row block and the column block of the block product with subset QQ, and let XQ=YQ=0X_Q = Y_Q = 0 for the other subsets QQ. Then one run of Full computes all K02K_0^2 block products of the tile (Lemma 9), and running it on every tile computes all of XYXY.

Tiling of row and column blocks into tiles

Figure 5. The tiling, drawn for N=6N0N = 6N_0 and K0=3K_0 = 3. A block product, a row block of XX times a column block of YY, holds N02N_0^2 entries of XYXY. A tile, a band of K0K_0 row blocks together with a band of K0K_0 column blocks, is one run of Full, which computes its K02≤KK_0^2 \le K block products, each with its own subset QQ (Q1,…,Q9Q_1,\ldots,Q_9 shown in the highlighted tile).

We pair the blocks in a grid like this, rather than arbitrarily, so that the left input array of a tile depends only on its row band and the right one only on its column band. This will let us share their encodings among tiles in Section 2.4.1 below. (To make the bands fit, we first pad NN to a multiple of K0N0K_0N_0 with zero rows of XX and zero columns of YY, which at most doubles NN since N≥K0N0N \ge K_0N_0, as we will see in Section 2.4.4.)

Before moving on, let us compute the number of operations performed by this algorithm. Let M:=KN02M := KN_0^2 denote the number of output entries among all KK products of a tile. Since K0≥K/2K_0 \ge\sqrt{K}/2, there are (N/K0N0)2≤4N2/M(N/K_0N_0)^2 \le4N^2/M tiles. Thus, recalling the operation count of a single tile from Section 2.3.1, the whole product takes O(N2ML⋅10L)O\left(\frac{N^2}{M}L \cdot10^L\right) operations, that is, O(L⋅10L/M)O(L \cdot10^L/M) per entry of XYXY. One can calculate that this is N2poly⁡(L)N^2\operatorname{poly}(L) in total when L=10mL = 10m, but about N2D0.2N^{2}D^{0.2} for our choice L=19mL = 19m. We nonetheless choose L=19mL = 19m, and in Section 2.4.3 below we explain why this is needed for our sparsity arguments.

Extracting only the desired entries

In this subsection, we present the main new idea of this paper. Our goal is now to compute only the wanted entries of XYXY, i.e., those at the positions in WW, which is a set of size ∣W∣≤N2/D|W| \le N^2/\sqrt{D}. We will modify the algorithm of Section 2.3 in two ways. First, we will observe that the encoding (step (2)) of each input array depends only on that array and not the other, and that each input array is shared by many tiles (defined in Section 2.3.4), so we can compute each encoding only once and share it among those tiles (Section 2.4.1). Second, we will prune the recursion tree for the multiplication and decoding steps (steps (3) and (4)), by skipping a recursive call whenever none of its outputs leads to an output entry from WW (Section 2.4.2). Finally we will analyze the algorithm by counting the leaves that are reached (Section 2.4.3), and adding up the costs (Section 2.4.4).

Sharing the encoding

The two numbers Φτ(a)\Phi_{\tau}(a) and Ψτ(b)\Psi_{\tau}(b) multiplied at a leaf τ\tau depend on aa alone and on bb alone, respectively, so we will compute them once per input array rather than once per tile. The encoding of aa is the array of the 10L10^L numbers Φτ(a)\Phi_{\tau}(a), indexed by the leaves τ\tau. This is the array that the encoding steps of Full compute from aa. To compute it, we run Full with bb left out and without step (4): by Lemma 7, the left number at the leaf τ\tau is Φτ(a)\Phi_{\tau}(a), and the leaf stores it. This takes O(10L)O(10^L) operations, the cost of the encoding in Section 2.3.1. The encoding of bb, the array of the numbers Ψτ(b)\Psi_{\tau}(b), is computed in the same way.

We compute the encodings of the input arrays of all row bands and all column bands (defined in Section 2.3.4), 2N/K0N02N/K_0N_0 arrays of 10L10^L numbers in all, and every tile reads its two encodings from these. It is important that these encodings are shared, since an encoding has 10L=(9+1)L10^L=(9+1)^L numbers, more than the M=(Lm)9L−mM=\binom{L}{m}9^{L-m} entries of the KK products of a tile, so encoding every tile separately would cost more than one operation per entry of the entire matrix product (even before focusing on WW). Since each encoding is computed only once per band, the 2N/K0N02N/K_0N_0 encodings are used by all (N/K0N0)2(N/K_0N_0)^2 tiles. Each one costs O(10L)O(10^L), independently of WW. The assumption N≥D18N \ge D^{18} makes this cost negligible (as we will compute in Section 2.4.4).

Skipping the calls that are not needed

Once the encodings are computed as above, we can skip that phase of Full. Instead, each leaf reads its two numbers from the encodings, and each call only performs the decoding of step (4). We now modify Full so that each call computes only the outputs that are wanted from it, i.e., the outputs that lead to entries in WW. We will implement this by passing to each call the set SS of the outputs that are wanted from it.

More precisely, the outputs of the vertex τ1⋯τk\tau_1\cdots\tau_k (defined in Section 2.3.1) are indexed by output strings of length L−kL-k, and SS is a set of such strings. If UU is the set passed to the root (in the final algorithm, this will be the set of output strings of the wanted entries of the tile), we will see in Lemma 10 that SS will consist of the suffixes wk+1⋯wLw_{k+1}\cdots w_L of the strings w∈Uw \in U to which the vertex contributes (as defined in Section 2.3.2). Sets of output strings have slices like arrays (see Section 2.3.1): for a set SS of output strings and an output variable zz, the slice SzS_z is the set of output strings w′w' with w′z′∈Sw'z' \in S, and an array on SS assigns an integer to each string of SS.

Our modified version of the recursive algorithm Full, which we call Pruned, is as follows. Pruned⁡τ1⋯τk(S)\operatorname{Pruned}_{\tau_1\cdots\tau_k}(S), for a set SS of output strings of length L−kL-k, returns the array returned by the vertex τ1⋯τk\tau_1\cdots\tau_k of Full⁡\operatorname{Full}, restricted to the strings in SS:

  1. If k=Lk=L, then look up Φτ(a)\Phi_\tau(a) and Ψτ(b)\Psi_\tau(b) from the precomputed encodings (Section 2.4.1) and return Φτ(a)Ψτ(b)\Phi_\tau(a)\Psi_\tau(b) for the leaf τ=τ1⋯τL\tau=\tau_1\cdots\tau_L.

  1. For each term λ\lambda of Schönhage’s identity, let SλS_\lambda be the union of the slices SzS_z over the zz to which λ\lambda contributes, i.e., SPij:=Szij∪Sz0S_{P_{ij}}:=S_{z_{ij}}\cup S_{z_0} and SP0:=Sz0S_{P_0}:=S_{z_0}.

  1. For each term λ\lambda of Schönhage’s identity with Sλ≠∅S_\lambda\ne\varnothing, compute Cλ:=Pruned⁡τ1⋯τkλ(Sλ)C_\lambda:=\operatorname{Pruned}_{\tau_1\cdots\tau_k\lambda}(S_\lambda), an array on SλS_\lambda.

  1. Return the array cc on SS whose slices are czij:=CPijc_{z_{ij}}:=C_{P_{ij}} and cz0:=∑λCλc_{z_0}:=\sum_\lambda C_\lambda, restricted to SzijS_{z_{ij}} and to Sz0S_{z_0}. (These restrictions make sense, since Szij⊆SPijS_{z_{ij}}\subseteq S_{P_{ij}} and Sz0⊆SλS_{z_0}\subseteq S_\lambda for every λ\lambda, by step (2).)

Let us confirm which leaves Pruned⁡\operatorname{Pruned} visits. Recall from (2) that Mult⁡(a,b)[w]\operatorname{Mult}(a,b)[w] is the sum of Φτ(a)Ψτ(b)\Phi_\tau(a)\Psi_\tau(b) over the leaves contributing to ww (as defined in Section 2.3.2), i.e., those that choose PijP_{ij} at every level where ww has zijz_{ij}, and may choose any term at levels where ww has z0z_0. For a set UU of output strings of length LL, we write Leaves⁡(U)\operatorname{Leaves}(U) for the set of leaves that contribute to some output string of UU.

Lemma 10. Let aa and bb be input arrays, and let UU be a set of output strings of length LL. Called at the root, Pruned⁡(U)\operatorname{Pruned}(U) returns Mult⁡(a,b)\operatorname{Mult}(a,b) restricted to UU. The leaves it visits are exactly those of Leaves⁡(U)\operatorname{Leaves}(U), and the sets passed to the calls it makes have total size at most (L+1)∣Leaves⁡(U)∣(L+1)|\operatorname{Leaves}(U)|.

Proof. The values are correct by induction on L−kL-k: each CλC_\lambda is the array of the corresponding child of Full⁡\operatorname{Full} restricted to SλS_\lambda, so step (4) is step (4) of Full⁡\operatorname{Full} restricted to SS.

Recall that SλS_\lambda consists of the last L−k−1L-k-1 variables of each string in SS such that λ\lambda contributes to the first variable of that string. Thus, an induction on kk shows that the set passed to the vertex τ1⋯τk\tau_1\cdots\tau_k consists of the suffixes wk+1⋯wLw_{k+1}\cdots w_L of the strings ww of UU to which the vertex contributes, and furthermore that the vertex is called if and only if this set is nonempty. This means a leaf is visited if and only if it contributes to some string of UU.

For the total size, map each suffix in the set passed to a vertex τ1⋯τk\tau_1\cdots\tau_k to the leaf that extends τ1⋯τk\tau_1\cdots\tau_k by picking PijP_{ij} at the levels where the suffix has zijz_{ij} and by picking P0P_0 where it has z0z_0. By the previous paragraph, the vertex contributes to some string ww of UU with this suffix, and then so does this leaf, so the leaf is in Leaves⁡(U)\operatorname{Leaves}(U). The leaf determines the vertex and the suffix. This means the sets passed to the vertices at each of the L+1L+1 depths have total size at most ∣Leaves⁡(U)∣|\operatorname{Leaves}(U)|.

In other words, each call is made at most once, no matter how many strings of UU depend on it, and the running time depends on the size of the union of the sets of leaves contributing to the strings of UU, rather than the sum of their sizes. It remains to bound this union.

Few leaves contribute to a sparse set of entries

In our final algorithm, which we present below in Section 2.4.4, the set UU passed to Pruned⁡\operatorname{Pruned} will consist only of the output strings we have been focusing on, i.e., output strings of length LL whose inner sets (defined in Section 2.3.3) have exactly mm elements, so that they index the entries of the products XQYQX_QY_Q (Lemma 9). There are M=(Lm)9L−m=KN2M=\binom{L}{m}9^{L-m}=K N^2 such output strings (with MM as defined in Section 2.3.4), and in this subsection all output strings are of this kind.

Our focus in this subsection is on counting how many leaves the Pruned⁡\operatorname{Pruned} algorithm visits. A single output string has 10m=Dlog⁡410≈D1.6610^m=D^{\log_4 10}\approx D^{1.66} leaves contributing to it. This may appear problematic, since it is more than the DD multiplications that computing that output entry directly, as an inner product, would take. Because of this, it is important that we do not simply count the leaves of each output string of UU separately. Instead, we will find that most leaves contributing to an output string also contribute to many other output strings, and there are few such leaves in total.

Let us begin by classifying leaves by how many levels they choose P0P_0 at (as opposed to one of the PijP_{ij}s). As we mentioned above, the leaves contributing to an output string with inner set QQ are the 10m10^m leaves that choose any term at each of the mm levels of QQ, but PijP_{ij} at every level outside QQ where the output string has zijz_{ij}. We call the one that chooses P0P_0 at every level of QQ the private leaf of the output string. The private leaf contributes to no other output string, since an output string with a different inner set requires a term other than P0P_0 at some level of QQ, and an output string with the same inner set but a different outer part (a different zijz_{ij} at some level outside QQ) requires a different term there.

To describe how close a leaf is to being a private leaf, we define the order of a leaf as mm minus the number of levels at which it chooses P0P_0. A leaf contributing to an output string chooses P0P_0 only at levels of the output string’s inner set, so its order is at least 0. Since P0P_0 is the only term that serves the inner product alone, this is the classification described in the technique overview: the order of a leaf contributing to an output string is the number of levels of the string’s inner set at which the leaf takes one of the terms PijP_{ij} shared with the outer product. The only leaf of order 0 contributing to an output string is its private leaf. Beyond this, exactly

αd:=(md)9d\alpha_d := \binom{m}{d}9^d

leaves of order dd contribute to an output string, namely its private leaf with P0P_0 replaced by one of the nine other terms at dd of the levels of QQ (Figure 6).

The leaves contributing to one output string, drawn for $L=6$, $m=2$, and the output string $w=z_{13}z_0z_{21}z_{33}z_0z_{12}$

Figure 6. The leaves contributing to one output string, drawn for L=6L=6, m=2m=2, and the output string w=z13z0z21z33z0z12w=z_{13}z_0z_{21}z_{33}z_0z_{12} of Figure 4. A leaf is written as the string of terms it chose, level by level. A leaf of order dd is the private leaf with P0P_0 replaced by one of the nine terms PijP_{ij} (shown as a generic PijP_{ij} in the shaded cells) at exactly dd levels. Leaves of higher order are more numerous per output string, but each is shared by more output strings: a leaf that chose P0P_0 at m−dm-d levels contributes to one output string for each set QQ of size mm containing those levels, (L−m+dd)\binom{L-m+d}{d} of them. At L=19mL=19m this makes them fewer in all, by (5).

The total number of leaves of order dd in the entire recursion tree is

βd:=(Lm−d)9L−m+d\beta_d := \binom{L}{m-d}9^{L-m+d}

since we can choose the m−dm-d levels with P0P_0 and one of the nine other terms at every other level. In particular, β0=(Lm)9L−m=M\beta_0 = \binom{L}{m}9^{L-m} = M since the leaves of order 0 are exactly the private leaves, and there is one per output string. A leaf of order dd contributes to (L−m+dd)\binom{L-m+d}{d} output strings, one for each inner set of size mm that contains the m−dm-d levels at which it chooses P0P_0. Indeed, Mαd=βd(L−m+dd)M\alpha_d = \beta_d\binom{L-m+d}{d}, as both sides count the pairs of an output string and a leaf of order dd contributing to it. Finally, if L=19mL = 19m, then for 1≤d≤m1 \le d \le m we have

βdβd−1=9(m−d+1)L−m+d≤9m18m+1<12,soβd≤2−dM.(5)\frac{\beta_d}{\beta_{d-1}} = \frac{9(m-d+1)}{L-m+d} \le\frac{9m}{18m+1} < \frac{1}{2}, \qquad\text{so}\qquad\beta_d \le2^{-d}M. \tag*{(5)}

As in the technique overview, leaves of higher order are more numerous per output string, but each of them is shared by more output strings, and by (5) there are fewer of them in all. Below, we count all the leaves of order d>m/9d > m/9, whether or not they contribute to a string of UU, and this count will be small enough since the βd\beta_d decrease geometrically. By the ratio in (5), this requires mm to be well below L/10L/10: at m≈L/10m \approx L/10, the choice that computes the whole product cheaply (Section 2.3.4), the ratio would be close to 1 for small dd, so the βd\beta_d would stay about MM instead of decreasing, and the count would give no saving. A small mm also makes D=4mD = 4^m small compared with N0=318mN_0 = 3^{18m} (about N00.07N_0^{0.07}), and since a tile must fit into the product, NN must be a large power of DD. Together with the cost of the encodings (Section 2.4.4), this is why Theorem 5 assumes N≥D18N \ge D^{18}.

From now on, we fix L=19mL=19m, so that N0=318mN_0=3^{18m} and K=(19mm)K=\binom{19m}{m}. Recall that D=4mD=4^m, so 2m=D2^m=\sqrt{D} and 2−m/9=D−1/182^{-m/9}=D^{-1/18}.

Lemma 11. For every set UU of output strings whose inner sets have exactly mm elements,

∣Leaves⁡(U)∣≤∑d=0mmin⁡{∣U∣αd,βd},\lvert\operatorname{Leaves}(U)\rvert\le\sum_{d=0}^{m}\min\{\lvert U\rvert\alpha_d,\beta_d\},

and if L=19mL=19m, then ∣Leaves⁡(U)∣≤2−m/9(2m∣U∣+2M)\lvert\operatorname{Leaves}(U)\rvert\le2^{-m/9}(2^m\lvert U\rvert+2M).

Proof. We bound the number of leaves of order dd in Leaves⁡(U)\operatorname{Leaves}(U) in two ways: by ∣U∣αd\lvert U\rvert\alpha_d, charging each output string of UU for its leaves of order dd, and by βd\beta_d, the number of all leaves of order dd. Since every leaf of Leaves⁡(U)\operatorname{Leaves}(U) has an order 0≤d≤m0\le d\le m, summing the smaller of the two over dd gives the first inequality. (Summed on their own, ∣U∣αd\lvert U\rvert\alpha_d gives ∣U∣⋅10m\lvert U\rvert\cdot10^m, the cost of computing each output string of UU by itself, and βd\beta_d gives less than 2M2M by (5), the cost of computing all MM output strings.) Neither ∣U∣αd\lvert U\rvert\alpha_d nor βd\beta_d depends on which output strings are in UU.

For the second inequality, let L=19mL=19m. We use ∣U∣αd\lvert U\rvert\alpha_d for the orders d≤m/9d\le m/9 and βd\beta_d for the orders d>m/9d>m/9 (Figure 7). The orders d>m/9d>m/9 contribute at most ∑d>m/9βd≤M∑d>m/92−d<2⋅2−m/9M\sum_{d>m/9}\beta_d\le M\sum_{d>m/9}2^{-d}<2\cdot2^{-m/9}M by (5). The orders d≤m/9d\le m/9 contribute at most ∣U∣∑d≤m/9(md)9d\lvert U\rvert\sum_{d\le m/9}\binom{m}{d}9^d, and since 9d=72d8−d≤72m/98−d9^d=72^d8^{-d}\le72^{m/9}8^{-d} for d≤m/9d\le m/9,

Schematic count of Lemma 11

Figure 7. The count of Lemma 11, schematically. The leaves of order dd in Leaves⁡(U)\operatorname{Leaves}(U) number at most min⁡{∣U∣αd,βd}\min\{|U|\alpha_d,\beta_d\}: the bound ∣U∣αd|U|\alpha_d grows with dd up to d≈0.9md \approx0.9m (more leaves of higher order contribute to each output string), and the bound βd\beta_d shrinks geometrically (there are fewer leaves of higher order). The proof splits at d=m/9d=m/9, which is not necessarily where the two bounds cross, and it bounds the total by the shaded area.

∑d≤m/9(md)9d≤72m/9∑d=0m(md)8−d=72m/9(98)m=(72⋅(98)9)m/9<256m/9=2m⋅2−m/9,\sum_{d\le m/9}\binom{m}{d}9^d\le72^{m/9}\sum_{d=0}^{m}\binom{m}{d}8^{-d}=72^{m/9}\left(\frac{9}{8}\right)^m=\left(72\cdot\left(\frac{9}{8}\right)^9\right)^{m/9}<256^{m/9}=2^m\cdot2^{-m/9},

since 72⋅(9/8)9<20872\cdot(9/8)^9<208. Adding the two parts gives the second inequality.

Since 2m=D2^m=\sqrt{D} and 2−m/9=D−1/182^{-m/9}=D^{-1/18}, the second inequality of Lemma 11 says that

∣Leaves⁡(U)∣≤D−1/18(D∣U∣+2M).|\operatorname{Leaves}(U)| \le D^{-1/18}(\sqrt{D}|U|+2M).

Consider a tile in which ∣U∣=M/D|U|=M/\sqrt{D} entries are wanted. (This is the density of Theorem 5, which allows N2/DN^2/\sqrt{D} wanted entries out of N2N^2.) Then D∣U∣=M\sqrt{D}|U|=M, and the bound says that only O(M/D1/18)O(M/D^{1/18}) leaves contribute to the wanted entries of the tile. This is a factor D1/18D^{1/18} below the number MM of output entries of the tile, and far below the ∣U∣⋅D=MD|U|\cdot D=M\sqrt{D} multiplications that computing each wanted entry directly, as an inner product, would take. Next in Section 2.4.4 we sum the number of leaves over all the tiles, and we will use the fact that the bound is linear in ∣U∣|U|, meaning the total is the same no matter how the wanted entries are spread over the tiles.

Proof of Theorem 5

We finally put everything together to state and analyze our algorithm. As before, set D=4mD=4^m and L=19mL=19m.

Two consequences of N≥D18N \ge D^{18}. We use the assumption N≥D18N \ge D^{18} twice, each time to check that NN is large enough compared with a quantity that grows exponentially in mm. Since D18=418mD^{18}=4^{18m}, we compare mm-th powers by comparing their bases.

First, the tiling of Section 2.3.4 requires that N≥K0N0N \ge K_0N_0 so that it does not lose too much when padding, since it pads NN to a multiple of K0N0K_0N_0. This holds: using the general bound (Lm)≤(eL/m)m\binom{L}{m}\le(eL/m)^m, we have K=(19mm)≤(19e)mK=\binom{19m}{m}\le(19e)^m, so KN0≤(19e⋅318)m≤418mKN_0\le(19e\cdot3^{18})^m\le4^{18m}, as 19e⋅318<41819e\cdot3^{18}<4^{18}, and hence K0N0≤KN0≤D18≤NK_0N_0\le KN_0\le D^{18}\le N. This means the padding at most doubles NN, and we continue to write NN for the padded size.

Second, the encoding phase of the algorithm (Section 2.4.1) has a cost that does not depend on WW at all, and we need to ensure it is not too large. Recall that we perform 2N/K0N02N/K_0N_0 encodings, which use O(10L)O(10^L) operations each. To afford them within our budget of O(2−m/9N2)O(2^{-m/9}N^2) operations, we need

10L≤2−m/9NN0.(6)10^{L} \le2^{-m/9}NN_{0}. \tag*{(6)}

This also holds: 1019⋅21/9/318<41810^{19}\cdot2^{1/9}/3^{18}<4^{18}, so 10L⋅2m/9/N0≤D18≤N10^{L}\cdot2^{m/9}/N_{0}\le D^{18}\le N.

The algorithm. We compute the encodings of all row bands and column bands (Section 2.4.1). Each wanted position (I,J)∈W(I,J)\in W lies in one tile TT and is indexed by one output string of TT, the string whose inner set is the subset QQ of the block product containing (I,J)(I,J) and whose row and column are those of (I,J)(I,J) within that block product (Sections 2.3.3 and 2.3.4). For each tile TT, let WTW_T be the set of the output strings of the wanted positions in TT. Then, for each tile TT with WT≠∅W_T\ne\emptyset, we run Pruned⁡(WT)\operatorname{Pruned}(W_T), and report, for each (I,J)∈W(I,J)\in W, the value at its output string. This is correct by Lemmas 9 and 10.

The cost. By (6), the encodings cost (2N/K0N0)⋅O(10L)=O(2−m/9N2)(2N/K_0N_0)\cdot O(10^L)=O(2^{-m/9}N^2) operations. Each position of WW lands in one set WTW_T, so ∑T∣WT∣≤∣W∣≤N2/D=2−mN2\sum_T|W_T|\le|W|\le N^2/\sqrt{D}=2^{-m}N^2, and there are at most 4N2/M4N^2/M tiles, so ∑TM≤4N2\sum_T M\le4N^2. A call of Pruned⁡\operatorname{Pruned} with a set SS takes O(L∣S∣)O(L|S|) operations, since each of its steps handles each string of SS a constant number of times and a string has length LL (we store the sets as sorted lists, so that a slice is a segment and a union of slices is a merge). By Lemma 10, the total number of operations per leaf of Leaves⁡(WT)\operatorname{Leaves}(W_T) is thus O(L2)=O(log⁡2D)O(L^2)=O(\log^2D). Thus, by Lemma 11 summed over the tiles, the pruned recursions use

O(L2∑T∣Leaves⁡(WT)∣)≤O(L22−m/9(2m∣W∣+2∑TM))=O(L22−m/9N2)O\left(L^2\sum_T|\operatorname{Leaves}(W_T)|\right)\le O\left(L^2 2^{-m/9}\left(2^m|W|+2\sum_T M\right)\right)=O\left(L^2 2^{-m/9}N^2\right)

operations, no matter how WW is distributed among the tiles. The remaining minutiae, which list the K02K_0^2 subsets, locate the output strings, and sort the sets WTW_T, take O(L)O(L) operations per subset, per tile, and per position of WW, which is O(L2−m/9N2)O(L2^{-m/9}N^2) in all (as K≤NK\le N, there are at most 4N2/N04N^2/N_0 tiles, ∣W∣≤2−mN2|W|\le2^{-m}N^2, and N,N0≥2m/9N,N_0\ge2^{m/9}). Finally, since L=19log⁡4DL=19\log_4D and 2−m/9=D−1/182^{-m/9}=D^{-1/18}, the total operation count is O(N2log⁡2D/D1/18)O(N^2\log^2D/D^{1/18}), as desired.

Word size. Every number the algorithm handles is an integer of magnitude NO(1)N^{O(1)}. The input entries are of this size, by assumption. Every number in an encoding, or formed on the way to one, is a ±1\pm1 combination of at most 7L7^L input entries, as step (2) only adds and subtracts slices, and every value computed by Pruned⁡\operatorname{Pruned} is a sum of at most 10L10^L products of two encoded numbers (Lemma 7), where 7L≤10L≤N27^L\le10^L\le N^2 by (6). Indices and list positions are at most the number of words in use, also NO(1)N^{O(1)}. Hence every integer has O(log⁡N)O(\log N) bits, as desired. □

Remark 12 (comparison with related techniques). Prior work on matrix multiplication typically counts only multiplications, since they are usually a dominant cost for the algorithm, whereas in our algorithm, the additions need to be dealt with carefully. Our encodings (Section 2.4.1) are Yates’ algorithm for Kronecker powers [168, 93], as is standard in recursive matrix multiplication algorithms. The pruned recursion of Section 2.4.2 is an analog of FFT pruning [128, 142], of trimmed Möbius inversion [40], and, transposed, of sparse evaluation of Kronecker-power circuits [22], which builds on [167]. The new part along these lines in this paper is the count of Section 2.4.3, which shows that the pruned recursion visits few leaves.

Exact Triangle reduces to computing certain entries of a thin matrix product

This section derives the faster deterministic algorithms for Exact Triangle (given a tripartite graph with integer weights on its edges, is there a triangle whose three weights sum to zero?), 3SUM, and APSP from our new matrix theorem. Theorem 5 already suffices for this, and its stronger form in Section 4, Corollary 26, gives the running times stated in the introduction. Later, in Section 5, we will similarly derive our other algorithmic results.

Almost nothing in this section is new. We will apply known reductions from fine-grained complexity theory, due to Pătraşcu [135], Kopelowitz, Pettie, and Porat [116], Vassilevska Williams and Williams [158, 157, 159], Vassilevska Williams and Xu [160], Chan and He [51], Chan and Xu [71], and Fischer, Kaliciak, and Polak [84]. We go into some detail rather than just citing these known results for two main reasons. First, the theorem statements in the literature do not quite match the parameter regime of the matrix theorem, and obtaining exactly the matrix shapes that our algorithm needs requires slight modifications of the known constructions. Second, for one step, the reduction from Exact Triangle to the lopsided triangle problem, the only known reduction that achieves the parameters we need is randomized [160], and the known deterministic one [71] targets the balanced problem. We will make a small modification to achieve a deterministic reduction, using a known tool [84]. The reductions from 3SUM and APSP to Exact Triangle are deterministic already, and we cite them as they are. Thus, all the steps are deterministic, and so we ultimately design deterministic algorithms for all these problems. In Figure 8 we give an overview of the relevant reductions.

The reductions of this section

Figure 8. The reductions of this section. Each arrow is a reduction, labeled with the prior work it follows and with the statement here that proves it. Each box gives two running times: the first follows from Theorem 5, and the second from its stronger form, Corollary 26. We reprove only the reduction from Exact Triangle to Lopsided All-Edges Sparse Triangle, deterministically and for the parameters of the matrix theorem; the reductions from 3SUM and APSP are cited as they are. The running times in the two bottom boxes assume n≥D18n \ge D^{18} and ∣W∣≤n2/D|W| \le n^2/\sqrt{D}.

We remind the reader of some basics from fine-grained complexity that we will use here. A reduction from a problem AA to a problem BB is an algorithm for AA that builds instances of BB, solves them using an oracle (an algorithm for BB that it treats as a constant time black box), and does some extra work. We will typically state three things about it: how many instances it builds, of what size, and how much extra time it uses. Composed with an algorithm for BB, it is an algorithm for AA, whose running time is the extra time plus the total time to solve BB on each instance created. Such a reduction can be interpreted as conferring hardness (if AA is hard then so is BB) or as an algorithmic tool (a faster algorithm for BB gives one for AA). Here we will use the second interpretation to design our algorithms.

The particular types of reductions we focus on are fine-grained reductions. Here, for two problems AA and BB and two time bounds a(n)a(n), b(n)b(n), an (a(n),b(n))(a(n),b(n))-fine-grained reduction from AA to BB is an algorithm RR that solves any nn-sized instance of AA by making oracle calls to instances of BB of some sizes n1,…,ntn_1,\ldots,n_t where for every δ>0\delta> 0 there is an ε>0\varepsilon> 0 s.t. ∑i=1t(b(ni))1−δ≤(a(n))1−ε\sum_{i=1}^{t}(b(n_i))^{1-\delta} \leq(a(n))^{1-\varepsilon} and so that RR solves AA in O(a(n)1−ε)O(a(n)^{1-\varepsilon}) time. In other words, if BB had an O(b(N)1−δ)O(b(N)^{1-\delta}) time algorithm, then replacing the oracle calls by calls to the algorithm, due to the inequality above, we would get an O(a(n)1−ε)O(a(n)^{1-\varepsilon}) time algorithm for AA.

Section 3.1 restates Theorem 5 and Corollary 26 in the language of graphs. Section 3.2 reproves the reduction from Exact Triangle to the lopsided problem in a deterministic way. It hashes the weights modulo a small prime (in place of the random hash functions of earlier reductions: almost-linear hashing in the reductions from 3SUM [135, 116], and a random map into a large prime field in [160]), chooses the prime deterministically by counting false positives, as in the 3SUM reduction of Fischer, Kaliciak, and Polak [84], and builds the instances and searches for witnesses as in Chan and Xu [71]. The false positive counting in [84] is accomplished using the FFT; here, similar to prior work (e.g., [32]), for Exact Triangle we compute the count by multiplying two matrices whose entries are polynomials of low degree which can be done efficiently using fast matrix multiplication. Section 3.3 combines this reduction with Theorem 5 and Corollary 26 to solve Exact Triangle in truly subcubic time. Section 3.4 restates the reductions from 3SUM and APSP to Exact Triangle [158, 157, 159, 51] with their overheads, and applies them.

The Lopsided All-Edges Sparse Triangle problem

We define a lopsided (rectangular) version of the well-studied problem All-Edges Sparse Triangle. When viewed in graph terms, Theorem 5 counts the triangles through prescribed pairs of vertices in a tripartite graph whose middle part is small, and thus in particular can be used to solve All-Edges Sparse Triangle in such graphs.

Definition 13 (Lopsided All-Edges Sparse Triangle, Lop-AE-SparseTri(nn, DD)). We are given an unweighted undirected tripartite graph with two parts AA and BB of nn vertices each and a middle part MM of at most DD vertices, with arbitrary edges in M×AM \times A and M×BM \times B. Let W⊆A×BW \subseteq A \times B be the set of edges between AA and BB. Decide, for every edge (a,b)∈W(a,b) \in W, whether it lies in a triangle with some vertex of MM, that is, whether aa and bb have a common neighbor in MM.

In this notation, the usual All-Edges Sparse Triangle problem is the balanced case D=nD = n (after the standard reduction to tripartite graphs), except that one asks about every edge of the graph, not only those between AA and BB, and that the running time is measured in terms of the number mm of edges. We think of WW as being polynomially smaller than n2n^2 and DD as polynomially smaller than nn, so the instance is sparse in this sense. The brute-force algorithm solves Lop-AE-SparseTri(nn, DD) in O(∣W∣D)O(|W|D) time. If D≤n0.321D \le n^{0.321}, then, since 0.321≤α0.321 \le\alpha [161],7 fast rectangular matrix multiplication can solve the problem in n2+o(1)n^{2+o(1)} time even when ∣W∣=n2|W| = n^2. We will beat both ∣W∣D|W|D and n2n^2 for D=nεD = n^\varepsilon and ∣W∣=n2/D|W| = n^2/\sqrt{D} with a constant ε>0\varepsilon> 0, and this will suffice to refute both the 3SUM and the APSP hypotheses.

Some of the known reductions, such as those from the real-valued problems in Section 5.2, reduce to the counting version of All-Edges Sparse Triangle, which asks for the number of triangles through each edge; we define the lopsided version.

Definition 14 (Lopsided All-Edges Sparse Triangle Counting, #Lop-AE-SparseTri(nn, DD)). This is the same problem as Lop-AE-SparseTri(nn, DD), except that for every edge (aa, bb) ∈W\in W we ask for the number of triangles it lies in, that is, the number of common neighbors of aa and bb in MM.

In matrix language, let X∈{0,1}n×DX \in\{0,1\}^{n \times D} and Y∈{0,1}D×nY \in\{0,1\}^{D \times n} be the biadjacency matrices of the edges between AA and MM and between MM and BB, that is, X[a,v]=1X[a,v] = 1 if and only if a∈Aa \in A and v∈Mv \in M are adjacent, and Y[v,b]=1Y[v,b] = 1 if and only if v∈Mv \in M and b∈Bb \in B are adjacent (padded with zeros if MM has fewer than DD vertices). Then Lop-AE-SparseTri(nn, DD) asks for the entries of the Boolean product of XX and YY at the positions in WW, and #Lop-AE-SparseTri(nn, DD) asks for the corresponding entries of the product of XX and $Y over the integers. In the language of Section 2, WW is the set of wanted positions, and we call its elements the query pairs.

The counting version #Lop-AE-SparseTri(nn, DD) is also equivalent, up to polylogarithmic factors, to the problem of Theorem 5 and Corollary 26, that is, to computing the wanted entries (XY)[I,J](XY)[I,J], (I,J)∈W(I,J) \in W, of a thin matrix product, for matrices X∈Zn×DX \in\mathbb{Z}^{n \times D} and Y∈ZD×nY \in\mathbb{Z}^{D \times n} whose entries have absolute value nO(1)n^{O(1)}.8

Besides asking for the wanted entries of a Boolean thin matrix product, the detection version Lop-AE-SparseTri(nn, DD) can also be viewed as offline Set Disjointness (see, e.g., [116, 160]): the sets are the neighborhoods in MM of the vertices of AA and BB, over a universe of at most DD elements, and a query pair (aa, bb) ∈W\in W asks whether the sets of aa and bb are disjoint. The reductions below (mostly from prior work) produce at most n2/Dn^2/\sqrt{D} query pairs and sets of at most D\sqrt{D} elements, which is the regime of [116] and of [160], Corollary 3.12.

With the above discussion in mind, Theorem 5 gives the following.

Corollary 15. Let D≥4D \ge4 be a power of four with n≥D18n \ge D^{18}, and consider an instance of #Lop-AE-SparseTri(nn, DD) or of Lop-AE-SparseTri(nn, DD) with ∣W∣|W| query pairs. If ∣W∣≤n2/D|W| \le n^2/\sqrt{D}, then the instance can be solved deterministically in O(n2log⁡2D/D1/18)O(n^2 \log^2 D/D^{1/18}) time. In general, splitting WW into sets of at most n2/Dn^2/\sqrt{D} query pairs solves it deterministically in time

O((n2+∣W∣D)log⁡2D/D1/18).O\left((n^2 + |W|\sqrt{D})\log^2 D/D^{1/18}\right).

Proof. Apply Theorem 5 with N=nN = n to the two biadjacency matrices: the entries (XY)[a,b](XY)[a,b], (a,b)∈W(a,b) \in W, are the numbers of common neighbors, and they are nonzero exactly for the query pairs that lie in a triangle. For larger WW, apply the theorem to each of at most ⌈∣W∣D/n2⌉+1\lceil|W|\sqrt{D}/n^2\rceil+ 1 pieces.

The data structure of Section 4 improves the saving D1/18D^{1/18} to D0.063D^{0.063} (Corollary 26), and gives the following.

Corollary 16. Let n≥D18n \ge D^{18}, and consider an instance of #Lop-AE-SparseTri(nn, DD) or of Lop-AE-SparseTri(nn, DD) with ∣W∣|W| query pairs. It can be solved deterministically in O(∣W∣D0.437+n2/D0.063)O(|W|D^{0.437} + n^2/D^{0.063}) time.

Proof. This is Corollary 26 with N=nN = n, applied to the two biadjacency matrices as above.

For ∣W∣=O(n2/D)|W| = O(n^2/\sqrt{D}), which is what the reductions below produce, the running time in Corollary 16 is O(n2/D0.063)O(n^2/D^{0.063}).

The reduction of Section 3.2 is stated for an arbitrary DD, with the number of oracle calls and the additional time as functions of DD and a free parameter gg, and Section 3.3 chooses DD and gg.

A deterministic reduction from Exact Triangle to Lop-AE-SparseTri

Exact Triangle. An instance of Exact Triangle (also called Zero-Weight Triangle, and sometimes “Love Triangle” [94]) consists of a complete tripartite graph on vertex parts A,B,CA, B, C of nn vertices each, and an integer weight w(e)w(e) on every edge, with ∣w(e)∣≤nν|w(e)| \le n^\nu for some constant ν≥1\nu\ge1. Let S(a,b,c):=w(a,b)+w(b,c)+w(a,c)S(a,b,c) := w(a,b) + w(b,c) + w(a,c). A zero triangle is a triangle (a,b,c)∈A×B×C(a,b,c) \in A \times B \times C with S(a,b,c)=0S(a,b,c) = 0, and the task is to decide whether one exists. As is standard, an instance on an arbitrary nn-vertex graph reduces to this form by taking three copies of the vertex set and giving every missing edge the weight 3nν+13n^\nu+ 1, which lies in no zero triangle (this replaces ν\nu by ν+1\nu+ 1), and the search version, which asks the algorithm to find a zero triangle if one exists, is equivalent to the decision version via a simple self-reduction (the reduction below finds one anyway).

Theorem 17 (Exact Triangle to Lop-AE-SparseTri, deterministically). Let 16≤D≤n16 \le D \le n, and let 1≤g≤D1 \le g \le\sqrt{D} be an integer. Exact Triangle on nn vertices per part with weights of absolute value at most nνn^\nu reduces deterministically to at most 4ng4ng instances of Lop-AE-SparseTri(n,D)(n,D), each with at most n2/Dn^2/\sqrt{D} query pairs, plus O(νn3log⁡n/g+nω+o(1)D3/2+n2Dg)O(\nu n^3 \log n/g + n^{\omega+o(1)}D^{3/2} + n^2Dg) additional time, where ω<2.372\omega< 2.372 is the matrix multiplication exponent [10]. The reduction is non-adaptive: it produces all the instances before it makes any oracle call, so they can be solved in any order, or all together.

The parameter gg trades the number of instances against the cost of the search for witnesses in the last step of the proof (the term νn3log⁡n/g\nu n^3 \log n/g); Section 3.3 balances the two. The oracle returns at most n2/Dn^2/\sqrt{D} answers per instance, and the time to read them is counted as part of the oracle calls, rather than as additional time.

Proof. The proof has three steps: we hash the weights modulo a prime, build the instances, and search for witnesses.

Hashing modulo a prime. We reduce the weights modulo a prime p∈[D/2,D)p \in[\sqrt{D}/2,\sqrt{D}), chosen deterministically. This size of pp fits the instances below: a piece of CC of up to D\sqrt{D} vertices, paired with the pp labels, gives a middle part of at most DD vertices, and the n2n^2 pairs (a,b)(a,b) fall into pp residue classes of about n2/Dn^2/\sqrt{D} pairs on average, which is the number of query pairs that an instance may have. A false positive of pp is a triple (a,b,c)(a,b,c) with S(a,b,c)≠0S(a,b,c) \ne0 and p∣S(a,b,c)p \mid S(a,b,c); let F(p)F(p) denote the number of false positives of pp. For every prime pp in the range we count the triples with S(a,b,c)=0(modp)S(a,b,c) = 0 \pmod p. This number is the number of false positives F(p)F(p) plus Z0Z_0, the number of zero triangles, which does not depend on pp. Each F(p)+Z0F(p) + Z_0 is computed by a standard trick for small weights [14, 172]: let P[a,c]:=xw(a,c) mod pP[a,c] := x^{w(a,c)} \bmod p and Q[c,b]:=xw(b,c) mod pQ[c,b] := x^{w(b,c)} \bmod p be matrices over the ring Z[x]/(xp−1)\mathbb{Z}[x]/(x^p - 1), so that the coefficient of xrx^r in (PQ)[a,b](PQ)[a,b] is the number of c∈Cc \in C with w(a,c)+w(b,c)≡r(modp)w(a,c) + w(b,c) \equiv r \pmod p; then F(p)+Z0F(p) + Z_0 is the sum over the pairs (a,b)∈A×B(a,b) \in A \times B of the coefficient of x−w(a,b) mod px^{-w(a,b)} \bmod p in (PQ)[a,b](PQ)[a,b]. Computing PQPQ takes nω+o(1)n^{\omega+o(1)} ring operations, or O(nlog⁡27)O(n^{\log_2 7}) with Strassen’s algorithm [147], each of them O(p2)O(p^2) word operations, so nω+o(1)D3/2n^{\omega+o(1)}D^{3/2} time over the fewer than D\sqrt{D} primes in the range. (Any matrix multiplication algorithm fast enough to make this term negligible suffices. For our choice of DD, Strassen’s algorithm already does, and keeps the reduction potentially practical.9

We select the prime with the smallest count, which is also the prime with the fewest false positives, and call it pp. To bound F(p)F(p), note that a triple with S(a,b,c)≠0S(a,b,c) \ne0 is a false positive exactly of the primes in the range that divide S(a,b,c)S(a,b,c). Since 0<∣S(a,b,c)∣≤3nν0 < \lvert S(a,b,c)\rvert\le3n^\nu and these primes are at least D/2\sqrt{D}/2, there are at most log⁡D/2(3nν)\log_{\sqrt{D}/2}(3n^\nu) of them. Hence the numbers of false positives of all the primes in the range add up to at most n3log⁡D/2(3nν)n^3\log_{\sqrt{D}/2}(3n^\nu). By the prime number theorem there are Ω(D/log⁡D)\Omega(\sqrt{D}/\log D) primes in the range, and F(p)F(p) is at most the average over them, so, as in [84], F(p)=O(n3log⁡(3nν)/D)=O(νn3log⁡n/D)F(p)=O(n^3\log(3n^\nu)/\sqrt{D})=O(\nu n^3\log n/\sqrt{D}), since log⁡D=O(log⁡(D/2))\log D=O(\log(\sqrt{D}/2)) for D≥16D\ge16.

The instances. As in [71], let s:=⌊D⌋s:=\lfloor\sqrt{D}\rfloor and split CC into pieces C1,…,ChC_1,\ldots,C_h of at most ⌈s/g⌉\lceil s/g\rceil vertices each, so that h≤⌈ng/s⌉h\le\lceil ng/s\rceil. For ϱ∈Zp\varrho\in\mathbb{Z}_p let WϱW_\varrho be the set of edges (a,b)∈A×B(a,b)\in A\times B with w(a,b)≡ϱ(modp)w(a,b)\equiv\varrho\pmod p, and cut it into chunks of at most n2/Dn^2/\sqrt{D} query pairs. There are at most p+D≤2Dp+\sqrt{D}\le2\sqrt{D} chunks in all. For each chunk Q⊆WϱQ\subseteq W_\varrho and each piece CkC_k form the instance of Lop-AE-SparseTri(n,D)(n,D) with query pairs W:=QW:=Q and middle part Ck×ZpC_k\times\mathbb{Z}_p, of size at most sp≤Dsp\le D, whose middle vertices are pairs (vertex, label) as in [71], with

a∼(c,σ)⟺σ≡w(a,c)+ϱ,(c,σ)∼b⟺σ≡−w(b,c)(modp).a\sim(c,\sigma)\Longleftrightarrow\sigma\equiv w(a,c)+\varrho,\qquad(c,\sigma)\sim b\Longleftrightarrow\sigma\equiv-w(b,c)\pmod p.

Within the chunk, the condition S(a,b,c)≡0(modp)S(a,b,c)\equiv0\pmod p has become the equality w(a,c)+ϱ≡−w(b,c)w(a,c)+\varrho\equiv-w(b,c) of a label of (a,c)(a,c) and a label of (b,c)(b,c), so a query pair (a,b)∈Q(a,b)\in Q has a common neighbor if and only if some c∈Ckc\in C_k has S(a,b,c)≡0(modp)S(a,b,c)\equiv0\pmod p. There are at most 2Dh≤2D(ng/s+1)≤4ng2\sqrt{D}h\le2\sqrt{D}(ng/s+1)\le4ng instances, since s≥D−1≥3D/4s\ge\sqrt{D}-1\ge3\sqrt{D}/4 because D≥16D\ge16, and D≤n≤2n/3\sqrt{D}\le\sqrt{n}\le2n/3 because D≤nD\le n and we may assume n≥3n\ge3, and they are produced non-adaptively, since pp is chosen before any of them. Writing them down costs O(n2Dg)O(n^2Dg): the two bipartite graphs of an instance have O(nD)O(nD) entries, and the chunks are computed once and shared by the pieces.

Witnesses. For every query pair that the oracle accepts, scan the piece CkC_k of its instance for a cc with S(a,b,c)=0S(a,b,c)=0, as in the exhaustive search of [71]. A zero triangle is always found, since its cc lies in some piece and makes the oracle accept its pair. We stop as soon as a zero triangle is found. A failed scan, of a piece CkC_k for a pair (a,b)(a,b), contains a c∈Ckc\in C_k with S(a,b,c)≡0(modp)S(a,b,c)\equiv0\pmod p but S(a,b,c)≠0S(a,b,c)\ne0, that is, a false positive (a,b,c)(a,b,c) of pp, and distinct scans contain distinct false positives, so there are at most F(p)F(p) failed scans, and the scans cost O((F(p)+1)D/g)=O(νn3log⁡n/g)O((F(p)+1)\sqrt{D}/g)=O(\nu n^3\log n/g).

Remark 18 (Comparison with [71] and [160]). We emulate the instances and the witness search of Chan and Xu [71], Section 3. The difference is in how the pairs are grouped so that the condition on S(a,b,c)S(a,b,c) becomes an equality of labels. For exact integer weights, w(a,b)w(a,b) takes too many values to group by, so Chan and Xu group the pairs by a reference witness kk with known S(a,b,k)S(a,b,k), which they find by a recursion on the bits of the weights, and use Fredman’s trick. Their labels are exact and there are no false positives. After hashing, w(a,b) mod pw(a,b)\bmod p takes only pp values, so we can group by it directly, in a single round of instances instead of a recursion. The labels take only pp values, so the middle part is small, but in exchange, this introduces false positives. Vassilevska Williams and Xu [160] also hash, but by a random map w(u,v)↦xw(u,v)+yu−yvw(u,v) \mapsto xw(u,v)+y_u-y_v into a large prime field, with xx and the vertex weights yvy_v random, followed by a split of the field into intervals. With residues in place of their intervals, the block Ck×{−j}C_k \times\{-j\} of our instance for ϱ\varrho and CkC_k is their graph G−ϱ−j,j,ϱG_{-\varrho-j,j,\varrho}, and our instance puts the pp graphs with the same ϱ\varrho side by side. They use randomness to bound the degrees and the false positives through each edge, which their listing step needs [160], whereas the scans above need only the total number of false positives, controlled by the choice of pp.

Exact Triangle in truly subcubic time

Theorem 19 (Exact Triangle). Let ε′:=0.00175\varepsilon' := 0.00175 and εT:=0.0017\varepsilon_T := 0.0017. For every constant ν≥1\nu\ge1, Exact Triangle on nn vertices per part with integer weights of absolute value at most nνn^\nu can be solved by a deterministic algorithm in O(n3−1/648log⁡2n)O(n^{3-1/648}\log^2 n) time using Theorem 5 (via Corollary 15), and in O(n3−ε′log⁡n)≤O(n3−εT)O(n^{3-\varepsilon'}\log n) \le O(n^{3-\varepsilon_T}) time using Corollary 26 (via Corollary 16).

Proof. Assume nn is larger than a constant depending on ν\nu (smaller instances are solved by brute force). In both cases we apply Theorem 17, whose instances have at most n2/Dn^2/\sqrt{D} query pairs each, and solve every instance by a corollary of Section 3.1. The values of gg below balance the cost of the instances against that of the scans (Remark 20).

By Theorem 5. Let DD be the largest power of four with D≤n1/18D \le n^{1/18}, so that D≥n1/18/4D \ge n^{1/18}/4, and let g:=⌈D1/36⌉g := \lceil D^{1/36}\rceil. Solve every instance by Corollary 15, which applies because D18≤nD^{18} \le n. The O(nD1/36)O(nD^{1/36}) instances cost O(n2log⁡2D/D1/18)O(n^2\log^2 D/D^{1/18}) each, so O(n3D−1/36log⁡2n)O(n^3D^{-1/36}\log^2 n) in all, the scans cost O(n3D−1/36log⁡n)O(n^3D^{-1/36}\log n), the choice of pp costs O(nlog⁡27D3/2)=O(n2.9)O(n^{\log_2 7}D^{3/2}) = O(n^{2.9}) with Strassen’s algorithm, and building the instances costs O(n2D1.03)O(n^2D^{1.03}). Finally D−1/36≤41/36n−1/648D^{-1/36} \le4^{1/36}n^{-1/648}, so the time is O(n3−1/648log⁡2n)O(n^{3-1/648}\log^2 n).

By Corollary 26. Let D:=⌊n1/18⌋D := \lfloor n^{1/18}\rfloor and g:=⌈D0.0315⌉g := \lceil D^{0.0315}\rceil, and solve every instance by Corollary 16, which applies because D18≤nD^{18} \le n. The instances cost O(nD0.0315)⋅O(n2/D0.063)=O(n3D−0.0315)O(nD^{0.0315}) \cdot O(n^2/D^{0.063}) = O(n^3D^{-0.0315}), the scans O(n3D−0.0315log⁡n)O(n^3D^{-0.0315}\log n), the choice of pp costs O(nlog⁡27D3/2)=O(n2.9)O(n^{\log_2 7}D^{3/2}) = O(n^{2.9}) with Strassen’s algorithm, and building the instances costs O(n2D1.04)O(n^2D^{1.04}). Finally D≥n1/18/2D \ge n^{1/18}/2 gives D−0.0315≤2n−0.0315/18=2n−0.00175D^{-0.0315} \le2n^{-0.0315/18} = 2n^{-0.00175}, so the time is O(n3−ε′log⁡n)≤O(n3−εT)O(n^{3-\varepsilon'}\log n) \le O(n^{3-\varepsilon_T}).

Remark 20. With g=Dηg = D^\eta and a saving DγD^\gamma per instance, the instances cost n3Dη−γn^3D^{\eta-\gamma} and the scans n3D−ηn^3D^{-\eta}, up to logarithmic factors. They balance at η=γ/2\eta= \gamma/2, that is, at η=1/36\eta= 1/36 for the saving D1/18D^{1/18} of Theorem 5 and at η=0.0315\eta= 0.0315 for the saving D0.063D^{0.063} of Corollary 26. Any improvement of these savings improves the final exponent η/18\eta/18 directly, and the factor 1/181/18 in it comes from the assumption N≥D18N \ge D^{18} of these theorems. Any other algorithm for Lop-AE-SparseTri(n,D)(n,D) can be plugged into Theorem 17 in the same way. With the straightforward algorithm (O(n2/g)O(n^2/g) per instance, since every vertex of AA has O(D/g)O(\sqrt{D}/g) neighbors in the middle part) the reduction recovers the brute-force bound n3n^3 up to a logarithmic factor.

3SUM and APSP reduce to Exact Triangle

The reductions here are known and deterministic. We recall them in the form we use, and then apply Theorem 19, with its bound O(n3−ε′log⁡n)O(n^{3-\varepsilon'}\log n), ε′=0.00175\varepsilon' = 0.00175, when it uses Corollary 26.

Theorem 21 (Known reductions). For every constant ν\nu: (a) (3SUM) 3SUM3SUM on nn integers of absolute value at most nνn^\nu reduces deterministically, in n3/2+o(1)n^{3/2+o(1)} time, to n1/2+o(1)n^{1/2+o(1)} instances of Exact Triangle on n1/2+o(1)n^{1/2+o(1)} vertices per part with weights of absolute value nO(1)n^{O(1)} [51, 158].

(b) ((min, +)-product and APSP) If a deterministic algorithm solves Exact Triangle on ss vertices per part with weights of absolute value at most cUcU, for a suitable constant cc, in time T(s)T(s) with T(s)/sT(s)/s nondecreasing, then the (min, +)-product of two n×nn \times n integer matrices with entries of absolute value at most UU can be computed deterministically in O(n2T(n1/3)log⁡2U)O(n^2T(n^{1/3})\log^2 U) time, and APSP on directed nn-vertex graphs with integer weights of absolute value at most nνn^\nu and no negative cycles in O(n2T(n1/3)log⁡3n)O(n^2T(n^{1/3})\log^3 n) time [157, 159, 158].

Using the above known reductions we solve both 3SUM and APSP polynomially faster:

Theorem 22 (3SUM and APSP). Let ν\nu be a constant. Using Theorem 5 (through Theorem 19), deterministic algorithms solve 3SUM3SUM on nn integers of absolute value at most nνn^\nu in n2−1/1296+o(1)≤O(n1.99923)n^{2-1/1296+o(1)} \le O(n^{1.99923}) time, and the (min, +)-product of two n×nn \times n integer matrices with entries of absolute value at most nνn^\nu, as well as APSP on directed nn-vertex graphs with integer weights of absolute value at most nνn^\nu and no negative cycles, in O~(n3−1/1944)≤O(n2.99949)\widetilde{O}(n^{3-1/1944}) \le O(n^{2.99949}) time. Using Corollary 26 instead, the times are n2−ε′/2+o(1)≤O(n1.9992)n^{2-\varepsilon'/2+o(1)} \le O(n^{1.9992}) and O~(n3−ε′/3)≤O(n2.99942)\widetilde{O}(n^{3-\varepsilon'/3}) \le O(n^{2.99942}).

Proof. Plug Theorem 19 into Theorem 21. With the bound O(n3−1/648log⁡2n)O(n^{3-1/648}\log^2 n) of Theorem 19, the cost for 3SUM is

n3/2+o(1)+n1/2+o(1)⋅O((n1/2+o(1))3−1/648log⁡2n)=n2−1/1296+o(1)=n1.999228…+o(1),n^{3/2+o(1)} + n^{1/2+o(1)} \cdot O\left((n^{1/2+o(1)})^{3-1/648}\log^2 n\right) = n^{2-1/1296+o(1)} = n^{1.999228\ldots+o(1)},

and for the (min, +)-product and APSP, with T(s)=O(s3−1/648log⁡2s)T(s)=O(s^{3-1/648}\log^2 s), for which T(s)/sT(s)/s is nondecreasing, it is

O~(n2(n1/3)3−1/648)=O~(n3−1/1944),3−1/1944=2.99948…<2.99949.\widetilde{O}\left(n^2(n^{1/3})^{3-1/648}\right) = \widetilde{O}(n^{3-1/1944}), \qquad3-1/1944 = 2.99948\ldots< 2.99949.

With the bound O(n3−ε′log⁡n)O(n^{3-\varepsilon'}\log n) instead, the cost for 3SUM is

n3/2+o(1)+n1/2+o(1)⋅O((n1/2+o(1))3−ε′log⁡n)=n2−ε′/2+o(1)=n1.999125+o(1),n^{3/2+o(1)} + n^{1/2+o(1)} \cdot O\left((n^{1/2+o(1)})^{3-\varepsilon'}\log n\right) = n^{2-\varepsilon'/2+o(1)} = n^{1.999125+o(1)},

and for the (min, +)-product and APSP, with T(s)=O(s3−ε′log⁡s)T(s)=O(s^{3-\varepsilon'}\log s), it is

O~(n2(n1/3)3−ε′)=O~(n3−ε′/3),3−ε′/3=2.99941…<2.99942.\widetilde{O}\left(n^2(n^{1/3})^{3-\varepsilon'}\right) = \widetilde{O}(n^{3-\varepsilon'/3}), \qquad3-\varepsilon'/3 = 2.99941\ldots< 2.99942.

Remark 23 (3XOR). The same approach as for 3SUM gives a deterministic truly subquadratic algorithm for 3XOR (given three lists of nn vectors in F2O(log⁡n)\mathbb{F}_2^{O(\log n)}, find one vector from each list such that the three XOR to zero [108, 77]), using linear hash functions over F2\mathbb{F}_2 whose rows are chosen one at a time from an ε\varepsilon-biased set [13] by the method of conditional expectations.

The matrix theorem in general: a data structure

In this section, we extend our algorithm from Section 2 in two directions. First, we turn it into a data structure. After preprocessing XX and YY in less time than it takes to write down XYXY, the data structure answers a query for any single entry of XYXY, not known in advance, in time polynomially smaller than the DD operations that it would take to compute that entry as an inner product. Second, we let the parameters of our construction vary. This will give larger time savings than D1/18D^{1/18}, and trade-offs between the time savings, how thin the product must be, the query time, and the density of the set WW of wanted entries. We assume that the reader is familiar with Section 2, whose notation we use throughout, although we will begin with a brief reminder of the relevant notions.

In Section 4.1, we state the main results, Theorems 24 and 25, with explicit parameter examples in Table 2, as well as Corollary 26, the instance of Theorem 24 that our reductions in Sections 3 and 5 use. In Section 4.2, we will introduce the key new idea, the partial sums that our data structure stores, which we call boxes. In Section 4.3, we will then give the data structure in terms of the parameters (listed in Table 1), and finally we will set the parameters in Section 4.4.

symbolmeaningin Section 2in this section
mm, D=4mD = 4^mthe number of inner levels, and the inner dimension of the product XYXY
LL, c=L/mc = L/mthe number of levels of the recursion, and its ratio to mmL=19mL = 19mL=cmL = cm, c>10c > 10
N0=3L−mN_0 = 3^{L-m}the number of rows of a row block, and of columns of a column block
K=(Lm)K = \binom{L}{m}the number of products XQYQX_QY_Q of a tile, one for each set QQ of mm levels
M=KN02M = KN_0^2the number of output entries of a tile
αd=(md)9d\alpha_d = \binom{m}{d}9^dthe number of leaves of order dd contributing to one output entry
βd=(Lm−d)9L−m+d\beta_d = \binom{L}{m-d}9^{L-m+d}the number of leaves of order dd in a tileβd≤2−dM\beta_d \le2^{-d}Mβd≤ρdM\beta_d \le\rho^dM
ρ=9m/(L−m+1)\rho= 9m/(L-m+1)the decay rate of the βd\beta_d: βd/βd−1≤ρ\beta_d/\beta_{d-1} \le\rho, see (7)ρ<12\rho< \frac{1}{2}ρ<1\rho< 1
ttthe switching order: a query reads the leaves of order below tt, and the preprocessing puts the others into boxes; in Section 2, the order at which the count of Lemma 11 splitst=m/9t = m/9t=θmt = \theta m, 0<θ<0.90 < \theta< 0.9
γ\gammathe preprocessing, or the whole computation when WW is given in advance, takes O(N2log⁡2D/Dγ)O(N^2 \log^2 D/D^\gamma) timeγ=1/18\gamma= 1/18see Table 2
ε\varepsilonthe results hold for D≤NεD \le N^\varepsilonε=1/18\varepsilon= 1/18ε<Rc(γ)<0.1204…\varepsilon< R_c(\gamma) < 0.1204\ldots
qqa query takes O(Dqlog⁡D)O(D^q \log D) timeno queriessee Table 2
κ\kappathe set WW of wanted entries has ∣W∣≤N2/Dκ|W| \le N^2/D^\kappaκ=12\kappa= \frac{1}{2}see Table 2

Table 1. The parameters of our construction. The last two columns give their values or bounds in Section 2 and in this section. Where these columns are empty, the parameter is given by the formula in the first column in both sections. In this section, LL and tt are cmcm and θm\theta m rounded up to integers, and the bound Rc(γ)R_c(\gamma) is defined in Section 4.4.

ratio ccD≤NεD \le N^{\varepsilon} ε\varepsilon\multicolumn{6}{c}{Theorem 24: the data structure γ\gamma for query time DqD^q, q=q =}\multicolumn{5}{c}{Theorem 25: the wanted entries γ\gamma for ∣W∣≤N2/Dκ|W| \le N^2/D^\kappa, κ=\kappa=}
0.100.250.430.500.750.900.100.250.500.751.00
400.0290.02050.06080.11750.14290.24170.30950.01660.04730.10600.17200.2442
210.0560.01120.03310.06400.07780.13160.16850.00990.02860.06530.10740.1546
190.0620.00970.02870.05550.06750.11420.14630.00870.02530.05780.09540.1379
150.0790.00610.01830.03540.04300.07280.09320.00570.01680.03890.06460.0941
120.0990.00280.00830.01600.01950.03300.04230.00270.00800.01860.03120.0459
10.50.1140.00070.00220.00430.00520.00890.01140.00070.00220.00520.00870.0129

Table 2. Explicit parameters for Theorems 24 and 25. Each row is a choice of the ratio c=L/mc = L/m. The parameter ε\varepsilon is determined by cc and says how thin the product must be, i.e., every entry of the row holds whenever D≤NεD \le N^\varepsilon. On the left, the columns correspond to a choice of qq, and the numerical entry is a value γ\gamma for which Theorem 24 holds, meaning that after O(N2log⁡2D/Dγ)O(N^2\log^2 D/D^\gamma) preprocessing, a query takes O(Dqlog⁡D)O(D^q\log D) time. On the right, the columns correspond to a choice of κ\kappa, and the numerical entry is a value γ\gamma for which Theorem 25 holds, meaning that any ∣W∣≤N2/Dκ|W| \le N^2/D^\kappa wanted entries take O(N2log⁡2D/Dγ)O(N^2\log^2 D/D^\gamma) time. On the left side, the column q=0.43q = 0.43 uses the switching order t=m/9t = m/9 of Section 2 (more precisely, q=0.4277…q = 0.4277\ldots), and its two bold entries are Theorem 5 (c=19c = 19, where γ=1/18=0.0555…\gamma= 1/18 = 0.0555\ldots) and Corollary 26 (c=21c = 21). A larger cc gives a larger γ\gamma but a smaller ε\varepsilon, and a slower query or a sparser WW allows a larger γ\gamma. We round all values down, and we will explain how we compute them in Section 4.4.

Notions from Section 2. We keep the recursion, the tiling, and the encodings of Sections 2.3 and 2.4.1, and we use the terminology of Sections 2.3.2 and 2.4.3 as defined there: the leaves contributing to an output string, its private leaf, the order of a leaf, and the counts αd\alpha_d and βd\beta_d. For convenience, we briefly recall these notions here.

  • A leaf τ=τ1⋯τL\tau= \tau_1 \cdots\tau_L is a string of LL terms of Schönhage’s identity, where τℓ\tau_\ell is the term chosen at level ℓ\ell of the recursion (Section 2.3.1). Throughout this section, we compare levels by their indices: we say that level ℓ\ell is lower than level ℓ′\ell' if ℓ<ℓ′\ell< \ell', so that the lowest level is the first level of the recursion.

  • An output string ww with inner set QQ has the variable z0z_0 at each of the mm levels of QQ, and one of the variables zijz_{ij} at every other level. It indexes the entry (XQYQ)[w](X_QY_Q)[w] of the product XQYQX_QY_Q (Section 2.3.3).

  • A leaf contributes to ww if it chooses PijP_{ij} at every level where ww has zijz_{ij}, while it may choose any of the ten terms at the levels of QQ, where ww has z0z_0 (Section 2.3.2).

  • The private leaf of ww is the leaf contributing to ww that chooses P0P_0 at every level of QQ (Section 2.4.3).

  • The order of a leaf is mm minus the number of levels at which it chooses P0P_0. For a leaf contributing to ww, this is the number of levels of QQ at which it chooses a term other than P0P_0 (Section 2.4.3).

  • A tile consists of a band of K0=⌊K⌋K_0 = \lfloor\sqrt{K}\rfloor row blocks of XX together with a band of K0K_0 column blocks of YY (Section 2.3.4), and the encoding of a band is the array of the 10L10^L numbers Φτ(a)\Phi_\tau(a), or Ψτ(b)\Psi_\tau(b), computed from its input array (Section 2.4.1). We will recall both in more detail in Section 4.3.

As in Section 2.4.3, all output strings in this section have inner sets of exactly mm elements, so that they index the M=KN02M = KN_0^2 entries of the KK products XQYQX_QY_Q of a tile, and we will use that M=β0≤10LM = \beta_0 \le10^L. For a leaf τ\tau of a tile with input arrays aa and bb, we call Φτ(a)Ψτ(b)\Phi_\tau(a)\Psi_\tau(b) the *product at τ\tau. We read its two factors from the encodings of the tile (Section 2.4.1), and by (2) and Lemma 9, (XQYQ)[w](X_QY_Q)[w] is the sum of the products at the leaves contributing to ww. The one change from Section 2 is that LL is now any integer with L≥10mL \ge10m, and we call c=L/mc = L/m the ratio.

Technique overview. The pruned recursion of Section 2.4 needs to know WW in advance, since it visits exactly the leaves that the wanted entries need. When the queries arrive one at a time, we must instead prepare for every possible output entry.

Recall that our preprocessing must take less time than it takes to write down XYXY. This means it stores fewer than one number per entry of XYXY, so each number that it stores must be useful for many different entries. Meanwhile, a query must take far fewer than the DD operations that it would take to compute the entry directly as an inner product. In Section 2, the running time had three parts: the leaves of small order, the leaves of large order, and the encodings (Lemma 11 and Section 2.4.4). Our data structure will divide these parts between the queries and the preprocessing. Each output entry uses only a few of the leaves of small order, so a query may just read them one by one. By contrast, each output entry may use many leaves of large order, but there are not too many such leaves in total, and each of them is shared by many output entries. Thus, in preprocessing we will add them up in advance, in groups which can be quickly summed during queries. The preprocessing also computes the encodings, once.

The 10m10^m leaves contributing to an output string form a cube: at each level of the inner set QQ of the output string, they choose any of the ten terms, and at each other level, they agree with the private leaf of the output string. Every one of these leaves, other than the private leaf, also contributes to other output entries. We will therefore add up parts of every cube in advance, into what we call boxes (which are themselves smaller cubes), so that a query adds up a few box values instead of 10m10^m products. For this we need a rule that cuts every cube into few boxes, with each of its leaves of large order in exactly one of them; we will prove this for our rule in Lemma 27. We will make sure that the definition of a box does not refer to the output entry, so that the same box serves many output entries, which keeps the total number of boxes small, as we will show in Lemma 29.

We also need to compute all the boxes of a tile quickly in preprocessing, and here we will use dynamic programming. Since a box is a cube, it has a fixed term at some levels, and its other levels are free, meaning all ten terms are allowed there. Fixing each of the ten terms in turn at the highest free level splits the box into ten smaller boxes, and its value is the sum of their values. Thus, in Lemma 29, we will compute the boxes from the smallest up, each from the values of smaller boxes computed before.

The order tt at which a query switches from leaves to boxes, which we call the switching order, trades off the query time (about αt\alpha^t) against the preprocessing time (about ρt\rho^t boxes per entry of the product, where ρ<1\rho< 1 is the rate at which the βd\beta_d decay). The ratio c=L/mc = L/m (which we fixed to be 19 in Section 2, but we now allow to vary) trades off the time savings against how thin the product must be. While a larger cc makes ρ\rho smaller, it also makes the encodings larger relative to DD, so that computing them stays within the time bound only when NN is a larger power of DD. With c=21c = 21 and t=m/9t = m/9, we will get the instance N≥D18N \ge D^{18} of Corollary 26, and pushing cc down toward 10 will give the upper limit for DD of our technique, namely D≤N0.1204D \le N^{0.1204} (Corollary 31).

The results

In this section, we design a data structure with the following guarantee. Let ε∗:=ln⁡4/(5ln⁡10)=0.1204…\varepsilon^* := \ln4/(5 \ln10) = 0.1204\ldots.

Theorem 24. For every ε<ε∗\varepsilon< \varepsilon^*, and every q>0q > 0, there is a γ>0\gamma> 0 such that the following holds. Given as input matrices X∈ZN×DX \in\mathbb{Z}^{N \times D} and Y∈ZD×NY \in\mathbb{Z}^{D \times N}, where 2≤D≤Nε2 \le D \le N^\varepsilon, whose entries are integers of absolute value at most NO(1)N^{O(1)}, we can preprocess them deterministically in O(N2log⁡2D/Dγ)O(N^2 \log^2 D/D^\gamma) time and space, after which any single entry (XY)[I,J](XY)[I,J] can be computed deterministically in O(Dqlog⁡D)O(D^q \log D) time.

The constant ε∗\varepsilon^* gives the upper limit for DD of our technique, and we will explain where it comes from in Section 4.4 below (after the proof of Corollary 31). To achieve the general form of the matrix theorem, where we know the positions in advance as in Section 2, we simply ask the data structure one query per position. Setting the parameters to balance the preprocessing time and the total time for all the queries gives the following.

Theorem 25. For every ε<ε∗\varepsilon< \varepsilon^* and every κ>0\kappa> 0 there is a γ>0\gamma> 0 such that the following holds. Given as input matrices X∈ZN×DX \in\mathbb{Z}^{N \times D} and Y∈ZD×NY \in\mathbb{Z}^{D \times N}, where 2≤D≤Nε2 \le D \le N^\varepsilon, whose entries are integers of absolute value at most NO(1)N^{O(1)}, as well as a set WW of at most N2/DκN^2/D^\kappa positions of an N×NN \times N matrix, the entries (XY)[I,J](XY)[I,J], (I,J)∈W(I,J) \in W, can be computed deterministically in time O(N2log⁡2D/Dγ)O(N^2 \log^2 D/D^\gamma).

The logarithmic factors in both theorems can be removed by halving γ\gamma and applying Theorem 24 with q/2q/2 in place of qq; for D=1D = 1 the bounds are trivial.

In Table 2, we list several parameter settings for Theorems 24 and 25. Theorem 5 is the entry c=19c = 19, q=0.43q = 0.43, applied to a set WW of N2/DN^2/\sqrt{D} wanted entries (that is, κ=12\kappa= \frac{1}{2}). We next state explicitly the parameter setting that we use in the introduction and in our reductions in Sections 3 and 5. It is the entry c=21c = 21, q=0.43q = 0.43 of Table 2, whose switching order is t=m/9t = m/9, as in Section 2, with the logarithmic factors absorbed into the exponents.

Corollary 26. Let N≥D18N \ge D^{18}, and let X∈ZN×DX \in\mathbb{Z}^{N \times D} and Y∈ZD×NY \in\mathbb{Z}^{D \times N} have entries of absolute value at most NO(1)N^{O(1)}. We can preprocess them deterministically in O(N2/D0.063)O(N^2/D^{0.063}) time and space, after which any single entry (XY)[I,J](XY)[I,J] can be computed deterministically in O(D0.437)O(D^{0.437}) time. Hence, for every set WW of positions of an N×NN \times N matrix, the entries (XY)[I,J](XY)[I,J], (I,J)∈W(I,J) \in W, can be computed deterministically in O(∣W∣D0.437+N2/D0.063)O(|W|D^{0.437} + N^2/D^{0.063}) time, which is O(N2/D0.063)O(N^2/D^{0.063}) whenever ∣W∣≤N2/D|W| \le N^2/\sqrt{D}.

Boxes

In this subsection, we define the boxes and prove two important facts about them. Intuitively, a box is a group of leaves that is shared by many output strings. In preprocessing we will add up the products at the leaves of each box, and then that value can help to answer many queries. In terms of the switching order tt, we will ensure that the boxes of an output string partition its leaves of order at least tt, and that there are only αt\alpha_t of them. We will thus see, in Lemmas 27 and 28, that every output entry is the sum of a few products and a few values of boxes.

Cubes. A cube is a string π=π1⋯πL\pi= \pi_1 \cdots\pi_L of LL symbols, each of which is one of the ten terms of Schönhage’s identity or a star ∗*. Its leaves are the leaves obtained by replacing each star by any of the ten terms, so a cube with ee stars has 10e10^e leaves, and a cube without stars is a single leaf.

The value of a cube π\pi is the sum of the products at its leaves,

val⁡(π):=∑τ a leaf of πΦτ(a)Ψτ(b).\operatorname{val}(\pi) := \sum_{\tau\text{ a leaf of }\pi} \Phi_\tau(a)\Psi_\tau(b).

Every output entry is the value of a cube. Indeed, recall that the entry (XQYQ)[w](X_QY_Q)[w] of an output string ww with inner set QQ is the sum of the products at the 10m10^m leaves contributing to ww. These are the leaves of the cube of ww, the cube πw\pi^w that has a star at each level where ww has z0z_0 (the levels of QQ) and the term PijP_{ij} at each level where ww has zijz_{ij}, so that (XQYQ)[w]=val⁡(πw)(X_QY_Q)[w] = \operatorname{val}(\pi^w). In Figure 6, this cube is all the rows taken together. Figure 9 shows the cube of an output string, and the boxes defined next, in the recursion tree of a small example.

The cube and the boxes of the output string $w=z_0z_{21}z_0$ in the recursion tree

Figure 9. The cube and the boxes of the output string w=z0z21z0w = z_0z_{21}z_0 in the recursion tree, for L=3L = 3 and switching order t=1t = 1. Since ww has z0z_0 at levels 1 and 3, its inner set is Q={1,3}Q = \{1, 3\} (so m=2m = 2). A query for ww reads the private leaf, which has order 0<t0 < t, and the values of the α1=18\alpha_1 = 18 boxes of ww, which contain the other 99 leaves (of orders 1 and 2). A box with a star is not a subtree: it consists of the same leaf of every subtree.

We will cut the cube of every output string into parts that are again cubes, in a way where each leaf of the cube lies in exactly one part, so that

(XQYQ)[w]=val⁡(πw)=∑parts π of πwval⁡(π),(X_QY_Q)[w] = \operatorname{val}(\pi^w) = \sum_{\text{parts }\pi\text{ of }\pi^w} \operatorname{val}(\pi),

and the value of a part will be shared by all the output strings that have it as a part. In Lemma 28 below, we will prove this equation for the parts that we will choose. There will be two kinds of parts. Each leaf of small order will be a part on its own (recall that a single leaf is a cube without stars), whereas the leaves of large order will be grouped together into larger parts, which we call boxes.

The definition of a box. The order of a leaf tells us how widely it is shared between output entries. Recall that the order is mm minus the number of levels at which the leaf chooses P0P_0, so that αd=(md)9d\alpha_d = \binom{m}{d}9^d leaves of order dd contribute to an output string, and that a leaf of larger order contributes to more output strings. Throughout, we fix the switching order tt, an integer with 0≤t≤m0 \le t \le m. The boxes will collect the leaves of order at least tt, i.e., the leaves that choose P0P_0 at most m−tm-t times, and a query will read the leaves of order below tt one by one (Section 4.3).

Before giving the formal definition, we describe the idea informally and give some examples. Consider an output string ww with inner set QQ, and a leaf τ\tau of order at least tt contributing to ww. To find the box of τ\tau, we look at the levels of QQ one at a time, from the highest down, and we stop as soon as we have seen tt levels at which τ\tau chooses a term other than P0P_0. The box of τ\tau then agrees with τ\tau everywhere, except that it has a star at every level of QQ below the level where we stopped. For instance, let m=4m=4 and t=2t=2 as in Figure 10, and suppose that τ\tau chooses the terms P12,P0,P31,P22P_{12}, P_0, P_{31}, P_{22} at the four levels ℓ1<ℓ2<ℓ3<ℓ4\ell_1 < \ell_2 < \ell_3 < \ell_4 of QQ. We see P22P_{22} at level ℓ4\ell_4 and P31P_{31} at level ℓ3\ell_3, and we stop there, so the box of τ\tau is ∗ ∗ P31 P22* \ * \ P_{31}\ P_{22} (in the first row of the figure). This box contains τ\tau along with the 99 other leaves that differ from τ\tau only at the levels ℓ1\ell_1 and ℓ2\ell_2. Similarly, for a leaf that chooses the terms P0,P23,P0,P11P_0, P_{23}, P_0, P_{11}, we stop at level ℓ2\ell_2, so its box is ∗ P23 P0 P11* \ P_{23}\ P_0\ P_{11} (in the second row of the figure). Since a box has stars at the levels that we did not reach, it contains many leaves. Moreover, although we described the box of τ\tau in terms of ww, the definition of a box below does not refer to an output string, and the same box serves many output strings.

The boxes of an output string $w$ for $m=4$ and $t=2$

Figure 10. The boxes of an output string ww for m=4m = 4 and t=2t = 2, drawn at the four levels ℓ1<ℓ2<ℓ3<ℓ4\ell_1 < \ell_2 < \ell_3 < \ell_4 of its inner set QQ (at every other level, they have the term of the private leaf of ww). Here PijP_{ij} stands for one of the nine terms other than P0P_0, and * for all ten terms. Each row is one of the six sets VV of m−t=2m-t=2 levels and stands for the 9t=819^t=81 boxes of BVB_V, one for each choice of the two terms PijP_{ij}. Read from right to left, a row stops at its second PijP_{ij}, and the levels to the left of it, those of FVF_V, carry stars. On the right are the sets ZZ of levels at which the leaves of such a box choose P0P_0, and the number 10∣FV∣10^{|F_V|} of its leaves. Every set ZZ of at most two levels appears in exactly one row (Lemma 27), so these 6⋅81=486=α26\cdot81=486=\alpha_2 boxes contain each of the α2+α3+α4=9963\alpha_2+\alpha_3+\alpha_4=9963 leaves of order at least 2 contributing to ww exactly once.

A box is a cube π=π1⋯πL\pi=\pi_1\cdots\pi_L such that (i) at most m−tm-t of its symbols are P0P_0 or stars, and (ii) every star is at a lower level than every P0P_0. That is, the symbols P0P_0 and stars of a box, read in increasing order of the levels, are

∗ ∗ ⋯ ∗⏟eP0 P0 ⋯ P0⏟f−efor some 0≤e≤f≤m−t,\underbrace{* \ * \ \cdots\ *}_{e}\quad\underbrace{P_0\ P_0\ \cdots\ P_0}_{f-e} \qquad\text{for some }0\le e\le f\le m-t,

and its other L−fL-f symbols are among the nine terms PijP_{ij}. A leaf of π\pi chooses P0P_0 at the f−ef-e levels where π\pi has P0P_0 and possibly at some of its ee star levels, and hence at most f≤m−t@f\le m-t @Winvalid? times by (i), so a box only contains leaves of order at least tt. By (ii), a box is obtained from a leaf of order at least tt by replacing its ee lowest symbols P0P_0 (rather than an arbitrary subset of them) by stars. Therefore, each leaf yields at most m+1m+1 boxes, one for each value of ee, which keeps their total number small, as we will show in Lemma 29. Boxes of this shape suffice: we will prove in Lemmas 27 and 28 that the leaves of order at least tt of an output string can be split among αt\alpha_t of them. (We will see below that the boxes of an output string all have exactly m−tm-t symbols that are P0P_0 or stars. We nonetheless allow fewer in the definition of a box, since boxes with fewer such symbols will arise as intermediate values in the dynamic program of Lemma 29.)

It is important here that a star stands for all ten terms, P0P_0 included, so that one box collects leaves of several orders (from m−fm-f to m−f+em-f+e, for a box with ee stars and f−ef-e symbols P0P_0). This is needed for fast queries. If a star stood only for the nine terms PijP_{ij}, then every box would fix the set of levels at which its leaves choose P0P_0, so an output string would need a separate box for each subset of QQ of size at most m−tm-t. That would be about 2m=D2^m=\sqrt{D} boxes when tt is small, so a query would take about D\sqrt{D} time, which gives no saving below N2N^2 when there are N2/DN^2/\sqrt{D} queries.

The boxes of an output string. We now make precise the informal rule above for finding the box of a leaf, and describe all the boxes of an output string ww with inner set QQ. Let τ\tau be a leaf of order at least tt contributing to ww, whose box we found above by going through the levels of QQ from the highest down (Figure 10). In symbols, let

Z:={ℓ∈Q:τℓ=P0}Z := \{\ell\in Q : \tau_\ell= P_0\}

(the levels at which τ\tau chooses P0P_0),

V:=Z∪{the m−t−∣Z∣ lowest levels of Q∖Z}V := Z \cup\{\text{the }m-t-|Z|\text{ lowest levels of }Q\setminus Z\}

(ZZ padded from the bottom),

FV:={ℓ∈Q:ℓ<min⁡(Q∖V)}F_V := \{\ell\in Q : \ell< \min(Q\setminus V)\}

(the levels that we have not reached).

Since the order of τ\tau is m−∣Z∣≥tm-|Z| \ge t, the set VV has exactly m−tm-t levels, namely, all the levels of QQ except the tt at which we saw a term other than P0P_0. We define FVF_V by the same formula for every V⊆QV \subseteq Q, with FV:=QF_V := Q if V=QV=Q. It is the longest initial segment of QQ contained in VV. (ZZ stands for zero, since these are the levels where τ\tau chooses P0P_0, and FF stands for free, since these are the levels where the box has a star.)

For V⊆QV \subseteq Q with ∣V∣=m−t|V|=m-t, let BV\mathcal{B}_V be the set of the 9t9^t cubes π\pi with

πℓ={∗if ℓ∈FV,P0if ℓ∈V∖FV,one of the nine terms Pijif ℓ∈Q∖V,the term Pij with wℓ=zijif ℓ∉Q.\pi_\ell= \begin{cases} * & \text{if }\ell\in F_V,\\ P_0 & \text{if }\ell\in V\setminus F_V,\\ \text{one of the nine terms }P_{ij} & \text{if }\ell\in Q\setminus V,\\ \text{the term }P_{ij}\text{ with }w_\ell=z_{ij} & \text{if }\ell\notin Q. \end{cases}

Every cube in BV\mathcal{B}_V is a box: it satisfies condition (i) of the definition because it has ∣V∣=m−t|V|=m-t symbols P0P_0 or stars, and condition (ii) because its stars are below its symbols P0P_0, since FVF_V is an initial segment of QQ. When VV is the set defined above from a leaf τ\tau, the box of τ\tau is the one in BV\mathcal{B}_V with the terms of τ\tau at the levels of Q∖VQ\setminus V. Since a box of BV\mathcal{B}_V has stars at the levels of FVF_V, it contains the leaves with any terms there, of which there are 10∣FV∣10^{|F_V|}. Notice that the set BV\mathcal{B}_V depends on ww (since it depends on QQ and on the terms at the levels outside QQ), but we omit this from the notation since ww will always be clear from context. We call the boxes in these sets, over all V⊆QV\subseteq Q with ∣V∣=m−t|V|=m-t, the boxes of ww.

There is another way to describe the boxes of ww, in terms of the leaves of order exactly tt contributing to ww. For such a leaf, consider the lowest level of QQ at which it chooses a term other than P0P_0, and replace its P0P_0 by a star at every lower level of QQ (or at every level of QQ, if t=0t = 0). The result is a box of ww, and each box of ww arises exactly once in this way. This means that ww has exactly αt\alpha_t boxes.

Every leaf of order at least tt lies in exactly one box. A leaf contributing to ww that chooses P0P_0 at the set ZZ of levels is a leaf of a box of BV\mathcal{B}_V if and only if it chooses P0P_0 at every level of V∖FVV \setminus F_V and at no level of Q∖VQ \setminus V, that is,

V∖FV⊆Z⊆V.V \setminus F_V \subseteq Z \subseteq V.

Furthermore, it is a leaf of exactly one of these boxes, namely, the one with its terms at the levels of Q∖VQ \setminus V. We will see in the following lemma that, for ∣Z∣≤m−t|Z| \leq m-t, exactly one VV satisfies this condition, namely ZZ padded from the bottom. Thus every leaf of order at least tt lands in exactly one box.

Lemma 27. Let QQ be a set of mm levels, and let 0≤t≤m0 \leq t \leq m. For every Z⊆QZ \subseteq Q with ∣Z∣≤m−t|Z| \leq m-t, there is exactly one set V⊆QV \subseteq Q with ∣V∣=m−t|V| = m-t and

V∖FV⊆Z⊆V,V \setminus F_V \subseteq Z \subseteq V,

namely ZZ together with the m−t−∣Z∣m-t-|Z| lowest levels of Q∖ZQ \setminus Z.

Proof. Let V⊆QV \subseteq Q with ∣V∣=m−t|V| = m-t and Z⊆VZ \subseteq V. We show that V∖FV⊆ZV \setminus F_V \subseteq Z holds if and only if V∖ZV \setminus Z consists of the ∣V∖Z∣=m−t−∣Z∣|V \setminus Z| = m-t-|Z| lowest levels of Q∖ZQ \setminus Z, which determines VV. If V=QV = Q, then both conditions hold: FV=QF_V = Q, so V∖FV=∅⊆ZV \setminus F_V = \varnothing\subseteq Z, and V∖ZV \setminus Z is all of Q∖ZQ \setminus Z. Otherwise, let ℓ\ell be the lowest level of Q∖VQ \setminus V. Then FVF_V consists of the levels of QQ below ℓ\ell, so V∖FV⊆ZV \setminus F_V \subseteq Z says that every level of V∖ZV \setminus Z is below ℓ\ell. Since Q∖ZQ \setminus Z is the disjoint union of V∖ZV \setminus Z and Q∖VQ \setminus V, and every level of Q∖VQ \setminus V is at least ℓ\ell, this holds if and only if V∖ZV \setminus Z consists of the lowest levels of Q∖ZQ \setminus Z.

Lemma 28. Let ww be an output string, with inner set QQ. The leaves of order at least tt contributing to ww are exactly the leaves of the boxes in ⋃V⊆Q, ∣V∣=m−tBV\bigcup_{V \subseteq Q,\ |V|=m-t} \mathcal{B}_V, the union over all V⊆QV \subseteq Q with ∣V∣=m−t|V|=m-t, and each of them is a leaf of exactly one of these boxes. Hence

(XQYQ)[w]=∑τ contributing to wof order<tΦτ(a)Ψτ(b)+∑V⊆Q∣V∣=m−t∑π∈BVval⁡(π),(X_QY_Q)[w] = \sum_{\substack{\tau\ \text{contributing to }w\\\text{of order}<t}} \Phi_\tau(a)\Psi_\tau(b) + \sum_{\substack{V\subseteq Q\\|V|=m-t}} \sum_{\pi\in\mathcal{B}_V}\operatorname{val}(\pi),

a sum of ∑d=0t−1αd\sum_{d=0}^{t-1}\alpha_d products and αt\alpha_t values of boxes.

Proof. Every leaf of a box of BV\mathcal{B}_V agrees with the private leaf of ww outside QQ, so it contributes to ww, and it chooses P0P_0 at most ∣V∣=m−t|V|=m-t times, so its order is at least tt. Conversely, a leaf τ\tau contributing to ww, of order at least tt, chooses P0P_0 at a set Z⊆QZ\subseteq Q of at most m−tm-t levels, and as we saw above, it is a leaf of a box of BV\mathcal{B}_V if and only if V∖FV⊆Z⊆VV\setminus F_V\subseteq Z\subseteq V, and then of exactly one such box. By Lemma 27, exactly one VV satisfies this condition. The desired equation follows, since (XQYQ)[w](X_QY_Q)[w] is the sum of the products at the leaves contributing to ww. Finally, αd\alpha_d leaves of order dd contribute to ww, and there are (mm−t)\binom{m}{m-t} sets VV with 9t9^t boxes each, i.e., (mm−t)9t=(mt)9t=αt\binom{m}{m-t}9^t=\binom{m}{t}9^t=\alpha_t boxes in all (as many as the leaves of order exactly tt contributing to ww, although they cover its leaves of every order from tt to mm).

The data structure, in terms of the parameters

In this subsection, we assemble the boxes into our data structure and bound its costs in terms of the parameters mm, LL, and tt. We will then choose settings for the parameters in Section 4.4. We begin by recalling two notions from Section 2 that the data structure builds on.

The tiling of Section 2.3.4 cuts the product XYXY into tiles. A row block is N0N_0 consecutive rows of XX, a column block is N0N_0 consecutive columns of YY, and a tile is a band of K0=⌊K⌋K_0 = \lfloor\sqrt{K}\rfloor consecutive row blocks together with a band of K0K_0 consecutive column blocks. One run of the recursion computes all K02K_0^2 block products of a tile at once, each as the product XQYQX_QY_Q for its own subset QQ. The encodings of Section 2.4.1 are the arrays of the 10L10^L numbers Φτ(a)\Phi_\tau(a), one for each leaf τ\tau, computed from the input array aa of a row band, and similarly the numbers Ψτ(b)\Psi_\tau(b) computed from the input array bb of a column band. We compute an encoding once per band and share it among all the tiles that use that band, and the product at a leaf of a tile is the product of its two encoded numbers.

Our data structure consists of three components:

  • the list of the K02K_0^2 subsets QQ assigned to the block products of a tile (recall that this list is the same for every tile),

  • the encodings of all row bands and all column bands, and

  • for every tile, the values of all its boxes (the boxes are the same strings in every tile, but their values depend on the input arrays of the tile).

To answer a query for an entry (XY)[I,J](XY)[I,J], the data structure performs the following three steps:

  1. Find the tile that contains (I,J)(I,J), the subset QQ of its block product, and the output string ww of (I,J)(I,J).

  2. Add up the products at the leaves of order below tt contributing to ww, by reading the two factors of each product from the encodings of the tile.

  3. Add to this the values of the αt\alpha_t boxes of ww, which are stored for the tile.

By Lemma 28, the result is (XQYQ)[w]=(XY)[I,J](X_QY_Q)[w] = (XY)[I,J]. We will give the details of the query, as well as the preprocessing, in the proof of Theorem 30 below.

The encodings are indexed by the leaves (Section 2.4.1), and for each tile we store its boxes, with their values, in a standard trie on their strings of LL symbols. Thus reading the product at a leaf, or looking up or inserting a box, takes O(L)O(L) operations.

We will next show that there are at most m+1m + 1 times as many boxes as there are leaves of order at least tt, and that the dynamic program described in the technique overview computes their values (a box with ee stars being the sum of ten boxes with e−1e - 1 stars).

Lemma 29. There are at most (m+1)∑d=tmβd(m + 1)\sum_{d=t}^{m}\beta_d boxes. Given the two encodings of a tile, we can compute the values of all these boxes, and store them in the trie for that tile, in O(L)O(L) time and space per box.

Proof. The count. A box in which ff of the symbols are P0P_0 or stars is obtained from a leaf of order m−fm-f (namely the leaf we get by replacing its stars with P0P_0) by turning the ee lowest symbols P0P_0 of that leaf into stars, for some e≤fe \leq f. Thus, such a box can be specified by choosing the ff levels of these symbols, the number ee, and a term other than P0P_0 at each of the other L−fL-f levels. There are hence (f+1)(Lf)9L−f=(f+1)βm−f(f+1)\binom{L}{f}9^{L-f} = (f+1)\beta_{m-f} such boxes, and summing over f≤m−tf \leq m-t gives the upper bound on the number of boxes.

The values. We compute the values of the boxes in increasing order of their number of stars. The boxes without stars are the leaves with at most m−tm-t symbols P0P_0, and the value of each of them is the product of its two numbers in the encodings.

For a box π\pi with e≥1e \ge1 stars, let ℓ\ell be the highest level at which π\pi has a star. The leaves of π\pi are the leaves of the ten strings π[ℓ←λ]\pi[\ell\leftarrow\lambda] obtained by replacing that star by a term λ\lambda, and each of these strings is again a box, with e−1e-1 stars. Indeed, if λ=P0\lambda= P_0, then the number of symbols that are P0P_0 or stars stays the same, and the new P0P_0 at level ℓ\ell is above all the remaining stars. If λ\lambda is any other term, then that number decreases by one, and every star is still below every P0P_0. Thus conditions (i) and (ii) in the definition of a box hold in both cases. (We expand the highest star because replacing a lower star by P0P_0 would leave a star above a P0P_0, which is not a box.) Hence we compute

val⁡(π)=∑λval⁡(π[ℓ←λ])\operatorname{val}(\pi) = \sum_{\lambda} \operatorname{val}(\pi[\ell\leftarrow\lambda])

with ten lookups in the trie, in O(L)O(L) operations. Generating the boxes with ee stars and inserting them into the trie also takes O(L)O(L) operations per box, and adds at most LL vertices per box.

See Figure 7 for an illustration of these counts (in that figure, the switching order tt is set to m/9m/9). At every order dd, the pruned recursion of Section 2.4 visits at most min⁡{∣U∣αd,βd}\min\{|U|\alpha_d,\beta_d\} leaves of order dd in a tile whose wanted output strings form the set UU (see the proof of Lemma 11), the smaller of the two bounds at that order. The data structure cannot do this, since UU is not known in advance. Instead, a query computes αd\alpha_d products at every order d<td < t, and looks up αt\alpha_t boxes at the order tt. The data structure also stores at most (m+1)∑d≥tβd(m+1)\sum_{d \ge t}\beta_d boxes per tile, even if they are not used by a query. The preprocessing time is therefore dominated by the sum ∑d≥tβd\sum_{d \ge t}\beta_d, and hence by how fast the βd\beta_d decay. Let

ρ:=9mL−m+1,\rho:= \frac{9m}{L-m+1},

which is less than 1 since L≥10mL \ge10m. It plays the role of 12\frac{1}{2} in (5): for 1≤d≤m1 \le d \le m,

βdβd−1=9(m−d+1)L−m+d≤9mL−m+1=ρ,soβd≤ρdM.(7)\frac{\beta_d}{\beta_{d-1}} = \frac{9(m-d+1)}{L-m+d} \le\frac{9m}{L-m+1} = \rho,\qquad\text{so}\qquad\beta_d \le\rho^d M. \tag*{(7)}

The closer the ratio c=L/mc=L/m is to 10, the closer ρ\rho is to 1, and the more boxes the preprocessing has to compute. This is one side of the trade-off mentioned at the beginning of this section between the time savings and how thin the product must be.

We can now bound the costs. The theorem below assumes that N≥KN0N \ge\sqrt{K}N_0. Since a tile spans K0N0≤KN0K_0N_0 \le\sqrt{K}N_0 rows and as many columns of the N×NN \times N product XYXY, this ensures that a tile fits inside XYXY, so padding NN to a multiple of K0N0K_0N_0 at most doubles it. We checked the same requirement in Section 2.4.4, where it was the first of the two consequences of N≥D18N \ge D^{18}. Here it will also follow, in Section 4.4, from the requirement that computing the encodings takes at most N2/DγN^2/D^\gamma time, since 10L≥M10^L \ge M.

Theorem 30. Let m≥1m \ge1, D=4mD=4^m, L≥10mL \ge10m, 0≤t≤m0 \le t \le m, and N≥KN0N \ge\sqrt{K}N_0. Given as input matrices X∈ZN×DX \in\mathbb{Z}^{N \times D} and Y∈ZD×NY \in\mathbb{Z}^{D \times N}, whose entries are integers of absolute value at most NO(1)N^{O(1)}, we can preprocess them deterministically in time and space

O(Lmρt1−ρ−N2+N⋅10LKN0).(8)O\left(Lm\frac{\rho^t}{1-\rho} - N^2 + \frac{N\cdot10^L}{\sqrt{K}N_0}\right). \tag*{(8)}

After this, any single entry (XY)[I,J](XY)[I,J] can be computed deterministically in O(L∑d=0tαd)O\left(L\sum_{d=0}^{t}\alpha_d\right) time. In particular, for every set WW of positions of an N×NN \times N matrix, the entries (XY)[I,J](XY)[I,J], (I,J)∈W(I,J) \in W, can be computed deterministically in time

O(L∣W∣∑d=0t−1αd+Lmρt1−ρN2+N⋅10LKN0)(9)O\left(L|W|\sum_{d=0}^{t-1}\alpha_d+Lm\frac{\rho^t}{1-\rho}N^2+\frac{N\cdot10^L}{\sqrt{K}N_0}\right) \tag*{(9)}

The constants hidden in the O(⋅)O(\cdot) depend only on the exponent in NO(1)N^{O(1)}.

Proof. Preprocessing. We tile the product as in Section 2.3.4, padding NN to a multiple of K0N0K_0N_0, which at most doubles it since N≥KN0≥K0N0N\ge\sqrt{K}N_0\ge K_0N_0, and we store the K02K_0^2 subsets, in O(KL)≤O(10L)O(KL)\le O(10^L) operations. We then form and encode the input arrays of all row bands and column bands, at most 4N/(KN0)4N/(\sqrt{K}N_0) of them since K0≥K/2K_0\ge\sqrt{K}/2. Each has at most KN0D≤7LKN_0D\le7^L nonzero entries, so we form it in O(L⋅7L)O(L\cdot7^L) operations, and its encoding takes O(10L)O(10^L) operations (Section 2.4.1). This is the last term of (8). Finally, we compute the values of all the boxes of each of the at most 4N2/M4N^2/M tiles, where M=KN02M=KN_0^2 is the number of output entries of a tile. By Lemma 29, this takes O(L(m+1)∑d≥tβd)O(L(m+1)\sum_{d\ge t}\beta_d) time and space per tile, and ∑d≥tβd≤Mρt/(1−ρ)\sum_{d\ge t}\beta_d\le M\rho^t/(1-\rho) by (7), which gives the first term.

Query. Given (I,J)(I,J), we find its tile from the bands of row II and column JJ, the subset QQ of its block product, and its output string ww (whose variables at the levels outside QQ we read off the row and column of (I,J)(I,J) within the block product), all in O(L)O(L) operations (Section 2.4.4). We then compute (XQYQ)[w](X_QY_Q)[w] as the sum in Lemma 28, which has two parts.

The first part is the sum of the products at the leaves of order below tt contributing to ww. Each of these leaves is obtained from the private leaf of ww, which has P0P_0 at every level of QQ, by picking fewer than tt of those levels and replacing P0P_0 with one of the nine other terms at each of them. We enumerate them, and for each such leaf τ\tau we look up its two numbers Φτ(a)\Phi_\tau(a) and Ψτ(b)\Psi_\tau(b) in the encodings of the tile and multiply them. The second part is the sum of the values of the boxes of ww: for every V⊆QV\subseteq Q with ∣V∣=m−t|V|=m-t and every box of BVB_V, we look up its value in the trie of the tile. In all, these are ∑d=0t−1αd+αt\sum_{d=0}^{t-1}\alpha_d+\alpha_t numbers, and we find each of them in O(L)O(L) operations, including forming its leaf or its box from the private leaf. Enumerating them also takes O(L)O(L) operations per number. By Section 2.4.4, the sum is (XY)[I,J](XY)[I,J]. For a set WW, we ask ∣W∣|W| queries, which gives (9).

Word size. As in Section 2.4.4, every number in an encoding is a sum of entries of the input array with coefficients 0,±10,\pm1, and every value we compute is a sum of at most 10m10^m products of two such numbers. Since N≥N0=3L−mN\ge N_0=3^{L-m} and L≥10mL\ge10m, we have 10L≤N5/210^L\le N^{5/2}, so, as in Section 2.4.4, all the values are NO(1)N^{O(1)} in absolute value, and every integer we use has O(log⁡N)O(\log N) bits.

Choosing the parameters

We now choose the parameters in Theorem 30 and prove the results of Section 4.1. In other words, we do the arithmetic and bookkeeping to derive the explicit exponents from Theorem 30. We first do the calculation in full for a single choice of the parameters, L=21mL=21m and t=⌈m/9⌉t=\lceil m/9\rceil, which proves Corollary 26. We then say what changes for other choices, which gives Theorems 24 and 25 and the entries of Table 2.

Proof of Corollary 26. Setting up. Let m:=⌈log⁡4D⌉m:=\lceil\log_4D\rceil, and pad the inner dimension to 4m<4D4^m<4D with zero columns of XX and zero rows of YY. This changes no entry of XYXY, and it changes DD by a factor less than 4, which only affects the constants. So from now on D=4mD=4^m, and since the original DD was larger than 4m−14^{m-1}, the assumption N≥D18N \ge D^{18} now reads N≥418(m−1)N \ge4^{18(m-1)}. Let L:=21mL := 21m and t:=⌈m/9⌉t := \lceil m/9\rceil. We will apply Theorem 30 with these parameters, and we will verify its condition N≥KN0N \ge\sqrt{K}N_0 below, in the step on the encodings.

Boxes. We have ρ=9m/(L−m+1)=9m/(20m+1)<9/20\rho= 9m/(L-m+1)=9m/(20m+1)<9/20, so 1/(1−ρ)<21/(1-\rho)<2, and since t≥m/9t \ge m/9, also ρt≤(9/20)m/9=D−γ\rho^t \le(9/20)^{m/9}=D^{-\gamma}, where γ:=ln⁡(20/9)/(9ln⁡4)=0.0640…\gamma:= \ln(20/9)/(9\ln4)=0.0640\ldots. Hence the first term of (8) is O(m2N2/Dγ)O(m^2N^2/D^\gamma).

Queries. A query reads ∑d≤tαd\sum_{d\le t}\alpha_d numbers, and we bound this sum as in the proof of Lemma 11. Since 9d=72d8−d≤72t8−d9^d=72^d8^{-d}\le72^t8^{-d} for d≤td\le t, and t<m/9+1t<m/9+1,

∑d=0t(md)9d≤72t∑d=0m(md)8−d=72t(98)m<72⋅(72⋅(98)9)m/9=72Dq.\sum_{d=0}^{t}\binom{m}{d}9^d \le72^t\sum_{d=0}^{m}\binom{m}{d}8^{-d}=72^t\left(\frac{9}{8}\right)^m<72\cdot\left(72\cdot\left(\frac{9}{8}\right)^9\right)^{m/9}=72D^q.

where q:=ln⁡(72⋅(9/8)9)/(9ln⁡4)=0.4277…q:=\ln(72\cdot(9/8)^9)/(9\ln4)=0.4277\ldots. Hence a query takes O(LDq)=O(mDq)O(LD^q)=O(mD^q) time.

Encodings. It remains to show that the last term of (8) is at most N2/DγN^2/D^\gamma, and that N≥KN0N\ge\sqrt{K}N_0. Both follow from

Dγ⋅10LKN0≤N,(10)\frac{D^\gamma\cdot10^L}{\sqrt{K}N_0}\le N, \tag*{(10)}

the first by rearranging, and the second because 10L≥M=KN0210^L\ge M=KN_0^2 and Dγ≥1D^\gamma\ge1. As in Section 2.4.4, we compare mm-th powers by comparing their bases. We have Dγ=(20/9)m/9D^\gamma=(20/9)^{m/9}, 10L=1021m10^L=10^{21m}, and N0=320mN_0=3^{20m}, and the standard bound (nk)≥1n+1nnkk(n−k)n−k\binom{n}{k}\ge\frac{1}{n+1}\frac{n^n}{k^k(n-k)^{n-k}} gives K=(21mm)≥121m+1(2121/2020)mK=\binom{21m}{m}\ge\frac{1}{21m+1}(21^{21}/20^{20})^m. Hence the left-hand side of (10) is at most 21m+1⋅Λm\sqrt{21m+1}\cdot\Lambda^m, where

Λ:=1021⋅(20/9)1/9(2121/2020)1/2⋅320=4.198…⋅1010.\Lambda:=\frac{10^{21}\cdot(20/9)^{1/9}}{(21^{21}/20^{20})^{1/2}\cdot3^{20}}=4.198\ldots\cdot10^{10}.

We now use the assumption N≥D18N\ge D^{18}. Its base 418=6.871…⋅10104^{18}=6.871\ldots\cdot10^{10} is larger than Λ\Lambda by a factor of more than 1.63. Since N≥418(m−1)N\ge4^{18(m-1)}, the inequality (10) therefore holds whenever 1.63m≥41821m+11.63^m\ge4^{18}\sqrt{21m+1}, which is the case for all m≥60m\ge60. (For m<60m<60, DD is bounded by a constant, and the corollary holds trivially.)

Conclusion. For m≥60m\ge60, Theorem 30 thus applies. The preprocessing takes O(m2N2/Dγ)O(m^2N^2/D^\gamma) time and space, and a query takes O(mDq)O(mD^q) time. Since m=O(log⁡D)m=O(\log D) and the exponents γ−0.063\gamma-0.063 and 0.437−q0.437-q are positive, we have m2=O(Dγ−0.063)m^2=O(D^{\gamma-0.063}) and m=O(D0.437−q)m=O(D^{0.437-q}), which gives the bounds O(N2/D0.063)O(N^2/D^{0.063}) and O(D0.437)O(D^{0.437}) of the corollary. The bound for a set WW follows by asking ∣W∣|W| queries.

Other choices of the parameters. The numbers 21 and 19\frac{1}{9} did not play a special role in this proof, and the same calculation works with L=⌈cm⌉L=\lceil cm\rceil and t=⌈θm⌉t=\lceil\theta m\rceil for any constants c>10c>10 and $0<\theta<0.9$. This gives Corollary 31 below, which we use for the left half of Table 2, with the cc of the row and the θ\theta that gives the qq of the column (θ=19\theta=\frac{1}{9} for $q=0.43). To state it, let H(x):=−xln⁡x−(1−x)ln⁡(1−x)H(x):=-x\ln x-(1-x)\ln(1-x) be the entropy function (with natural logarithms), let

Λ:=10ce−12cH(1/c)3−(c−1)4γ\Lambda:=10^c e^{-\frac{1}{2}cH(1/c)}3^{-(c-1)}4^\gamma

be the general form of the base Λ\Lambda above, and let

Rc(γ):=ln⁡4ln⁡Λ=ln⁡4cln⁡10−12cH(1/c)−(c−1)ln⁡3+γln⁡4.(11)R_c(\gamma):=\frac{\ln4}{\ln\Lambda}=\frac{\ln4}{c\ln10-\frac{1}{2}cH(1/c)-(c-1)\ln3+\gamma\ln4}. \tag*{(11)}

Corollary 31. Let c>10c > 10 and 0<θ<0.90 < \theta< 0.9, let ρc:=9/(c−1)\rho_c := 9/(c - 1), and let

γ:=θln⁡(1/ρc)ln⁡4>0andq:=H(θ)+θln⁡9ln⁡4.\gamma:= \frac{\theta\ln(1/\rho_c)}{\ln4} > 0 \qquad\text{and}\qquad q := \frac{H(\theta) + \theta\ln9}{\ln4}.

Given as input matrices X∈ZN×DX \in\mathbb{Z}^{N \times D} and Y∈ZD×NY \in\mathbb{Z}^{D \times N} whose entries are integers of absolute value at most NO(1)N^{O(1)}, where 2≤D≤Nε2 \le D \le N^\varepsilon and ε<Rc(γ)\varepsilon< R_c(\gamma), with RcR_c as in (11), we can preprocess them deterministically in O(N2log⁡2D/Dγ)O(N^2 \log^2 D/D^\gamma) time and space, after which any single entry (XY)[I,J](XY)[I,J] can be computed deterministically in O(Dqlog⁡D)O(D^q \log D) time. The constants hidden in the O(⋅)O(\cdot) depend on cc, θ\theta, and ε\varepsilon.

Moreover, Rc(0)R_c(0) increases to ε∗=ln⁡4/(5ln⁡10)=0.1204…\varepsilon^* = \ln4/(5 \ln10) = 0.1204\ldots as cc decreases to 10.

Proof. We repeat the proof of Corollary 26 with L:=⌈cm⌉L := \lceil cm\rceil and t:=⌈θm⌉t := \lceil\theta m\rceil. After the padding, the assumption D≤NεD \le N^\varepsilon now reads N≥4(m−1)/εN \ge4^{(m-1)/\varepsilon}. For the boxes, ρ<ρc\rho< \rho_c gives ρt≤ρcθm=D−γ\rho^t \le\rho_c^{\theta m} = D^{-\gamma}. For the queries, the same calculation with x:=(1−θ)/θx := (1-\theta)/\theta in place of 8, where 9x>19x > 1 because θ<0.9\theta< 0.9, gives ∑d≤tαd≤(9x)t(1+1/x)m=O(Dq)\sum_{d \le t} \alpha_d \le(9x)^t(1+1/x)^m = O(D^q). For the encodings, the same bound on the binomial coefficient, (nk)≥enH(k/n)/(n+1)\binom{n}{k} \ge e^{nH(k/n)}/(n+1), shows that the left-hand side of (10) is O(m⋅Λm)O(\sqrt{m}\cdot\Lambda^m). As ε<Rc(γ)\varepsilon< R_c(\gamma) says that Λ<41/ε\Lambda< 4^{1/\varepsilon}, the inequality (10) thus holds once mm exceeds a constant depending on cc, θ\theta, and ε\varepsilon, and for smaller mm the corollary again holds trivially.

Finally, a direct calculation shows that for γ=0\gamma= 0, ln⁡Λ\ln\Lambda increases with cc and tends to 5ln⁡105\ln10 as cc decreases to 10, by the identity H(1/10)+(9/10)ln⁡9=ln⁡10H(1/10) + (9/10)\ln9 = \ln10. Hence Rc(0)R_c(0) increases to ln⁡4/(5ln⁡10)=ε∗\ln4/(5\ln10) = \varepsilon^*.

Where ε∗\varepsilon^* comes from. The identity H(1/10)+(9/10)ln⁡9=ln⁡10H(1/10) + (9/10)\ln9 = \ln10 says that (10mm)99m\binom{10m}{m}9^{9m}, the largest term of the binomial expansion of (1+9)10m(1+9)^{10m}, is 1010m10^{10m} up to polynomial factors. So at c=10c=10 a tile has M≈10LM \approx10^L output entries, as many as the recursion has leaves, and the encodings cost N⋅10L/M≈N⋅10L/2N \cdot10^L/\sqrt{M} \approx N \cdot10^{L/2}, which is below N2N^2 exactly when N≥10L/2=D1/ε∗N \ge10^{L/2} = D^{1/\varepsilon^*}.

Proof of Theorem 24. Let ε<ε∗\varepsilon< \varepsilon^* and q>0q > 0. Choose c>10c > 10 with Rc(0)>εR_c(0) > \varepsilon (Corollary 31), and then θ∈(0,0.9)\theta\in(0,0.9) small enough that (H(θ)+θln⁡9)/ln⁡4<q(H(\theta) + \theta\ln9)/\ln4 < q and Rc(θln⁡(1/ρc)/ln⁡4)>εR_c(\theta\ln(1/\rho_c)/\ln4) > \varepsilon. This is possible since, as θ→0\theta\to0, the first expression tends to 0 and the second to Rc(0)R_c(0). Corollary 31 with these cc and θ\theta gives the theorem.

Proof of Theorem 25. Apply Theorem 24 with q:=κ/2q := \kappa/2, and ask one query for each position of WW. As ∣W∣≤N2/Dκ|W| \le N^2/D^\kappa, this takes O(N2log⁡2D/Dγ+∣W∣Dκ/2log⁡D)=O(N2log⁡2D/Dγ′)O(N^2 \log^2 D/D^\gamma+ |W|D^{\kappa/2}\log D) = O(N^2 \log^2 D/D^{\gamma'}) time, where γ′:=min⁡{γ,κ/2}\gamma' := \min\{\gamma,\kappa/2\}.

With Corollary 31 in place of Theorem 24, the same argument gives explicit exponents, which we use for the right half of Table 2, with the θ\theta at which γ=κ−q\gamma= \kappa- q. The ε\varepsilon of a row of the table is the smallest Rc(γ)R_c(\gamma) over its entries.

Corollary 32. Let cc, θ\theta, γ\gamma, qq, XX, YY, DD, and ε\varepsilon be as in Corollary 31, and let κ>0\kappa> 0. For every set WW of at most N2/DκN^2/D^\kappa positions of an N×NN \times N matrix, the entries (XY)[I,J](XY)[I,J], (I,J)∈W(I,J) \in W, can be computed deterministically in time

O(N2log⁡2D(D−γ+Dq−κ)),O\left(N^2 \log^2 D\left(D^{-\gamma} + D^{q-\kappa}\right)\right),

a saving of Dmin⁡{γ,κ−q}D^{\min\{\gamma,\kappa-q\}}, up to logarithmic factors, over the size N2N^2 of the product.

Further reductions

This section presents the remaining algorithmic results of the introduction: directed unweighted APSP (Section 5.1), the real-valued versions of 3SUM, APSP, and Exact Triangle (Section 5.2), the weighted kk-Clique problems (Section 5.3), and the refutation of the rectangular hinted OMv conjectures of van den Brand, Nanongkai, and Saranurak [155] (Section 5.4). Each result but the last composes a known reduction with the algorithms of Sections 3 and 4; the last applies the data structure of Section 4 directly. We cite the reduction we use in each case and modify it only where our parameter regime requires it, saying what changes.

What we use. We recall the three results of Sections 3 and 4 that the reductions plug into.

  • Exact Triangle (Section 3.2) asks whether a complete tripartite graph with parts A,B,CA,B,C of nn vertices and integer edge weights of absolute value at most nνn^\nu has a triangle of weight zero. Theorem 19 solves it deterministically in O(n3−εTlog⁡n)≤O(n3−εT)O(n^{3-\varepsilon_T}\log n) \le O(n^{3-\varepsilon_T}) time, where ε′=0.00175\varepsilon' = 0.00175 and εT=0.0017\varepsilon_T = 0.0017, and Theorem 22 derives from this a deterministic O~(n3−ε′/3)\widetilde{O}(n^{3-\varepsilon'/3})-time algorithm for the (min⁡,+)(\min,+)-product of two n×nn \times n matrices with integer entries of absolute value nO(1)n^{O(1)}.

  • Lop-AE-SparseTri(n,D)(n,D) and #Lop-AE-SparseTri(n,D)(n,D) (Definitions 13 and 14) are given a tripartite graph with parts AA and BB of nn vertices and a middle part of at most DD vertices, together with a set WW of query pairs (a,b)∈A×B(a,b) \in A \times B, and ask for every query pair in WW whether aa and bb have a common neighbor in the middle part, or for the counting version, how many they have. Corollary 16 solves both deterministically in O(∣W∣D0.437+n2/D0.063)O(|W|D^{0.437} + n^2/D^{0.063}) time when n≥D18n \ge D^{18}. Theorem 17 reduces Exact Triangle to Lop-AE-SparseTri deterministically by hashing the weights modulo a prime.

  • Corollary 26 is the data structure behind Corollary 16. Given X∈ZN×DX \in\mathbb{Z}^{N \times D} and Y∈ZD×NY \in\mathbb{Z}^{D \times N} with N≥D18N \ge D^{18} and entries of absolute value NO(1)N^{O(1)}, it preprocesses them deterministically in O(N2/D0.063)O(N^2/D^{0.063}) time, after which it computes any entry of XYXY in O(D0.437)O(D^{0.437}) time. Section 5.2 applies it to matrices whose entries are not 0/1, and Section 5.4 uses its queries online.

The algorithms of Sections 5.1, 5.3, and 5.4 are deterministic. Those of Section 5.2 are randomized (Las Vegas), because the reductions of [?] that they use as black boxes are randomized.

Directed APSP with small integer weights

Let ω(1,r,1)\omega(1,r,1) denote the exponent of multiplying an n×nrn \times n^r matrix by an nr×nn^r \times n matrix, and let μ\mu be the solution of ω(1,μ,1)=1+2μ\omega(1,\mu,1)=1+2\mu. Then μ≥12\mu\ge\frac{1}{2}, since ω(1,μ,1)≥2\omega(1,\mu,1) \ge2, and μ<0.5275\mu< 0.5275 by the bounds of [10]. Zwick’s algorithm [172] solves APSP in directed unweighted graphs in O~(n2+μ)\widetilde{O}(n^{2+\mu}) time, and the Directed Unweighted APSP hypothesis [66, ?, 82] asserts that no algorithm is polynomially faster. We refute this in Theorem 34.

We revisit Theorem 3.1 of Chan, Vassilevska Williams, and Xu [66], which is just a presentation of Zwick’s algorithm [172] as a reduction. Zwick’s algorithm is typically used in its randomized form because the proof is simple, so the reduction in [66] was stated in its randomized form. However, following an argument by Yuster and Zwick [171], Section 8, the reduction has a deterministic version as well:

Theorem 33 (Zwick’s algorithm as a deterministic reduction [172, 67]). If the (min⁡,+)(\min,+)-product of an n×nμn \times n^\mu matrix by an nμ×nn^\mu\times n matrix, both with integer entries of absolute value at most O~(n1−μ)\widetilde{O}(n^{1-\mu}), can be computed in O(n2+μ−ε1)O(n^{2+\mu-\varepsilon_1}) time for a constant ε1>0\varepsilon_1 > 0, then APSP in directed nn-vertex graphs with integer weights of absolute value polylog nn and no negative cycles can be solved in O(n2+μ−ε′′)O(n^{2+\mu-\varepsilon''}) time for a constant ε′′>0\varepsilon'' > 0 that depends on ε1\varepsilon_1 and μ\mu. If the algorithm for the product is deterministic, then so is the algorithm for APSP.

The randomized proof of [67] follows the randomized version of Zwick’s algorithm, which takes random samples of vertices to hit the long shortest paths, so the algorithm that it produces is randomized. Zwick [172], Sections 6 and 7 also gives a deterministic version of his algorithm, which constructs the hitting sets (his bridging sets) from witnesses of the products by a greedy hitting-set computation, within the same running time up to polylogarithmic factors, and Yuster and Zwick [170], Section 8 announce, without details, a faster deterministic construction of bridging sets for their distance oracle. Zwick’s construction lists a path with ss vertices for each of the n2n^2 pairs, which is more than the reduction can afford when ss is large. We therefore give a deterministic version of the reduction, which lists only walks with an endpoint in the previous hitting set, in the spirit of [170]. We believe that this is likely what Yuster and Zwick [170] had in mind.

Proof of Theorem 33. The deterministic algorithm follows the randomized reduction, with two changes. It constructs the hitting sets deterministically, by a hierarchy of bridging sets in the manner of Zwick [172], Section 6, and it computes the distances that this construction needs only to and from small sets of vertices, like the distance oracle of Yuster and Zwick [170]. The hypothesized algorithm for the (min⁡,+)(\min,+)-product is used only for the values of its products. (This is convenient but not essential: the witness-finding method of Seidel [145] and Alon, Galil, Margalit, and Naor [15, 91], derandomized by Alon and Naor [24] and applied to (min⁡,+)(\min,+)-products by Zwick [172], Lemma 3.3, uses the product algorithm only on submatrices, so any deterministic algorithm for the product can be made to return witnesses at a polylogarithmic cost.) The price is a factor nγn^\gamma in the running time, for an arbitrarily small constant γ>0\gamma> 0, which the polynomial saving of the hypothesis absorbs. Throughout, MM is the largest absolute weight, which is polylogarithmic, and O~\widetilde{O} hides polylogarithmic factors.

Bridges. For vertices uu and vv, let δ(u,v)\delta(u,v) be the distance from uu to vv, and let η(u,v)\eta(u,v) be the smallest number of edges on a shortest path from uu to vv. Every subpath of a shortest path with the fewest edges is again a shortest path with the fewest edges. For a threshold tt and a constant CC, a set B⊆VB \subseteq V is a (t,C)(t,C)-bridge if every pair (u,v)(u,v) with η(u,v)≥t\eta(u,v) \ge t has a shortest walk from uu to vv that passes through a vertex of BB and has at most Cη(u,v)C\eta(u,v) edges. This is Zwick’s strong bridging set with a constant-factor slack in the number of edges, and with walks in place of paths because a shortest walk may run around zero-weight cycles. Let R:=⌈nγ⌉R := \lceil n^\gamma\rceil (so RR is tiny!) and ti:=min⁡{Ri,n}t_i := \min\{R^i,n\} for i=0,1,…,⌈1/γ⌉i = 0,1,\ldots,\lceil1/\gamma\rceil. We shall construct (ti,Ci)(t_i,C_i)-bridges BiB_i with ∣Bi∣=O~(n/ti)|B_i| = \widetilde{O}(n/t_i), starting with B0=VB_0 = V and C0=1C_0 = 1, where CiC_i is a constant that depends only on ii. The slack CiC_i grows by a constant factor from each level to the next. This is why the levels are a factor nγn^\gamma apart, so that there are only O(1/γ)O(1/\gamma) of them, rather than a factor 3/23/2 apart as in Zwick’s algorithm.

The tables Ei(T,H)E_i(T,H). The distances to and from small sets of vertices are computed by the following routine. Given the bridges B0,…,BiB_0,\ldots,B_i, a set TT of O~(n/ti)\widetilde{O}(n/t_i) target vertices, and a horizon HH with ti≤H≤O(Rti)t_i \le H \le O(Rt_i), the routine returns two tables, Ei(T,H)[V,T]E_i(T,H)[V,T] and Ei(T,H)[T,V]E_i(T,H)[T,V], with three properties: every finite entry is the weight of a walk that the routine represents explicitly, as described next; every represented walk has O(H)O(H) edges, with a constant that depends on ii; and the entry for (u,v)(u,v) is δ(u,v)\delta(u,v) whenever η(u,v)≤H\eta(u,v) \le H. The products in the routine are computed with the deterministic (min⁡,+)(\min,+)-product algorithm with witnesses of [172], which finds the witnesses deterministically by the method of [24]. A witness of an entry (u,v)(u,v) of a product is an index kk at which its minimum is attained, and we store it with the entry. The walk that the entry represents is then the concatenation of the walks represented by the entries (u,k)(u,k) and (k,v)(k,v) of the two factors, and it is listed, when needed, by following the stored witnesses recursively down to the entries of the weight matrix, which represent single edges; this takes O(H)O(H) time, because the walk is a concatenation of O(H)O(H) such entries. For a product in which one dimension is nn and the other two are at most qq, with entries of absolute value at most WW, that algorithm takes O~(Wnqω−1)\widetilde{O}(Wnq^{\omega-1}) time, by cutting the product into n/qn/q square products.

The routine for level 00 takes the weight matrix with zeroes on the diagonal and squares it O(log⁡H)O(\log H) times, with the entries larger than 2HM2HM replaced by ∞\infty, and keeps the rows and columns of TT. The routine for level i≥1i \ge1 first calls the routine for level i−1i-1 with the target set T∪BiT \cup B_i and the horizon L:=2CitiL := 2C_i t_i. This call is okay, because ∣T∪Bi∣=O~(n/ti)≤O~(n/ti−1)|T \cup B_i| = \widetilde{O}(n/t_i) \le\widetilde{O}(n/t_{i-1}) and L=O(Rti−1)L = O(Rt_{i-1}). Let FF be the pair of tables that it returns; they have exact distances for the pairs with η≤L\eta\le L, and they have the entries of V×(T∪Bi)V \times(T \cup B_i) and (T∪Bi)×V(T \cup B_i) \times V. Let QQ be the smallest power of two above H/tiH/t_i, and set the diagonal of F[Bi,Bi]F[B_i,B_i] to zero. The routine computes, by repeated squaring,

Ei(T,H)[V,T]:=min⁡{F[V,T],F[V,Bi]⋆F[Bi,Bi]⋆Q⋆F[Bi,T]},E_i(T,H)[V,T] := \min\{F[V,T], F[V,B_i] \star F[B_i,B_i]^{\star Q} \star F[B_i,T]\},

where ⋆\star is the (min⁡,+)(\min,+)-product and the minimum is entrywise, and it computes Ei(T,H)[T,V]E_i(T,H)[T,V] symmetrically.

The entry for a pair (u,v)(u,v) with v∈Tv \in T and η(u,v)≤H\eta(u,v) \le H is exact. To see this, take a shortest path from uu to vv with the fewest edges, and cut it into blocks of tit_i edges followed by a remainder of fewer than tit_i edges. Each block is a shortest path with the fewest edges between its endpoints, so the bridge property of BiB_i replaces it by a shortest walk between the same endpoints that has at most CitiC_i t_i edges and passes through a vertex of BiB_i; choose one such vertex in each block. The result is a shortest walk from uu to vv through at most H/tiH/t_i chosen vertices of BiB_i, in which uu, the chosen vertices, and vv are consecutively at most L=2CitiL = 2C_i t_i edges apart. The table FF is exact on these consecutive pairs, so the product above finds δ(u,v)\delta(u,v). The represented walks have O(H)O(H) edges, since those of FF have O(L)O(L) edges and at most Q+2=O(H/ti)Q+2 = O(H/t_i) of them are concatenated. Every product of the routine has one dimension nn, the two others O~(n/ti)\widetilde{O}(n/t_i), and entries O(HM)=O~(Rti)O(HM) = \widetilde{O}(Rt_i), so it takes O~(Rti⋅n⋅(n/ti)ω−1)≤O~(nω+γ)\widetilde{O}(Rt_i \cdot n \cdot(n/t_i)^{\omega-1}) \le\widetilde{O}(n^{\omega+\gamma}) time, and the recursion has O(1/γ)O(1/\gamma) levels.

The stages. The algorithm maintains a matrix of distance estimates, initially the weight matrix with zeros on the diagonal, and runs one stage for each level i=0,1,…i = 0,1,\ldots until ti+1=nt_{i+1} = n. The stage for level ii computes the tables Ei:=Ei(Bi,Citi+1)E_i := E_i(B_i,C_i t_{i+1}), then the (min⁡,+)(\min,+)-product

Ei[V,Bi]⋆Ei[Bi,V],E_i[V,B_i] \star E_i[B_i,V],

and takes its entrywise minimum with the matrix of estimates. Then, if ti+1<nt_{i+1} < n, it constructs Bi+1B_{i+1} from the walks represented in EiE_i, as described below. The product fixes every pair (u,v)(u,v) with ti≤η(u,v)≤ti+1t_i \le\eta(u,v) \le t_{i+1}: by the bridge property of BiB_i, gives b∈Bib \in B_i with δ(u,v)=δ(u,b)+δ(b,v)\delta(u,v) = \delta(u,b) + \delta(b,v) and η(u,b),η(b,v)≤Ciη(u,v)≤Citi+1\eta(u,b),\eta(b,v) \le C_i\eta(u,v) \le C_i t_{i+1}, so both Ei[u,b]E_i[u,b] and Ei[b,v]E_i[b,v] are exact. The stages thus find all distances, and every estimate is the weight of a walk, so none is too small.

The cost of the stages. Let s:=ti+1s := t_{i+1}. The product of the stage for level ii has middle dimension ∣Bi∣=O~(n/ti)=O~(Rn/s)|B_i| = \widetilde{O}(n/t_i) = \widetilde{O}(Rn/s) and entries O~(s)\widetilde{O}(s). Cutting BiB_i into O~(R)\widetilde{O}(R) groups of ⌈n/s⌉\lceil n/s\rceil vertices turns it into O~(nγ)\widetilde{O}(n^\gamma) products of an n×⌈n/s⌉n \times\lceil n/s\rceil matrix by an ⌈n/s⌉×n\lceil n/s\rceil\times n matrix with entries O~(s)\widetilde{O}(s). Up to this grouping, these are the products of the randomized reduction, and the analysis of [66] applies to them. Fix a small constant a>0a > 0. When s≤n1−μ−as \le n^{1-\mu-a}, the middle dimension nr:=⌈n/s⌉n^r := \lceil n/s\rceil has r≥μ+ar \ge\mu+ a, and fast rectangular matrix multiplication computes the product in O~(snω(1,r,1))=O(n2+μ−ca)\widetilde{O}(s n^{\omega(1,r,1)}) = O(n^{2+\mu-ca}) time [172], for a constant c>0c > 0, by the convexity of ω(1,⋅,1)\omega(1,\cdot,1), since ω(1,μ,1)=1+2μ\omega(1,\mu,1) = 1 + 2\mu and ω<2+μ\omega< 2 + \mu. When s≥n1−μ+as \ge n^{1-\mu+a}, the naive algorithm computes it in O(n2⋅n/s)=O(n2+μ−a)O(n^2 \cdot n/s) = O(n^{2+\mu-a}) time. In between, the middle dimension is at most nμ+an^{\mu+a} and the entries are O~(n1−μ+a)\widetilde{O}(n^{1-\mu+a}); we cut the middle dimension into at most nan^a pieces of nμn^\mu columns and pad each piece to an instance with n1+O(a)n^{1+O(a)} rows, so that its entries fit the range of the hypothesis, and the hypothesized algorithm computes it in O(n2+μ−ε1+O(a))O(n^{2+\mu-\varepsilon_1+O(a)}) time. With aa small enough, the product of every stage takes O(n2+μ+γ−ε2)O(n^{2+\mu+\gamma-\varepsilon_2}) time, for a constant ε2>0\varepsilon_2 > 0 that depends on ε1\varepsilon_1 and μ\mu.

The next bridge. Let s:=ti+1<ns := t_{i+1} < n. The bridge Bi+1B_{i+1} is read off the walks represented in Ei=Ei(Bi,Cis)E_i = E_i(B_i, C_i s), and this is where the small target set pays off. These are 2n∣Bi∣2n|B_i| walks with O(s)O(s) edges each, so listing them all takes O~(n∣Bi∣s)=O~(n2R)≤O~(n2+γ)\widetilde{O}(n|B_i|s) = \widetilde{O}(n^2R) \le\widetilde{O}(n^{2+\gamma}) time, whereas listing a path for every pair of vertices, as Zwick’s construction does, would take O(n2s)O(n^2s) time, which exceeds our budget at the large scales. From each listed walk, erase the cycles, and keep the resulting path if it has at least s/2s/2 edges. Let Bi+1B_{i+1} be a greedy hitting set of the vertex sets of the kept paths, each of which has more than s/2s/2 vertices. It has O((n/s)log⁡n)O((n/s)\log n) vertices by the analysis of the greedy heuristic [122, 56], and it is computed in time linear in the total size of the sets, up to a logarithmic factor.

This Bi+1B_{i+1} is an (s,Ci+1)(s,C_{i+1})-bridge for a constant Ci+1C_{i+1} that depends only on ii. Consider first a pair (x,y)(x,y) with η(x,y)=s\eta(x,y) = s. The bridge BiB_i gives bb with δ(x,y)=δ(x,b)+δ(b,y)\delta(x,y) = \delta(x,b) + \delta(b,y) and η(x,b)+η(b,y)≤Cis\eta(x,b) + \eta(b,y) \le C_i s, so the entries of EiE_i for (x,b)(x,b) and (b,y)(b,y) are exact, and the two walks that represent them are shortest walks. A cycle on a shortest walk has weight zero, so the two paths obtained by erasing the cycles are still shortest, and their concatenation is a shortest walk from xx to yy with O(s)O(s) edges. This walk has at least ss edges, since otherwise erasing its cycles would give a shortest path from xx to yy with fewer than η(x,y)\eta(x,y) edges. So one of the two paths has at least s/2s/2 edges and was kept, and Bi+1B_{i+1} contains one of its vertices, which lies on the concatenated walk. For a pair with η(x,y)>s\eta(x,y) > s, apply this to the first ss edges of a shortest path from xx to yy with the fewest edges, and keep the rest of that path; the walk obtained has at most Ci+1s+η(x,y)−s≤Ci+1η(x,y)C_{i+1}s + \eta(x,y) - s \le C_{i+1}\eta(x,y) edges.

Running time. There are O(1/γ)O(1/\gamma) stages. Each computes its tables in O~(nω+γ)\widetilde{O}(n^{\omega+\gamma}) time, its product in O(n2+μ+γ−ε2)O(n^{2+\mu+\gamma-\varepsilon_2}) time, and its bridge in O~(n2+γ)\widetilde{O}(n^{2+\gamma}) time. Choosing γ\gamma smaller than both ε2/2\varepsilon_2/2 and (2+μ−ω)/2(2+\mu-\omega)/2 gives the running time O(n2+μ−ε′′)O(n^{2+\mu-\varepsilon''}) for a constant ε′′>0\varepsilon'' > 0, and every step is deterministic.

We compose the known reduction with the deterministic (min⁡,+)(\min,+)-product algorithm of Theorem 22.

Theorem 34 (Directed unweighted APSP). There is a constant ε′′>0\varepsilon'' > 0 such that APSP in directed unweighted nn-vertex graphs, and more generally in directed nn-vertex graphs with integer weights of absolute value at most (log⁡n)c(\log n)^c and no negative cycles, for any constant cc, can be solved in O(n2+μ−ε′′)O(n^{2+\mu-\varepsilon''}) time by a deterministic algorithm.

Proof. Cut the n×nμn \times n^\mu matrix into n1−μn^{1-\mu} blocks of nμn^\mu consecutive rows, and the nμ×nn^\mu\times n matrix into n1−μn^{1-\mu} blocks of nμn^\mu consecutive columns. The (min⁡,+)(\min,+)-product then consists of n2−2μn^{2-2\mu} products of two nμ×nμn^\mu\times n^\mu matrices, one for each pair of blocks. Their entries have absolute value O~(n1−μ)≤O~(nμ)\widetilde{O}(n^{1-\mu}) \le\widetilde{O}(n^\mu), because μ≥12\mu\ge\frac{1}{2}, so Theorem 22 computes each of them in O~((nμ)3−ε′/3)\widetilde{O}((n^\mu)^{3-\varepsilon'/3}) time, and all of them in O~(n2+μ−με′/3)\widetilde{O}(n^{2+\mu-\mu\varepsilon'/3}) time. This is O(n2+μ−ε1)O(n^{2+\mu-\varepsilon_1}) for any constant ε1<με′/3\varepsilon_1 < \mu\varepsilon'/3, so [8] applies, in the deterministic form of Theorem 33, since the algorithm of Theorem 22 is deterministic.

3SUM, APSP, and Exact Triangle with real inputs

Theorem 35 (Real inputs). In the real RAM in which the only operations allowed on real numbers are comparisons, additions, and subtractions, Las Vegas algorithms solve the following problems on real inputs: 3SUM on nn numbers in O(n1.998)O(n^{1.998}) expected time, and the (min⁡,+)(\min,+)-product of two n×nn \times n matrices, APSP with no negative cycles, and Exact Triangle in O(n2.998)O(n^{2.998}) expected time. The bounds also hold with probability 1−n−c1-n^{-c} for any constant cc.

The reductions are by Chan, Vassilevska Williams, and Xu [?], who reduce the real-valued problems to the counting version of All-Edges Sparse Triangle on graphs with mm edges (and real APSP also to the Boolean version). Our version of All-Edges Sparse Triangle in Corollary 16 needs lopsided sparse graphs. To deal with this slight change, we follow the reductions of [?] down to the point where the All-Edges Sparse Triangle oracle is called, and change the call. At that point, the reductions only need the oracle to compute comparison counts, which we define next. These come from Fredman’s trick [87]: a′+b′<a+ba' + b' < a + b if and only if a′−a<b−b′a' - a < b - b'. This turns a comparison of two sums into a comparison of a number that depends only on the row against a number that depends only on the column.

We first define comparison counts, then restate the reductions of [?] as reductions to comparison counts (Lemma 36), and then solve the comparison counts problem: following [?], Lemma 37 reduces it to the wanted entries of one thin matrix product using Matoušek’s technique for the dominance product [129], and Corollary 38 applies Corollary 26 to that product. The proof of Theorem 35 then adds up the running times. The only randomized steps are in the reductions of [?], and the algorithms never output a wrong answer, so they are Las Vegas.

Comparison counts. We are given nn row lists: for every r∈[n]r \in[n], a list Rr\mathcal{R}_r of at most dd real numbers xx, where each x∈Rrx \in\mathcal{R}_r has a color χ(x)∈[d]\chi(x) \in[d] associated with it.

Similarly, we are given nn column lists: for every c∈[n]c \in[n], a list Cc\mathcal{C}_c of at most dd real numbers yy, each y∈Ccy \in\mathcal{C}_c again with a color χ(y)∈[d]\chi(y) \in[d] associated with it.

Given a set P⊆[n]2P \subseteq[n]^2 of (row, column) pairs, we want, for every (r,c)∈P(r,c) \in P, the number

γ(r,c):=∣{(x,y):x∈Rr, y∈Cc, χ(x)=χ(y), x<y}∣.\gamma(r,c) := \left|\{(x,y): x \in\mathcal{R}_r,\ y \in\mathcal{C}_c,\ \chi(x) = \chi(y),\ x < y\}\right|.

The reductions. We follow the reductions of [?] down to their two counting problems [?], Problems 4.1 and 4.5, which we define in the proof of Lemma 36 below, and turn every call of a counting problem into comparison counts, in place of the triangle-counting instances of [?], Lemmas 4.3 and 4.7. Throughout, d∈[n]d \in[n] is a parameter, which the proof of Theorem 35 chooses.

Lemma 36 (after Chan, Vassilevska Williams, and Xu [?]). Let 1≤d≤n1 \le d \le n.

  • (a) The (min⁡,+)(\min,+)-product of two n×nn \times n real matrices, APSP with real edge weights and no negative cycles on nn vertices, and Exact Triangle with real weights on nn vertices reduce, with Las Vegas randomization, to O~(n/d)\widetilde{O}(n/d) counting calls and O~(n3/d)\widetilde{O}(n^3/d) further time. A counting call consists of dd comparison counts, each with nn row lists and nn column lists of at most dd numbers, with at most one number of each color in a list, and with pair sets P1,…,PdP_1,\ldots,P_d satisfying ∑k∣Pk∣=n2\sum_k |P_k| = n^2; forming its lists costs O(nd2)O(nd^2) subtractions.

  • (b) 33SUM on nn real numbers reduces, with Las Vegas randomization, to polylogarithmically many comparison counts, each with nn row lists and nn column lists of at most dd numbers, all of the same color, and a pair set PP of size O(n2/d)O(n^2/d), and O~(n2/d)\widetilde{O}(n^2/d) further time; forming the lists of a comparison count costs O(nd)O(nd) subtractions.

A comparison count may have ≤\le in place of <<. The only operations on real numbers performed by the reductions are comparisons, additions, and subtractions.

Proof. (a) (min⁡,+)(\min,+)-product, APSP, and Exact Triangle. Let A,B,C∈Rn×nA,B,C \in\mathbb{R}^{n \times n}. As in [67], Section 3.2, cut AA into n/dn/d blocks A′∈Rn×dA' \in\mathbb{R}^{n \times d} of dd consecutive columns, and BB into the corresponding blocks B′∈Rd×nB' \in\mathbb{R}^{d \times n} of dd consecutive rows. For each pair (A′,B′)(A',B') we solve [67], Problem 3.2: find, for every (i,j)(i,j), the predecessor and the successor of C[i,j]C[i,j] among the dd sums A′[i,k]+B′[k,j]A'[i,k] + B'[k,j], where a sum equal to C[i,j]C[i,j] counts as its predecessor. For Exact Triangle, A[i,k]:=w(i,k)A[i,k] := w(i,k), B[k,j]:=w(k,j)B[k,j] := w(k,j), and C[i,j]:=−w(i,j)C[i,j] := -w(i,j), and there is a triangle of weight zero if and only if, in some block, some C[i,j]C[i,j] is its own predecessor. For the (min⁡,+)(\min,+)-product of AA and BB, we take every C[i,j]C[i,j] smaller than all the sums, for instance C[i,j]:=min⁡kA[i,k]+min⁡kB[k,j]−1C[i,j] := \min_k A[i,k] + \min_k B[k,j] - 1. Then the successor of C[i,j]C[i,j] in a block is the smallest sum of the block, and the product is the entrywise minimum over the n/dn/d blocks, which costs O(n3/d)O(n^3/d) comparisons. APSP with real weights and no negative cycles can be computed by successive squaring of the weight matrix, performing ⌈log⁡2n⌉\lceil\log_2 n \rceil such products.

Fix a pair (A′,B′)(A',B'). We solve the following counting problem [67], Problem 4.1: we are given a pivot kij∈[d]k_{ij} \in[d] for every (i,j)∈[n]2(i,j) \in[n]^2 and a subset S⊆[d]S \subseteq[d], and we must count, for every (i,j)(i,j), the indices k′∈Sk' \in S with A′[i,k′]+B′[k′,j]<A′[i,kij]+B′[kij,j]A'[i,k'] + B'[k',j] < A'[i,k_{ij}] + B'[k_{ij},j]; a call of the problem may also have ≤\le in place of <<.

By Lemmas 3.4 and 4.2 of [67], the problem for one pair (A′,B′)(A',B') reduces, with Las Vegas randomization, to polylogarithmically many calls of the counting problem, and O~(n2)\widetilde{O}(n^2) further time: Lemma 3.4 finds the predecessors and successors by a randomized search that repeatedly asks, for every (i,j)(i,j), for a sum strictly between two given sums, and Lemma 4.2 finds these sums by counting, for each of the two given sums, the sums below it, and by sampling at random. Lemma 4.3 of [67] turns a call into O(d)O(d) triangle-counting instances; we turn it into dd comparison counts instead.

Following [67], we group the pairs by their pivot, Pk:={(i,j):kij=k}P_k := \{(i,j): k_{ij} = k\}. For k∈[d]k \in[d], let the row list Ri\mathcal{R}_i consist of the numbers A′[i,k′]−A′[i,k]A'[i,k'] - A'[i,k], k′∈Sk' \in S, each with color k′k', and let the column list Cj\mathcal{C}_j consist of the numbers B′[k,j]−B′[k′,j]B'[k,j] - B'[k',j], k′∈Sk' \in S, again with color k′k'.

By Fredman’s trick, A′[i,k′]+B′[k′,j]<A′[i,k]+B′[k,j]A'[i,k'] + B'[k',j] < A'[i,k] + B'[k,j] if and only if A′[i,k′]−A′[i,k]<B′[k,j]−B′[k′,j]A'[i,k'] - A'[i,k] < B'[k,j] - B'[k',j], where both numbers in the latter comparison have color k′k'.

Thus the count of a pair (i,j)∈Pk(i,j) \in P_k is the comparison count γ(i,j)\gamma(i,j) of these lists with P:=PkP := P_k. Forming the lists costs us O(nd)O(nd) subtractions for each kk. Over the n/dn/d pairs (A′,B′)(A',B'), and the ⌈log⁡2n⌉\lceil\log_2 n \rceil products in the case of APSP, this gives O~(n/d)\widetilde{O}(n/d) counting calls and O~(n3/d)\widetilde{O}(n^3/d) additional time, which includes the O(n3/d)O(n^3/d) comparisons of the entrywise minimum.

(b) 3SUM. Let A,B,CA,B,C be sets of nn reals, the problem asks whether a+b=ca+b=c for some a∈Aa\in A, b∈Bb\in B, and c∈Cc\in C. The 3SUM version with one set and a+b+c=0a+b+c=0 reduces to this version in the standard way.

Now, sort AA and BB, and cut them into n/dn/d consecutive blocks A1,…,An/dA_1,\ldots,A_{n/d} and B1,…,Bn/dB_1,\ldots,B_{n/d} of dd numbers each, writing Ai[k]A_i[k] for the kk-th number of AiA_i. Here the counting problem [67] is the following: we are given a set QQ of O(n2/d)O(n^2/d) quadruples (i,j,k,ℓ)(i,j,k,\ell), and we must count, for every (i,j,k,ℓ)∈Q(i,j,k,\ell)\in Q, the pairs (k′,ℓ′)∈[d]2(k',\ell')\in[d]^2 with Ai[k′]+Bj[ℓ′]<Ai[k]+Bj[ℓ]A_i[k']+B_j[\ell']<A_i[k]+B_j[\ell]; again, a call may have ≤\leq in place of <<, and it may restrict k′k' and ℓ′\ell' to subsets of [d][d]. By Section 3.3 and Lemmas 3.9 and 4.6 of [67], 3SUM reduces, with Las Vegas randomization, to polylogarithmically many calls of this counting problem, and O~(n2/d)\widetilde{O}(n^2/d) additional time. By Fredman’s trick, the condition is Ai[k′]−Ai[k]<Bj[ℓ]−Bj[ℓ′]A_i[k']-A_i[k]<B_j[\ell]-B_j[\ell']. So a call is one comparison count: the rows are the nn pairs (i,k)(i,k) and the columns are the nn pairs (j,ℓ)(j,\ell), the row list R(i,k)R_{(i,k)} consists of the dd numbers Ai[k′]−Ai[k]A_i[k']-A_i[k], k′∈[d]k'\in[d], the column list C(j,ℓ)C_{(j,\ell)} of the dd numbers Bj[ℓ]−Bj[ℓ′]B_j[\ell]-B_j[\ell'], ℓ′∈[d]\ell'\in[d], all numbers have the same color, and P:=QP:=Q. A restriction of k′k' or of ℓ′\ell' deletes numbers from the lists. Forming the lists can be done using O(nd)O(nd) subtractions.

Solving comparison counts. In the comparison counts of Lemma 36(a), every list has at most one number of each color, so that γ(r,c)\gamma(r,c) is the number of colors kk with A[r,k]<B[k,c]A[r,k]<B[k,c], where A[r,k]A[r,k] is the number of color kk in RrR_r and B[k,c]B[k,c] the one in CcC_c (a color missing from either list is skipped); this is the dominance product of the n×dn\times d matrix AA and the d×nd\times n matrix BB at the positions in PP. In those of Lemma 36(b), all numbers have the same color, and γ(r,c)\gamma(r,c) is the number of pairs x<yx<y between the two lists. Merging the two sorted lists of every pair in PP takes O(∣P∣d)O(|P|d) time. To improve on this, we utilize Matoušek’s technique for the dominance product [129], which counts the pairs that lie in different blocks of the sorted order by one thin matrix product, and the pairs in the same block directly.

Lemma 37 (after Matoušek [129]). Let s≥1s\geq1 be an integer and D′′:=⌈2nd/s⌉+dD'' := \lceil2nd/s\rceil+d. Given row lists RrR_r and column lists CcC_c as above and a set P⊆[n]2P\subseteq[n]^2, we can build matrices X∈{0,…,d}n×D′′X\in\{0,\ldots,d\}^{n\times D''} and Y∈{0,…,d}D′′×nY\in\{0,\ldots,d\}^{D''\times n} and compute integers γ2(r,c)\gamma_2(r,c), (r,c)∈P(r,c)\in P, with

γ(r,c)=(XY)[r,c]+γ2(r,c)for every (r,c)∈P,\gamma(r,c)=(XY)[r,c]+\gamma_2(r,c) \qquad\text{for every }(r,c)\in P,

deterministically in O(nD′′+(∣P∣+nds+ds2)log⁡n)O(nD''+(|P|+nds+ds^2)\log n) time. The only operations on real numbers are the comparisons made when sorting the numbers of each color. The same holds with ≤\leq in place of << in the definition of γ\gamma.

Proof. For each color kk, sort the numbers of color kk of all the lists, and break ties so that, among equal numbers, those from column lists precede those from row lists. Let pos⁡(x)\operatorname{pos}(x) be the position of xx in this order. For xx from a row list and yy from a column list of the same color, x<yx<y holds if and only if pos⁡(x)<pos⁡(y)\operatorname{pos}(x)<\operatorname{pos}(y). (For ≤\leq, we reverse the tie-breaking rule.) Cut the order into blocks of ss consecutive positions, and let blk⁡(x):=⌊pos⁡(x)/s⌋\operatorname{blk}(x):=\lfloor\operatorname{pos}(x)/s\rfloor. Then x<yx<y holds if and only if either blk⁡(x)<blk⁡(y)\operatorname{blk}(x)<\operatorname{blk}(y), or blk⁡(x)=blk⁡(y)\operatorname{blk}(x)=\operatorname{blk}(y) and pos⁡(x)<pos⁡(y)\operatorname{pos}(x)<\operatorname{pos}(y). As in Matoušek’s algorithm, we count the pairs of the first kind, which lie in different blocks, by a matrix product, and the pairs of the second kind, which lie in the same block, by brute force.

Different blocks. The lists contain at most 2nd2nd numbers in all, so there are at most 2nd/s+d≤D′′2nd/s+d\leq D'' pairs (color, block), and we index the columns of XX and the rows of YY by these pairs, padding with zeros if needed. Let X[r,(k,β)]X[r,(k,\beta)] be the number of numbers of color kk in RrR_r that lie in block β\beta, and let Y[(k,β),c]Y[(k,\beta),c] be the number of numbers of color kk in CcC_c that lie in a block after β\beta. Then (XY)[r,c]=∑(k,β)X[r,(k,β)]Y[(k,β),c](XY)[r,c] = \sum_{(k,\beta)} X[r,(k,\beta)]Y[(k,\beta),c] is the number of pairs (x,y)(x,y) of the same color with blk⁡(x)<blk⁡(y)\operatorname{blk}(x) < \operatorname{blk}(y), as required, and the entries of XX and YY are between 0 and dd because a list has at most dd numbers. We use O(ndlog⁡n)O(nd\log n) comparisons to sort and then fill in XX and YY in O(nD′′)O(nD^{\prime\prime}) time.

Same block. For every color kk and block β\beta, let II be the numbers xx of row lists in the block, each with its row, and let JJ be the numbers yy of column lists in the block, each with its column, so that ∣I∣+∣J∣≤s|I|+|J|\le s. For every (x,y)∈I×J(x,y)\in I\times J with pos⁡(x)<pos⁡(y)\operatorname{pos}(x)<\operatorname{pos}(y) whose row and column form a pair (r,c)∈P(r,c)\in P (this can be tested via a binary search in PP after it is sorted), we add 1 to γ2(r,c)\gamma_2(r,c). Then γ2\gamma_2 counts the pairs of the second kind. Since ∣I∣∣J∣≤s2/4|I||J|\le s^2/4 and there are at most 2nd/s+d2nd/s+d blocks, we enumerate at most (2nd/s+d)s2/4≤nds+ds2(2nd/s+d)s^2/4\le nds+ds^2 pairs (x,y)(x,y). Together with sorting PP and outputting the ∣P∣|P| integers γ2(r,c)\gamma_2(r,c), this takes O((∣P∣+nds+ds2)log⁡n)O((|P|+nds+ds^2)\log n) time.

Corollary 38. Let d≤n1/40d\le n^{1/40}, and let nn be larger than a suitable constant. Given row lists Rr\mathcal{R}_r and column lists Cc\mathcal{C}_c as above and a set P⊆[n]2P\subseteq[n]^2, the counts γ(r,c)\gamma(r,c), (r,c)∈P(r,c)\in P, with << or with ≤\le, can be computed deterministically in

O(∣P∣n0.0229+n2d0.126+n2−1/440log⁡n)O\left(|P|n^{0.0229}+\frac{n^2}{d^{0.126}}+n^{2-1/440}\log n\right)

time, by an algorithm whose only operations on real numbers are comparisons.

Proof. Apply Lemma 37 with s:=⌈n1−1/440/d⌉s:=\lceil n^{1-1/440}/d\rceil, so that D′′≤2d2n1/440+d+1≤3d2n1/440D^{\prime\prime}\le2d^2n^{1/440}+d+1\le3d^2n^{1/440}, and pad the product to the inner dimension D∗:=⌈3d2n1/440⌉D^*:=\lceil3d^2n^{1/440}\rceil with zero columns of XX and zero rows of YY. Since d≤n1/40d\le n^{1/40}, we have D∗≤4n23/440D^*\le4n^{23/440}, so (D∗)18≤418n0.941≤n(D^*)^{18}\le4^{18}n^{0.941}\le n, and Corollary 26 with N:=nN:=n and D:=D∗D:=D^* computes (XY)[r,c](XY)[r,c] for all (r,c)∈P(r,c)\in P deterministically in O(∣P∣(D∗)0.437+n2/(D∗)0.063)O(|P|(D^*)^{0.437}+n^2/(D^*)^{0.063}) time. Here (D∗)0.437≤40.437n0.437⋅23/440=O(n0.0229)(D^*)^{0.437}\le4^{0.437}n^{0.437\cdot23/440}=O(n^{0.0229}) and (D∗)0.063≥(3d2)0.063≥d0.126(D^*)^{0.063}\ge(3d^2)^{0.063}\ge d^{0.126}.

Since nD∗=O(n1.06)nD^*=O(n^{1.06}), nds≤2n2−1/440nds\le2n^{2-1/440} and ds2≤4n2−1/440ds^2\le4n^{2-1/440}, the time of Lemma 37 itself is

O(nD∗+(∣P∣+nds+ds2)log⁡n)=O(∣P∣n0.0229+n2−1/440log⁡n).O(nD^*+(|P|+nds+ds^2)\log n)=O(|P|n^{0.0229}+n^{2-1/440}\log n).

Proof of Theorem 35. Let d:=⌊n1/40⌋d:=\lfloor n^{1/40}\rfloor, apply Lemma 36 with this dd, and answer every comparison count by Corollary 38.

(min⁡,+)(\min,+)-product, APSP, and Exact Triangle. By Corollary 38, the dd comparison counts of a counting call cost

∑k∈[d]O(∣Pk∣n0.0229+n2d0.126+n2−1/440log⁡n)=O(n2.0229log⁡n),\sum_{k\in[d]} O\left(|P_k|n^{0.0229}+\frac{n^2}{d^{0.126}}+n^{2-1/440}\log n\right)=O(n^{2.0229}\log n),

since ∑k∣Pk∣=n2\sum_k|P_k|=n^2, d⋅n2/d0.126≤n2+0.874/40≤n2.0219d\cdot n^2/d^{0.126}\le n^{2+0.874/40}\le n^{2.0219}, and d⋅n2−1/440≤n2+1/40−1/440≤n2.0228d\cdot n^{2-1/440}\le n^{2+1/40-1/440}\le n^{2.0228}; forming the lists costs O(nd2)=O(n1.05)O(nd^2)=O(n^{1.05}). So the O~(n/d)\widetilde{O}(n/d) counting calls of Lemma 36(a) cost

O~((n/d)n2.0229)=O~(n3−1/40+0.0229)≤O(n2.998)\widetilde{O}((n/d)n^{2.0229})=\widetilde{O}(n^{3-1/40+0.0229})\le O(n^{2.998})

expected time, and its additional time is O~(n3/d)=O~(n2.975)\widetilde{O}(n^3/d)=\widetilde{O}(n^{2.975}).

3SUM. By Corollary 38, a comparison count of Lemma 36(b) costs

O(n2dn0.0229+n2d0.126+n2−1/440log⁡n)=O(n2−1/40+0.0229log⁡n)=O(n1.9979log⁡n),O\left(\frac{n^2}{d}n^{0.0229}+\frac{n^2}{d^{0.126}}+n^{2-1/440}\log n\right)=O(n^{2-1/40+0.0229}\log n)=O(n^{1.9979}\log n),

so 3SUM can also be solved in O~(n1.9979)≤O(n1.998)\widetilde{O}(n^{1.9979}) \le O(n^{1.998}) expected time.

Las Vegas, and high probability. The reductions of [67] never return a wrong answer and Corollary 38 is deterministic, so the output is always correct, and only the running time is random. The bounds also hold with probability 1−n−c1-n^{-c} for any constant cc: we stop a run that exceeds twice the bound on its expected time and start again, and clog⁡2nc\log^2 n runs all fail with probability at most n−cn^{-c}.

Zero-Weight, Min-Weight, and Max-Weight kk-Clique

The classical reduction of Nešetřil and Poljak [132] from kk-Clique to triangle detection turns the weighted kk-Clique problems into Exact Triangle instances with n⌊k/3⌋n^{\lfloor k/3\rfloor} vertices per part (after fixing k−3⌊k/3⌋k-3\lfloor k/3\rfloor vertices when 3∤k3\nmid k), so Theorem 19 gives:

Corollary 39 (Weighted kk-Clique). Let k≥3k \ge3 and ν≥1\nu\ge1 be constants. Given a complete kk-partite graph with parts of nn vertices and integer edge weights of absolute value at most nνn^\nu, deterministic algorithms decide in O(nk−εT⌊k/3⌋)O(n^{k-\varepsilon_T\lfloor k/3\rfloor}) time whether some kk-clique, with one vertex in each part, has total edge weight zero, and find a kk-clique of minimum, or of maximum, total edge weight.

Proof. We apply the classical reduction from kk-Clique to triangle detection of Nešetřil and Poljak [132]. When kk is divisible by 3, the reduction is simple. Split the kk parts into three groups of k/3k/3 parts each, and build a tripartite graph HH whose vertices in the iith part (for i=1,2,3i=1,2,3) are the k/3k/3-cliques of the original graph with one vertex in each part of the iith group, with an edge between two such cliques when together they form a 2k/32k/3-clique. Since the original graph is complete kk-partite, every choice of one vertex from each part of a group is a k/3k/3-clique, and any two such cliques from different groups form a 2k/32k/3-clique, so HH is simply the complete tripartite graph with nk/3n^{k/3} vertices per part. The triangles of HH correspond bijectively to the kk-cliques of the original graph with one vertex in each part.

When kk is not divisible by 3, let t:=k−3⌊k/3⌋∈{1,2}t := k-3\lfloor k/3\rfloor\in\{1,2\}. We enumerate the ntn^t ways of fixing one vertex in each of the first tt parts, and for each of them we build HH as above from the remaining 3⌊k/3⌋3\lfloor k/3\rfloor parts; now the triangles of HH correspond to the kk-cliques through the tt fixed vertices. In both cases HH has N:=n⌊k/3⌋N := n^{\lfloor k/3\rfloor} vertices per part, and we index its parts by i∈Z3i \in\mathbb{Z}_3.

We give HH edge weights so that a triangle and its kk-clique have the same weight. Let UU be a vertex of HH in part ii and VV a vertex in part i+1i+1. The weight of the edge UVUV of HH is the total weight of the edges of the original graph between a vertex of UU and a vertex of VV, of the edges inside UU, of the edges between UU and the fixed vertices, and, if i=1i=1 and t=2t=2, of the edge between the two fixed vertices. The edges inside VV and the edges between VV and the fixed vertices are not counted here; they are counted in the edge from VV to part i+2i+2. In this way every edge of a kk-clique is counted exactly once over the three edges of its triangle, so there is no double-counting and the weights agree. The weight of an edge of HH has absolute value at most (k2)nν≤N2ν\binom{k}{2}n^\nu\le N^{2\nu} for n≥k2n \ge k^2.

Theorem 19 decides whether HH has a triangle of weight zero in O(N3−ε′log⁡N)O(N^{3-\varepsilon'\log N}) time, with the constants ε′>εT\varepsilon' > \varepsilon_T of that theorem. By [158], Theorem 3.3, finding a maximum weight triangle costs O(log⁡2n)O(\log^2 n) times as much, and a minimum weight triangle is a maximum weight triangle for the negated weights. Since ε′>εT\varepsilon' > \varepsilon_T, the logarithmic factors are absorbed, so each graph HH costs O(N3−εT)O(N^{3-\varepsilon_T}) time, and the ntn^t graphs together cost O(ntN3−εT)=O(nk−εT⌊k/3⌋)O(n^tN^{3-\varepsilon_T}) = O(n^{k-\varepsilon_T\lfloor k/3\rfloor}).

Consequently, the Zero-Weight, Min-Weight, and Max-Weight kk-Clique hypotheses [21], [125, 36] with polynomially bounded weights are refuted, also on general graphs, by the standard reduction to the complete kk-partite form.

Three conjectures of van den Brand, Nanongkai, and Saranurak

Van den Brand, Nanongkai, and Saranurak [155] propose three “hinted” variants of the Online Matrix–Vector conjecture [100], which they use to prove matching lower bounds for the running times of their dynamic matrix inverse algorithms. All three are over the Boolean semiring, allow polynomial preprocessing time in the first phase, and have parameters t=nτt=n^{\tau} and ti=nτit_i=n^{\tau_i} for constants τ,τi∈(0,1)\tau,\tau_i \in(0,1). We write ω(a,b,c)\omega(a,b,c) for the exponent of multiplying an na×nbn^a \times n^b matrix by an nb×ncn^b \times n^c matrix. Each conjecture asserts that no algorithm simultaneously beats all of its listed bounds, for any ε>0\varepsilon> 0.

  • vv-hinted Mv (Definition 5.1 and Conjecture 5.2 of [155]). Phase 1: an n×tn \times t matrix MM. Phase 2: a t×nt \times n matrix VV. Phase 3: an index ii, after which the algorithm outputs MV[n],iMV_{[n],i}, the product of MM and column ii of VV. Bounds conjectured to be impossible to achieve simultaneously: nω(1,1,τ)−εn^{\omega(1,1,\tau)-\varepsilon} for Phase 2 and n1+τ−εn^{1+\tau-\varepsilon} for Phase 3.

  • MvMv-hinted Mv (Definition 5.6 and Conjecture 5.7 of [155]). Phase 1: N∈{0,1}n×nN \in\{0,1\}^{n \times n} and V∈{0,1}t×nV \in\{0,1\}^{t \times n}. Phase 2: a vector I∈[n]tI \in[n]^t of column indices. Phase 3: an index jj, after which the algorithm outputs N[n],IV[t],jN_{[n],I}V_{[t],j}, where N[n],IN_{[n],I} is the n×tn \times t matrix whose kk-th column is column IkI_k of NN. Bounds conjectured to be impossible to achieve simultaneously: nω(1,τ,1)−εn^{\omega(1,\tau,1)-\varepsilon} for Phase 2 and n1+τ−εn^{1+\tau-\varepsilon} for Phase 3.

  • uMvuMv-hinted uMvuMv (Definition 5.11 and Conjecture 5.12 of [155]). Phase 1: U∈{0,1}n×t1U \in\{0,1\}^{n \times t_1}, N∈{0,1}n×nN \in\{0,1\}^{n \times n}, and V∈{0,1}t2×nV \in\{0,1\}^{t_2 \times n}. Phase 2: I∈[n]t1I \in[n]^{t_1}. Phase 3: J∈[n]t2J \in[n]^{t_2}. Phase 4: indices ii and jj, after which the algorithm outputs (UNI,JV)i,j(UN_{I,J}V)_{i,j}, where NI,JN_{I,J} is the t1×t2t_1 \times t_2 submatrix of NN with the rows II and the columns JJ. Bounds conjectured to be impossible to achieve simultaneously: nω(1,τ1,1)−εn^{\omega(1,\tau_1,1)-\varepsilon} for Phase 2, nω(τ2,τ1,1)−εn^{\omega(\tau_2,\tau_1,1)-\varepsilon} for Phase 3, and nτ1+τ2−εn^{\tau_1+\tau_2-\varepsilon} for Phase 4.

The two obvious algorithms are to multiply everything out with fast matrix multiplication as soon as the hint arrives, or to wait and compute one matrix–vector product at the end, and the conjectures say that no algorithm is polynomially faster than both of these. The main lower bounds of [155], n1.528n^{1.528} for dynamic matrix inverse with column updates and row queries and n1.407n^{1.407} with element updates and element queries, use the conjectures at τ≈0.53\tau\approx0.53 and at τ1+τ2≈1.41\tau_1+\tau_2 \approx1.41, where they match the algorithms of [155]. For thin hints, the conjectures are false, because the data structure of Corollary 26 is faster than both obvious algorithms.

Corollary 40 (Hinted OMv). Conjectures 5.2 and 5.7 of [155] fail for every 0<τ<1/180 < \tau< 1/18: Phase 2 takes O(n2−0.063τ)O(n^{2-0.063\tau}) time and Phase 3 takes O(n1+0.437τ)O(n^{1+0.437\tau}) time. Conjecture 5.12 fails for every 0<τ1<τ2/180 < \tau_1 < \tau_2/18: Phase 3 takes O(n1+τ2−0.063τ1)O(n^{1+\tau_2-0.063\tau_1}) time and Phase 4 takes O(nτ2+0.437τ1)O(n^{\tau_2+0.437\tau_1}) *time, with polynomial Phase 1 and a Phase 2 that only stores II.

More generally, Conjectures 5.2 and 5.7 fail for every 0<τ<ε∗=0.1204…0 < \tau< \varepsilon^* = 0.1204\ldots, and Conjecture 5.12 fails for every 0<τ1<ε∗τ20 < \tau_1 < \varepsilon^*\tau_2. In each case the phases beat the conjectured bounds whatever the value of ω\omega, since ω(1,1,τ)=ω(1,τ,1)≥2\omega(1,1,\tau)=\omega(1,\tau,1)\ge2 and ω(τ2,τ1,1)≥1+τ2\omega(\tau_2,\tau_1,1)\ge1+\tau_2 because of the input and output sizes.

Proof. We compute over Z\mathbb{Z} with 0/10/1 matrices; a Boolean entry is 1 exactly when the corresponding integer entry is positive. Let D:=t=nτD := t = n^{\tau} be the inner dimension. For τ<1/18\tau< 1/18 we have D18=n18τ≤nD^{18} = n^{18\tau} \le n, so Corollary 26 applies with N=nN = n.

Conjecture 5.2 of [155]. In Phase 2, we preprocess X:=MX := M and Y:=VY := V by Corollary 26, in O(n2/D0.063)=O(n2−0.063τ)O(n^2/D^{0.063}) = O(n^{2-0.063\tau}) time. In Phase 3, the nn entries of column ii of MVMV are nn queries, which take O(nD0.437)=O(n1+0.437τ)O(nD^{0.437}) = O(n^{1+0.437\tau}) time.

Conjecture 5.7 of [155]. The proof is the same, with X:=N[n],IX := N_{[n],I} and Y:=VY := V, which are both known in Phase 2 (XX may have repeated columns, which do not affect the argument). Phase 1 only reads its input.

Conjecture 5.12 of [155]. Let X:=UX := U, an n×t1n \times t_1 matrix, and Y:=NI,JY := N_{I,J}, a t1×t2t_1 \times t_2 matrix, which are both known in Phase 3, with the inner dimension D:=t1=nτ1D := t_1 = n^{\tau_1}. Cut the nn rows of UU into n/t2n/t_2 blocks of t2t_2 rows, and preprocess each of the n/t2n/t_2 products of a block with YY, which are products of a t2×t1t_2 \times t_1 matrix by a t1×t2t_1 \times t_2 matrix, by Corollary 26. It applies because t2=nτ2≥n18τ1=D18t_2 = n^{\tau_2} \ge n^{18\tau_1} = D^{18} when τ1<τ2/18\tau_1 < \tau_2/18. So Phase 3 costs (n/t2)⋅O(t22/D0.063)=O(n1+τ2−0.063τ1)(n/t_2)\cdot O(t_2^2/D^{0.063}) = O(n^{1+\tau_2-0.063\tau_1}) time. In Phase 4, (UNI,JV)i,j=∑ℓ=1t2(UNI,J)i,ℓVℓ,j(UN_{I,J}V)_{i,j} = \sum_{\ell=1}^{t_2}(UN_{I,J})_{i,\ell}V_{\ell,j} is a sum of at most t2t_2 entries of XYXY, which are t2t_2 queries and take O(t2D0.437)=O(nτ2+0.437τ1)O(t_2D^{0.437}) = O(n^{\tau_2+0.437\tau_1}) time. Phase 2 only stores II.

General τ\tau. Let 0<τ<ε∗0 < \tau< \varepsilon^*, and fix ε\varepsilon with τ<ε<ε∗\tau< \varepsilon< \varepsilon^*. By Corollary 31, with cc and θ\theta chosen as in the proof of Theorem 24 for q:=12q := \frac{1}{2}, there is, after absorbing the logarithmic factors, a γ>0\gamma> 0 such that, since D=nτ≤nεD = n^\tau\le n^\varepsilon, the arguments above go through with Phase 2 in O(n2/Dγ)=O(n2−γτ)O(n^2/D^\gamma) = O(n^{2-\gamma\tau}) time and Phase 3 in O(nD1/2)=O(n1+τ/2)O(nD^{1/2}) = O(n^{1+\tau/2}) time. For Conjecture 5.12, we use the same blocks, which requires nτ1≤nετ2n^{\tau_1} \le n^{\varepsilon\tau_2}, that is, τ1≤ετ2\tau_1 \le\varepsilon\tau_2 for some ε<ε∗\varepsilon< \varepsilon^*.

We conclude this section by discussing which results of [155] rely on the conjectures in the refuted regime. From Conjectures 5.2 and 5.7, [155] derive trade-offs between the worst-case update time uu and query time qq of dynamic algorithms, for every 0<τ<10 < \tau< 1: either u=Ω(nω(1,1,τ)−τ−ε)u = \Omega(n^{\omega(1,1,\tau)-\tau-\varepsilon}) or q=Ω(n1+τ−ε)q = \Omega(n^{1+\tau-\varepsilon}). These trade-offs cover the dynamic matrix product, inverse, and adjoint problems with column updates and row queries (Theorem 5.3 and Corollary 5.5 in [155]) or with element updates and row queries (Theorem 5.8 and Corollary 5.9 in [155]), and dynamic transitive closure and DAG path counting with vertex or edge updates and source queries (Corollaries 5.4 and 5.10 in [155]). For element or pair queries, the condition becomes q=Ω(nτ−ε)q = \Omega(n^{\tau-\varepsilon}) (Corollaries 5.9 and 5.10 in [155]).

The main bounds, such as u+q=Ω(n1.528)u+q = \Omega(n^{1.528}) for column updates and row queries, balance the two terms at τ≈0.53\tau\approx0.53. For this setting, the current best upper bound on ω(1,1,τ)\omega(1,1,\tau) is strictly greater than 2, so the products are far from thin enough for our construction, and these bounds are still supported by the unrefuted forms of the conjectures. The same holds for the bounds from Conjecture 5.12 in [155], such as Ω(n1.407)\Omega(n^{1.407}) for dynamic determinant, rank, and bipartite perfect matching (Corollaries 5.15 and 5.16 in [155]), since Corollary 40 refutes Conjecture 5.12 in [155] only for τ1<0.1204τ2\tau_1 < 0.1204\tau_2, far from the τ1+τ2≈1.41\tau_1+\tau_2 \approx1.41 at which these bounds are proved.

For τ<0.1204\tau< 0.1204, however, where ω(1,1,τ)=2\omega(1,1,\tau) = 2, the trade-offs say that an update requires n2−τ−o(1)n^{2-\tau-o(1)} time unless a row or source query takes n1+τ−o(1)n^{1+\tau-o(1)} time, or, in the versions with element or pair queries, unless such a query takes nτ−o(1)n^{\tau-o(1)} time; Corollary 40 refutes the forms of the conjectures that would imply these trade-offs. This is the end of the trade-offs with the fastest queries, where they match the algorithms of [141], [155], such as element updates in O(n2−τ)O(n^{2-\tau}) time with element queries in O(nτ)O(n^\tau) time [141], Theorem 3]. For small τ\tau, these algorithms are no longer known to be conditionally optimal.

The same goes for results that rely on this end of the trade-offs. Haeupler, Long, and Saranurak [101] cite Corollary 5.10 of [155] as showing that incremental and decremental distance oracles with approximation factor below 5/35/3 cannot have worst-case update time n2−Ω(1)n^{2-\Omega(1)} and query time no(1)n^{o(1)}. With queries this fast, ruling out update time n2−δn^{2-\delta} needs Conjecture 5.7 of [155] for some τ<δ\tau< \delta, so new evidence of hardness would be needed for δ≤0.1204\delta\le0.1204, although the remaining cases of the conjecture still rule out update time O(n1.87)O(n^{1.87}). Van den Brand, Song, and Zhou [156] show that their data structure for dynamic attention, with amortized update time nω(1,1,τ)−τn^{\omega(1,1,\tau)-\tau}, is conditionally optimal for every 0<τ≤10 < \tau\le1 under a variant of Conjecture 5.7 of [155] in which Phase 2 gives a matrix with at most nτn^\tau nonzero entries instead of the vector II. Our proof applies to this variant as well, since after Phase 2 the product again has inner dimension at most nτn^\tau, so this lower bound needs a new hypothesis for τ<0.1204\tau< 0.1204.

Conclusion

We believe our results open exciting research directions in both algorithm design and complexity theory, and we highlight a few here.

Fine-grained complexity. An important message from our paper is that the fine-grained reductions that FGC has built up are incredibly valuable, and that it is even more important to design more reductions to enable further algorithm design and improved conditional hardness.

Which hypotheses should take the place of 3SUM and APSP? As discussed in the introduction, one possibility is to restrict these hypotheses to combinatorial algorithms [157, 154, 26], motivated by the search for more practical algorithms or practical hardness. Another possibility is the hypothesis that the balanced case of All-Edges Sparse Triangle, with mm edges, needs m4/3−o(1)m^{4/3-o(1)} time. Our algorithms do not speed up this balanced case, and since it is the target of several lower-bound reductions from 3SUM and Exact Triangle [136, 116, 160, 71], the hypothesis still gives many problems evidence of hardness. Is it possible that the lopsided version has a faster algorithm but the balanced version does not?

More broadly, the complexity of the many problems that are only known to be 3SUM-hard or APSP-hard, rather than equivalent to 3SUM or APSP, is now open (the gray boxes of Figure 1); we get no faster algorithms for them, since the reductions go the other way. For instance, can one decide in truly subquadratic time whether nn points in the plane contain three on a line [92]? As far as we know, the fastest known running time is still O(n2)O(n^2), without even any polylogarithmic improvements. A similar question arises for the hypotheses that our results say nothing about, such as kk-SUM for k≥4k \ge4, 3SUM-Indexing, OMv (without hints), and Orthogonal Vectors. Do ideas like ours help to speed up algorithms for any of them?

Our new technique gives a way to deal with sparsity, at least in lopsided instances. Much work has gone into algorithms for sparse matrix multiplication [171, 25, 137, 2, 38, 82, 95]. However, our techniques do not seem to give new algorithms for sparse matrix multiplication. Is improving upon the known algorithms for this problem hard, or is there another technique that could help here? This question is related to the balanced version of All-Edges Sparse Triangle.

What are the true exponents of 3SUM, APSP, and the many other problems of Figure 1 that now have faster algorithms? Our exponents can certainly be improved, and one place to gain is the reductions. Each of our algorithms composes known reductions with the matrix theorem, and many reductions lose a constant fraction of the saving in the exponent. For instance, the reduction from Exact Triangle to Lopsided All-Edges Sparse Triangle keeps only half of the saving in the exponent, and the reductions from 3SUM and APSP to Exact Triangle keep a half and a third (Section 3). These reductions, like most fine-grained reductions, were designed to prove hardness, where it only matters that they keep some polynomial saving. Now that they are being used as algorithms, how much they keep is more important. Which of them can be improved? Are there more efficient reductions from all these different problems to Lopsided All-Edges Sparse Triangle, or to thin matrix products themselves, that skip the intermediate problems?10

Some of these losses cannot be removed by reductions alone. Sheffield, Vassilevska Williams, and Xi [149] show that the loss of a third in the reduction from the all-edges version of a triangle problem to its detection version [157, 159] is optimal for black-box reductions, those that work for every relation on the three edge weights at once, so a tighter reduction must use the structure of the particular problem. The loss can still be avoided on the algorithmic side, as in the footnote: our algorithm for Exact Triangle solves the all-edges version at no extra cost, as all known algorithms for triangle problems do [149]. Our reductions are not black-box in this sense either: the reduction from Exact Triangle to Lopsided All-Edges Sparse Triangle hashes the weights modulo a prime, which uses the additive structure of the problem, so the barriers of [149] say nothing against improving the half that it loses. The same paper also gives new black-box reductions among triangle, listing, and matrix problems, and such reductions are now of algorithmic interest as well.

Beyond the reductions, all of our algorithms use the same matrix theorem, and a different technique might give improvements such as better exponents, combinatorial or practical algorithms, or algorithms for All-Edges Sparse Triangle with a middle part larger than n0.12n^{0.12}, such as the n1/2n^{1/2} that arises in an approach to girth approximation [139].

Algebraic algorithm design. Any improvement to the matrix theorem carries over to all the other speedups we achieve here. We do not know the true complexity of computing a set WW of entries of a thin product XYXY, as a function of DD and ∣W∣|W|. In particular, to handle D>N0.12D > N^{0.12}, one could look for new base identities that compute longer inner products per multiplication than Schönhage’s, perhaps by computer search [84, 114, 134], or ask whether other known identities, such as border rank expressions for the Coppersmith–Winograd tensor [69], which underlie the current bounds on ω\omega and α\alpha [161, 10, 72], can be used in the same way. It is not immediately clear how to make use of other tensors, since our analysis uses specific properties of Schönhage’s identity, such as its sparsity and the way the leaves of its recursion are shared among the output entries (Section 2.4). If other tensors cannot be used in this way, it would be interesting to understand why. For instance, even if the rank or border rank of a tensor is known, it might be that we need to find different rank or border rank expressions to use, similar to work on improving leading constants of matrix multiplication algorithms (see, e.g., [36, 118, 33, 31, 131]).

Acknowledgments and Methodology

How the result was originally found and shared with the authors. An Anthropic employee used an internal research model to investigate open problems in the theory of cryptography. One of them was about cryptographic constructions based on the average-case hardness of Zero-kk-Clique [121, 20]. Claude was tasked with verifying and improving the constructions, but instead developed this algorithm, first for the average case, then for the worst case. The session used 16M output tokens with no human input.

Anthropic shared the algorithm with the authors in September 2026 under a confidentiality agreement, offered compensation, and provided access to the public version of Claude.

Shared algorithm. The algorithm that was shared with the authors is essentially the algorithm in Section 2, although presented differently and with other numerical parameters. A different reduction from Exact Triangle to the problem of Section 2 was also shared, although the authors did not include it here, and instead used known reductions to All-Edges Sparse Triangle, which suffice and strengthen the connection. The authors derived the data structure version in Section 4 and its connection with Hinted OMv.

Lean certification. After the paper was completely written, Anthropic used an internal research model to certify this paper’s main results using the Lean 4 proof assistant with the Mathlib library. The formalization is available at https://github.com/anthropics/formal-math/tree/main/3sum-apsp. The following are formalized there: Theorem 19 (Exact Triangle in O(n2.9983)O(n^{2.9983}) time), Theorem 22 (3SUM in O(n1.9992)O(n^{1.9992}) time, and the (min⁡,+)(\min,+)-product and APSP in O(n2.99942)O(n^{2.99942}) time), and the Zero-Weight case of Corollary 39 (Zero-Weight kk-Clique in O(nk−0.0017⌊k/3⌋)O(n^{k-0.0017\lfloor k/3\rfloor}) time for every k≥3k \ge3). All lemmas and prior results that these statements rely on are also formalized there.

Further acknowledgments. The authors used Claude to help with writing, figure creation, and checking mathematical details throughout this project. They have attempted to make the entire paper accessible and well-written, and take full responsibility for its contents.

The authors’ contribution to this publication was done in their individual capacities, not in connection with their duties or responsibilities to Columbia University or to MIT. Any opinions expressed in this work are opinions of the authors; they are not official positions or endorsements of Columbia University or of MIT, and do not represent the research of the authors at Columbia University or MIT.

References

  1. [1][ABF23] Amir Abboud, Karl Bringmann, and Nick Fischer. Stronger 3-SUM lower bounds for approximate distance oracles via additive combinatorics. In Proc. 55th ACM Symposium on Theory of Computing (STOC 2023), pages 391–404, 2023.
  2. [2][ABFK24] Amir Abboud, Karl Bringmann, Nick Fischer, and Marvin Künnemann. The time complexity of fully sparse matrix multiplication. In Proc. 35th ACM-SIAM Symposium on Discrete Algorithms (SODA 2024), pages 4670–4703, 2024.arxiv.org/abs/2309.06317
  3. [3]Amir Abboud, Karl Bringmann, Seri Khoury, and Or Zamir. Hardness of approximation in P via short cycle removal: Cycle detection, distance oracles, and beyond. In Proc. 54th ACM Symposium on Theory of Computing (STOC 2022), pages 1487–1500, 2022. Full version: arXiv:2204.10465.arxiv.org/abs/2204.10465
  4. [4]Nir Ailon and Bernard Chazelle. Lower bounds for linear degeneracy testing. Journal of the ACM, 52(2):157–171, 2005.
  5. [6]Amihood Amir, Timothy M. Chan, Moshe Lewenstein, and Noa Lewenstein. On hardness of jumbled indexing. In Proc. 41st International Colloquium on Automata, Languages, and Programming (ICALP 2014), volume 8572 of LNCS, pages 114–125, 2014.arxiv.org/abs/1405.0189
  6. [7]Josh Alman, Timothy M. Chan, and Ryan Williams. Polynomial representations of threshold functions and algorithmic applications. In Proc. 57th IEEE Symposium on Foundations of Computer Science (FOCS 2016), pages 467–476, 2016.arxiv.org/abs/1608.04355
  7. [8]Josh Alman, Timothy M. Chan, and R. Ryan Williams. Faster deterministic and Las Vegas algorithms for offline approximate nearest neighbors in high dimensions. In Proc. 31st ACM-SIAM Symposium on Discrete Algorithms (SODA 2020), pages 637–649, 2020.
  8. [9]Vladimir L. Arlazarov, Efim A. Dinic, Mikhail A. Kronrod, and Igor A. Faradžev. On economical construction of the transitive closure of an oriented graph. Soviet Mathematics Doklady, 11:1209–1210, 1970.
  9. [10]Josh Alman, Ran Duan, Virginia Vassilevska Williams, Yinzhan Xu, Zixuan Xu, and Renfei Zhou. More asymmetry yields faster matrix multiplication. In Proc. 36th ACM-SIAM Symposium on Discrete Algorithms (SODA 2025), pages 2005–2039, 2025.arxiv.org/abs/2404.16349
  10. [11]Amir Abboud, Nick Fischer, Zander Kelley, Shachar Lovett, and Raghu Meka. New graph decompositions and combinatorial Boolean matrix multiplication algorithms. In Proc. 56th ACM Symposium on Theory of Computing (STOC 2024), pages 935–943, 2024.arxiv.org/abs/2311.09095
  11. [12]Amir Abboud, Shon Feller, and Oren Weimann. On the fine-grained complexity of parity problems. In Proc. 47th International Colloquium on Automata, Languages, and Programming (ICALP 2020), volume 168 of LIPIcs, pages 5:1–5:19, 2020.arxiv.org/abs/2002.07415
  12. [13]Noga Alon, Oded Goldreich, Johan Håstad, and René Peralta. Simple constructions of almost k-wise independent random variables. Random Structures & Algorithms, 3(3):289–304, 1992.DOI
  13. [14]Noga Alon, Zvi Galil, and Oded Margalit. On the exponent of the all pairs shortest path problem. Journal of Computer and System Sciences, 54(2):255–262, 1997.DOI
  14. [15]Noga Alon, Zvi Galil, Oded Margalit, and Moni Naor. Witnesses for Boolean matrix multiplication and for shortest paths. In Proc. 33rd IEEE Symposium on Foundations of Computer Science (FOCS 1992), pages 417–426, 1992.DOI
  15. [16]Amir Abboud, Fabrizio Grandoni, and Virginia Vassilevska Williams. Subcubic equivalences between graph centrality problems, APSP and diameter. In Proc. 26th ACM-SIAM Symposium on Discrete Algorithms (SODA 2015), pages 1681–1697, 2015.
  16. [17]Amir Abboud, Fabrizio Grandoni, and Virginia Vassilevska Williams. Subcubic equivalences between graph centrality problems, APSP, and diameter. ACM Transactions on Algorithms, 19(1):3:1–3:30, 2023.
  17. [18]Boris Aronov and Sariel Har-Peled. On approximating the depth and related problems. SIAM Journal on Computing, 38(3):899–921, 2008.
  18. [19]Alfred V. Aho, John E. Hopcroft, and Jeffrey D. Ullman. The Design and Analysis of Computer Algorithms. Addison-Wesley, 1974.
  19. [20]Josh Alman, Yizhi Huang, and Kevin Yeo. Fine-grained complexity in a world without cryptography. In Advances in Cryptology – EUROCRYPT 2025, Part VII, volume 15607 of LNCS, pages 375–405, 2025.DOI
  20. [21]Amir Abboud and Kevin Lewi. Exact weight subgraphs and the k-sum conjecture. In Proc. 40th International Colloquium on Automata, Languages, and Programming (ICALP 2013), volume 7965 of LNCS, pages 1–12, 2013.arxiv.org/abs/1304.7558
  21. [22]Josh Alman and Baitian Li. Kronecker powers, orthogonal vectors, and the asymptotic spectrum. In Proc. 66th IEEE Symposium on Foundations of Computer Science (FOCS 2025), pages 1411–1441, 2025. arXiv:2509.14489.arxiv.org/abs/2509.14489
  22. [23]Amir Abboud, Kevin Lewi, and Ryan Williams. Losing weight by gaining edges. In Proc. 22nd European Symposium on Algorithms (ESA 2014), volume 8737 of LNCS, pages 1–12, 2014.arxiv.org/abs/1311.3054
  23. [24]Noga Alon and Moni Naor. Derandomization, witnesses for Boolean matrix multiplication and construction of perfect hash functions. Algorithmica, 16(4–5):434–449, 1996.
  24. [25]Rasmus Resen Amossen and Rasmus Pagh. Faster join-projects and sparse matrix multiplications. In Proc. 12th International Conference on Database Theory (ICDT 2009), pages 121–126, 2009.
  25. [26]Amir Abboud and Virginia Vassilevska Williams. Popular conjectures imply strong lower bounds for dynamic problems. In Proc. 55th IEEE Symposium on Foundations of Computer Science (FOCS 2014), pages 434–443, 2014.arxiv.org/abs/1402.0054
  26. [28]Amir Abboud, Virginia Vassilevska Williams, and Huacheng Yu. Matching triangles and basing hardness on an extremely popular conjecture. In Proc. 47th ACM Symposium on Theory of Computing (STOC 2015), pages 41–50, 2015.
  27. [29]Josh Alman and Ryan Williams. Probabilistic polynomials and Hamming nearest neighbors. In Proc. 56th IEEE Symposium on Foundations of Computer Science (FOCS 2015), pages 136–150, 2015.DOI
  28. [30]Amir Abboud, Ryan Williams, and Huacheng Yu. More applications of the polynomial method to algorithm design. In Proc. 26th ACM-SIAM Symposium on Discrete Algorithms (SODA 2015), pages 218–230, 2015.
  29. [31]Josh Alman and Hantao Yu. Improving the leading constant of matrix multiplication. In Proc. 36th ACM-SIAM Symposium on Discrete Algorithms (SODA 2025), pages 1933–1971, 2025.arxiv.org/abs/2410.20538
  30. [32]Noga Alon, Raphael Yuster, and Uri Zwick. Finding and counting given length cycles. Algorithmica, 17(3):209–223, 1997.
  31. [33]Austin R. Benson and Grey Ballard. A framework for practical parallel fast matrix multiplication. In Proc. 20th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP 2015), pages 42–53, 2015.
  32. [34]David Bremner, Timothy M. Chan, Erik D. Demaine, Jeff Erickson, Ferran Hurtado, John Iacono, Stefan Langerman, Mihai Pătrașcu, and Perouz Tasslakian. Necklaces, convolutions, and X + Y. Algorithmica, 69(2):294–314, 2014.
  33. [35]Ilya Baran, Erik D. Demaine, and Mihai Pătrașcu. Subquadratic algorithms for 3SUM. Algorithmica, 50(4):584–596, 2008.
  34. [36]Arturs Backurs, Nishanth Dikkala, and Christos Tzamos. Tight hardness results for maximum weight rectangles. In Proc. 43rd International Colloquium on Automata, Languages, and Programming (ICALP 2016), volume 55 of LIPIcs, pages 81:1–81:13, 2016.arxiv.org/abs/1602.05837
  35. [38]Huck Bennett, Karthik Gajulapalli, Alexander Golovnev, and Evelyn Warton. Output-sparse matrix multiplication using compressed sensing. In Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques (APPROX/RANDOM 2026), volume 392 of LIPIcs, pages 40:1–40:20, 2026. Full version: arXiv:2508.10250.arxiv.org/abs/2508.10250
  36. [39]Karl Bringmann, Paweł Gawrychowski, Shay Mozes, and Oren Weimann. Tree edit distance cannot be computed in strongly subcubic time (unless APSP can). ACM Transactions on Algorithms, 16(4):48:1–48:22, 2020.
  37. [40]Andreas Björklund, Thore Husfeldt, Petteri Kaski, and Mikko Koivisto. Trimmed Moebius inversion and graphs of bounded degree. Theory of Computing Systems, 47(3):637–654, 2010.
  38. [42]Dario Bini. Relations between exact and approximate bilinear algorithms. Applications. Calcolo, 17:87–97, 1980.DOI
  39. [44]Karl Bringmann and Vasileios Nakos. A fine-grained perspective on approximating subset sum and partition. In Proc. 32nd ACM-SIAM Symposium on Discrete Algorithms (SODA 2021), pages 1797–1815, 2021.arxiv.org/abs/1912.12529
  40. [45]Karl Bringmann. Fine-grained complexity theory (tutorial). In Proc. 36th International Symposium on Theoretical Aspects of Computer Science (STACS 2019), volume 126 of LIPIcs, pages 4:1–4:7, 2019.DOI
  41. [46]Karl Bringmann. Knapsack with small items in near-quadratic time. In Proc. 56th ACM Symposium on Theory of Computing (STOC 2024), pages 259–270, 2024.arxiv.org/abs/2308.03075
  42. [50]Marco L. Carmosino, Jiawei Gao, Russell Impagliazzo, Ivan Mihajlin, Ramamohan Paturi, and Stefan Schneider. Nondeterministic extensions of the strong exponential time hypothesis and consequences for non-reducibility. In Proc. 7th ACM Conference on Innovations in Theoretical Computer Science (ITCS 2016), pages 261–270, 2016.
  43. [51]Timothy M. Chan and Qizheng He. Reducing 3SUM to convolution-3SUM. In Proc. 3rd SIAM Symposium on Simplicity in Algorithms (SOSA 2020), pages 1–7, 2020.DOI
  44. [52]Timothy M. Chan. All-pairs shortest paths with real weights in O(n³/log n) time. Algorithmica, 50(2):236–243, 2008. Preliminary version in WADS 2005.
  45. [53]Timothy M. Chan. More algorithms for all-pairs shortest paths in weighted graphs. SIAM Journal on Computing, 39(5):2075–2089, 2010.
  46. [54]Timothy M. Chan. Speeding up the four Russians algorithm by about one more logarithmic factor. In Proc. 26th ACM-SIAM Symposium on Discrete Algorithms (SODA 2015), pages 212–217, 2015.DOI
  47. [55]Timothy M. Chan. More logarithmic-factor speedups for 3SUM, (median,+)-convolution, and some geometric 3SUM-hard problems. ACM Transactions on Algorithms, 16(1):7:1–7:23, 2020.
  48. [56]Vašek Chvátal. A greedy heuristic for the set-covering problem. Mathematics of Operations Research, 4(3):233–235, 1979.DOI
  49. [59]Marek Cygan, Marcin Mucha, Karol Węgrzycki, and Michał Włodarczyk. On problems equivalent to (min,+)-convolution. ACM Transactions on Algorithms, 15(1):14:1–14:25, 2019.
  50. [60]Norishige Chiba and Takao Nishizeki. Arboricity and subgraph listing algorithms. SIAM Journal on Computing, 14(1):210–223, 1985.DOI
  51. [61]Stephen A. Cook. The complexity of theorem-proving procedures. In Proc. 3rd ACM Symposium on Theory of Computing (STOC 1971), pages 151–158, 1971.DOI
  52. [62]Don Coppersmith. Rapid multiplication of rectangular matrices. SIAM Journal on Computing, 11(3):467–471, 1982.DOI
  53. [63]Don Coppersmith. Rectangular matrix multiplication revisited. Journal of Complexity, 13(1):42–49, 1997.DOI
  54. [64]Hagai Cohen and Ely Porat. Fast set intersection and two-patterns matching. Theoretical Computer Science, 411(40–42):3795–3800, 2010.
  55. [65]James W. Cooley and John W. Tukey. An algorithm for the machine calculation of complex Fourier series. Mathematics of Computation, 19(90):297–301, 1965.
  56. [66]Timothy M. Chan, Virginia Vassilevska Williams, and Yinzhan Xu. Algorithms, reductions and equivalences for small weight variants of all-pairs shortest paths. In Proc. 48th International Colloquium on Automata, Languages, and Programming (ICALP 2021), volume 198 of LIPIcs, pages 47:1–47:21, 2021. Full version: arXiv:2102.06181, whose numbering we follow.arxiv.org/abs/2102.06181
  57. [67]Timothy M. Chan, Virginia Vassilevska Williams, and Yinzhan Xu. Hardness for triangle problems under even more believable hypotheses: Reductions from real APSP, real 3SUM, and OV. In Proc. 54th ACM Symposium on Theory of Computing (STOC 2022), pages 1501–1514, 2022. Full version: arXiv:2203.08356, whose numbering we follow.arxiv.org/abs/2203.08356
  58. [68]Timothy M. Chan, Virginia Vassilevska Williams, and Yinzhan Xu. Fredman’s trick meets dominance product: Fine-grained complexity of unweighted APSP, 3SUM counting, and more. In Proc. 55th ACM Symposium on Theory of Computing (STOC 2023), pages 419–432, 2023.arxiv.org/abs/2303.14572
  59. [69]Don Coppersmith and Shmuel Winograd. Matrix multiplication via arithmetic progressions. Journal of Symbolic Computation, 9(3):251–280, 1990.
  60. [71]Timothy M. Chan and Yinzhan Xu. Simpler reductions from exact triangle. In Proc. 7th SIAM Symposium on Simplicity in Algorithms (SOSA 2024), pages 28–38, 2024.arxiv.org/abs/2310.11575
  61. [72]Emilien Dupont, Marvin Eisenberger, Borislav Kozlovskii, Abbas Mehrabian, Francisco J. R. Ruiz, Abigail See, Renfei Zhou, Josh Alman, Virginia Vassilevska Williams, and Matej Balog. Improving the matrix multiplication exponent with modern optimization and AlphaEvolve. arXiv:2608.16884, 2026.arxiv.org/abs/2608.16884
  62. [73]Bartłomiej Dudek, Paweł Gawrychowski, and Tatiana Starikovskaya. All non-trivial variants of 3-LDT are equivalent. In Proc. 52nd ACM Symposium on Theory of Computing (STOC 2020), pages 974–981, 2020.DOI
  63. [74]Lech Duraj, Krzysztof Kleiner, Adam Polak, and Virginia Vassilevska Williams. Equivalences between triangle and range query problems. In Proc. 31st ACM-SIAM Symposium on Discrete Algorithms (SODA 2020), pages 30–47, 2020.DOI
  64. [75]Erik D. Demaine, Shay Mozes, Benjamin Rossman, and Oren Weimann. An optimal decomposition algorithm for tree edit distance. ACM Transactions on Algorithms, 6(1):2:1–2:19, 2009.
  65. [76]Włodzimierz Dobosiewicz. A more efficient algorithm for the min-plus multiplication. International Journal of Computer Mathematics, 32(1–2):49–60, 1990.DOI
  66. [77]Martin Dietzfelbinger, Philipp Schlag, and Stefan Walzer. A subquadratic algorithm for 3XOR. In Proc. 43rd International Symposium on Mathematical Foundations of Computer Science (MFCS 2018), volume 117 of LIPIcs, pages 59:1–59:15, 2018.arxiv.org/abs/1804.11086
  67. [79]Jeff Erickson. Lower bounds for linear satisfiability problems. Chicago Journal of Theoretical Computer Science, 1999(8), 1999.
  68. [82]Nick Fischer. Universe reduction for APSP: Equivalence of three fine-grained hypotheses. In Proc. 58th ACM Symposium on Theory of Computing (STOC 2026), pages 922–932, 2026.
  69. [83]Nick Fischer, Ce Jin, and Yinzhan Xu. New applications of 3SUM-counting in fine-grained complexity and pattern matching. In Proc. 36th ACM-SIAM Symposium on Discrete Algorithms (SODA 2025), pages 4547–4595, 2025.arxiv.org/abs/2410.20764
  70. [84]Nick Fischer, Piotr Kaliciak, and Adam Polak. Deterministic 3SUM-hardness. In Proc. 15th Innovations in Theoretical Computer Science Conference (ITCS 2024), volume 287 of LIPIcs, pages 49:1–49:24, 2024. Full version: arXiv:2310.12913, whose numbering we follow.arxiv.org/abs/2310.12913
  71. [85]Robert W. Floyd. Algorithm 97: Shortest path. Communications of the ACM, 5(6):345, 1962.DOI
  72. [87]Michael L. Fredman. New bounds on the complexity of the shortest path problem. SIAM Journal on Computing, 5(1):83–89, 1976.DOI
  73. [88]Alexander Golovnev, Siyao Guo, Thibaut Horel, Sunoo Park, and Vinod Vaikuntanathan. Data structures meet cryptography: 3SUM with preprocessing. In Proc. 52nd ACM Symposium on Theory of Computing (STOC 2020), pages 294–307, 2020.DOI
  74. [89]Isaac Goldstein, Tsvi Kopelowitz, Moshe Lewenstein, and Ely Porat. Conditional lower bounds for space/time tradeoffs. In Proc. 15th Algorithms and Data Structures Symposium (WADS 2017), volume 10389 of LNCS, pages 421–436, 2017.DOI
  75. [90]Isaac Goldstein, Moshe Lewenstein, and Ely Porat. On the hardness of set disjointness and set intersection with bounded universe. In Proc. 30th International Symposium on Algorithms and Computation (ISAAC 2019), volume 149 of LIPIcs, pages 7:1–7:22, 2019.arxiv.org/abs/1910.00831
  76. [91]Zvi Galil and Oded Margalit. Witnesses for Boolean matrix multiplication and for transitive closure. Journal of Complexity, 9(2):201–221, 1993.DOI
  77. [92]Anka Gajentaan and Mark H. Overmars. On a class of O(n²) problems in computational geometry. Computational Geometry: Theory and Applications, 5(3):165–185, 1995.
  78. [93]Irving J. Good. The interaction algorithm and practical Fourier analysis. Journal of the Royal Statistical Society, Series B, 20(2):361–372, 1958.
  79. [94]Allan Grøn­lund and Seth Pettie. Threesomes, degenerates, and love triangles. Journal of the ACM, 65(4):22:1–22:25, 2018.
  80. [95]Omar Graia. Optimal deterministic fully sparse matrix multiplication. arXiv:2608.18496, 2026.arxiv.org/abs/2608.18496
  81. [97]Yijie Han. Improved algorithm for all pairs shortest paths. Information Processing Letters, 91(5):245–250, 2004.DOI
  82. [98]Yijie Han. An O(n³(log log n/ log n)⁵⧸⁴) time algorithm for all pairs shortest path. Algorithmica, 51(4):428–434, 2008. Preliminary version in ESA 2006.DOI
  83. [99]Timon Hertli. 3-SAT faster and simpler—unique-SAT bounds for PPSZ hold in general. SIAM Journal on Computing, 43(2):718–729, 2014.
  84. [100]Monika Henzinger, Sebastian Krinninger, Danupon Nanongkai, and Thatchaphol Saranurak. Unifying and strengthening hardness for dynamic problems via the online matrix-vector multiplication conjecture. In Proc. 47th ACM Symposium on Theory of Computing (STOC 2015), pages 21–30, 2015.DOI
  85. [101]Bernhard Haeupler, Yaowei Long, and Thatchaphol Saranurak. Dynamic deterministic constant-approximate distance oracles with nᵋ worst-case update time. In Proc. 65th IEEE Symposium on Foundations of Computer Science (FOCS 2024), pages 2033–2044, 2024.
  86. [102]Yijie Han and Tadao Takaoka. An O(n³ log log n/ log² n) time algorithm for all pairs shortest paths. Journal of Discrete Algorithms, 38–41:9–19, 2016. Preliminary version in SWAT 2012.
  87. [103]Russell Impagliazzo and Ramamohan Paturi. On the complexity of k-SAT. Journal of Computer and System Sciences, 62(2):367–375, 2001.DOI
  88. [104]Russell Impagliazzo, Ramamohan Paturi, and Francis Zane. Which problems have strongly exponential complexity? Journal of Computer and System Sciences, 63(4):512–530, 2001.
  89. [105]Alon Itai and Michael Rodeh. Finding a minimum circuit in a graph. SIAM Journal on Computing, 7(4):413–423, 1978.
  90. [106]Ce Jin. 0-1 knapsack in nearly quadratic time. In Proc. 56th ACM Symposium on Theory of Computing (STOC 2024), pages 271–282, 2024.arxiv.org/abs/2308.04093
  91. [107]Donald B. Johnson. Efficient algorithms for shortest paths in sparse networks. Journal of the ACM, 24(1):1–13, 1977.DOI
  92. [108]Zahra Jafargoli and Emanuele Viola. 3SUM, 3XOR, triangles. Algorithmica, 74(1):326–343, 2016.
  93. [109]Ce Jin and Yinzhan Xu. Removing additive structure in 3SUM-based reductions. In Proc. 55th ACM Symposium on Theory of Computing (STOC 2023), pages 405–418, 2023.
  94. [110]Richard M. Karp. Reducibility among combinatorial problems. In Complexity of Computer Computations, pages 85–103. Plenum Press, 1972.
  95. [111]Leslie Robert Kerr. The Effect of Algebraic Structure on the Computational Complexity of Matrix Multiplication. PhD thesis, Cornell University, 1970.
  96. [112]David R. Karger, Daphne Koller, and Steven J. Phillips. Finding the hidden path: Time bounds for all-pairs shortest paths. SIAM Journal on Computing, 22(6):1199–1217, 1993.
  97. [113]Daniel M. Kane, Shachar Lovett, and Shay Moran. Near-optimal linear decision trees for k-SUM and related problems. Journal of the ACM, 66(3):16:1–16:18, 2019.
  98. [114]Manuel Kauers and Jakob Moosbauer. Flip graphs for matrix multiplication. In Proc. 48th International Symposium on Symbolic and Algebraic Computation (ISSAC 2023), pages 381–388, 2023.arxiv.org/abs/2212.01175
  99. [115]Tsvi Kopelowitz and Ely Porat. The strong 3SUM-INDEXING conjecture is false. arXiv:1907.11206, 2019.arxiv.org/abs/1907.11206
  100. [116]Tsvi Kopelowitz, Seth Pettie, and Ely Porat. Higher lower bounds from the 3SUM conjecture. In Proc. 27th ACM-SIAM Symposium on Discrete Algorithms (SODA 2016), pages 1272–1287, 2016.
  101. [118]Elaye Karstadt and Oded Schwartz. Matrix multiplication, a little faster. Journal of the ACM, 67(1):1:1–1:31, 2020. Preliminary version in SPAA 2017.
  102. [119]Tsvi Kopelowitz and Virginia Vassilevska Williams. Towards optimal set-disjointness and set-intersection data structures. In Proc. 47th International Colloquium on Automata, Languages, and Programming (ICALP 2020), volume 168 of LIPIcs, pages 74:1–74:16, 2020.
  103. [120]François Le Gall. Faster algorithms for rectangular matrix multiplication. In Proc. 53rd IEEE Symposium on Foundations of Computer Science (FOCS 2012), pages 514–523, 2012.DOI
  104. [121]Rio LaVigne, Andrea Lincoln, and Virginia Vassilevska Williams. Public-key cryptography in the fine-grained setting. In Advances in Cryptology – CRYPTO 2019, Part III, volume 11694 of LNCS, pages 605–635, 2019.DOI
  105. [122]László Lovász. On the ratio of optimal integral and fractional covers. Discrete Mathematics, 13(4):383–390, 1975.DOI
  106. [123]Andrea Lincoln, Adam Polak, and Virginia Vassilevska Williams. Monochromatic triangles, intermediate matrix products, and convolutions. In Proc. 11th Innovations in Theoretical Computer Science Conference (ITCS 2020), volume 151 of LIPIcs, pages 53:1–53:18, 2020. Full version: arXiv:2009.14479, whose statement of Theorem 8 we follow.DOI
  107. [124]François Le Gall and Florent Urrutia. Improved rectangular matrix multiplication using powers of the Coppersmith–Winograd tensor. In Proc. 29th ACM-SIAM Symposium on Discrete Algorithms (SODA 2018), pages 1029–1046, 2018.DOI
  108. [125]Andrea Lincoln, Virginia Vassilevska Williams, and R. Ryan Williams. Tight hardness for shortest cycles and paths in sparse graphs. In Proc. 29th ACM-SIAM Symposium on Discrete Algorithms (SODA 2018), pages 1236–1252, 2018.arxiv.org/abs/1712.08147
  109. [126]Andrea Lincoln, Virginia Vassilevska Williams, Joshua R. Wang, and R. Ryan Williams. Deterministic time-space trade-offs for k-SUM. In Proc. 43rd International Colloquium on Automata, Languages, and Programming (ICALP 2016), volume 55 of LIPIcs, pages 58:1–58:14, 2016.DOI
  110. [127]Xiao Mao. Breaking the cubic barrier for (unweighted) tree edit distance. In Proc. 62nd IEEE Symposium on Foundations of Computer Science (FOCS 2021), pages 792–803, 2021. Journal version: SIAM J. Comput., pp. FOCS21-195–FOCS21-223, 2023.arxiv.org/abs/2106.02026
  111. [128]John D. Markel. FFT pruning. IEEE Transactions on Audio and Electroacoustics, 19(4):305–311, 1971.DOI
  112. [129]Jiří Matoušek. Computing dominances in Eⁿ. Information Processing Letters, 38(5):277–278, 1991.DOI
  113. [130]Friedhelm Meyer auf der Heide. A polynomial linear search algorithm for the n-dimensional knapsack problem. Journal of the ACM, 31(3):668–676, 1984.
  114. [131]Erik Mårtensson and Paul Stankovski Wagner. The number of the beast: Reducing additions in fast matrix multiplication algorithms for dimensions up to 666. In Proc. SIAM Conference on Applied and Computational Discrete Algorithms (ACDA 2025), pages 47–60, 2025.DOI
  115. [132]Jaroslav Nešetřil and Svatopluk Poljak. On the complexity of the subgraph problem. Commentationes Mathematicae Universitatis Carolinae, 26(2):415–419, 1985.
  116. [133]Jakob Nogler, Adam Polak, Barna Saha, Virginia Vassilevska Williams, Yinzhan Xu, and Christopher Ye. Faster weighted and unweighted tree edit distance and APSP equivalence. In Proc. 57th ACM Symposium on Theory of Computing (STOC 2025), pages 2167–2178, 2025.arxiv.org/abs/2411.06502
  117. [134]Alexander Novikov, Ngân Vũ, Marvin Eisenberger, Emilien Dupont, Po-Sen Huang, Adam Zsolt Wagner, Sergey Shirobokov, Borislav Kozlovskii, Francisco J. R. Ruiz, Abbas Mehrabian, M. Pawan Kumar, Abigail See, Swarat Chaudhuri, George Holland, Alex Davies, Sebastian Nowozin, Pushmeet Kohli, and Matej Balog. AlphaEvolve: A coding agent for scientific and algorithmic discovery. arXiv:2506.13131, 2025.arxiv.org/abs/2506.13131
  118. [135]Mihai Pătraşcu. Towards polynomial lower bounds for dynamic problems. In Proc. 42nd ACM Symposium on Theory of Computing (STOC 2010), pages 603–610, 2010.DOI
  119. [136]Ramamohan Paturi, Pavel Pudlák, Michael E. Saks, and Francis Zane. An improved exponential-time algorithm for k-SAT. Journal of the ACM, 52(3):337–364, 2005.
  120. [137]Rasmus Pagh and Morten Stöckel. The input/output complexity of sparse matrix multiplication. In Proc. 22nd European Symposium on Algorithms (ESA 2014), volume 8737 of LNCS, pages 750–761, 2014.arxiv.org/abs/1403.3551
  121. [138]Liam Roditty and Virginia Vassilevska Williams. Minimum weight cycles and triangles: Equivalences and algorithms. In Proc. 52nd IEEE Symposium on Foundations of Computer Science (FOCS 2011), pages 180–189, 2011.
  122. [139]Liam Roditty and Virginia Vassilevska Williams. Subquadratic time approximation algorithms for the girth. In Proc. 23rd ACM-SIAM Symposium on Discrete Algorithms (SODA 2012), pages 833–845, 2012.
  123. [140]Liam Roditty and Uri Zwick. On dynamic shortest paths problems. In Proc. 12th European Symposium on Algorithms (ESA 2004), volume 3221 of LNCS, pages 580–591, 2004. Journal version: Algorithmica 61(2):389–401, 2011.
  124. [141]Piotr Sankowski. Dynamic transitive closure via dynamic matrix inverse. In Proc. 45th IEEE Symposium on Foundations of Computer Science (FOCS 2004), pages 509–517, 2004.DOI
  125. [142]Henrik V. Sorensen and C. Sidney Burrus. Efficient computation of the DFT with only a subset of input or output points. IEEE Transactions on Signal Processing, 41(3):1184–1200, 1993.DOI
  126. [143]Arnold Schönhage. Partial and total matrix multiplication. SIAM Journal on Computing, 10(3):434–455, 1981.DOI
  127. [144]Uwe Schöning. A probabilistic algorithm for k-SAT and constraint satisfaction problems. In Proc. 40th IEEE Symposium on Foundations of Computer Science (FOCS 1999), pages 410–414, 1999.
  128. [145]Raimund Seidel. On the all-pairs-shortest-path problem in unweighted undirected graphs. Journal of Computer and System Sciences, 51(3):400–403, 1995.
  129. [146]Michael Soss, Jeff Erickson, and Mark H. Overmars. Preprocessing chains for fast dihedral rotations is hard or even impossible. Computational Geometry: Theory and Applications, 26(3):235–246, 2003.
  130. [147]Volker Strassen. Gaussian elimination is not optimal. Numerische Mathematik, 13:354–356, 1969.DOI
  131. [148]Volker Strassen. Vermeidung von Divisionen. Journal für die reine und angewandte Mathematik, 264:184–202, 1973.DOI
  132. [149]Nathan Sheffield, Virginia Vassilevska Williams, and Zoe Xi. The limits of black-box reductions for all-pairs triangle detection. In Proc. 38th ACM-SIAM Symposium on Discrete Algorithms (SODA 2027), 2027. To appear. Full version: arXiv:2608.19092.
  133. [150]Tadao Takaoka. A new upper bound on the complexity of the all pairs shortest path problem. Information Processing Letters, 43(4):195–199, 1992.
  134. [151]Tadao Takaoka. A faster algorithm for the all-pairs shortest path problem and its application. In Proc. 10th International Computing and Combinatorics Conference (COCOON 2004), volume 3106 of LNCS, pages 278–289, 2004.DOI
  135. [152]Tadao Takaoka. An O(n^3 log log n / log n) time algorithm for the all-pairs shortest path problem. Information Processing Letters, 96(5):155–161, 2005.DOI
  136. [154]Virginia Vassilevska Williams. On some fine-grained questions in algorithms and complexity. In Proceedings of the International Congress of Mathematicians (ICM 2018), pages 3447–3487. World Scientific, 2018.DOI
  137. [155]Jan van den Brand, Danupop Nanongkai, and Thatchaphol Saranurak. Dynamic matrix inverse: Improved algorithms and matching conditional lower bounds. In Proc. 60th IEEE Symposium on Foundations of Computer Science (FOCS 2019), pages 456–480, 2019. Full version: arXiv:1905.05067.arxiv.org/abs/1905.05067
  138. [156]Jan van den Brand, Zhao Song, and Tianyi Zhou. Algorithm and hardness for dynamic attention maintenance in large language models. In Proc. 41st International Conference on Machine Learning (ICML 2024), volume 235 of PMLR, pages 49008–49028, 2024.arxiv.org/abs/2304.02207
  139. [157]Virginia Vassilevska Williams and Ryan Williams. Subcubic equivalences between path, matrix and triangle problems. In Proc. 51st IEEE Symposium on Foundations of Computer Science (FOCS 2010), pages 645–654, 2010.
  140. [158]Virginia Vassilevska Williams and Ryan Williams. Finding, minimizing, and counting weighted subgraphs. SIAM Journal on Computing, 42(3):831–854, 2013.
  141. [159]Virginia Vassilevska Williams and R. Ryan Williams. Subcubic equivalences between path, matrix, and triangle problems. Journal of the ACM, 65(5):27:1–27:38, 2018.
  142. [160]Virginia Vassilevska Williams and Yinzhan Xu. Monochromatic triangles, triangle listing and APSP. In Proc. 61st IEEE Symposium on Foundations of Computer Science (FOCS 2020), pages 786–797, 2020. Full version: arXiv:2007.09318, whose numbering we follow.arxiv.org/abs/2007.09318
  143. [161]Virginia Vassilevska Williams, Yinzhan Xu, Zixuan Xu, and Renfei Zhou. New bounds for matrix multiplication: From alpha to omega. In Proc. 35th ACM-SIAM Symposium on Discrete Algorithms (SODA 2024), pages 3792–3835, 2024.arxiv.org/abs/2307.07970
  144. [162]Stephen Warshall. A theorem on Boolean matrices. Journal of the ACM, 9(1):11–12, 1962.DOI
  145. [163]Ryan Williams. A new algorithm for optimal 2-constraint satisfaction and its implications. Theoretical Computer Science, 348(2–3):357–365, 2005.DOI
  146. [164]R. Ryan Williams. The polynomial method in circuit complexity applied to algorithm design (invited talk). In Proc. 34th International Conference on Foundation of Software Technology and Theoretical Computer Science (FSTTCS 2014), volume 29 of LIPIcs, pages 47–60, 2014.DOI
  147. [165]R. Ryan Williams. Strong ETH breaks with Merlin and Arthur: Short, non-interactive proofs of batch evaluation. In Proc. 31st Computational Complexity Conference (CCC 2016), volume 50 of LIPIcs, pages 2:1–2:17, 2016.arxiv.org/abs/1601.04743
  148. [166]R. Ryan Williams. Faster all-pairs shortest paths via circuit complexity. SIAM Journal on Computing, 47(5):1965–1985, 2018.
  149. [167]R. Ryan Williams. The orthogonal vectors conjecture and non-uniform circuit lower bounds. In Proc. 65th IEEE Symposium on Foundations of Computer Science (FOCS 2024), pages 1372–1387, 2024. ECCC TR24-142.DOI
  150. [168]Frank Yates. The design and analysis of factorial experiments. Technical Communication 35, Imperial Bureau of Soil Science, Harpenden, 1937.
  151. [169]Huacheng Yu. An improved combinatorial algorithm for Boolean matrix multiplication. Information and Computation, 261:240–247, 2018.
  152. [170]Raphael Yuster and Uri Zwick. Answering distance queries in directed graphs using fast matrix multiplication. In Proc. 46th IEEE Symposium on Foundations of Computer Science (FOCS 2005), pages 389–396, 2005.DOI
  153. [171]Raphael Yuster and Uri Zwick. Fast sparse matrix multiplication. ACM Transactions on Algorithms, 1(1):2–13, 2005.
  154. [172]Uri Zwick. All pairs shortest paths using bridging sets and rectangular matrix multiplication. Journal of the ACM, 49(3):289–317, 2002.
  155. [173]Uri Zwick. A slightly improved sub-cubic algorithm for the all pairs shortest paths problem with real edge lengths. Algorithmica, 46(2):181–192, 2006. Preliminary version in ISAAC 2004.

Paper details

Contents