Ranking Functions for Linear-Constraint Loops (original) (raw)
Related papers
On the linear ranking problem for integer linear-constraint loops
Proceedings of the 40th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages, 2013
In this paper we study the complexity of the problems: given a loop, described by linear constraints over a finite set of variables, is there a linear or lexicographical-linear ranking function for this loop? While existence of such functions implies termination, these problems are not equivalent to termination. When the variables range over the rationals (or reals), it is known that both problems are PTIME decidable. However, when they range over the integers, whether for single-path or multipath loops, the complexity has not yet been determined. We show that both problems are coNP-complete. However, we point out some special cases of importance of PTIME complexity. We also present complete algorithms for synthesizing linear and lexicographical-linear ranking functions, both for the general case and the special PTIME cases. Moreover, in the rational setting, our algorithm for synthesizing lexicographical-linear ranking functions extends existing ones, because our class of ranking functions is more general, yet it has polynomial time complexity.
Linear Ranking with Reachability
Lecture Notes in Computer Science, 2005
We present a complete method for synthesizing lexicographic linear ranking functions supported by inductive linear invariants for loops with linear guards and transitions. Proving termination via linear ranking functions often requires invariants; yet invariant generation is expensive. Thus, we describe a technique that discovers just the invariants necessary for proving termination. Finally, we describe an implementation of the method and provide extensive experimental evidence of its effectiveness for proving termination of C loops.
On the Edge of Decidability in Complexity Analysis of Loop Programs
International Journal of Foundations of Computer Science, 2012
We investigate the decidability of the feasibility problem for imperative programs with bounded loops. A program is called feasible if all values it computes are polynomially bounded in terms of the input. The feasibility problem is representative of a group of related properties, like that of polynomial time complexity. It is well known that such properties are undecidable for a Turing-complete programming language. They may be decidable, however, for languages that are not Turing-complete. But if these languages are expressive enough, they do pose a challenge for analysis. We are interested in tracing the edge of decidability for the feasibility problem and similar problems. In previous work, we proved that such problems are decidable for a language where loops are bounded but indefinite (that is, the loops may exit before completing the given iteration count). In this paper, we consider definite loops. A second language feature that we vary, is the kind of assignment statements. ...
What’s decidable about linear loops?
Proceedings of the ACM on Programming Languages
We consider the MSO model-checking problem for simple linear loops, or equivalently discrete-time linear dynamical systems, with semialgebraic predicates (i.e., Boolean combinations of polynomial inequalities on the variables). We place no restrictions on the number of program variables, or equivalently the ambient dimension. We establish decidability of the model-checking problem provided that each semialgebraic predicate either has intrinsic dimension at most 1, or is contained within some three-dimensional subspace. We also note that lifting either of these restrictions and retaining decidability would necessarily require major breakthroughs in number theory.
Polyranking for Polynomial Loops
Although every terminating loop has a ranking function, not every loop has a rank-ing function of a restricted form, such as a lexicographic tuple of polynomials over program variables. We propose polyranking functions as a generalization of ranking functions for analyzing termination of loops. We define lexicographic polyranking functions in a general context and then specialize their synthesis and application to loops with polynomial guards and assignments of polynomial expressions. Finally, we demonstrate that our prototype implementation for C source code scales to large software projects, proving termination for a high percentage of targeted loops.
On the Decidability of Termination for Polynomial Loops
ArXiv, 2019
We consider the termination problem for triangular weakly non-linear loops (twn-loops) over a ring mathbbZleqmathcalSleqmathbbR\mathbb{Z} \leq \mathcal{S} \leq \mathbb{R}mathbbZleqmathcalSleqmathbbR. The body of such a loop consists of a single assignment (x1,ldots,xd)leftarrow(c1cdotx1+p1,...,cdcdotxd+pd)(x_1, \ldots, x_d) \leftarrow (c_1 \cdot x_1 + p_1, ..., c_d \cdot x_d + p_d)(x1,ldots,xd)leftarrow(c1cdotx1+p1,...,cdcdotxd+pd) where each xix_ixi is a variable, ciinmathcalSc_i \in \mathcal{S}ciinmathcalS, and each pip_ipi is a (possibly non-linear) polynomial over mathcalS\mathcal{S}mathcalS and the variables xi+1,ldots,xdx_{i+1}, \ldots, x_dxi+1,ldots,xd. We present a reduction from the question of termination to the existential fragment of the first-order theory of mathcalS\mathcal{S}mathcalS and mathbbR\mathbb{R}mathbbR ($\mathrm{Th}_\exists(\mathcal{S},\mathbb{R})$). For loops over mathbbR\mathbb{R}mathbbR, our reduction entails decidability of termination. For loops over mathbbZ\mathbb{Z}mathbbZ or mathbbQ\mathbb{Q}mathbbQ, it proves semi-decidability of non-termination. Furthermore, we show how to transform loops where the right-hand side of the assignment in the loop body consists of arbitrary polynomials into twn-loops. Then the original loop te...
The Automatic Synthesis of Linear Ranking Functions: The Complete Unabridged Version
Computing Research Repository, 2010
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
On the Termination of Integer Loops
ACM Transactions on Programming Languages and Systems, 2012
In this article we study the decidability of termination of several variants of simple integer loops, without branching in the loop body and with affine constraints as the loop guard (and possibly a precondition). We show that termination of such loops is undecidable in some cases, in particular, when the body of the loop is expressed by a set of linear inequalities where the coefficients are from Z ∪ { r } with r an arbitrary irrational; when the loop is a sequence of instructions, that compute either linear expressions or the step function; and when the loop body is a piecewise linear deterministic update with two pieces. The undecidability result is proven by a reduction from counter programs, whose termination is known to be undecidable. For the common case of integer linear-constraint loops with rational coefficients we have not succeeded in proving either decidability or undecidability of termination, but we show that a Petri net can be simulated with such a loop; this implies...
Eventual linear ranking functions
Program termination is a hot research topic in program analysis. The last few years have witnessed the development of termination analyzers for programming languages such as C and Java with remarkable precision and performance. These systems are largely based on techniques and tools coming from the field of declarative constraint programming. In this paper, 1 we first recall an algorithm based on Farkas' Lemma for discovering linear ranking functions proving termination of a certain class of loops. Then we propose an extension of this method for showing the existence of eventual linear ranking functions, i.e., linear functions that become ranking functions after a finite unrolling of the loop. We show correctness and completeness of this algorithm.
Journal of Computer and System Sciences, 1990
This paper structurally characterizes the complexity of ranking. A set A is (strongly) P-rankable if there is a polynomial time computable functionfso that for all x,f(x) computes the number of elements of A that are lexicographically < x, i.e., the rank of x with respect to A. This is the strongest of three notions of P-ranking we consider in this paper. We say a class %' is P-rankable if all sets in %? are P-rankable. Our main results show that with the same certainty with which we believe counting to be complex, and thus with at least the certainty with which we believe P #NP, P has no uniform, strong, weak, or enumerative ranking functions. We show that: l P and NP are equally likely to be P-rankable, i.e., P is P-rankable if and only if NP is P-rankable.