Automatic Complexity Analysis of Simple Imperative Programs Zachi Mann
Consider the following “Core” Language: Non-deterministic branching Bounded non-deterministic loops Variables hold only positive integer values
Problem Statement The polynomial-bound analysis problem is to find, for any given command, which output variables are bounded by a polynomial in the input variables. A variant: The linear-bound problem identifies linearly-bounded output values instead. The problem can be easily extended to identify the overall runtime upper bound.
A Short Example
Ben-Amram, Jones & Kristiansen (2008) Sound & complete compositional analysis algorithm running in polynomial time. Algorithm assigns a certificate(DFR) to each command: DFR
Ben-Amram, Jones & Kristiansen (2008) DFR left part represents the variables dependencies. type: DFR
Ben-Amram, Jones & Kristiansen (2008) DFR right part is used to identify computations that double an input value by adding two copies of it: DFR
Ben-Amram (2010) Core language is extended with the constant zero. The analysis problem is shown to be PSPACE-complete.
Back to the Example
Ben-Amram (2010)
The link between inference rules and DFR: – The inference rules generate the variable dependences (arcs) within the DFR.
Implementation Bottom Up – For every command the set of all true judgments are generated. Top Down – An abstract interpreter generates for every command the dependence judgments according to the inference rules and the reset contexts that were computed so far from previous commands. Output Extension – Algorithm output is extended to include a description of a computation path which results with each computed variable dependence.
Loops
Performance Comparison
Related Work What happens if features are added/dropped from the core language? – Deterministic loops, the constant 1, weak assignment, … Is the analysis problem decidable? With what run time complexity? – Some answers in paper by Amir Ben Amram & Lars Kristiansen (2011)paper