The halting problem is undecidable #
Every word w describes a machine, Turing.MultiTapeTM.Universal.decodeDesc w, and the encoded
description eDesc (desc eS eBit tm) of a machine tm with a binary alphabet and finitely many
states describes tm itself. The halting problem asks, of a pair of words (w, x), whether the
machine described by w halts on x, read as symbols under the coding
Turing.MultiTapeTM.Universal.eBit (Turing.MultiTapeTM.haltingProblem); the acceptance problem
asks whether it halts with output [true] (Turing.MultiTapeTM.acceptanceProblem). Their
self-application forms ask the same of a word run on itself
(Turing.MultiTapeTM.selfHaltingProblem, Turing.MultiTapeTM.selfAcceptanceProblem). None of the
four is decidable Turing Sipser, Theorems 4.11 and 5.1.
All four results come from one diagonal argument, that of the time hierarchy theorem
(Cslib.Complexity.not_forall_halted_diagonal, in
Complexity.Computability.Complexity.Classes.Hierarchy) without the clock. A machine run on its own
description can make its behavior depend on any computable verdict about that description
(Turing.MultiTapeTM.exists_self_desc): Turing.MultiTapeTM.partialize turns a total machine
computing the verdict, followed by a choice of a partial result for each verdict, into a machine
that diverges or halts with the chosen output. So no computable verdict is true on the
descriptions of all machines behaving in one way on their own descriptions and false on those of
all machines behaving in another way (Turing.MultiTapeTM.not_separates_self_desc): some machine
behaves, on its own description, in the way its verdict excludes. Halting separates divergence
from halting with output [], and acceptance separates halting with output [false] from halting
with output [true], so neither is decidable even on descriptions of machines
(Turing.MultiTapeTM.halting_problem, Turing.MultiTapeTM.acceptance_problem and their
self-application forms). The undecidability of the four sets of words follows
(Turing.MultiTapeTM.not_isDecidable_of_separates_self_desc), the encoded-pair forms through the
mapping reduction w ↦ (w, w).
Turing.MultiTapeTM.not_isDecidable_of_separates_self_desc is Rice's theorem for the behavior of
machines on their own descriptions. The classical theorem Rice, about the behavior on
all inputs, is Turing.MultiTapeTM.rice in
Complexity.Computability.Machines.Turing.MultiTape.Halting.Rice; it needs in addition an s-m-n
theorem for descriptions (Turing.MultiTapeTM.Universal.hardwire).
Mathlib proves corresponding theorems for its own model of computation, partial recursive codes.
ComputablePred.halting_problem fixes the input: for each n, no computable predicate decides
whether the code c halts on n. Its native counterpart, for each input of bits, is
Turing.MultiTapeTM.not_isDecidable_halts, a corollary of Rice's theorem in
Complexity.Computability.Machines.Turing.MultiTape.Halting.Rice; the halting problem here,
Turing.MultiTapeTM.haltingProblem, takes the input as part of the instance instead.
ComputablePred.rice and ComputablePred.rice₂ are Rice's theorem for codes. Transferring these
results would need simulations in both directions between codes and the machines of this library,
which are not developed here, so the native results are proved directly, on the universal
simulation of Christian Reitwiessner (Turing.MultiTapeTM.Universal.simulate_desc) and the decoder
of descriptions (Turing.MultiTapeTM.Universal.decodeDesc_eDesc).
Main definitions #
Turing.MultiTapeTM.haltingProblem,Turing.MultiTapeTM.selfHaltingProblem: halting.Turing.MultiTapeTM.acceptanceProblem,Turing.MultiTapeTM.selfAcceptanceProblem: acceptance.
Main results #
Turing.MultiTapeTM.IsComputable.exists_partialize: computable partial results are the behaviors of machines.Turing.MultiTapeTM.exists_self_desc,Turing.MultiTapeTM.not_separates_self_desc: self-reference by self-application, and the diagonal argument.Turing.MultiTapeTM.halting_problem,Turing.MultiTapeTM.halting_problem_self: no computable function decides halting on descriptions of machines.Turing.MultiTapeTM.acceptance_problem,Turing.MultiTapeTM.acceptance_problem_self: no computable function decides acceptance on descriptions of machines.Turing.MultiTapeTM.not_isDecidable_haltingProblem,Turing.MultiTapeTM.not_isDecidable_selfHaltingProblem,Turing.MultiTapeTM.not_isDecidable_acceptanceProblem,Turing.MultiTapeTM.not_isDecidable_selfAcceptanceProblem: the four problems are undecidable.Turing.MultiTapeTM.not_isDecidable_of_separates_self_desc: Rice's theorem for the behavior of machines on their own descriptions.
References #
Machines from computable partial results #
Computable partial results are the behaviors of machines: if f is computable with
results encoded by encPartial, some machine with a binary alphabet and finitely many states
halts on encIn a with output o exactly when f a = some o, and diverges when f a = none.
The diagonal argument #
Self-reference by self-application. For every computable verdict f on words and every
choice r of a partial result for each verdict, some machine with a binary alphabet and finitely
many states, run on its own description w, has the partial result r (f w): it halts with
output o exactly when r (f w) = some o, and diverges when r (f w) = none.
The diagonal argument. No computable verdict on words is false on the description of
every machine whose behavior on its own description is r₀ and true on the description of
every machine whose behavior on its own description is r₁: some machine behaves on its own
description as r₀ when the verdict is true, and as r₁ when it is false. A behavior is a
partial result: none for divergence, some o for halting with output o.
Halting and acceptance on descriptions of machines #
The halting problem, in self-application form. No computable function decides, on the description of every machine with a binary alphabet and finitely many states, whether the machine halts on its own description.
The halting problem. No computable function decides, on the description of every machine with a binary alphabet and finitely many states and every input, whether the machine halts on the input.
The acceptance problem, in self-application form. No computable function decides, on the
description of every machine with a binary alphabet and finitely many states, whether the machine
halts with output [true] on its own description.
The acceptance problem. No computable function decides, on the description of every
machine with a binary alphabet and finitely many states and every input, whether the machine halts
with output [true] on the input.
The halting and acceptance problems on words #
The words w such that the machine described by w halts on w.
Instances For
The words w such that the machine described by w halts on w with output [true].
Instances For
On the description of a machine, the halting problem asks whether the machine halts.
On the description of a machine, the self-application form of the halting problem asks whether the machine halts on its own description.
On the description of a machine, the acceptance problem asks whether the machine halts with
output [true].
On the description of a machine, the self-application form of the acceptance problem asks
whether the machine halts with output [true] on its own description.
Rice's theorem for the behavior on self-descriptions. A set of words containing the
description of every machine whose behavior on its own description is r₁, and the description of
no machine whose behavior on its own description is r₀, is undecidable.
The halting problem is undecidable, in self-application form.
Running a word on itself is a mapping reduction of the self-application form of halting to halting.
The halting problem is undecidable.
The acceptance problem is undecidable, in self-application form.
Running a word on itself is a mapping reduction of the self-application form of acceptance to acceptance.
The acceptance problem is undecidable.