Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Halting.Rice

Rice's theorem #

Every nontrivial property of the behavior of machines is undecidable on their descriptions (Turing.MultiTapeTM.rice) Rice Sipser, Problem 5.28. The behavior of the machine described by a word w (Turing.MultiTapeTM.behavior) relates each input of bits on which it halts to the output it halts with; a property of behaviors is nontrivial when the machine described by some word has it and the machine described by another does not. Equivalently, a set of words that depends only on the behavior of the machines they describe, and is neither empty nor everything, is undecidable (Turing.MultiTapeTM.not_isDecidable_of_behavior).

The proof goes through the two-way case of Kleene's recursion theorem (Turing.MultiTapeTM.exists_behavior_eq) Sipser, Theorem 6.3: for every computable verdict f on words and descriptions d false and d true, some word e describes a machine behaving as d (f e). The full theorem allows any computable transformation of descriptions in place of the choice between d false and d true; the choice is all that Rice's theorem needs. Applied to a decider of the property, with d true outside the property and d false inside it, it gives a word describing a machine inside the property exactly when it is outside. For each input of bits x, halting on x is such a property (Turing.MultiTapeTM.not_isDecidable_halts), the native form of Mathlib's ComputablePred.halting_problem.

The recursion theorem is Kleene's construction, from two constructions on descriptions. The s-m-n theorem builds an input prefix into a description (Turing.MultiTapeTM.Universal.hardwire), in polynomial time. Dispatching (Turing.MultiTapeTM.Universal.dispatch) runs a machine computing a total function, keeping its output on a work tape, and then runs d b on that output without its first bit b (Turing.MultiTapeTM.Universal.Desc.computes_dispatch). Let t describe the machine that reads a word y before its input x and dispatches on f (s y) :: x, where s y describes the machine described by y with y built in. Then e = s t describes a machine that runs the machine described by t on y = t and x, so behaves as d (f (s t)). No universal machine is needed: d false and d true are fixed, and their transitions are part of the description of the dispatching machine, reading their input from the work tape as in Turing.MultiTapeTM.Universal.Redirect.redirect. The dispatch program and its clean-machine run proof are confined to Internal.RiceDispatch; ordinary imports of this facade expose the computability and Rice statements without that machine-level premise.

Main definitions #

Main results #

References #

The recursion theorem and Rice's theorem #

The behavior, on inputs of bits, of the machine described by the word w: the relation between the inputs on which it halts and the outputs it halts with.

Building the description of a word into itself, as an input prefix, is computable in polynomial time.

Kleene's recursion theorem, in its two-way case. For every computable verdict f on words and descriptions d false, d true, some word e describes a machine behaving on inputs of bits as d (f e) does: a machine can make its whole behavior depend on a computable verdict about its own description. The full recursion theorem allows any computable transformation of descriptions in place of the choice between d false and d true. The proof is Kleene's construction: a machine reads a word y before its input, computes the verdict on the description of the machine described by y with y built in, and dispatches on it; e is that description for y the description of the machine itself.

theorem Turing.MultiTapeTM.rice {C : Set (List Bool → List ℕ → Prop)} {w₀ w₁ : List Bool} (h₀ : behavior w₀ ∉ C) (h₁ : behavior w₁ ∈ C) :

Rice's theorem. Every nontrivial property of the behavior of machines is undecidable on their descriptions: if C contains the behavior of the machine described by some word and not that of the machine described by another, then the set of words describing machines whose behavior is in C is undecidable Rice Sipser, Problem 5.28.

theorem Turing.MultiTapeTM.not_isDecidable_of_behavior {P : Set (List Bool)} (hP : ∀ (w w' : List Bool), behavior w = behavior w' → w ∈ P → w' ∈ P) {w₀ w₁ : List Bool} (h₀ : w₀ ∉ P) (h₁ : w₁ ∈ P) :

Rice's theorem, for sets of words. A set of words that holds of a word or not according to the behavior of the machine it describes, and is neither empty nor everything, is undecidable. This is the counterpart of Mathlib's ComputablePred.rice₂ for partial recursive codes.

Halting on a fixed input #

Halting on a fixed input is undecidable: for every input of bits x, no computable function decides, of a word, whether the machine it describes halts on x. This is the native counterpart of Mathlib's ComputablePred.halting_problem, a corollary of Rice's theorem.