Size-Change Termination Analysis in k-Bits Michael Codish 1,⋆ , Vitaly Lagoon 2 , Peter Schachte 2 , and Peter J. Stuckey 2, 3 1 Department of Computer Science, Ben-Gurion University, Israel 2 Department of Computer Science and Software Engineering, The University of Melbourne, Australia 3 NICTA Victoria Laboratory mcodish@cs.bgu.ac.il {lagoon, schachte, pjs}@cs.mu.oz.au Abstract. Size-change termination analysis is a simple and powerful technique successfully applied for a variety of programming paradigms. A main advantage is that termination for size-change graphs is decidable and based on simple linear ranking functions. A main disadvantage is that the size-change termination problem is PSPACE-complete. Proving size change termination may have to consider exponentially many size change graphs. This paper is concerned with the representation of large sets of size-change graphs. The approach is constraint based and the nov- elty is that sets of size-change graphs are represented as disjunctions of size-change constraints. A constraint solver to facilitate size-change ter- mination analysis is obtained by interpreting size-change constraints over a sufficiently large but finite non-negative integer domain. A Boolean k- bit modeling of size change graphs using binary decision diagrams leads to a concise representation. Experimental evaluation indicates that the 2-bit representation facilitates an efficient implementation which is guar- anteed complete for our entire benchmark suite. 1 Introduction Size-change termination analysis [8] is a simple and powerful technique to verify program termination. First, the transition relation of a program is approximated by a set of size-change graphs. Then, termination is guaranteed if all of the idempotent size change graphs in the closure of this set under a composition operation have (possibly different) ranking functions. A typical example is the analysis of the Prolog program depicted in Figure 1(a) which computes Ackermann’s function. The size-change graphs in the figure describe all transitions in computations of this program. Between sub- sequent function calls, either the first argument decreases in size (Figure 1(b)), or else it does not increase and the second argument decreases in size (Figure 1(c)). As formalised below, these graphs are idempotent, closed under composition and have as ranking functions f u)= u 1 and f u)= u 2 respectively. Research performed at the University of Melbourne P. Sestoft (Ed.): ESOP 2006, LNCS 3924, pp. 230–245, 2006. c Springer-Verlag Berlin Heidelberg 2006