The Automatic Synthesis of Linear Ranking Functions I

The classical technique for proving termination of a generic sequential computer program involves the synthesis of a ranking function for each loop of the program. Linear ranking functions are particularly interesting because many terminating loops admit one and algorithms exist to automatically synthesize it. In this paper we present two such algorithms: one based on work dated 1991 by Sohn and Van Gelder; the other, due to Podelski and Rybalchenko, dated 2004. Remarkably, while the two algorithms will synthesize a linear ranking function under exactly the same set of conditions, the former is mostly unknown to the community of termination analysis and its general applicability has never been put forward before the present paper. In this paper we thoroughly justify both algorithms, we prove their correctness, we compare their worst-case complexity and experimentally evaluate their efficiency, and we present an open-source implementation of them that will make it very easy to include termination-analysis capabilities in automatic program verifiers.

[1]  Étienne Payet,et al.  A termination analyzer for Java bytecode based on path-length , 2010, TOPL.

[2]  Patrick Cousot,et al.  'A la Floyd' induction principles for proving inevitability properties of programs , 1986 .

[3]  Jeffrey C. Lagarias,et al.  The 3x + 1 Problem and its Generalizations , 1985 .

[4]  Henny B. Sipma,et al.  Linear Ranking with Reachability , 2005, CAV.

[5]  Frédéric Mesnard,et al.  The Automatic Synthesis of Linear Ranking Functions: The Complete Unabridged Version , 2010, ArXiv.

[6]  Danny De Schreye,et al.  Deriving Termination Proofs for Logic Programs, Using Abstract Procedures , 1991, ICLP.

[7]  Frédéric Mesnard,et al.  Recurrence with affine level mappings is P-time decidable for CLP$({\mathbb R})$ , 2007, Theory and Practice of Logic Programming.

[8]  Patrick Cousot,et al.  Proving Program Invariance and Termination by Parametric Abstraction, Lagrangian Relaxation and Semidefinite Programming , 2005, VMCAI.

[9]  Allen Van Gelder,et al.  Termination detection in logic programs using argument sizes (extended abstract) , 1991, PODS.

[10]  Roberto Bagnara,et al.  The Parma Polyhedra Library: Toward a complete set of numerical abstractions for the analysis and verification of hardware and software systems , 2006, Sci. Comput. Program..

[11]  Nachum Dershowitz,et al.  A General Framework for Automatic Termination Analysis of Logic Programs , 2000, Applicable Algebra in Engineering, Communication and Computing.

[12]  Edsger W. Dijkstra,et al.  A Discipline of Programming , 1976 .

[13]  Andrey Rybalchenko,et al.  Temporal verification with transition invariants , 2004 .

[14]  Frédéric Mesnard,et al.  On Termination of Binary CLP Programs , 2004, LOPSTR.

[15]  Jan Maluszy¿ski Verification, Model Checking, and Abstract Interpretation , 2009, Lecture Notes in Computer Science.

[16]  Michael Codish,et al.  A Semantic Basis for the Termination Analysis of Logic Programs , 1999, J. Log. Program..

[17]  Neil D. Jones,et al.  The size-change principle for program termination , 2001, POPL '01.

[18]  Sumit Gulwani,et al.  Proving Conditional Termination , 2008, CAV.

[19]  Nicolas Halbwachs,et al.  Automatic discovery of linear restraints among variables of a program , 1978, POPL.

[20]  Kenneth Steiglitz,et al.  Combinatorial Optimization: Algorithms and Complexity , 1981 .

[21]  Alexander Schrijver,et al.  Theory of linear and integer programming , 1986, Wiley-Interscience series in discrete mathematics and optimization.

[22]  Henny B. Sipma,et al.  Synthesis of Linear Ranking Functions , 2001, TACAS.

[23]  Henny B. Sipma,et al.  Practical Methods for Proving Program Termination , 2002, CAV.

[24]  MANH THANG NGUYEN,et al.  Polynomial Interpretations as a Basis for Termination Analysis of Logic Programs , 2005, ICLP.

[25]  Robert W. Floyd,et al.  Assigning Meanings to Programs , 1993 .

[26]  David S. Johnson,et al.  Computers and Intractability: A Guide to the Theory of NP-Completeness , 1978 .

[27]  Frédéric Mesnard,et al.  Inferring Left-terminating Classes of Queries for Constraint Logic Programs , 1996 .

[28]  Kirack Sohn,et al.  Automated termination analysis for logic programs , 1993 .

[29]  Peter J. Stuckey,et al.  Testing for Termination with Monotonicity Constraints , 2005, ICLP.

[30]  Andreas Podelski,et al.  A Complete Method for the Synthesis of Linear Ranking Functions , 2004, VMCAI.