EN FR
EN FR


Section: New Software and Platforms

HoCA

Higher-Order Complexity Analysis

Scientific Description

Over the last decade, various tools for the static analysis of resource properties of programs have emerged. In particular, the rewriting community has recently developed several tools for the time complexity analysis of term rewrite systems. These tools have matured and are nowadays able to treat non-trivial programs, in a fully automatic setting. However, none of these automatic complexity analysers can deal with higher-order functions, a pervasive feature of functional programs. HoCA (Higher-Order Complexity Analyser) overcomes this limitation by translating higher-order programs – in the form of side-effect free OCaml programs - into equivalent first-order rewrite systems. At the heart of our tool lies Reynold’s defunctionalization technique. Defunctionalization however is not enough. Resulting programs have a recursive structure too complicated to be analyzed automatically in all but trivial cases. To overcome this issue, HoCA integrates a handful of well-established program transformation techniques, noteworthy dead-code elimination, inlining, instantiation and uncurrying. All these techniques have been specifically suited to the methods integrated in modern first-order complexity analyzers. A complexity bound on the resulting first-order program can be relayed back reliably to the higher-order program of interest. A detailed description of HoCA is available on http://arxiv.org/abs/1506.05043

Functional Description

HOCA is an abbreviation for Higher-Order Complexity Analysis, and is meant as a laboratory for the automated complexity analysis of higher-order functional programs. Currently, HOCA consists of one executable pcf2trs which translates a pure subset of OCaml to term rewrite systems, in a complexity-reflecting manner. As a first step, HOCA desugars the given program to a variation of Plotkin's PCF with data-constructors. Via Reynold's defunctionalization, the PCF program is turned into an applicative term rewrite system (ATRS for short), and call-by-value reductions of the PCF program are simulated by the ATRS step-by-step. On the ATRS, various complexity reflecting transformations are performed: inlining, dead-code-elimination, instantiation of higher-order variables through a call-flow-analysis and finally uncurrying. This results in a first-order rewrite system, whose runtime-complexity asymptotically reflects the complexity of the initial program.