Termination analysis

Termination analysis

In computer science, a termination analysis is program analysis which attempts to determine whether the evaluation of a given program will definitely terminate. Because the halting problem is undecidable, termination analysis cannot work correctly in all cases. The aim is to find the answer "program does terminate" (or "program does not terminate") whenever this is possible. Without success the algorithm (or human) working on the termination analysis may answer with "maybe" or continue working infinitely long.

Contents

Termination proof

A termination proof is a type of mathematical proof that plays a critical role in formal verification because total correctness of an algorithm depends on termination.

A simple, general method for constructing termination proofs involves associating a measure with each step of an algorithm. The measure is taken from the domain of a well-founded relation, such as from the ordinal numbers. If the measure "decreases" according to the relation along every possible step of the algorithm, it must terminate, because there are no infinite descending chains with respect to a well-founded relation.

Some types of termination analysis can automatically generate or imply the existence of a termination proof.

Example

An example of a programming language construct which may or may not terminate is a loop, as they can be run repeatedly. Loops implemented using a counter variable as typically found in data processing algorithms will usually terminate, demonstrated by the pseudocode example below:

i := 0
loop until i = SIZE_OF_DATA
   process_data(data[i])) //process the data chunk at position i
   i := i + 1 //move to the next chunk of data to be processed

If the value of SIZE_OF_DATA is non-negative, fixed and finite, the loop will eventually terminate, assuming process_data terminates too.

Some loops can be shown to always terminate or never terminate, through human inspection. For example, even a non-programmer should see that, in theory, the following never stops (but it may halt on physical machines due to arithmetic overflow):

i := 1
loop until i = 0
    i := i + 1

In termination analysis one may also try to determine the termination behaviour of some program depending on some unknown input. The following example illustrates this problem.

i := 1
loop until i = UNKNOWN
    i := i + 1

Here the loop condition is defined using some value UNKNOWN, where the value of UNKNOWN is not known (e.g. defined by the user's input when the program is executed). Here the termination analysis must take into account all possible values of UNKNOWN and find out that in the possible case of UNKNOWN = 0 (as in the original example) the termination cannot be shown.

There is, however, no general procedure for determining whether an expression involving looping instructions will halt, even when humans are tasked with the inspection. The theoretical reason for this is the undecidability of the Halting Problem: there cannot exist some algorithm which determines whether any given program stops after finitely many computation steps.

In practice one fails to show termination (or non-termination) because every algorithm works with a finite set of methods being able to extract relevant information out of a given program. A method might look at how variables change with respect to some loop condition (possibly showing termination for that loop), other methods might try to transform the program's calculation to some mathematical construct and work on that, possibly getting information about the termination behaviour out of some properties of this mathematical model. But because each method is only able to "see" some specific reasons for (non)termination, even through combination of such methods one cannot cover all possible reasons for (non)termination.

Recursive functions and loops are equivalent in expression; any expression involving loops can be written using recursion, and vice versa. Thus the termination of recursive expressions are also undecidable in general. Most recursive expressions found in common usage (ie. not pathological) can be shown to terminate through various means, usually depending on the definition of the expression itself. As an example, the function argument in the recursive expression for the factorial function below will always decrease by 1; from the well-ordering property on natural numbers, the argument will eventually reach 1 and the recursion will terminate.

function factorial (argument as natural number)
    if argument = 0 or 1
        return 1
    otherwise
        return argument * factorial(argument - 1)

Current Research

There are several research teams that work on new methods that can show (non)termination. Many researchers include these methods into programs[1] that try to analyze the termination behavior automatically (so without human interaction). An on-going aspect of research is to allow the existing methods to be used to analyze termination behavior of programs written in "real world" programming languages. For declarative languages like Haskell and Prolog, many results exist[2][3] (mainly because of the strong mathematical background of these languages). The research community also works on new methods to analyze termination behavior of programs written in imperative languages like C and Java.

Because of the undecidability of the Halting Problem research in this field cannot reach completeness. One can always think of new methods that find new (complicated) reasons for termination.


References

See also

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Termination — may refer to:In science: *Termination codon, in molecular biology *Termination factor, in genetics, part of the process of transcribing RNA *Termination type, in lithic reduction, a characteristic indicating the manner in which the distal end of… …   Wikipedia

  • Termination type — In lithic reduction, termination type is a characteristic indicating the manner in which the distal end of a lithic flake detaches from a core (Andrefsky 1998:18). Common types include:* Step/snap termination – these occur when a flake snaps or… …   Wikipedia

  • Strictness analysis — In computer science, strictness analysis refers to any algorithm used to prove that a function in a non strict functional programming language is strict in one or more of its arguments. This information is useful to compilers because strict… …   Wikipedia

  • Performance analysis — In software engineering, performance analysis, more commonly today known as profiling, is the investigation of a program s behavior using information gathered as the program executes (i.e. it is a form of dynamic program analysis, as opposed to… …   Wikipedia

  • Cognitive behavioral analysis system of psychotherapy — The Cognitive Behavioral Analysis System of Psychotherapy (CBASP) is a talking therapy, a synthesis model of interpersonal and cognitive and behavioral therapies developed (and patented) by James P. McCullough Jr [2000, 2006] of Virginia… …   Wikipedia

  • Halting problem — In computability theory, the halting problem can be stated as follows: Given a description of a computer program, decide whether the program finishes running or continues to run forever. This is equivalent to the problem of deciding, given a… …   Wikipedia

  • Μ-recursive function — In mathematical logic and computer science, the μ recursive functions are a class of partial functions from natural numbers to natural numbers which are computable in an intuitive sense. In fact, in computability theory it is shown that the μ… …   Wikipedia

  • DNA sequencing — Part of a series on Genetics Key components Chromosome DNA • RNA Genome Heredity Mutation Nucleotide Variation …   Wikipedia

  • international relations — a branch of political science dealing with the relations between nations. [1970 75] * * * Study of the relations of states with each other and with international organizations and certain subnational entities (e.g., bureaucracies and political… …   Universalium

  • Smith chart — The Smith Chart, invented by Phillip H. Smith (1905 1987), [Smith, P. H.; Transmission Line Calculator; Electronics, Vol. 12, No. 1, pp 29 31, January 1939] [Smith, P. H.; An Improved Transmission Line Calculator; Electronics, Vol. 17, No. 1, p… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”