[Paper Review] PURRS: Towards Computer Algebra Support for Fully Automatic Worst-Case Complexity Analysis
PURRS is a C++ software library that provides fully automatic, computer algebra-supported worst-case complexity analysis by solving or approximating recurrence relations arising in program analysis. It uniquely supports exact solutions and tight upper/lower bounds for complex recurrences—including divide-and-conquer and multivariate types—using symbolic computation, approximation techniques, and specialized algorithms for recurrences beyond the reach of general-purpose computer algebra systems.
Fully automatic worst-case complexity analysis has a number of applications in computer-assisted program manipulation. A classical and powerful approach to complexity analysis consists in formally deriving, from the program syntax, a set of constraints expressing bounds on the resources required by the program, which are then solved, possibly applying safe approximations. In several interesting cases, these constraints take the form of recurrence relations. While techniques for solving recurrences are known and implemented in several computer algebra systems, these do not completely fulfill the needs of fully automatic complexity analysis: they only deal with a somewhat restricted class of recurrence relations, or sometimes require user intervention, or they are restricted to the computation of exact solutions that are often so complex to be unmanageable, and thus useless in practice. In this paper we briefly describe PURRS, a system and software library aimed at providing all the computer algebra services needed by applications performing or exploiting the results of worst-case complexity analyses. The capabilities of the system are illustrated by means of examples derived from the analysis of programs written in a domain-specific functional programming language for real-time embedded systems.
Motivation & Objective
- To address the lack of fully automatic, user-intervention-free tools for solving or approximating recurrence relations in worst-case complexity analysis.
- To overcome limitations of existing computer algebra systems that either restrict recurrence classes, require manual input, or return overly complex exact solutions.
- To provide practical, usable bounds (upper and lower) for recurrences that arise in real-world program analysis, especially in embedded and real-time systems.
- To integrate seamlessly with automated complexity analyzers for domain-specific languages like Hume.
- To extend support to multivariate and infinite-order recurrences through symbolic rewriting and approximation.
Proposed method
- Classifying recurrences into categories such as linear, polynomial, exponential, and divide-and-conquer types for targeted solution strategies.
- Applying symbolic algorithms including Gosper’s and Zeilberger’s algorithms for hypergeometric sum simplification and telescoping.
- Using range transformations and substitution to linearize and reduce complex recurrences to solvable forms.
- Implementing approximation techniques that bound solutions as f(n) − g−(n) ≤ xn ≤ f(n) + g+(n), where f, g−, g+ are of the form c·nd·αn.
- Automatically rewriting multivariate recurrences with constant argument differences or sums into univariate forms via variable substitution.
- Leveraging a solver for algebraic equations with rational coefficients and a sophisticated simplification engine for symbolic expressions, including binomials and exponentials.
Experimental results
Research questions
- RQ1Can a fully automatic system solve or approximate recurrence relations arising in worst-case complexity analysis without user intervention?
- RQ2How can recurrence relations from complex algorithms (e.g., Strassen’s or mergesort) be approximated with tight, practical upper and lower bounds?
- RQ3What techniques enable the handling of multivariate recurrences by reducing them to univariate forms?
- RQ4Can approximation methods be designed to work effectively even when closed-form solutions do not exist?
- RQ5How can symbolic computation be used to derive precise yet manageable bounds for recurrences in real-time embedded systems?
Key findings
- PURRS successfully derives tight bounds for Strassen’s algorithm recurrence: n^(log 7)/log 2 − 3/2 n² ≤ xn ≤ 7n^(log 7)/log 2 − 6n².
- For mergesort, PURRS approximates xn = 2xn/2 + n − 1 with h(n) − 3n + 3 + ½nx₁ ≤ xn ≤ h(n) − ½n + 1 + nx₁, where h(n) = n(log n)/log 2, correctly capturing the asymptotic behavior xn ∼ n(log n)/log 2.
- The system computes the exact solution xm,n = 9 + am for the recurrence xm,n = a + xm−1,n+1 with x₀,n = 9, demonstrating capability on multivariate recurrences.
- For the recurrence xn = xn−1 + xn−3 + 2n + n − 1, PURRS derives bounds involving the dominant root λ of x³ − x² − 1 = 0: 8/3·2ⁿ − 35/3·λ/(λ−1)·λⁿ ≤ xn ≤ 8/3·2ⁿ + λⁿ/(λ−1)²·(X+1).
- PURRS supports divide-and-conquer recurrences of the form xn = αxn/β + g(n) with α > 0, β > 1, and non-negative non-decreasing g(n), providing bounds valid for all n ∈ ℕ \ {0}.
- The library integrates with a Hume program complexity analyzer, enabling end-to-end automatic worst-case space and time complexity analysis for real-time embedded systems.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.