HOME

TheInfoList



OR:

In computability theory, the halting problem is the problem of determining, from a description of an arbitrary
computer program A computer program is a sequence or set of instructions in a programming language for a computer to execute. Computer programs are one component of software, which also includes documentation and other intangible components. A computer program ...
and an input, whether the program will finish running, or continue to run forever.
Alan Turing Alan Mathison Turing (; 23 June 1912 – 7 June 1954) was an English mathematician, computer scientist, logician, cryptanalyst, philosopher, and theoretical biologist. Turing was highly influential in the development of theoretical co ...
proved in 1936 that a general
algorithm In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
to solve the halting problem for all possible program–input pairs cannot exist. For any program that might determine whether programs halt, a "pathological" program , called with some input, can pass its own source and its input to ''f'' and then specifically do the opposite of what ''f'' predicts ''g'' will do. No ''f'' can exist that handles this case. A key part of the proof is a mathematical definition of a computer and program, which is known as a
Turing machine A Turing machine is a mathematical model of computation describing an abstract machine that manipulates symbols on a strip of tape according to a table of rules. Despite the model's simplicity, it is capable of implementing any computer algori ...
; the halting problem is '' undecidable'' over Turing machines. It is one of the first cases of
decision problem In computability theory and computational complexity theory, a decision problem is a computational problem that can be posed as a yes–no question of the input values. An example of a decision problem is deciding by means of an algorithm wheth ...
s proven to be unsolvable. This proof is significant to practical computing efforts, defining a class of applications which no programming invention can possibly perform perfectly. Jack Copeland attributes the introduction of the term ''halting problem'' to the work of Martin Davis in the 1950s.


Background

