encyclopegia.org

Termination analysis

In computer science, termination analysis is program analysis which attempts to determine whether the evaluation of a given program halts for each input. This means to determine whether the input program computes a total function. It is closely related to the halting problem, which is to determine whether a given program halts for a given input and which is undecidable. The termination analysis is even more difficult than the halting problem: the termination analysis in the model of Turing machines as the model of programs implementing computable functions would have the goal of deciding whether a given Turing machine is a total Turing machine, and this problem is at level \Pi^0_2 of the arithmetical hierarchy and thus is strictly more difficult than the halting problem. Now as the question whether a computable function is total is not semi-decidable, each sound termination analyzer (i.e. an affirmative answer is never given for a non-terminating program) is incomplete, i.e. must fail in determining termination for infinitely many terminating programs, either by running forever or halting with an indefinite answer.

In computer science, termination analysis is program analysis which attempts to determine whether the evaluation of a given program halts for each input. This means to determine whether the input program computes a total function. It is closely related to the halting problem, which is to determine whether a given program halts for a given input and which is undecidable. The termination analysis is even more difficult than the halting problem: the termination analysis in the model of Turing machines as the model of programs implementing computable functions would have the goal of deciding whether a given Turing machine is a total Turing machine, and this problem is at level \Pi^0_2 of the arithmetical hierarchy and thus is strictly more difficult than the halting problem. Now as the question whether a computable function is total is not semi-decidable, each sound termination analyzer (i.e. an affirmative answer is never given for a non-terminating program) is incomplete, i.e. must fail in determining termination for infinitely many terminating programs, either by running forever or halting with an indefinite answer. 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, the following loop will, in theory, never stop. However, it may halt when executed on a physical machine due to arithmetic overflow: either leading to an exception or causing the counter to wrap to a negative value and enabling the loop condition to be fulfilled. 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 is also undecidable in general. Most recursive expressions found in common usage (i.e. 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; by the well-ordering property of natural numbers, the argument will eventually reach 1 and the recursion will terminate. function factorial (argument as natural number) if argument = 0 or argument = 1 return 1 otherwise return argument * factorial(argument - 1) === Sized types=== One of the approaches to termination checking in dependently typed programming languages are sized types. The main idea is to annotate the types over which we can recurse with size annotations and allow recursive calls only on smaller arguments. Sized types are implemented in Agda as a syntactic extension.

References

  1. Rogers, Jr., Hartley (1988). Theory of recursive functions and effective computability . Cambridge (MA), London (England): The MIT Press. p. 476. ISBN 0-262-68052-1 . Wikipedia revision 1378975704, retrieved 2026-11-21 · retrieved 2026-11-20 · rev 1378975704
    Cite this reference

    MLA "Rogers, Jr., Hartley (1988). Theory of recursive functions and effective computability . Cambridge (MA), London (England): The MIT Press. p. 476. ISBN 0-262-68052-1 . Wikipedia revision 1378975704, retrieved 2026-11-21." Rogers, Jr. 2026-11-20. https://en.wikipedia.org/wiki/ISBN_(identifier). Accessed 24 November 2026.

    Chicago "Rogers, Jr., Hartley (1988). Theory of recursive functions and effective computability . Cambridge (MA), London (England): The MIT Press. p. 476. ISBN 0-262-68052-1 . Wikipedia revision 1378975704, retrieved 2026-11-21." Rogers, Jr. 2026-11-20. https://en.wikipedia.org/wiki/ISBN_(identifier).

    APA Rogers, Jr. (2026). Rogers, Jr., Hartley (1988). Theory of recursive functions and effective computability . Cambridge (MA), London (England): The MIT Press. p. 476. ISBN 0-262-68052-1 . Wikipedia revision 1378975704, retrieved 2026-11-21. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/ISBN_(identifier)

  2. Category:Tools - Termination-Portal.org · retrieved 2026-11-20 · rev 1378975704
    Cite this reference

    MLA "Category:Tools - Termination-Portal.org." "Category:Tools - Termination-Portal. 2026-11-20. https://termination-portal.org/wiki/Category:Tools. Accessed 24 November 2026.

    Chicago "Category:Tools - Termination-Portal.org." "Category:Tools - Termination-Portal. 2026-11-20. https://termination-portal.org/wiki/Category:Tools.

    APA "Category:Tools - Termination-Portal. (2026). Category:Tools - Termination-Portal.org. Retrieved November 24, 2026, from https://termination-portal.org/wiki/Category:Tools

  3. Giesl, J.; Swiderski, S.; Schneider-Kamp, P.; Thiemann, R. Pfenning, F. (ed.). Automated Termination Analysis for Haskell: From Term Rewriting to Programming Languages (invited lecture) (postscript) . Term Rewriting and Applications, 17th Int. Conf., RTA-06. LNCS. Vol. 4098. pp. 297– 312. (link: springerlink.com ). Wikipedia revision 1378975704, retrieved 2026-11-21 · retrieved 2026-11-20 · rev 1378975704
    Cite this reference

    MLA "Giesl, J.; Swiderski, S.; Schneider-Kamp, P.; Thiemann, R. Pfenning, F. (ed.). Automated Termination Analysis for Haskell: From Term Rewriting to Programming Languages (invited lecture) (postscript) . Term Rewriting and Applications, 17th Int. Conf., RTA-06. LNCS. Vol. 4098. pp. 297– 312. (link: springerlink.com ). Wikipedia revision 1378975704, retrieved 2026-11-21." Giesl, J. 2026-11-20. http://verify.rwth-aachen.de/psk/papers/RTA06Haskell.ps. Accessed 24 November 2026.

    Chicago "Giesl, J.; Swiderski, S.; Schneider-Kamp, P.; Thiemann, R. Pfenning, F. (ed.). Automated Termination Analysis for Haskell: From Term Rewriting to Programming Languages (invited lecture) (postscript) . Term Rewriting and Applications, 17th Int. Conf., RTA-06. LNCS. Vol. 4098. pp. 297– 312. (link: springerlink.com ). Wikipedia revision 1378975704, retrieved 2026-11-21." Giesl, J. 2026-11-20. http://verify.rwth-aachen.de/psk/papers/RTA06Haskell.ps.

    APA Giesl, J. (2026). Giesl, J.; Swiderski, S.; Schneider-Kamp, P.; Thiemann, R. Pfenning, F. (ed.). Automated Termination Analysis for Haskell: From Term Rewriting to Programming Languages (invited lecture) (postscript) . Term Rewriting and Applications, 17th Int. Conf., RTA-06. LNCS. Vol. 4098. pp. 297– 312. (link: springerlink.com ). Wikipedia revision 1378975704, retrieved 2026-11-21. Retrieved November 24, 2026, from http://verify.rwth-aachen.de/psk/papers/RTA06Haskell.ps

  4. Compiler options for termination analysis in Mercury Wikipedia revision 1378975704, retrieved 2026-11-21 · retrieved 2026-11-20 · rev 1378975704
    Cite this reference

    MLA "Compiler options for termination analysis in Mercury Wikipedia revision 1378975704, retrieved 2026-11-21." 2026-11-20. http://www.mercury.csse.unimelb.edu.au/information/doc-release/mercury_ref/Termination-analysis.html#Termination-analysis. Accessed 24 November 2026.

    Chicago "Compiler options for termination analysis in Mercury Wikipedia revision 1378975704, retrieved 2026-11-21." 2026-11-20. http://www.mercury.csse.unimelb.edu.au/information/doc-release/mercury_ref/Termination-analysis.html#Termination-analysis.

    APA encyclopegia.org. (2026). Compiler options for termination analysis in Mercury Wikipedia revision 1378975704, retrieved 2026-11-21. Retrieved November 24, 2026, from http://www.mercury.csse.unimelb.edu.au/information/doc-release/mercury_ref/Termination-analysis.html#Termination-analysis

  5. Termination Analysis of Logic Programs based on Dependency Graphs · retrieved 2026-11-20 · rev 1378975704
    Cite this reference

    MLA "Termination Analysis of Logic Programs based on Dependency Graphs." Nguyen, Manh Thang; Giesl, Jürgen; Schneider-Kamp, Peter; De Schreye, Danny. 2026-11-20. http://verify.rwth-aachen.de/giesl/papers/lopstr07-distribute.pdf. Accessed 24 November 2026.

    Chicago "Termination Analysis of Logic Programs based on Dependency Graphs." Nguyen, Manh Thang; Giesl, Jürgen; Schneider-Kamp, Peter; De Schreye, Danny. 2026-11-20. http://verify.rwth-aachen.de/giesl/papers/lopstr07-distribute.pdf.

    APA Nguyen, Manh Thang; Giesl, Jürgen; Schneider-Kamp, Peter; De Schreye, Danny. (2026). Termination Analysis of Logic Programs based on Dependency Graphs. Retrieved November 24, 2026, from http://verify.rwth-aachen.de/giesl/papers/lopstr07-distribute.pdf

  6. Probabilistic Program Analysis with Martingales · retrieved 2026-10-06 · rev 1378975704
    Cite this reference

    MLA "Probabilistic Program Analysis with Martingales." Chakarov, Aleksandar; Sankaranarayanan, Sriram (2013). 2026-10-06. http://link.springer.com/10.1007/978-3-642-39799-8_34. Accessed 24 November 2026.

    Chicago "Probabilistic Program Analysis with Martingales." Chakarov, Aleksandar; Sankaranarayanan, Sriram (2013). 2026-10-06. http://link.springer.com/10.1007/978-3-642-39799-8_34.

    APA Chakarov, Aleksandar; Sankaranarayanan, Sriram (2013). (2026). Probabilistic Program Analysis with Martingales. Retrieved November 24, 2026, from http://link.springer.com/10.1007/978-3-642-39799-8_34

  7. Chakarov, Aleksandar. Computer Aided Verification . Spri . · retrieved 2026-10-06 · rev 1378975704
    Cite this reference

    MLA "Chakarov, Aleksandar. Computer Aided Verification . Spri ." Chakarov, Aleksandar. 2026-10-06. https://en.wikipedia.org/w/index.php?oldid=1378975704. Accessed 24 November 2026.

    Chicago "Chakarov, Aleksandar. Computer Aided Verification . Spri ." Chakarov, Aleksandar. 2026-10-06. https://en.wikipedia.org/w/index.php?oldid=1378975704.

    APA Chakarov, Aleksandar. (2026). Chakarov, Aleksandar. Computer Aided Verification . Spri . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378975704

  8. Category:Tools - Termination-Portal.org . termination-portal.org . · retrieved 2026-10-06 · rev 1378975704
    Cite this reference

    MLA "Category:Tools - Termination-Portal.org . termination-portal.org ." Category:Tools - Termination-Portal. 2026-10-06. https://en.wikipedia.org/w/index.php?oldid=1378975704. Accessed 24 November 2026.

    Chicago "Category:Tools - Termination-Portal.org . termination-portal.org ." Category:Tools - Termination-Portal. 2026-10-06. https://en.wikipedia.org/w/index.php?oldid=1378975704.

    APA Category:Tools - Termination-Portal. (2026). Category:Tools - Termination-Portal.org . termination-portal.org . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378975704

  9. Automated Termination Analysis for Haskell: From Term Rewriting to Programming Langu . · retrieved 2026-10-06 · rev 1378975704
    Cite this reference

    MLA "Automated Termination Analysis for Haskell: From Term Rewriting to Programming Langu ." 2026-10-06. https://en.wikipedia.org/w/index.php?oldid=1378975704. Accessed 24 November 2026.

    Chicago "Automated Termination Analysis for Haskell: From Term Rewriting to Programming Langu ." 2026-10-06. https://en.wikipedia.org/w/index.php?oldid=1378975704.

    APA encyclopegia.org. (2026). Automated Termination Analysis for Haskell: From Term Rewriting to Programming Langu . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378975704

  10. [http://www.mercury.csse.unimelb.edu.au/information/doc-release/mercury_ref/Termination-analysis.html#Termination-analysis Compiler options for termination analysis in Mercury] . · retrieved 2026-10-06 · rev 1378975704
    Cite this reference

    MLA "[http://www.mercury.csse.unimelb.edu.au/information/doc-release/mercury_ref/Termination-analysis.html#Termination-analysis Compiler options for termination analysis in Mercury] ." http://www. 2026-10-06. https://en.wikipedia.org/w/index.php?oldid=1378975704. Accessed 24 November 2026.

    Chicago "[http://www.mercury.csse.unimelb.edu.au/information/doc-release/mercury_ref/Termination-analysis.html#Termination-analysis Compiler options for termination analysis in Mercury] ." http://www. 2026-10-06. https://en.wikipedia.org/w/index.php?oldid=1378975704.

    APA http://www. (2026). [http://www.mercury.csse.unimelb.edu.au/information/doc-release/mercury_ref/Termination-analysis.html#Termination-analysis Compiler options for termination analysis in Mercury] . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378975704

  11. Termination Analysis of Logic Programs based on Dependency Graphs . · retrieved 2026-10-06 · rev 1378975704
    Cite this reference

    MLA "Termination Analysis of Logic Programs based on Dependency Graphs ." 2026-10-06. https://en.wikipedia.org/w/index.php?oldid=1378975704. Accessed 24 November 2026.

    Chicago "Termination Analysis of Logic Programs based on Dependency Graphs ." 2026-10-06. https://en.wikipedia.org/w/index.php?oldid=1378975704.

    APA encyclopegia.org. (2026). Termination Analysis of Logic Programs based on Dependency Graphs . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1378975704

Cite this article

MLA

"Termination analysis." encyclopegia.org, 2026, https://encyclopegia.org/wiki/termination-analysis. Accessed 24 November 2026.

Chicago

"Termination analysis." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/termination-analysis.

APA

encyclopegia.org. (2026). Termination analysis. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/termination-analysis

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

canonical correlation analysis

stub · references available

functional analysis

stub · references available

regression analysis

stub · references available

stakeholder analysis

stub · references available

arterial blood gas analysis

stub · references available

image analysis

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1378975704 · 0.5 · snapshot enwiki-001378975704

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.