Automated Recurrence Analysis for Almost-Linear Expected-Runtime Bounds

Krishnendu Chatterjee, Hongfei Fu, Aniket Murhekar

This paper presents a significant step forward in automated program analysis by shifting the focus from "how bad can it get?" (worst-case analysis) to "how well does it usually perform?" (expected-runtime analysis).

TL;DR

The authors introduce a linear-time automated method to derive tight expected-runtime bounds—specifically logarithmic, linear, and almost-linear ($O(n \log n)$)—for randomized algorithms. By using a sound "guess-and-check" framework powered by calculus-based over-approximations, the tool can prove asymptotically optimal bounds for classic algorithms like Quicksort and Coupon Collector in milliseconds.

What Problem Does This Paper Address?

In computer science, we often rely on worst-case analysis to guarantee performance. However, for many randomized algorithms, the worst-case is either a gross overestimation or completely unhelpful. For example, Quick-Sort is $O(n^2)$ in the worst case but $O(n \log n)$ in practice. The Coupon Collector problem has an infinite worst-case runtime (you might never get that last coupon!), yet its expected runtime is a very manageable $O(n \log n)$.

While humans can prove these expected bounds using "mathematical ingenuity," automating this process is difficult. Standard tools like the Master Theorem or Akra-Bazzi’s Theorem struggle with the "unbounded summations" that arise when an algorithm makes a random choice (like picking a pivot from $n$ possible elements). This paper aims to bridge that gap with an efficient, automated approach.

Methods

The authors developed a two-step algorithmic framework: UniDec (for deciding if a bound exists) and UniSynth (for synthesizing the specific constants of that bound).

  1. Mini-Specification Language: They define a syntax for univariate (one variable, $n$) and separable bivariate (two variables, $n$ and $m$) recurrence relations. This covers a wide range of divide-and-conquer and randomized selection algorithms.
  2. Over-approximation via Calculus: To handle the messy summations inherent in randomized recurrences, the authors use Taylor expansions and integrals. This allows them to bound discrete sums with continuous functions that are much easier for a computer to manipulate.
  3. Pseudo-polynomials: They introduce "pseudo-polynomials"—functions composed of terms like $n^k \ln^\ell n$. By defining a "degree" for these functions, the algorithm can compare the growth rates of different terms using simple algebraic rules.
  4. Bivariate Reduction: For problems with two variables (like the Coupon Collector), they provide a sound reduction method to transform the bivariate recurrence into a univariate one, allowing their core engine to solve it.

Datasets

As a theoretical and tool-oriented paper, the "datasets" consist of a suite of classic randomized algorithms used as benchmarks:

  • RANDOMIZED-SEARCH: (Sherwood’s algorithm)
  • QUICK-SORT & QUICK-SELECT: The gold standards for randomized performance.
  • DIAMETER-COMPUTATION: Finding the distance between points in 3D space.
  • COUPON-COLLECTOR: A fundamental stochastic process.
  • CHANNEL-CONFLICT RESOLUTION: A distributed networking protocol.

Key Insights and Ideas

  • Soundness over Completeness: The authors prioritize a "sound" approach—meaning if the tool says a bound holds, it definitely does. While it might fail to find a bound for extremely complex, non-standard recurrences, it succeeds on almost all "textbook" cases.
  • Calculus to the Rescue: The "aha moment" is realizing that the manual tricks researchers use (like bounding a sum with an integral) can be formalized into an automated "over-approximation" function (OvAp).
  • Efficiency: Because the algorithm relies on comparing leading terms of pseudo-polynomials, it operates in linear time relative to the size of the recurrence relation.

Key Results

  • Asymptotic Optimality: The tool successfully inferred the best possible asymptotic bounds for all benchmark algorithms. It correctly identified $O(n \log n)$ for Quick-Sort and $O(n)$ for Quick-Select.
  • Speed: The implementation is incredibly fast. All experimental tests completed in less than 0.02 seconds on a standard laptop.
  • Precise Constants: Beyond just saying "it's $O(n \log n)$," the UniSynth algorithm generated constants ($d$) that were very close to the theoretical optima. For Randomized-Search, the tool found a constant of ~19.7, where the optimal value is known to be around 15.1.

Limitations and Future Work

  • Bound Complexity: The current work is limited to logarithmic, linear, and almost-linear ($n \log n$) bounds. It does not currently handle higher-order polynomials (like $O(n^2)$) or exponential bounds, though the authors suggest the framework could be extended.
  • Bivariate Constraints: The bivariate analysis only works for "separable" recurrences—where the two variables don't interact in highly complex, non-linear ways.
  • Future Directions: The authors suggest expanding the tool to handle more general randomized recurrences and exploring interactions between multiple variables in non-separable cases. There is also interest in integrating this recurrence solver into larger static analysis pipelines that extract recurrences directly from source code.

Summary updated

BibTeX
@inproceedings{chatterjee2017automated,
  author = {Krishnendu Chatterjee and Hongfei Fu and Aniket Murhekar},
  title = {{Automated Recurrence Analysis for Almost-Linear Expected-Runtime Bounds}},
  booktitle = {CAV},
  year = {2017},
  url = {https://openreview.net/forum?id=6cTBn3MF66},
}
Figure