The halting problem is a decision problem about properties of computer programs on a fixed
Turing-complete In computability theory, a system of data-manipulation rules (such as a computer's instruction set, a programming language, or a cellular automaton) is said to be Turing-complete or computationally universal if it can be used to simulate any ...
model of computation, i.e., all programs that can be written in some given
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
that is general enough to be equivalent to a Turing machine. The problem is to determine, given a program and an input to the program, whether the program will eventually halt when run with that input. In this abstract framework, there are no resource limitations on the amount of memory or time required for the program's execution; it can take arbitrarily long and use an arbitrary amount of storage space before halting. The question is simply whether the given program will ever halt on a particular input. For example, in pseudocode, the program :while (true) continue does not halt; rather, it goes on forever in an
infinite loop In computer programming, an infinite loop (or endless loop) is a sequence of instructions that, as written, will continue endlessly, unless an external intervention occurs ("pull the plug"). It may be intentional. Overview This differs from: * ...
. On the other hand, the program : print "Hello, world!" does halt. While deciding whether these programs halt is simple, more complex programs prove problematic. One approach to the problem might be to run the program for some number of steps and check if it halts. But if the program does not halt, it is unknown whether the program will eventually halt or run forever. Turing proved no algorithm exists that always correctly decides whether, for a given arbitrary program and input, the program halts when run with that input. The essence of Turing's proof is that any such algorithm can be made to produce contradictory output and therefore cannot be correct.


Programming consequences

Some
infinite loop In computer programming, an infinite loop (or endless loop) is a sequence of instructions that, as written, will continue endlessly, unless an external intervention occurs ("pull the plug"). It may be intentional. Overview This differs from: * ...
s can be quite useful. For instance,
event loop In computer science, the event loop is a programming construct or design pattern that waits for and dispatches events or messages in a program. The event loop works by making a request to some internal or external "event provider" (that generally ...
s are typically coded as infinite loops. However, most subroutines are intended to finish. In particular, in hard
real-time computing Real-time computing (RTC) is the computer science term for hardware and software systems subject to a "real-time constraint", for example from event to system response. Real-time programs must guarantee response within specified time constra ...
, programmers attempt to write subroutines that are not only guaranteed to finish, but are also guaranteed to finish before a given deadline Sometimes these programmers use some general-purpose (Turing-complete) programming language, but attempt to write in a restricted style—such as
MISRA C MISRA C is a set of software development guidelines for the C (programming language), C programming language developed by Motor Industry Software Reliability Association, The MISRA Consortium. Its aims are to facilitate code safety, Computer securi ...
or
SPARK Spark commonly refers to: * Spark (fire), a small glowing particle or ember * Electric spark, a form of electrical discharge Spark may also refer to: Places * Spark Point, a rocky point in the South Shetland Islands People * Spark (surname) * ...
—that makes it easy to prove that the resulting subroutines finish before the given deadline. Other times these programmers apply the
rule of least power In programming, the rule of least power is a design principle that "suggests choosing the least powerful omputerlanguage suitable for a given purpose". Stated alternatively, given a choice among computer languages, classes of which range from ...
—they deliberately use a computer language that is not quite fully Turing-complete. Frequently, these are languages that guarantee all subroutines finish, such as
Coq Coq is an interactive theorem prover first released in 1989. It allows for expressing mathematical assertions, mechanically checks proofs of these assertions, helps find formal proofs, and extracts a certified program from the constructive proof ...
.


Common pitfalls

The difficulty in the halting problem lies in the requirement that the decision procedure must work for all programs and inputs. A particular program either halts on a given input or does not halt. Consider one algorithm that always answers "halts" and another that always answers "does not halt". For any specific program and input, one of these two algorithms answers correctly, even though nobody may know which one. Yet neither algorithm solves the halting problem generally. There are programs (
interpreters Interpreting is a translational activity in which one produces a first and final target-language output on the basis of a one-time exposure to an expression in a source language. The most common two modes of interpreting are simultaneous interp ...
) that simulate the execution of whatever source code they are given. Such programs can demonstrate that a program does halt if this is the case: the interpreter itself will eventually halt its simulation, which shows that the original program halted. However, an interpreter will not halt if its input program does not halt, so this approach cannot solve the halting problem as stated; it does not successfully answer "does not halt" for programs that do not halt. The halting problem is theoretically decidable for linear bounded automata (LBAs) or deterministic machines with finite memory. A machine with finite memory has a finite number of configurations, and thus any deterministic program on it must eventually either halt or repeat a previous configuration: However, a computer with a million small parts, each with two states, would have at least 21,000,000 possible states: Although a machine may be finite, and finite automata "have a number of theoretical limitations": It can also be decided automatically whether a nondeterministic machine with finite memory halts on none, some, or all of the possible sequences of nondeterministic decisions, by enumerating states after each possible decision.


History

The halting problem is historically important because it was one of the first problems to be proved undecidable. In April 1936,
Alonzo Church Alonzo Church (June 14, 1903 – August 11, 1995) was an American mathematician, computer scientist, logician, philosopher, professor and editor who made major contributions to mathematical logic and the foundations of theoretical computer scien ...
published his proof of the undecidability of a problem in the lambda calculus.
Turing's proof Turing's proof is a proof by Alan Turing, first published in January 1937 with the title "On Computable Numbers, with an Application to the ". It was the second proof (after Church's theorem) of the negation of Hilbert's ; that is, the conjecture ...
was published later, in January 1937. Since then, many other undecidable problems have been described.


Timeline

* * * * * * * * * * * * * letter from Davis to Copeland, 12 December 2001, Footnote 61 in


Etymology of the phrase "halting problem"

In none of his work did Turing use the word "halting" or "termination". Turing's biographer Hodges does not have the word "halting" or words "halting problem" in his index. The earliest recorded use of the words "halting problem" is in a proof by Davis in 1958: Davis adds no attribution for his proof, so one infers that it is original with him. But Davis has said that Kleene stated the proof informally. Copeland states that:


Formalization

In his original proof Turing formalized the concept of ''
algorithm In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
'' by introducing
Turing machine A Turing machine is a mathematical model of computation describing an abstract machine that manipulates symbols on a strip of tape according to a table of rules. Despite the model's simplicity, it is capable of implementing any computer algori ...
s. However, the result is in no way specific to them; it applies equally to any other model of computation that is equivalent in its computational power to Turing machines, such as Markov algorithms, Lambda calculus, Post systems,
register machine In mathematical logic and theoretical computer science a register machine is a generic class of abstract machines used in a manner similar to a Turing machine. All the models are Turing equivalent. Overview The register machine gets its name fro ...
s, or tag systems. What is important is that the formalization allows a straightforward mapping of algorithms to some data type that the
algorithm In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
can operate upon. For example, if the formalism lets algorithms define functions over strings (such as Turing machines) then there should be a mapping of these algorithms to strings, and if the formalism lets algorithms define functions over natural numbers (such as
computable function Computable functions are the basic objects of study in computability theory. Computable functions are the formalized analogue of the intuitive notion of algorithms, in the sense that a function is computable if there exists an algorithm that can do ...
s) then there should be a mapping of algorithms to natural numbers. The mapping to strings is usually the most straightforward, but strings over an
alphabet An alphabet is a standardized set of basic written graphemes (called letters) that represent the phonemes of certain spoken languages. Not all writing systems represent language in this way; in a syllabary, each character represents a syllab ...
with ''n''
characters Character or Characters may refer to: Arts, entertainment, and media Literature * ''Character'' (novel), a 1936 Dutch novel by Ferdinand Bordewijk * ''Characters'' (Theophrastus), a classical Greek set of character sketches attributed to The ...
can also be mapped to numbers by interpreting them as numbers in an ''n''-ary
numeral system A numeral system (or system of numeration) is a writing system for expressing numbers; that is, a mathematical notation for representing numbers of a given set, using digits or other symbols in a consistent manner. The same sequence of symbo ...
.


Representation as a set

The conventional representation of decision problems is the set of objects possessing the property in question. The ''halting set'' : ''K'' = represents the halting problem. This set is
recursively enumerable In computability theory, a set ''S'' of natural numbers is called computably enumerable (c.e.), recursively enumerable (r.e.), semidecidable, partially decidable, listable, provable or Turing-recognizable if: *There is an algorithm such that the ...
, which means there is a computable function that lists all of the pairs (''i'', ''x'') it contains. However, the complement of this set is not recursively enumerable. There are many equivalent formulations of the halting problem; any set whose
Turing degree In computer science and mathematical logic the Turing degree (named after Alan Turing) or degree of unsolvability of a set of natural numbers measures the level of algorithmic unsolvability of the set. Overview The concept of Turing degree is fund ...
equals that of the halting problem is such a formulation. Examples of such sets include: * *.


Proof concept

Christopher Strachey Christopher S. Strachey (; 16 November 1916 – 18 May 1975) was a British computer scientist. He was one of the founders of denotational semantics, and a pioneer in programming language design and computer time-sharing.F. J. Corbató, et al. ...
outlined a proof by contradiction that the halting problem is not solvable. The proof proceeds as follows: Suppose that there exists a total
computable function Computable functions are the basic objects of study in computability theory. Computable functions are the formalized analogue of the intuitive notion of algorithms, in the sense that a function is computable if there exists an algorithm that can do ...
''halts(f)'' that returns true if the subroutine ''f'' halts (when run with no inputs) and returns false otherwise. Now consider the following subroutine: def g(): if halts(g): loop_forever() ''halts(g)'' must either return true or false, because ''halts'' was assumed to be total. If ''halts(g)'' returns true, then ''g'' will call ''loop_forever'' and never halt, which is a contradiction. If ''halts(g)'' returns false, then ''g'' will halt, because it will not call ''loop_forever''; this is also a contradiction. Overall, ''g'' does the opposite of what ''halts'' says ''g'' should do, so ''halts(g)'' can not return a truth value that is consistent with whether ''g'' halts. Therefore, the initial assumption that ''halts'' is a total computable function must be false.


Sketch of rigorous proof

The concept above shows the general method of the proof, but the computable function ''halts'' does not directly take a subroutine as an argument; instead it takes the source code of a program. Moreover, the definition of ''g'' is
self-referential Self-reference occurs in natural or formal languages when a sentence, idea or formula refers to itself. The reference may be expressed either directly—through some intermediate sentence or formula—or by means of some encoding. In philoso ...
. A rigorous proof addresses these issues. The overall goal is to show that there is no total
computable function Computable functions are the basic objects of study in computability theory. Computable functions are the formalized analogue of the intuitive notion of algorithms, in the sense that a function is computable if there exists an algorithm that can do ...
that decides whether an arbitrary program ''i'' halts on arbitrary input ''x''; that is, the following function ''h'' (for "halts") is not computable: :h(i,x) = \begin 1 & \text \texti\textx, \\ 0 & \text \end Here ''program i'' refers to the ''i'' th program in an
enumeration An enumeration is a complete, ordered listing of all the items in a collection. The term is commonly used in mathematics and computer science to refer to a listing of all of the elements of a set. The precise requirements for an enumeration (fo ...
of all the programs of a fixed
Turing-complete In computability theory, a system of data-manipulation rules (such as a computer's instruction set, a programming language, or a cellular automaton) is said to be Turing-complete or computationally universal if it can be used to simulate any ...
model of computation.
Possible values for a total computable function ''f'' arranged in a 2D array. The orange cells are the diagonal. The values of ''f''(''i'',''i'') and ''g''(''i'') are shown at the bottom; ''U'' indicates that the function ''g'' is undefined for a particular input value.
The proof proceeds by directly establishing that no total computable function with two arguments can be the required function ''h''. As in the sketch of the concept, given any total computable binary function ''f'', the following
partial function In mathematics, a partial function from a set to a set is a function from a subset of (possibly itself) to . The subset , that is, the domain of viewed as a function, is called the domain of definition of . If equals , that is, if is de ...
''g'' is also computable by some program ''e'': :g(i) = \begin 0 & \text f(i,i) = 0,\\ \text & \text \end The verification that ''g'' is computable relies on the following constructs (or their equivalents): * computable subprograms (the program that computes ''f'' is a subprogram in program ''e''), * duplication of values (program ''e'' computes the inputs ''i'',''i'' for ''f'' from the input ''i'' for ''g''), * conditional branching (program ''e'' selects between two results depending on the value it computes for ''f''(''i'',''i'')), * not producing a defined result (for example, by looping forever), * returning a value of 0. The following pseudocode for ''e'' illustrates a straightforward way to compute ''g'':
procedure e(i): if f(i, i)

0 then return 0 else loop forever
Because ''g'' is partial computable, there must be a program ''e'' that computes ''g'', by the assumption that the model of computation is Turing-complete. This program is one of all the programs on which the halting function ''h'' is defined. The next step of the proof shows that ''h''(''e'',''e'') will not have the same value as ''f''(''e'',''e''). It follows from the definition of ''g'' that exactly one of the following two cases must hold: * ''f''(''e'',''e'') = 0 and so ''g''(''e'') = 0. In this case program ''e'' halts on input ''e'', so ''h''(''e'',''e'') = 1. * ''f''(''e'',''e'') ≠ 0 and so ''g''(''e'') is undefined. In this case program ''e'' does not halt on input ''e'', so ''h''(''e'',''e'') = 0. In either case, ''f'' cannot be the same function as ''h''. Because ''f'' was an ''arbitrary'' total computable function with two arguments, all such functions must differ from ''h''. This proof is analogous to
Cantor's diagonal argument In set theory, Cantor's diagonal argument, also called the diagonalisation argument, the diagonal slash argument, the anti-diagonal argument, the diagonal method, and Cantor's diagonalization proof, was published in 1891 by Georg Cantor as a m ...
. One may visualize a two-dimensional array with one column and one row for each natural number, as indicated in the table above. The value of ''f''(''i'',''j'') is placed at column ''i'', row ''j''. Because ''f'' is assumed to be a total computable function, any element of the array can be calculated using ''f''. The construction of the function ''g'' can be visualized using the main diagonal of this array. If the array has a 0 at position (''i'',''i''), then ''g''(''i'') is 0. Otherwise, ''g''(''i'') is undefined. The contradiction comes from the fact that there is some column ''e'' of the array corresponding to ''g'' itself. Now assume ''f'' was the halting function ''h'', if ''g''(''e'') is defined (''g''(''e'') = 0 in this case), ''g''(''e'') halts so ''f''(''e,e'') = 1. But ''g''(''e'') = 0 only when ''f''(''e,e'') = 0, contradicting ''f''(''e,e'') = 1. Similarly, if ''g''(''e'') is not defined, then halting function ''f''(''e,e'') = 0, which leads to ''g''(''e'') = 0 under ''gs construction. This contradicts the assumption of ''g''(''e'') not being defined. In both cases contradiction arises. Therefore any arbitrary computable function ''f'' cannot be the halting function ''h''.


Computability theory

A typical method of proving a problem to be undecidable is to '' reduce'' it to the halting problem. For example, there cannot be a general algorithm that decides whether a given statement about
natural number In mathematics, the natural numbers are those numbers used for counting (as in "there are ''six'' coins on the table") and ordering (as in "this is the ''third'' largest city in the country"). Numbers used for counting are called ''cardinal ...
s is true or false. The reason for this is that the
proposition In logic and linguistics, a proposition is the meaning of a declarative sentence. In philosophy, " meaning" is understood to be a non-linguistic entity which is shared by all sentences with the same meaning. Equivalently, a proposition is the no ...
stating that a certain program will halt given a certain input can be converted into an equivalent statement about natural numbers. If an algorithm could find the truth value of every statement about natural numbers, it could certainly find the truth value of this one; but that would determine whether the original program halts.
Rice's theorem In computability theory, Rice's theorem states that all non-trivial semantic properties of programs are undecidable. A semantic property is one about the program's behavior (for instance, does the program terminate for all inputs), unlike a synta ...
generalizes the theorem that the halting problem is unsolvable. It states that for ''any'' non-trivial property, there is no general decision procedure that, for all programs, decides whether the partial function implemented by the input program has that property. (A partial function is a function which may not always produce a result, and so is used to model programs, which can either produce results or fail to halt.) For example, the property "halt for the input 0" is undecidable. Here, "non-trivial" means that the set of partial functions that satisfy the property is neither the empty set nor the set of all partial functions. For example, "halts or fails to halt on input 0" is clearly true of all partial functions, so it is a trivial property, and can be decided by an algorithm that simply reports "true." Also, this theorem holds only for properties of the partial function implemented by the program; Rice's Theorem does not apply to properties of the program itself. For example, "halt on input 0 within 100 steps" is ''not'' a property of the partial function that is implemented by the program—it is a property of the program implementing the partial function and is very much decidable.
Gregory Chaitin Gregory John Chaitin ( ; born 25 June 1947) is an Argentine-American mathematician and computer scientist. Beginning in the late 1960s, Chaitin made contributions to algorithmic information theory and metamathematics, in particular a computer-t ...
has defined a halting probability, represented by the symbol Ω, a type of real number that informally is said to represent the
probability Probability is the branch of mathematics concerning numerical descriptions of how likely an event is to occur, or how likely it is that a proposition is true. The probability of an event is a number between 0 and 1, where, roughly speakin ...
that a randomly produced program halts. These numbers have the same
Turing degree In computer science and mathematical logic the Turing degree (named after Alan Turing) or degree of unsolvability of a set of natural numbers measures the level of algorithmic unsolvability of the set. Overview The concept of Turing degree is fund ...
as the halting problem. It is a
normal Normal(s) or The Normal(s) may refer to: Film and television * ''Normal'' (2003 film), starring Jessica Lange and Tom Wilkinson * ''Normal'' (2007 film), starring Carrie-Anne Moss, Kevin Zegers, Callum Keith Rennie, and Andrew Airlie * ''Norma ...
and
transcendental number In mathematics, a transcendental number is a number that is not algebraic—that is, not the root of a non-zero polynomial of finite degree with rational coefficients. The best known transcendental numbers are and . Though only a few classes ...
which can be defined but cannot be completely computed. This means one can prove that there is no
algorithm In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
which produces the digits of Ω, although its first few digits can be calculated in simple cases. Since the negative answer to the halting problem shows that there are problems that cannot be solved by a Turing machine, the Church–Turing thesis limits what can be accomplished by any machine that implements
effective method In logic, mathematics and computer science, especially metalogic and computability theory, an effective method Hunter, Geoffrey, ''Metalogic: An Introduction to the Metatheory of Standard First-Order Logic'', University of California Press, 1971 or ...
s. However, not all machines conceivable to human imagination are subject to the Church–Turing thesis (e.g.
oracle machine In complexity theory and computability theory, an oracle machine is an abstract machine used to study decision problems. It can be visualized as a Turing machine with a black box, called an oracle, which is able to solve certain problems in a ...
s). It is an open question whether there can be actual deterministic
physical process Physical changes are changes affecting the form of a chemical substance, but not its chemical composition. Physical changes are used to separate mixtures into their component compounds, but can not usually be used to separate compounds into chem ...
es that, in the long run, elude simulation by a Turing machine, and in particular whether any such hypothetical process could usefully be harnessed in the form of a calculating machine (a
hypercomputer Hypercomputation or super-Turing computation refers to models of computation that can provide outputs that are not Turing-computable. Super-Turing computing, introduced at the early 1990's by Hava Siegelmann, refers to such neurological inspired, ...
) that could solve the halting problem for a Turing machine amongst other things. It is also an open question whether any such unknown physical processes are involved in the working of the
human brain The human brain is the central organ (anatomy), organ of the human nervous system, and with the spinal cord makes up the central nervous system. The brain consists of the cerebrum, the brainstem and the cerebellum. It controls most of the act ...
, and whether humans can solve the halting problem.


Approximations

Turing's proof shows that there can be no mechanical, general method (i.e., a Turing machine or a program in some equivalent
model of computation In computer science, and more specifically in computability theory and computational complexity theory, a model of computation is a model which describes how an output of a mathematical function is computed given an input. A model describes how ...
) to determine whether algorithms halt. However, each individual instance of the halting problem has a definitive answer, which may or may not be practically computable. Given a specific algorithm and input, one can often show that it halts or does not halt, and in fact computer scientists often do just that as part of a correctness proof. There are some
heuristics A heuristic (; ), or heuristic technique, is any approach to problem solving or self-discovery that employs a practical method that is not guaranteed to be optimal, perfect, or rational, but is nevertheless sufficient for reaching an immediate, ...
that can be used in an automated fashion to attempt to construct a proof, which frequently succeed on typical programs. This field of research is known as automated termination analysis. Some results have been established on the theoretical performance of halting problem heuristics, in particular the fraction of programs of a given size that may be correctly classified by a recursive algorithm. These results do not give precise numbers because the fractions are uncomputable and also highly dependent on the choice of program encoding used to determine "size". For example, consider classifying programs by their number of states and using a specific "Turing semi-infinite tape" model of computation that errors (without halting) if the program runs off the left side of the tape. Then \lim_ P(x\,\text \mid x\,\text\,n\,\text) = 1, over programs x chosen uniformly by number of states. But this result is in some sense "trivial" because these decidable programs are simply the ones that fall off the tape, and the heuristic is simply to predict not halting due to error. Thus a seemingly irrelevant detail, namely the treatment of programs with errors, can turn out to be the deciding factor in determining the fraction of programs. To avoid these issues, several restricted notions of the "size" of a program have been developed. A dense Gödel numbering assigns numbers to programs such that each computable function occurs a positive fraction in each sequence of indices from 1 to n, i.e. a Gödelization φ is dense iff for all i, there exists a c > 0 such that \liminf_ \#\/n\geq c. For example, a numbering that assigns indexes 2^n to nontrivial programs and all other indices the error state is not dense, but there exists a dense Gödel numbering of syntactically correct
Brainfuck Brainfuck is an esoteric programming language created in 1993 by Urban Müller. Notable for its extreme minimalism, the language consists of only eight simple commands, a data pointer and an instruction pointer. While it is fully Turing com ...
programs. A dense Gödel numbering is called optimal if, for any other Gödel numbering \alpha, there is a 1-1 total recursive function f and a constant c such that for all i, \alpha_i=\phi_ and f(i) \leq c i. This condition ensures that all programs have indices not much larger than their indices in any other Gödel numbering. Optimal Gödel numberings are constructed by numbering the inputs of a
universal Turing machine In computer science, a universal Turing machine (UTM) is a Turing machine that can simulate an arbitrary Turing machine on arbitrary input. The universal machine essentially achieves this by reading both the description of the machine to be simu ...
. A third notion of size uses universal machines operating on binary strings and measures the length of the string needed to describe the input program. A universal machine ''U'' is a machine for which every other machine ''V'' there exists a total computable function h such that V (x) = U (h(x)). An optimal machine is a universal machine that achieves the Kolmogorov complexity invariance bound, i.e. for every machine ''V'', there exists ''c'' such that for all outputs ''x'', if a ''V''-program of length ''n'' outputs ''x'', then there exists a ''U''-program of at most length n+c outputting ''x''. We consider partial
computable function Computable functions are the basic objects of study in computability theory. Computable functions are the formalized analogue of the intuitive notion of algorithms, in the sense that a function is computable if there exists an algorithm that can do ...
s (algorithms) A. For each n we consider the fraction \epsilon_n(A) of errors among all programs of size metric at most n, counting each program x for which A fails to terminate, produces a "don't know" answer, or produces a wrong answer, i.e. x halts and A(x) outputs DOES_NOT_HALT, or x does not halt and A(x) outputs HALTS. The behavior may be described as follows, for dense Gödelizations and optimal machines: * For every algorithm A, \liminf_ \epsilon_n(A) > 0 * There exists \epsilon > 0 such that for every algorithm A, \limsup_ \epsilon_n(A) \geq \epsilon * \inf_ \liminf_ \epsilon_n(A) = 0. However, this includes algorithms that produce wrong answers. * If we consider only "honest" algorithms that may be undefined but never produce wrong answers, then depending on the metric \inf_ \liminf_ \epsilon_n(A) may or may not be 0. In particular it is 0 for left-total universal machines, but for effectively optimal machines it is greater than 0. The complex nature of these bounds is due to the oscillatory behavior of \epsilon_n(A). There are infrequently occurring new varieties of programs that come in arbitrarily large "blocks", and a constantly growing fraction of repeats. If the blocks of new varieties are fully included, the error rate is at least \epsilon, but between blocks the fraction of correctly categorized repeats can be arbitrarily high. In particular a "tally" heuristic that simply remembers the first N inputs and recognizes their equivalents allows reaching an arbitrarily low error rate infinitely often.


Gödel's incompleteness theorems


Generalization

Many variants of the halting problem can be found in computability textbooks.for example, , , , , Typically, these problems are RE-complete and describe sets of complexity \Sigma^0_1 in the
arithmetical hierarchy In mathematical logic, the arithmetical hierarchy, arithmetic hierarchy or Kleene–Mostowski hierarchy (after mathematicians Stephen Cole Kleene and Andrzej Mostowski) classifies certain sets based on the complexity of formulas that define th ...
, the same as the standard halting problem. The variants are thus undecidable, and the standard halting problem reduces to each variant and vice-versa. However, some variants have a higher degree of unsolvability and cannot be reduced to the standard halting problem. The next two examples are common.


Halting on all inputs

The ''universal halting problem'', also known (in
recursion theory Computability theory, also known as recursion theory, is a branch of mathematical logic, computer science, and the theory of computation that originated in the 1930s with the study of computable functions and Turing degrees. The field has sinc ...
) as ''totality'', is the problem of determining whether a given computer program will halt ''for every input'' (the name ''totality'' comes from the equivalent question of whether the computed function is total). This problem is not only undecidable, as the halting problem is, but highly undecidable. In terms of the
arithmetical hierarchy In mathematical logic, the arithmetical hierarchy, arithmetic hierarchy or Kleene–Mostowski hierarchy (after mathematicians Stephen Cole Kleene and Andrzej Mostowski) classifies certain sets based on the complexity of formulas that define th ...
, it is \Pi^0_2-complete. This means, in particular, that it cannot be decided even with an oracle for the halting problem.


Recognizing partial solutions

There are many programs that, for some inputs, return a correct answer to the halting problem, while for other inputs they do not return an answer at all. However the problem "given program ''p'', is it a partial halting solver" (in the sense described) is at least as hard as the halting problem. To see this, assume that there is an algorithm PHSR ("partial halting solver recognizer") to do that. Then it can be used to solve the halting problem, as follows: To test whether input program ''x'' halts on ''y'', construct a program ''p'' that on input (''x'',''y'') reports ''true'' and diverges on all other inputs. Then test ''p'' with PHSR. The above argument is a reduction of the halting problem to PHS recognition, and in the same manner, harder problems such as ''halting on all inputs'' can also be reduced, implying that PHS recognition is not only undecidable, but higher in the
arithmetical hierarchy In mathematical logic, the arithmetical hierarchy, arithmetic hierarchy or Kleene–Mostowski hierarchy (after mathematicians Stephen Cole Kleene and Andrzej Mostowski) classifies certain sets based on the complexity of formulas that define th ...
, specifically \Pi^0_2-complete.


Lossy computation

A ''lossy Turing machine'' is a Turing machine in which part of the tape may non-deterministically disappear. The halting problem is decidable for a lossy Turing machine but non- primitive recursive.


Oracle machines

A machine with an oracle for the halting problem can determine whether particular Turing machines will halt on particular inputs, but they cannot determine, in general, whether machines equivalent to themselves will halt.


See also

* Busy beaver * Gödel's incompleteness theorem * Brouwer–Hilbert controversy *
Kolmogorov complexity In algorithmic information theory (a subfield of computer science and mathematics), the Kolmogorov complexity of an object, such as a piece of text, is the length of a shortest computer program (in a predetermined programming language) that produ ...
*
P versus NP problem The P versus NP problem is a major unsolved problem in theoretical computer science. In informal terms, it asks whether every problem whose solution can be quickly verified can also be quickly solved. The informal term ''quickly'', used above ...
* Termination analysis *
Worst-case execution time The worst-case execution time (WCET) of a computational task is the maximum length of time the task could take to execute on a specific hardware platform. What it is used for Worst case execution time is typically used in reliable real-time sys ...


Notes


References

* * * . Turing's paper is #3 in this volume. Papers include those by Godel, Church, Rosser, Kleene, and Post. * . * . Chapter XIII ("Computable Functions") includes a discussion of the unsolvability of the halting problem for Turing machines. In a departure from Turing's terminology of circle-free nonhalting machines, Kleene refers instead to machines that "stop", i.e. halt. * . See chapter 8, Section 8.2 "Unsolvability of the Halting Problem." * * . First published in 1970, a fascinating history of German mathematics and physics from 1880s through 1930s. Hundreds of names familiar to mathematicians, physicists and engineers appear in its pages. Perhaps marred by no overt references and few footnotes: Reid states her sources were numerous interviews with those who personally knew Hilbert, and Hilbert's letters and papers. * * , This is the epochal paper where Turing defines
Turing machine A Turing machine is a mathematical model of computation describing an abstract machine that manipulates symbols on a strip of tape according to a table of rules. Despite the model's simplicity, it is capable of implementing any computer algori ...
s, formulates the halting problem, and shows that it (as well as the
Entscheidungsproblem In mathematics and computer science, the ' (, ) is a challenge posed by David Hilbert and Wilhelm Ackermann in 1928. The problem asks for an algorithm that considers, as input, a statement and answers "Yes" or "No" according to whether the state ...
) is unsolvable. * . Cf. Chapter 2, "Algorithms and Turing Machines". An over-complicated presentation (see Davis's paper for a better model), but a thorough presentation of Turing machines and the halting problem, and Church's Lambda Calculus. * . See Chapter 7 "Turing Machines." A book centered around the machine-interpretation of "languages", NP-Completeness, etc. * . Cf. Chapter "The Spirit of Truth" for a history leading to, and a discussion of, his proof. * *


Further reading

* c2:HaltingProblem * Alfred North Whitehead and
Bertrand Russell Bertrand Arthur William Russell, 3rd Earl Russell, (18 May 1872 – 2 February 1970) was a British mathematician, philosopher, logician, and public intellectual. He had a considerable influence on mathematics, logic, set theory, linguistics, ...
, ''Principia Mathematica'' to *56, Cambridge at the University Press, 1962. Re: the problem of paradoxes, the authors discuss the problem of a set not be an object in any of its "determining functions", in particular "Introduction, Chap. 1 p. 24 "...difficulties which arise in formal logic", and Chap. 2.I. "The Vicious-Circle Principle" p. 37ff, and Chap. 2.VIII. "The Contradictions" p. 60ff. * Martin Davis, "What is a computation", in ''Mathematics Today'', Lynn Arthur Steen, Vintage Books (Random House), 1980. A wonderful little paper, perhaps the best ever written about Turing Machines for the non-specialist. Davis reduces the Turing Machine to a far-simpler model based on Post's model of a computation. Discusses Chaitin proof. Includes little biographies of
Emil Post Emil Leon Post (; February 11, 1897 – April 21, 1954) was an American mathematician and logician. He is best known for his work in the field that eventually became known as computability theory. Life Post was born in Augustów, Suwałki Gove ...
,
Julia Robinson Julia Hall Bowman Robinson (December 8, 1919July 30, 1985) was an American mathematician noted for her contributions to the fields of computability theory and computational complexity theory—most notably in decision problems. Her work on Hilber ...
. *
Edward Beltrami Edward is an English given name. It is derived from the Anglo-Saxon name ''Ēadweard'', composed of the elements '' ēad'' "wealth, fortune; prosperous" and '' weard'' "guardian, protector”. History The name Edward was very popular in Anglo-Sax ...
, ''What is Random? Chance and order in mathematics and life'', Copernicus: Springer-Verlag, New York, 1999. Nice, gentle read for the mathematically inclined non-specialist, puts tougher stuff at the end. Has a Turing-machine model in it. Discusses the Chaitin contributions. *
Ernest Nagel Ernest Nagel (November 16, 1901 – September 20, 1985) was an American philosopher of science. Suppes, Patrick (1999)Biographical memoir of Ernest Nagel In '' American National Biograph''y (Vol. 16, pp. 216-218). New York: Oxford University Pr ...
and James R. Newman, ''Godel’s Proof'', New York University Press, 1958. Wonderful writing about a very difficult subject. For the mathematically inclined non-specialist. Discusses
Gentzen Gerhard Karl Erich Gentzen (24 November 1909 – 4 August 1945) was a German mathematician and logician. He made major contributions to the foundations of mathematics, proof theory, especially on natural deduction and sequent calculus. He died o ...
's proof on pages 96–97 and footnotes. Appendices discuss the
Peano Axioms In mathematical logic, the Peano axioms, also known as the Dedekind–Peano axioms or the Peano postulates, are axioms for the natural numbers presented by the 19th century Italian mathematician Giuseppe Peano. These axioms have been used nearly ...
briefly, gently introduce readers to formal logic. * . Chapter 3 Section 1 contains a quality description of the halting problem, a proof by contradiction, and a helpful graphic representation of the Halting Problem. * Taylor Booth, ''Sequential Machines and Automata Theory'', Wiley, New York, 1967. Cf. Chapter 9, Turing Machines. Difficult book, meant for electrical engineers and technical specialists. Discusses recursion, partial-recursion with reference to Turing Machines, halting problem. Has a
Turing Machine A Turing machine is a mathematical model of computation describing an abstract machine that manipulates symbols on a strip of tape according to a table of rules. Despite the model's simplicity, it is capable of implementing any computer algori ...
model in it. References at end of Chapter 9 catch most of the older books (i.e. 1952 until 1967 including authors Martin Davis, F. C. Hennie, H. Hermes, S. C. Kleene, M. Minsky, T. Rado) and various technical papers. See note under Busy-Beaver Programs. * Busy Beaver Programs are described in Scientific American, August 1984, also March 1985 p. 23. A reference in Booth attributes them to Rado, T.(1962), On non-computable functions, Bell Systems Tech. J. 41. Booth also defines Rado's Busy Beaver Problem in problems 3, 4, 5, 6 of Chapter 9, p. 396. * David Bolter, ''Turing’s Man: Western Culture in the Computer Age'', The University of North Carolina Press, Chapel Hill, 1984. For the general reader. May be dated. Has yet another (very simple) Turing Machine model in it. * Sven Köhler, Christian Schindelhauer, Martin Ziegler, ''On approximating real-world halting problems'', pp.454-466 (2005) Springer Lecture Notes in Computer Science volume 3623: Undecidability of the Halting Problem means that not all instances can be answered correctly; but maybe "some", "many" or "most" can? On the one hand the constant answer "yes" will be correct infinitely often, and wrong also infinitely often. To make the question reasonable, consider the
density Density (volumetric mass density or specific mass) is the substance's mass per unit of volume. The symbol most often used for density is ''ρ'' (the lower case Greek letter rho), although the Latin letter ''D'' can also be used. Mathematical ...
of the instances that can be solved. This turns out to depend significantly on the Programming System under consideration.
Logical Limitations to Machine Ethics, with Consequences to Lethal Autonomous Weapons
- paper discussed in
Does the Halting Problem Mean No Moral Robots?


External links



- a poetic proof of undecidability of the halting problem
animated movie
- an animation explaining the proof of the undecidability of the halting problem
A 2-Minute Proof of the 2nd-Most Important Theorem of the 2nd Millennium
- a proof in only 13 lines {{Authority control Theory of computation Computability theory Mathematical problems Undecidable problems 1936 introductions