Fine-Grained Complexity
SETH, 3SUM and APSP: why some polynomial algorithms seem impossible to beat.
The edit distance of two strings has been computed by the same quadratic dynamic program since the 1970s, and decades of effort have shaved off only logarithmic factors. Is a faster algorithm waiting to be found? Fine-grained complexity answers "probably not" with a theorem: an algorithm for edit distance would also solve CNF-SAT faster than almost anyone believes possible.
What you’ll learn
- State SETH, the 3SUM conjecture and the APSP conjecture precisely, with their models, and define fine-grained reductions.
- Prove that SETH implies the orthogonal vectors conjecture by Williams's split-and-list reduction, and trace its consequences for edit distance, LCS and graph diameter.
- Reduce 3SUM to collinearity of points, and summarize what is known about 3SUM's true complexity.
- Explain the subcubic equivalences among APSP, the min-plus product and negative-triangle detection.
- Use conditional lower bounds in algorithm design: when to stop looking for a better exponent, and which routes (parameters, word-level parallelism, approximation) remain open.
Hardness inside P
NP-completeness separates polynomial time from (presumably) exponential time, and says nothing about exponents: is edit distance , or could it be ? Proving that it needs time unconditionally is far beyond current techniques.
Fine-grained complexity does what NP-completeness did: it picks a few problems believed to be hard for exact exponents and connects other problems to them by reductions that preserve exponents.
| Hypothesis | Statement (unproven) | Best algorithm known |
|---|---|---|
| SETH (Impagliazzo & Paturi, 2001) | for every there is a such that -SAT on variables cannot be solved in time | for -SAT (PPSZ) |
| 3SUM conjecture | deciding whether integers in contain needs time on the word RAM | (Chan, 2018) |
| APSP conjecture | all-pairs shortest paths on vertices with integer weights in needs time on the word RAM | , randomized (Williams, 2014) |
SETH and orthogonal vectors
Take a CNF formula with variables and clauses . Split the variables into two halves. For each assignment of the first half build , and for each assignment of the second half build the same way:
Coordinate contributes to exactly when neither half satisfies , that is, when the combined assignment falsifies :
So the formula is satisfiable exactly when the OV instance with vectors per side and has an orthogonal pair, and building it takes time. A fast OV algorithm then gives:
Few clauses. A -CNF may have up to about clauses, but the sparsification lemma (Impagliazzo, Paturi & Zane, 2001) splits it, for any , into -CNFs with clauses each, whose disjunction is equivalent to it. With the total time is:
from itertools import product
def cnf_to_ov(n, clauses):
"""Split-and-list reduction: variables 1..n, clauses as lists of DIMACS literals."""
def vectors(variables):
out = []
for bits in product([False, True], repeat=len(variables)):
value = dict(zip(variables, bits))
out.append([0 if any(value.get(abs(l)) == (l > 0) for l in c) else 1 # 0: this half satisfies c
for c in clauses])
return out
half = n // 2
return vectors(range(1, half + 1)), vectors(range(half + 1, n + 1))
def has_orthogonal_pair(A, B): # the O(N^2 d) brute force
return any(all(a * b == 0 for a, b in zip(u, v)) for u in A for v in B)
F1 = [[1, 2], [-1, 3], [-2, -3], [1, -3]] # satisfiable: x1 = 1, x2 = 0, x3 = 1
F2 = [[1, 2], [-1, 2], [1, -2], [-1, -2]] # unsatisfiable
print(has_orthogonal_pair(*cnf_to_ov(3, F1)), has_orthogonal_pair(*cnf_to_ov(2, F2))) # True FalseFor F1, the first half's assignment gives and the second half's gives : orthogonal, and together a satisfying assignment. The reduction agreed with brute-force SAT on 3,000 random formulas.
Since 2005, OV has been reduced to dozens of problems, each by gadgets that turn vectors into strings, curves or graphs, so each of these lower bounds holds under SETH:
| Problem | Classic algorithm | Ruled out under SETH |
|---|---|---|
| Edit distance | dynamic programming | (Backurs & Indyk, 2015) |
| Longest common subsequence | (Abboud, Backurs & Vassilevska Williams, 2015; Bringmann & Künnemann, 2015) | |
| Fréchet distance between two curves | (Alt & Godau, 1995) | (Bringmann, 2014) |
| Diameter of a sparse graph: is it 2 or 3? | BFS from every vertex, | , hence any -approximation in that time (Roditty & Vassilevska Williams, 2013) |
| Orthogonal vectors itself | (Abboud, Williams & Yu, 2015) |
OV reduces to edit distance: OV instances become pairs of strings whose edit distance reveals the answer. What would an edit-distance algorithm imply?
- Nothing about OV, because the reduction goes the other way
- That P = NP
- A truly subquadratic algorithm for OV, and therefore that SETH is false
- A faster OV algorithm, while SETH could still hold
Show the answer
C. A truly subquadratic algorithm for OV, and therefore that SETH is false
A reduction from OV to edit distance carries fast edit-distance algorithms back to OV: for OV, and by Williams's theorem a algorithm for every -SAT, refuting SETH.
3SUM and geometry
3SUM asks whether integers contain three, . Sorting and two pointers solve it in time (the lesson 3SUM & the k-SUM Problem). Gajentaan and Overmars (1995) called a problem 3SUM-hard when 3SUM reduces to it with overhead, and found such problems all over computational geometry. The first is the simplest.
Map each number to the point . For , the slope between their points is:
Three points with distinct are collinear exactly when the slopes from to and from to agree:
So, for distinct integers, a 3SUM triple exists exactly when three of the points are collinear: a linear-time reduction. For example, , and , , lie on one line of slope 49.
Gajentaan and Overmars's list runs from covering a region by triangles to planar motion planning, and Pătraşcu (2010) extended 3SUM-hardness to dynamic data structures and to listing triangles in graphs. Yet 3SUM itself is less hard than it was once thought:
You want to show that a new geometry problem is 3SUM-hard. Which reduction must you give?
- A reduction from to 3SUM, solving with a 3SUM algorithm
- A reduction from 3SUM to : turn any 3SUM instance into an instance of in time, so that a fast algorithm for would solve 3SUM fast
- Either direction works
- A proof that is in NP
Show the answer
B. A reduction from 3SUM to : turn any 3SUM instance into an instance of in time, so that a fast algorithm for would solve 3SUM fast
Hardness flows along reductions from the hard problem: if 3SUM reduces to cheaply, an algorithm for would give one for 3SUM, contradicting the conjecture. The collinearity reduction above has this shape.
APSP and subcubic equivalences
All-pairs shortest paths takes time with Floyd–Warshall, and up to logarithmic factors it is the same problem as the min-plus product : repeated squaring of the weight matrix computes all distances with products, and one product is a shortest-path computation in a three-layer graph (the lesson All-Pairs Shortest Paths). Unlike the ordinary matrix product, the min-plus product has no known truly subcubic algorithm: fast matrix multiplication ( as of 2025) relies on subtraction, which lacks.
Easy direction. One min-plus product finds a negative triangle: a triangle through and is negative exactly when the best two-step path from to plus the edge back is negative.
Hard direction, step 1. To compute , it is enough to answer, for every pair at once, whether for given thresholds; binary search over the thresholds, all pairs in parallel, then recovers every entry in rounds. Each round is a negative-triangle question on a tripartite graph with weights , and :
Hard direction, step 2. A detector only says whether a negative triangle exists, not for which pairs. Splitting the vertex sets into blocks and running the detector on triples of blocks, discarding each pair once a triangle through it is found, turns a detector running in time into APSP in time, truly subcubic whenever is:
The same circle of ideas places graph radius and median among the APSP-equivalent problems (Abboud, Grandoni & Vassilevska Williams, 2015), while diameter is not known to be APSP-hard. Some problems, such as finding a triangle of total weight exactly zero, are hard under both the 3SUM and the APSP conjectures. In unweighted undirected graphs APSP takes time (Seidel, 1995): the weights carry the hardness.
Triangle detection in an unweighted graph takes time with fast matrix multiplication, and . Why does this not refute the APSP conjecture?
- Because might still equal 3
- Because triangle detection is NP-hard
- Because is not subcubic
- Because the conjecture concerns weighted graphs; with weights, triangle detection becomes negative-triangle detection, where the subtraction behind fast matrix multiplication is not available
Show the answer
D. Because the conjecture concerns weighted graphs; with weights, triangle detection becomes negative-triangle detection, where the subtraction behind fast matrix multiplication is not available
Unweighted triangle detection is a Boolean matrix product, which fast matrix multiplication handles. Negative-triangle detection needs the min-plus product, and that equivalence with APSP is exactly what the theorem states.
What it means for algorithm design
A conditional lower bound changes what you look for. If your problem is SETH-hard for , stop hunting for a better exponent on arbitrary inputs: such an algorithm would be a breakthrough on CNF-SAT, one of the most studied problems in computer science. The productive routes lie elsewhere, and edit distance shows all of them:
| Route | Edit distance of two strings of length |
|---|---|
| Exploit a parameter | if the distance is small, time (Ukkonen, 1985) |
| Word-level parallelism | bit-parallel dynamic programming updates a whole machine word of cells per operation, for (Myers, 1999) |
| Shave logarithms | the Four Russians technique gives (Masek & Paterson, 1980) |
| Approximate | constant-factor approximations in truly subquadratic time (Chakraborty, Das, Goldenberg, Koucký & Saks, 2018), later in near-linear time (Andoni & Nosatzki, 2020) |
The hypotheses themselves are debated. SETH is far stronger than P ≠ NP, and some researchers doubt it; the 3SUM conjecture had to be weakened once already. Still, a conditional lower bound is strong evidence: refuting it would itself be a celebrated result, with faster algorithms for SAT, 3SUM or APSP as a consequence. The lesson Edit Distance & Its Limits applies all of this to one problem in detail.
The quadratic edit-distance algorithm fills table cells. At cells per second, how many seconds does it take for two strings of characters?
Show the answer
100
cells at per second take 100 seconds. Under SETH no exact algorithm beats this by a polynomial factor on arbitrary inputs, but a bit-parallel implementation with 64-bit words divides it by up to 64, and a small edit distance changes the picture entirely.
Key takeaways
- Fine-grained complexity classifies polynomial problems by exponent, through reductions that preserve exponents from three unproven hypotheses: SETH, the 3SUM conjecture and the APSP conjecture.
- Williams's split-and-list reduction shows that SETH implies the OV conjecture; OV in turn rules out truly subquadratic algorithms for edit distance, LCS, Fréchet distance and approximate diameter, unless SETH fails.
- 3SUM reduces to many geometric problems, such as three collinear points via ; its true complexity is subtle, with near-linear decision trees and algorithms.
- APSP, min-plus product and negative-triangle detection stand or fall together; the weights carry the hardness, since unweighted versions use fast matrix multiplication.
- A conditional lower bound redirects effort toward parameters, word-level parallelism, logarithmic savings and approximation.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Which statement is the Strong Exponential Time Hypothesis?
- 3-SAT cannot be solved in time
- For every there is a such that -SAT on variables cannot be solved in time
- P ≠ NP
- CNF-SAT needs exactly steps
Show the answer
B. For every there is a such that -SAT on variables cannot be solved in time
SETH says the base of the exponential must approach 2 as the clause width grows. It implies ETH, the first option, which only forbids subexponential time, and both are far stronger than P ≠ NP.
The split-and-list reduction turns a CNF formula with variables and clauses into an OV instance. How large is it?
- vectors of dimension
- vectors per side, of dimension
- vectors per side, of dimension
- vectors per side, of dimension
Show the answer
B. vectors per side, of dimension
One vector per assignment of each half, with one coordinate per clause. Brute-force OV on it costs , matching brute-force SAT, so beating brute-force OV by a polynomial factor beats brute-force SAT by an exponential one.
The reduction from 3SUM to collinearity maps each number to the point . Why a cubic curve?
- Any curve would do, for instance
- Because for distinct , the points , , are collinear exactly when
- Because cubes keep the coordinates within the word size
- Because a cubic curve has no three collinear points
Show the answer
B. Because for distinct , the points , , are collinear exactly when
Slopes on the cubic are , and equal slopes factor as . On the parabola the slope is , and equal slopes force : three distinct points on a parabola are never collinear, so it encodes nothing.
APSP, the min-plus product and negative-triangle detection are equivalent under subcubic reductions. Which statement follows?
- An algorithm for negative-triangle detection would give an algorithm for APSP
- Negative-triangle detection needs time
- APSP can be solved in time with fast matrix multiplication
- Triangle detection in unweighted graphs is as hard as APSP
Show the answer
A. An algorithm for negative-triangle detection would give an algorithm for APSP
A detector running in gives APSP in time, which is for . Equivalence transfers speedups in both directions; it proves no lower bound by itself.
Further reading
- V. Vassilevska Williams, "On some fine-grained questions in algorithms and complexity," Proceedings of the International Congress of Mathematicians (ICM 2018) (2019).
- R. Williams, "A new algorithm for optimal 2-constraint satisfaction and its implications," Theoretical Computer Science 348(2–3) (2005), 357–365.
- A. Backurs & P. Indyk, "Edit distance cannot be computed in strongly subquadratic time (unless SETH is false)," Proceedings of STOC (2015).
- A. Gajentaan & M. H. Overmars, "On a class of O(n²) problems in computational geometry," Computational Geometry: Theory and Applications 5(3) (1995).
- V. Vassilevska Williams & R. Williams, "Subcubic equivalences between path, matrix, and triangle problems," Journal of the ACM 65 (2018).