Deterministic Monotone Min-Plus Product and Convolution
Abstract
The Monotone Min-Plus Product problem is a useful primitive that has seen many algorithmic applications over the past decade. It also generalizes various other structured Min-Plus products studied in the literature, such as Bounded Difference Min-Plus Product and Bounded Integer Min-Plus Product. In this problem, we are given two integer matrices and , where each row of is a monotone non-decreasing sequence of integers from , and the goal is to compute their Min-Plus product, defined as the matrix with . The fastest known algorithm for this task [Chi, Duan, Xie, and Zhang, STOC’22] runs in time, significantly improving over the brute-force cubic algorithm. However, its main disadvantage is that it requires randomization, which is then inherited by all downstream applications.
Our main result is a deterministic algorithm for Monotone Min-Plus product with the same running time as its randomized counterpart, improving upon the previous deterministic bound [Gu, Polak, Vassilevska Williams, and Xu, ICALP’21]. Our derandomization also applies to previously studied extensions and variants (e.g., [Dürr, IPL’23]), including rectangular matrices, bounded range , and column-monotone matrices. As an immediate consequence, we derandomize state-of-the-art algorithms for multiple problems, including Language Edit Distance, RNA Folding, Optimum Stack Generation, unweighted Tree Edit Distance, Batched Range Mode, and Approximate All-Pairs Shortest Paths.
Our techniques also yield a deterministic algorithm for the Monotone Min-Plus Convolution problem that runs in time, nearly matching the best-known randomized time complexity [Chi, Duan, Xie, and Zhang, STOC’22]. This algorithm can be used to derandomize state-of-the-art algorithms for Jumbled Indexing for binary strings and several variants of Knapsack.
Keywords and phrases:
Min-plus product, min-plus convolution, monotone matrices, fine-grained complexity, deterministic algorithmsCategory:
Track A: Algorithms, Complexity and GamesFunding:
Ce Jin: Supported by the Miller Research Fellowship at the Miller Institute for Basic Research in Science, UC Berkeley.Copyright and License:
2012 ACM Subject Classification:
Theory of computation Design and analysis of algorithmsEditors:
Sayan Bhattacharya, Danupon Nanongkai, Michael Benedikt, and Gabriele PuppisSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
One of the most fundamental problems in algorithm design is the All-Pairs Shortest Paths problem (APSP), which asks us to compute pairwise distances in an -node weighted graph. APSP is known to be asymptotically equivalent to Min-Plus product [27], where we are given two matrices and and need to compute an matrix such that
The fastest known algorithm for these problems runs in time, due to Williams [29], and further improving this running time remains a major open problem. In fact, a popular hypothesis in fine-grained complexity is that APSP, or equivalently Min-Plus product, does not admit an -time algorithm for any ; see [26] for a survey on fine-grained complexity.
Despite the difficulty of designing faster algorithms for Min-Plus product, researchers have identified several structured cases where it admits truly subcubic-time algorithms. For instance, bounded integer Min-Plus product, where both matrices have entries from 111For a positive integer , denotes . for some integer , can be computed in time [2].222In this paper, we use to hide factors and to hide factors.333 [1] denotes the square matrix multiplication exponent; that is, is the smallest constant such that the product of two matrices can be computed in arithmetic operations. More generally, we use to denote the smallest constant such that the product of an matrix and an matrix can be computed in arithmetic operations. A generalization of bounded integer Min-Plus product is bounded difference Min-Plus product, where adjacent entries in the input matrices differ by at most . Bringmann, Grandoni, Saha, and Vassilevska Williams [7] first studied this setting and gave an -time randomized algorithm and an -time deterministic algorithm for the case . They used bounded difference Min-Plus product as a tool to obtain the first subcubic-time algorithms for Language Edit Distance, RNA Folding, and Optimum Stack Generation.
An important setting that further generalizes bounded difference Min-Plus product, and is the focus of this paper, is monotone Min-Plus product; see [19] for a discussion of this generalization. An matrix is called row-monotone if
-
for every , we have ;
-
for every and , we have .
Column-monotone matrices are defined analogously. The task of computing the Min-Plus product between an arbitrary integer matrix and a row-monotone matrix is called the monotone Min-Plus product problem. The importance of monotone Min-Plus product is reflected in its wide range of applications, including Language Edit Distance [7], RNA Folding [7], Optimum Stack Generation [7], Batched Range Mode [28, 19, 14], unweighted Tree Edit Distance [23, 14, 24], Single-Source Replacement Paths [19, 14], approximate APSP [13, 14, 25], and -Dyck Edit Distance [17, 14].
The fastest known algorithm for monotone Min-Plus product, due to Chi, Duan, Xie, and Zhang [11], runs in time. Unfortunately, this running time is achieved by a randomized algorithm, making the fastest algorithms for applications of monotone Min-Plus product randomized as well. More frustratingly, for many of these algorithms, the only source of randomness is the black-box call to monotone Min-Plus product; see Tables 1 and 2 for examples. Thus, prior to our work, obtaining deterministic algorithms for these applications required replacing the randomized monotone Min-Plus product algorithm with a slower deterministic one, such as the -time algorithm of [19], or the -time bounded difference Min-Plus product algorithm of [7].
| Problem | Randomized Runtime | Deterministic Runtime |
|---|---|---|
| Language Edit Distance | [7, 11] | [7] |
| RNA Folding | [7, 11] | [7] |
| Optimum Stack Generation | [7, 11] | [7] |
| Batched Range Mode | [14] | [18] |
| Unweighted Tree Edit Distance | [24] | [23] |
| -Dyck Edit Distance | [17, 14] | [17] |
| Additive error | Runtime for -approximate APSP |
|---|---|
| (randomized) [21] | |
| (deterministic) [21] | |
| (deterministic) [21] | |
| (randomized) [25] | |
| (randomized) [25] | |
| (randomized) [25] |
Remark.
We briefly explain how some of the randomized running times in Tables 1 and 2 are obtained. The randomized running times for Language Edit Distance, RNA Folding, and Optimum Stack Generation in Table 1 are obtained by replacing the bounded difference Min-Plus product algorithm of [7] with the monotone Min-Plus product algorithm of [11]. For every positive integer , the algorithm of [25] for -approximate APSP in Table 2 runs in time, where is the solution to , and uses the monotone Min-Plus product oracle as its only source of randomness. For additive error with , this is the fastest known algorithm. The work of [21] improves the running times of the - and -approximation algorithms of [25] using deterministic algorithms, and further improves the running time for -approximation using a randomized algorithm whose randomness does not come from the monotone Min-Plus product oracle.
A problem closely related to Min-Plus product is Min-Plus convolution. In the Min-Plus convolution problem, the input consists of two length- arrays and , and the output is an array indexed by , where
with out-of-bounds entries set to . The fastest known algorithm for Min-Plus convolution runs in time, which can be obtained by combining Williams’ APSP algorithm [29] with the reduction in [3]. A popular hypothesis in fine-grained complexity is the Min-Plus convolution hypothesis, which postulates that Min-Plus convolution cannot be solved in time for any ; see [12, 22]. It is known that the Min-Plus convolution hypothesis implies the Min-Plus product hypothesis [3].
Similar to Min-Plus product, Min-Plus convolution admits significantly faster algorithms when the input is structured. A length- array is called monotone if
-
for every , we have ;
-
for every , we have .
When both input arrays are monotone, Chan and Lewenstein [9] gave an -time randomized algorithm and an -time deterministic algorithm. Chi, Duan, Xie, and Zhang [11] improved the randomized running time to . Bringmann, Dürr, and Polak [6] generalized this result to a randomized -time algorithm for arrays with entries in and with only one of the input arrays being monotone.
Monotone Min-Plus convolution also has a wide range of applications, including Jumbled Indexing [9], Knapsack problems with bounded weights and profits [5, 6], and weak approximation schemes for Knapsack problems [5, 10].444These Knapsack results use Max-Plus convolution instead of Min-Plus convolution, but the two are equivalent up to a sign change. Due to the gap between the best-known randomized and deterministic algorithms for monotone Min-Plus convolution, the best-known running times for all these applications are achieved by randomized algorithms. For some applications, the monotone Min-Plus convolution subroutine is the only remaining source of randomness; see Table 3.
| Problem | Randomized Runtime | Deterministic Runtime |
|---|---|---|
| Jumbled Indexing for Binary Strings | [9, 11] | [9] |
| Unbounded Knapsack | [6] | [5] |
| 0-1 Knapsack | [6] | [5, 8] |
| Weakly-Approximate Unbounded Knapsack | [5] | [5] |
Remark.
We explain how some of the running times in Table 3 are obtained. The randomized running time for Jumbled Indexing for Binary Strings follows by replacing the monotone Min-Plus convolution algorithm in [9] with the faster randomized algorithm of [11]. For Unbounded Knapsack, the randomized -time algorithm of Bringmann and Cassis [5], combined with the rectangular and -bounded generalization of [6], yields the refined bounds and .
For - Knapsack, the randomized bound follows from [6, Theorem 12]. We state this bound, rather than their stronger bound, because it is the one to which our derandomization applies. The deterministic 0-1 Knapsack bound shown in the table is not explicitly stated in the literature. The - Knapsack algorithm of [5] has another source of randomness, namely the random partitioning technique originating from [4, 12]. This additional source of randomness was recently derandomized by [8]; see [8, Appendix A] for a deterministic reduction from - Knapsack to Min-Plus convolution in [12]. The same derandomization also applies to the random partitioning step used in [5]. More specifically, if monotone Min-Plus convolution with -bounded inputs can be solved deterministically in time, then the results of [8, 5] imply a deterministic - Knapsack algorithm running in time. The previously known deterministic algorithm for -bounded monotone Min-Plus convolution can be obtained using the deterministic -time algorithm for the -bounded case [9] as a black box, together with blocking and balancing (details omitted). This yields a deterministic -time algorithm for -bounded monotone Min-Plus convolution, and therefore yields the deterministic bound shown in the table.
1.1 Our Results
We close the gap between the deterministic and randomized running times for monotone Min-Plus product and monotone Min-Plus convolution. Our work is inspired by the randomized algorithm of Chi, Duan, Xie, and Zhang [11]. However, our presentation is more streamlined due to several reductions. Moreover, our algorithm for monotone Min-Plus product applies to rectangular matrices and to the case where the entries of lie in an arbitrary range , rather than only in . This matches the extensions studied in the randomized setting by [14, 17, 25], which generalized the framework of [11].
Theorem 1.
There is a deterministic algorithm that, given an integer matrix and an row-monotone matrix with entries in , computes their Min-Plus product in time .
Note that the terms and above are necessary due to input and output sizes. As in [11], our algorithm also extends to the case where is column-monotone. Owing to our more streamlined algorithm, this extension is more modular than in prior approaches.
Theorem 2.
There is a deterministic algorithm that, given an integer matrix and an column-monotone matrix with entries in , computes their Min-Plus product in time .
Very recently, Fischer [15] showed, unless the APSP hypothesis fails, there is no -time algorithm for column-monotone Min-Plus product for any when . Thus, if , our algorithm is near-optimal in this case under the APSP hypothesis.
As in [11], our techniques also extend to monotone Min-Plus convolution. Our algorithm for monotone Min-Plus convolution applies when the array entries lie in . Its running time essentially matches the best-known randomized running time [11, 6].
Theorem 3.
There is a deterministic algorithm that, given two length- monotone arrays and , both with entries in , computes their Min-Plus convolution in time .
Using the reduction of [6, Theorem 8] from the case where both arrays are monotone to the case where only one array is monotone, our algorithm also applies when only one of the two arrays is monotone.
Our algorithms directly derandomize the best randomized algorithms for many problems.
Corollary 4.
In fact, we can derandomize the -approximate APSP algorithm of [21] shown in Table 2. This algorithm does not use monotone Min-Plus product, so its derandomization is not an immediate consequence of our algorithms; nevertheless, it can be derandomized using standard techniques. A proof can be found in the full version.
2 Technical Overview
In this technical overview, we focus on row-monotone Min-Plus product in the parameter regime originally considered by [11], where both input matrices have dimension and entries from . The extensions to rectangular matrices, larger entry ranges, column-monotone matrices, and monotone Min-Plus convolution are handled in the main body.
Our algorithm is a derandomization of the algorithm of [11]. The only source of randomization in their algorithm is to pick a random prime from some appropriate range. Hence, it may appear straightforward to derandomize their algorithm because there is now a standard recipe for derandomizing the choice of a prime (see, e.g., [9, 16]): Instead of choosing a prime from a relatively large range, one can take to be the product of several smaller primes from a smaller range, which are found one by one. For each such prime, one can afford to deterministically enumerate all primes in the smaller range and choose one that works. However, this approach faces several difficulties when applied to the algorithm of [11].
-
A.
The intuition for why [11] needs a random prime is the following. There is an implicit set of roughly nonzero integers, and we want only a small number of integers in to be divisible by ; call this quantity . When is a random prime from , the expected value of can be upper bounded by roughly . If we aim to use the standard approach to derandomize the choice of , we would keep finding primes from a smaller range , and maintain , where is the current number of primes we have determined. For each additional prime, we expect to drop by a factor of roughly . In theory, one can show that such a prime exists, and even a random prime likely works. However, in order for a deterministic algorithm to pick , it would naively need to compute the value of for each choice of . Unfortunately, there does not seem to be an efficient algorithm for this task, which marks the first difficulty in applying this derandomization approach.
-
B.
In addition to the previous role, the prime in [11] also serves another role: it is used to separate an integer into a high-order part () and a low-order part (). If we use the standard approach to derandomize the choice of by multiplying small primes one by one, the high-order parts and low-order parts of the integers keep changing, making it difficult to derandomize the algorithm.
Standard Reductions
To address Item B, we separate the two roles played by . As it turns out, it suffices to pick an arbitrary integer from an appropriate range to separate the integers into high-order parts and low-order parts. Let be such an integer. By standard reductions, it suffices to solve the following problem.
Problem 1.
Let be integer matrices with nonnegative entries bounded by , where both and are row-monotone. In addition, all entries of the matrices satisfy . For every , determine whether there exists such that .
At a high level, the reduction has two steps. First, by recursively halving the entries of and , the product of the halved instance gives an approximation to each entry of : if is the product of the halved instance, then each true value must be one of , , or . Thus, a verifier for candidate values can recover the full product by testing these three candidates. Second, using a standard residue-shifting reduction similar to [11], we transform the verification instance into constantly many promised instances in which the relevant residues of , , and lie in a small interval modulo .
These standard reductions were also present in the algorithm of [11], appearing as a recursive step. By explicitly applying the standard reductions first, we move the recursive step outside the main algorithm, making the algorithm more streamlined. In addition, this helps unify the algorithms for the row-monotone and column-monotone cases. As it turns out, the column-monotone case can also be reduced to a version of Problem 1, where for every , we need to determine the existence of such a ; see Section 5 for details.
Main algorithm
Define , and define and analogously. The algorithm first finds a modulus satisfying ; we defer the additional properties required of , as well as the description of how to find it, until later in the overview. Then the algorithm computes the following quantities:
-
, the number of such that ;
-
, the number of such that and .
It is not difficult to see that if and only if and . Hence, for each pair , there exists a witness if and only if . Therefore, it suffices to compute and for every pair .
Using an approach similar to [2], one can compute all values in time. To discuss how to compute , we define segments, similarly to [11], and a special type of segment called active segments. Let .
Definition 5.
For , a level- segment is a tuple such that, for every , we have and , and cannot be further extended.
Definition 6.
For , a level- segment is called active with respect to if and . Let be the set of active level- segments.
Since and are row-monotone, the number of level- segments is .
We will find a modulus so that, for every , . For now, assume that we have such a modulus . We show how to compute under this assumption.
To see why active segments help compute , consider a triple such that and ; that is, contributes one to . Let be the unique level- segment where . It is not difficult to see that this segment is active. Hence, we proceed by computing :
-
First, we find by enumerating all level- segments and checking whether each segment is active. The number of level- segments is . Hence, this part takes time.
-
Suppose we have computed the set of active level- segments. For every segment , we enumerate all level- segments contained in and check whether they are active. Here, a segment is contained in another segment if , , and . It can be shown that every segment in is contained in some segment in , so this procedure correctly computes . Moreover, each level- segment contains only a constant number of level- segments. By the assumption for every , this step takes time.
Recall that the segments in contain all triples that can contribute to . For every level- segment , the values are constant over , and the values are also constant over this interval. Hence, either all triples with contribute to , or none of them do. We can therefore use a simple data structure to compute all values from in time.
Finding a Good Modulus
It remains to find a modulus such that for every . To do so, consider the following multiset of numbers for every level :
and let denote the number of elements in that are divisible by . Clearly, . When (and hence ), is exactly the number of level- segments such that and . Using the assumptions in Problem 1, it is not difficult to show that one can equivalently replace the second condition with . Hence, is exactly .
To summarize, we have several multisets , each containing nonzero integers, and we need to find a modulus such that, for every , the number of elements of divisible by is at most . This is exactly the setting where the standard recipe of constructing as a product of smaller primes applies. More precisely, we construct as the product of primes from , for some relatively small . Let be the set of primes in . At each step, we find an additional prime by enumerating all primes in and choosing a suitable one. We stop once the product of the chosen primes exceeds . By a standard probability analysis, there exist primes such that if , then is bounded by roughly for every . Since , this gives for every , as desired. Hence, it remains to find these suitable primes deterministically.
In this overview, we illustrate our approach by showing how to find the first prime such that for every . The same idea extends easily to finding the remaining primes. Since , we can afford to enumerate all primes in and choose one that works. However, even when is fixed, it is unclear how to compute efficiently: the straightforward approach requires enumerating all level- segments, which takes time. When is small, this bound can be as high as . This reflects the first difficulty mentioned in Item A, although the setting here is already somewhat different.
Instead of computing , we take a more indirect approach. Let
This multiset has the same definition as , except that we do not remove the zero elements. Let denote the number of elements in that are divisible by . As it turns out, one can compute efficiently in time, following the high-level idea of [2]. Next, observe that is exactly the number of pairs such that , where is a level- segment and . In particular, does not depend on ; denote this quantity by .
In our algorithm, we compute for every , and then choose a prime minimizing . This prime can be found deterministically in time, since this procedure only uses the computable values , rather than the values . Note that is exactly . Hence, minimizes
By a standard probabilistic argument, for every . Thus, minimizes up to a additive error. Again by a standard probabilistic argument,
Therefore, for every , as desired.
3 Preliminaries
Notations
For integers and , we write for the unique integer such that . For a positive integer , we write . For integers , we write .
Min-Plus Product
Let be an integer matrix and let be an integer matrix. The Min-Plus product of and is the matrix defined by
Min-Plus Convolution
Let and be arrays of length indexed from . The Min-Plus convolution of and is an array indexed by , defined by
Monotonicity
An matrix is row-monotone if for every and , .555Unlike in the introduction, where boundedness is included for readability, monotonicity here only refers to the ordering condition; boundedness is stated separately. It is column-monotone if for every and , . An array of length is monotone if for every , .
Rectangular Matrix Multiplication
Polynomial Multiplication
Let be bivariate polynomials whose degree in is at most and whose degree in is at most . We can compute and in time, and compute in time using FFT. Let and be polynomial matrices whose entries have degree at most . Then the matrix product can be computed in time.
Prime Number Theorem
Let denote the number of primes at most . The prime number theorem states that . As a corollary, for any sufficiently large integer , the number of primes in the interval is .
4 Deterministic Monotone Min-Plus Product
In this section, we present a deterministic algorithm for row-monotone Min-Plus product, whose definition we recall below.
Problem 2.
Let be an integer matrix. Let be an row-monotone integer matrix with entries in . Given as input, compute .
4.1 Reduction to a Verification Problem
We start with a standard reduction that transforms the problem into a simpler form. Consider the following verification problem.
Problem 3.
Let be an integer matrix with nonnegative entries bounded by . Let be an row-monotone integer matrix with nonnegative entries bounded by . Let be an row-monotone integer matrix with nonnegative entries bounded by . Given as input, for every , decide whether there exists such that .
Lemma 7.
Proof.
First, by a simple observation of [11], we may assume that all entries of are nonnegative integers bounded by : for each , subtract from every entry in the -th row of , where is the minimum value in that row. Then any entry of greater than can be set to , since it can never participate in an optimal solution. After computing the Min-Plus product of the modified matrix and , we simply add back to the -th row of the result.
Let and . Flooring preserves row-monotonicity, so the rows of are also row-monotone. We compute recursively. The base case occurs when both and are zero matrices, in which case we can compute trivially. Now define three candidate matrices by for . Since the rows of are monotone, one can prove that the rows of are also monotone. Therefore, the rows of each are monotone as well, and we can run the algorithm for Problem 3 on the instance for each .
Since and , we have
and
Together, these inequalities imply . Thus, for each fixed pair , there exists at least one such that , and we can recover by taking the minimum value among for which the verifier accepts on . Moreover, if the verifier accepts on with witness , then . Therefore, taking the minimum accepted value among the returns exactly .
For the running time, we make calls to the -time verifier per recursion level. The recursion depth is . The additional costs of forming , , and the matrices are dominated by . Hence, the total running time is .
Using an approach similar to that of [11, Lemma 3.5], we further reduce Problem 3 to the following problem and focus on solving it efficiently. Since the reduction is standard, we defer the proof to the full version.
Problem 4.
Let be an instance of Problem 3, and let be a positive integer that is a multiple of and satisfies . Additionally, assume that for every , , and , we have . Given as input, for every , decide whether there exists such that .
4.2 Algorithm for Problem 4
Suppose we are given an instance of Problem 4 with for some constant . Define
We also define
The high-level outline of our algorithm is as follows:
-
1.
Find a “good” modulus with . The definition of “good” is deferred to Definition 16.
-
2.
For every , compute , the number of such that .
-
3.
For every , compute , the number of such that and .
-
4.
For each , output Yes if and only if .
We first prove two simple facts that bound , depending on whether , and then prove the correctness of the algorithm assuming that our subroutines are correct.
Fact 9.
For every , if , then .
Proof.
We decompose . If , then . By the promise of Problem 4, . Therefore, using , we have
Fact 10.
For every , if , then .
Proof.
Since , we have by the same argument as in Fact 9.
Recall that is the number of such that , and is the number of such that and . We now prove the correctness of our algorithm.
Lemma 11 (Correctness).
For every , there exists such that if and only if .
Proof.
Fix and suppose there exists such that . Then , so this contributes one to . Moreover, under the promise of Problem 4, we have , so adding the low parts creates no carry across a multiple of . Hence, . Therefore, this does not contribute to , and so .
Conversely, suppose . Then there exists such that and . By Fact 10, we have . Since is a multiple of and has magnitude strictly less than , it must be zero. Therefore, .
In the following sections, we describe how to compute and efficiently, and how to construct a suitable modulus . To this end, we introduce several objects used by the subroutines and their analysis. Let be such that .
Definition 12 (Segments).
For , a level- segment is a triple such that, for every , and , and cannot be extended further.
Fact 13.
For , the total number of level- segments is .
Definition 14 (Active segment).
For , a level- segment is called active with respect to if and there exists such that .
Definition 15 (Set of active segments).
For , let be the set of all level- segments that are active with respect to .
Definition 16 (Good modulus).
We say that an integer is a good modulus if and for all .
4.3 Computing and
Recall that is the number of indices such that . We compute for all using polynomial matrix multiplication. The technique is standard, so we defer the proof to the full version.
Lemma 17 (Computing ).
We can compute for every in time .
Recall that is the number of indices such that and . Suppose that is a good modulus as defined in Definition 16; we show how to find such a modulus in the next section. For simplicity, let denote the set of all active level- segments, suppressing the dependence on . We first prove a property used by our subroutine, and then prove two lemmas describing the procedure for computing .
Lemma 18.
For all and , the unique level- segment with is active, i.e., .
Proof.
Fix . By definition of a level- segment, we have . Hence, . Moreover, by the promise of Problem 4. Hence, if , then
which contradicts the previous bound. Therefore, is constant for , and by a similar argument, is constant for . Now, since , we have . Because , we conclude that , satisfying the high-part condition of being active.
For the congruence condition, note that and is a level- segment. Hence, and , which implies . Since , we have for some . Take
Then and . Thus, the level- segment is active.
Lemma 19 (Computing ).
We can compute in time.
Proof.
We first compute all level- segments as follows. For each , we use binary search on to group maximal consecutive indices on which and are both constant. We then enumerate all those level- segments and filter the active ones to obtain . Next, for , we construct from as follows. Every segment in refines into level- subsegments, since decreasing by can split a maximal constant block into at most two blocks for and at most two blocks for . We use binary search to compute these subsegments. For each resulting subsegment, we test whether it is active at level and, if so, insert it into .
For correctness, note that every active level- segment is a subsegment of an active level- segment by Lemma 18; the correctness therefore follows by induction.
By Fact 13, computing all level- segments via binary search and constructing takes time. For the refinement, we note that is a good modulus, so for each , we have , and each active segment generates only subsegments. There are levels, so the total time spent in this refinement step is .
Lemma 20 (Computing ).
We can compute for all in time .
Proof.
We first compute the set using Lemma 19. To compute all , we aggregate the contributions of active level- segments in as follows. For each fixed , we maintain a difference array of length , indexed by , and initialized to zero. For each active level- segment , we test whether . If the test succeeds, we increment by one and decrement by one. After processing all active level- segments, we compute prefix sums and set for all .
For correctness, fix any triple counted in . Then we have and . Let be the unique level- segment such that . Since is a level- segment, the values and are constant over all . Since , we have and . Hence, is an active level- segment in , and the algorithm performs the range update for . This update increases the reconstructed value by one for this exactly when .
Conversely, whenever the algorithm performs a range update for , we have . Since is a level- segment, the values and are constant over all . Therefore, for every . Moreover, the segment is active, so for every , and the update contributes exactly the intended triples to .
For the running time, scanning all segments in and performing the constant-time test and update takes . The total time to compute prefix sums is , since for each fixed we scan once. Together with the time to compute , which is by Lemma 19, this yields the claimed running time.
4.4 Finding a Good Modulus
We now construct a good modulus , namely an integer with such that the number of active level- segments is for every .
Let be a parameter to be fixed later, and let be the set of primes in . We take to be a product of primes with for all . We choose these primes inductively: at step , we select a prime and multiply it into the current modulus , obtaining
For the analysis, define as the number of pairs , where is a level- segment and , such that
Our inductive invariant for is that
| (1) |
Later, we choose so that . Then, by the following lemma, is a good modulus.
Lemma 21.
For every , we have .
Proof.
Let . By definition of an active segment, there exists an integer such that and . We claim that . Indeed, since , Fact 9 implies . On the other hand, , so . Therefore, every active segment in yields a pair counted by , and hence .
We now explain how to choose so that the invariant Equation 1 continues to hold. For the base case , we have . Since counts level- segment–shift pairs, we trivially have by Fact 13, and thus satisfies the invariant. Now assume Equation 1 holds for and that is fixed. For any prime , let denote the value of when is set to . Our goal is to find a prime such that Equation 1 holds with respect to .
First, such a prime exists; applying the following lemma inductively yields the entire sequence . The proof is standard, so we defer it to the full version.
Lemma 22.
There exists such that, for every ,
| (2) |
Moreover, for every , if is chosen uniformly at random from , then .
We now discuss how to deterministically select these primes. For this, it is convenient to track the following additional quantities.
-
1.
Let denote the number of pairs , where is a level- segment and , satisfying
-
2.
Let denote the number of pairs , where is a level- segment and , satisfying
As with , let denote the value of when the modulus is .
As discussed in Section 2, we can afford to compute for all and . Computing is essentially the same as computing : we reduce modular counting to rectangular matrix multiplication over a polynomial ring. The only difference is that we count segments rather than all column indices. More formally, we have the following lemma.
Lemma 23 (Computing ).
We can compute for all primes and all levels in time .
Proof.
Fix a prime and a level . We present an algorithm to compute for the modulus in time. Since there are levels, , and , the total running time to compute for all and all levels is .
Recall that counts pairs where is a level- segment, , and . A level- segment is a maximal interval on which both and are constant. Therefore, starts at column if and only if either , or at least one of and changes at . Hence, it suffices to check each segment exactly once via its start column . More concretely, define an boundary indicator matrix by
and an boundary indicator matrix by
Then it suffices to count, for each , the indices with or , grouped by the residue class of , and then weight each residue class by the number of admissible shifts in that class.
To do this, we use the polynomial matrix multiplication technique. Work over the ring , where is a field of sufficiently large characteristic. Construct an matrix and two matrices and by
Compute the matrix products and over using fast rectangular matrix multiplication, and finally construct an matrix defined by
For each and , let be the coefficient of in . Then is the number of indices such that and either or . Next, define
Note that the pair is counted in exactly when . Equivalently, if , then . Thus, grouping by , the contribution of a fixed to is
Therefore, summing over and , we recover .
For the running time, arithmetic in reduces exponents modulo , so the cost of the rectangular matrix product is , and we compute such products. Extracting for all and costs , computing for all costs , and evaluating the triple sum costs . Hence, for fixed and we can compute in time.
Lemma 24.
We can find a prime satisfying Equation 1; that is, for all . Moreover, can be found in time .
Proof.
We run the algorithm in Lemma 23 to compute for all primes and all levels . For each , define , and choose that minimizes
For correctness, we first note that . Since for all and , we have for every , and thus .
Now, let be a prime satisfying Equation 2, which exists by Lemma 22. Then, for every ,
where the last equality follows from the inductive hypothesis Equation 1. Therefore, , and by the choice of minimizing , we obtain
Next, define . By minimality, Lemma 22, and the inductive hypothesis Equation 1,
Also, since for all and is independent of , we have
Combining the above bounds, for every we get
For the running time, computing for all and all via Lemma 23 dominates, giving time. The remaining steps, namely taking minima and selecting , take at most additional time, which is lower order.
It remains to set the parameters so that the above procedure yields a good modulus.
Fact 25.
Let and . Then .
Lemma 26 (Computing a good modulus).
We can compute a good modulus in time .
Proof.
By applying Lemma 24 inductively for steps, we obtain primes and a modulus such that Equation 1 holds. Since for all , we have . In particular, to ensure it suffices to take . Moreover, if we take to be the first index such that , then and hence , so overshoots by at most a factor of . We set
Then , and therefore . Finally, by Fact 25, we have , and so . Hence satisfies , and
Therefore, is a good modulus.
For the running time, we apply Lemma 24 for steps. At step , the cost of computing is . Since , the total time is
where the last bound uses for our choice of .
4.5 Combining the Results
Theorem 27.
There is a deterministic -time algorithm for Problem 4.
Proof.
Proof of Theorem 1.
Our claimed running time is . Let . Since , we have : indeed, would imply , contradicting the trivial lower bound . Furthermore, we may assume that : if , then . In this case, Lemma 17 of [19] gives an algorithm running in time , which is dominated by our claimed bound. Hence, we may assume .
Now, by Lemmas 7 and 8, it suffices to solve Problem 4. By Theorem 27, there is a deterministic algorithm for Problem 4 that runs in time . We take as the exponent for ; that is, take . Then the two terms balance, yielding
which is dominated by our claimed bound.
5 Extension to Column-Monotone Min-Plus Product
In this section, we present a deterministic algorithm for column-monotone Min-Plus product, whose definition we recall below.
Problem 5.
Let be an integer matrix. Let be an column-monotone integer matrix with entries in . Given as input, compute .
We start by reducing column-monotone Min-Plus product to the following problem, which is a “rotated” version of Problem 3 (the differences have been highlighted).
Problem 3’.
Let be an integer matrix with nonnegative entries bounded by . Let be an row-monotone integer matrix with nonnegative entries bounded by . Let be an row-monotone integer matrix with nonnegative entries bounded by . Given as input, for every , decide whether there exists such that .
Theorem 28.
There is a deterministic algorithm for ˜3’ that runs in time.
We defer the proof of Theorem 28 to the full version, as it largely repeats arguments from Section 4. Instead, we prove Theorem 2 assuming Theorem 28.
Proof of Theorem 2 assuming Theorem 28.
Let be an instance of Problem 5. Similar to the proof of Lemma 7, we may assume that all entries of are nonnegative integers bounded by . By an observation in [11], we may also assume that each row of is monotonically non-increasing: if there exist such that and , then for every by the monotonicity of . Hence, replacing by does not change .
Now we follow the same recursive halving approach as in the proof of Lemma 7. Let and . Flooring preserves monotonicity, so the columns of are monotone and the rows of are monotonically non-increasing. We compute recursively, with the trivial base case when both matrices are zero. Define three candidate matrices by for .
As in the proof of Lemma 7, it suffices to check, for each and , whether there exists such that . Let be the maximum entry of , , and . This condition is equivalent to . Thus, it can be solved by ˜3’ on the input , where denotes the all- matrix. All entries are bounded by , and both and are row-monotone, so the input satisfies the requirements of ˜3’. The dimensions are rotated as follows: the three matrices have dimensions , , and . Hence, by Theorem 28 and the symmetry , each verifier call takes time . Since there are only constantly many verifier calls per recursion level and the recursion depth is , the asymptotic running time remains the same.
6 Deterministic Monotone Min-Plus Convolution
In this section, we present a deterministic algorithm for monotone Min-Plus convolution, whose definition we recall below.
Problem 6.
Let and be two monotone arrays of length with entries in . Given as input, compute .
We defer most details in this section to the full version, since they largely repeat the core arguments from Section 4.
As in Section 4, we first reduce Problem 6 to a corresponding verification problem and then to a promised version in which all entries have small residues modulo a parameter .
Problem 7.
Let and be two monotone arrays of length with nonnegative entries bounded by . Let be an array of length indexed from to with nonnegative entries bounded by . Let be a positive integer that is a multiple of and at most . Additionally, assume that for every , we have , and for every , we have . Given as input, for every , decide whether there exists such that and .
Lemma 29.
6.1 Algorithm for Problem 7
Suppose we are given an instance of Problem 7 with for some constant . Define , , and . We also define , , and . The high-level outline of our algorithm is as follows:
-
1.
Find a “good” modulus with . The definition of “good” is deferred to Definition 35.
-
2.
For every , compute , the number of indices such that and .
-
3.
For every , compute , the number of indices such that and and .
-
4.
For each , output Yes if and only if .
Lemma 30 (Correctness).
For every , there exists such that and if and only if .
Let be such that . We define segments, active segments, and the notion of a good modulus analogously to Section 4.
Definition 31 (Segments).
For , a level- segment is a pair such that , for every , , and , and cannot be extended further.
Fact 32.
For , the number of level- segments is .
Definition 33 (Active segment).
For , a level- segment is called active with respect to if and there exists such that .
Definition 34 (Set of active segments).
For , let be the set of all active level- segments with respect to .
Definition 35 (Good modulus).
We say that an integer is a good modulus if and, for every , .
Let be a parameter to be fixed later, and let be the set of primes in . We take to be a product of primes , where for all . Let be the modulus at step . The natural invariant corresponding to Equation 1 is
| (3) |
Here, counts pairs , where is a level- segment, , , and . One can show that . Let count pairs , where is a level- segment and , such that . For any prime , let (resp., ) denote the value of (resp., ) when the modulus is . Fix . As in Section 4.4, we compute for all primes and all levels , and use them to find a suitable prime that satisfies Equation 3. Such a prime exists by a probabilistic argument, as in Lemma 22; we defer the details to the full version.
Lemma 36 (Computing ).
We can compute for all primes and all levels in time.
Lemma 37.
We can find a prime satisfying Equation 3; that is, for all in time.
By computing suitable primes with , we obtain the following lemma.
Lemma 38 (Computing a good modulus).
We can compute a good modulus in time.
Let be the good modulus obtained by this procedure. We use polynomial multiplication to compute . The computation of is analogous to that in Lemma 20.
Lemma 39 (Computing ).
We can compute for every in time .
Lemma 40.
For all , and , the unique level- segment such that is active, i.e., .
Lemma 41 (Computing ).
We can compute for all in time.
Proof sketch.
First, compute similarly to Lemma 19. Its correctness follows inductively using Lemma 40. Then compute the values using as follows: for each segment , we test whether . If the test succeeds, we increment by . For correctness, fix any such that , , and . Let be the unique level- segment containing . Since is a level- segment, the values and are constant for all . Because , we have and . Hence, is an active level- segment and thus belongs to . Moreover, the above identities hold for every . For a fixed , the level- segments form disjoint maximal intervals, so exactly indices in this segment satisfy these conditions. Therefore, the algorithm correctly increments by exactly .
The time for computing is by an argument analogous to that in Lemma 20. We scan all segments in and perform a constant-time test and update for each segment, so this final step takes time.
Combining these results, we obtain the following theorem, as well as Theorem 3.
Theorem 42.
There is a deterministic algorithm that solves Problem 7 in time .
Proof of Theorem 3.
By the reduction in Lemma 29, it suffices to solve Problem 7 efficiently. By Theorem 42, there is a deterministic algorithm that solves Problem 7 in time . Take . Then the two terms balance, yielding the claimed time bound .
References
- [1] Josh Alman, Ran Duan, Virginia Vassilevska Williams, Yinzhan Xu, Zixuan Xu, and Renfei Zhou. More asymmetry yields faster matrix multiplication. In Proceedings of the 2025 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 2005–2039, 2025. doi:10.1137/1.9781611978322.63.
- [2] Noga Alon, Zvi Galil, and Oded Margalit. On the exponent of the all pairs shortest path problem. J. Comput. Syst. Sci., 54(2):255–262, 1997. doi:10.1006/JCSS.1997.1388.
- [3] David Bremner, Timothy M. Chan, Erik D. Demaine, Jeff Erickson, Ferran Hurtado, John Iacono, Stefan Langerman, Mihai Pătraşcu, and Perouz Taslakian. Necklaces, convolutions, and X+Y. Algorithmica, 69(2):294–314, 2014. doi:10.1007/S00453-012-9734-3.
- [4] Karl Bringmann. A near-linear pseudopolynomial time algorithm for subset sum. In Proceedings of the 28th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1073–1084, 2017. doi:10.1137/1.9781611974782.69.
- [5] Karl Bringmann and Alejandro Cassis. Faster Knapsack algorithms via bounded monotone min-plus-convolution. In Proceedings of the 49th International Colloquium on Automata, Languages, and Programming (ICALP), pages 31:1–31:21, 2022. doi:10.4230/LIPIcs.ICALP.2022.31.
- [6] Karl Bringmann, Anita Dürr, and Adam Polak. Even faster Knapsack via rectangular monotone min-plus convolution and balancing. In Proceedings of the 32nd Annual European Symposium on Algorithms (ESA), pages 33:1–33:15, 2024. Full version at https://arxiv.org/abs/2404.05681. doi:10.4230/LIPIcs.ESA.2024.33.
- [7] Karl Bringmann, Fabrizio Grandoni, Barna Saha, and Virginia Vassilevska Williams. Truly subcubic algorithms for language edit distance and RNA folding via fast bounded-difference min-plus product. SIAM J. Comput., 48(2):481–512, 2019. doi:10.1137/17M112720X.
- [8] Timothy M. Chan. Derandomizing pseudopolynomial algorithms for subset sum. In Proceedings of the 2026 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 3600–3610, 2026. doi:10.1137/1.9781611978971.131.
- [9] Timothy M. Chan and Moshe Lewenstein. Clustered integer 3sum via additive combinatorics. In Proceedings of the 47th Annual ACM on Symposium on Theory of Computing (STOC), pages 31–40, 2015. doi:10.1145/2746539.2746568.
- [10] Lin Chen, Jiayi Lian, Yuchen Mao, and Guochuan Zhang. Weakly approximating Knapsack in subquadratic time. In Proceedings of the 52nd International Colloquium on Automata, Languages, and Programming (ICALP), pages 51:1–51:18, 2025. doi:10.4230/LIPIcs.ICALP.2025.51.
- [11] Shucheng Chi, Ran Duan, Tianle Xie, and Tianyi Zhang. Faster min-plus product for monotone instances. In Proceedings of the 54th Annual ACM SIGACT Symposium on Theory of Computing (STOC), pages 1529–1542, 2022. doi:10.1145/3519935.3520057.
- [12] Marek Cygan, Marcin Mucha, Karol Węgrzycki, and Michał Włodarczyk. On problems equivalent to (min, +)-convolution. In Proceedings of the 44th International Colloquium on Automata, Languages, and Programming (ICALP), pages 22:1–22:15, 2017. doi:10.4230/LIPIcs.ICALP.2017.22.
- [13] Mingyang Deng, Yael Kirkpatrick, Victor Rong, Virginia Vassilevska Williams, and Ziqian Zhong. New additive approximations for shortest paths and cycles. In Proceedings of the 49th International Colloquium on Automata, Languages, and Programming (ICALP), pages 50:1–50:10, 2022. doi:10.4230/LIPIcs.ICALP.2022.50.
- [14] Anita Dürr. Improved bounds for rectangular monotone min-plus product and applications. Inf. Process. Lett., 181:106358, 2023. doi:10.1016/J.IPL.2023.106358.
- [15] Nick Fischer. Universe reduction for apsp: Equivalence of three fine-grained hypotheses. In Proceedings of the 58th Annual ACM SIGACT Symposium on Theory of Computing (STOC), page to appear, 2026.
- [16] Nick Fischer, Piotr Kaliciak, and Adam Polak. Deterministic 3SUM-hardness. In Proceedings of the 15th Innovations in Theoretical Computer Science Conference (ITCS), pages 49:1–49:24, 2024. doi:10.4230/LIPIcs.ITCS.2024.49.
- [17] Dvir Fried, Shay Golan, Tomasz Kociumaka, Tsvi Kopelowitz, Ely Porat, and Tatiana Starikovskaya. An improved algorithm for the k-dyck edit distance problem. ACM Trans. Algorithms, 20(3):26, 2024. doi:10.1145/3627539.
- [18] Younan Gao and Meng He. Faster path queries in colored trees via sparse matrix multiplication and min-plus product. In Proceedings of the 30th Annual European Symposium on Algorithms (ESA), pages 59:1–59:15, 2022. doi:10.4230/LIPIcs.ESA.2022.59.
- [19] Yuzhou Gu, Adam Polak, Virginia Vassilevska Williams, and Yinzhan Xu. Faster monotone min-plus product, range mode, and single source replacement paths. In Proceedings of the 48th International Colloquium on Automata, Languages, and Programming (ICALP), volume 198, pages 75:1–75:20, 2021. doi:10.4230/LIPIcs.ICALP.2021.75.
- [20] Xiaohan Huang and Victor Y. Pan. Fast rectangular matrix multiplication and applications. J. Complex., 14(2):257–299, 1998. doi:10.1006/JCOM.1998.0476.
- [21] Ce Jin, Yael Kirkpatrick, Michał Stawarz, and Virginia Vassilevska Williams. Improved additive approximation algorithms for apsp. In Proceedings of the 2026 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 3639–3651, 2026. doi:10.1137/1.9781611978971.133.
- [22] Marvin Künnemann, Ramamohan Paturi, and Stefan Schneider. On the fine-grained complexity of one-dimensional dynamic programming. In 44th International Colloquium on Automata, Languages, and Programming, ICALP 2017, Warsaw, Poland, July 10-14, 2017, pages 21:1–21:15. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2017. doi:10.4230/LIPIcs.ICALP.2017.21.
- [23] Xiao Mao. Breaking the cubic barrier for (unweighted) tree edit distance. In Proceedings of the 62nd IEEE Annual Symposium on Foundations of Computer Science (FOCS), pages 792–803, 2021. doi:10.1109/FOCS52979.2021.00082.
- [24] 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 Proceedings of the 57th Annual ACM Symposium on Theory of Computing (STOC), pages 2167–2178, 2025. doi:10.1145/3717823.3718116.
- [25] Barna Saha and Christopher Ye. Faster approximate all pairs shortest paths. In Proceedings of the 2024 ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 4758–4827, 2024. doi:10.1137/1.9781611977912.170.
- [26] Virginia Vassilevska Williams. On some fine-grained questions in algorithms and complexity. In Proceedings of the international congress of mathematicians: Rio de janeiro 2018, pages 3447–3487. World Scientific, 2018.
- [27] Virginia Vassilevska Williams and R. Ryan Williams. Subcubic equivalences between path, matrix, and triangle problems. J. ACM, 65(5):27:1–27:38, 2018. doi:10.1145/3186893.
- [28] Virginia Vassilevska Williams and Yinzhan Xu. Truly subcubic min-plus product for less structured matrices, with applications. In Proceedings of the 2020 ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 12–29, 2020. doi:10.1137/1.9781611975994.2.
- [29] R. Ryan Williams. Faster all-pairs shortest paths via circuit complexity. SIAM J. Comput., 47(5):1965–1985, 2018. doi:10.1137/15M1024524.
