Turing machines

Undecidability

Reading preferences

Optional display controls need JavaScript. All reading content and navigation work without it.

Source file content/turing-machines/undecidability/undecidability.tex

Source file content/turing-machines/undecidability/introduction.tex

Introduction

It might seem obvious that not every function, even every arithmetical function, can be computable. There are just too many, whose behavior is too complicated. Functions defined from the decay of radioactive particles, for instance, or other chaotic or random behavior. Suppose we start counting 1-second intervals from a given time, and define the function f(n)f(n)source as the number of particles in the universe that decay in the nnsource-th 1-second interval after that initial moment. This seems like a candidate for a function we cannot ever hope to compute.

But it is one thing to not be able to imagine how one would compute such functions, and quite another to actually prove that they are uncomputable. In fact, even functions that seem hopelessly complicated may, in an abstract sense, be computable. For instance, suppose the universe is finite in time---some day, in the very distant future the universe will contract into a single point, as some cosmological theories predict. Then there is only a finite (but incredibly large) number of seconds from that initial moment for which f(n)f(n)source is defined. And any function which is defined for only finitely many inputs is computable: we could list the outputs in one big table, or code it in one very big Turing machine state transition diagram.

We are often interested in special cases of functions whose values give the answers to yes/no questions. For instance, the question “is nnsource a prime number?” is associated with the function

isprime(n)={1if n is prime0otherwise.\fn{isprime}(n) = \begin{cases} 1 & \text{if $n$ is prime}\\ 0 & \text{otherwise.} \end{cases}source

We say that a yes/no question can be effectively decided, if the associated 1/01/0source-valued function is effectively computable.

To prove mathematically that there are functions which cannot be effectively computed, or problems that cannot effectively decided, it is essential to fix a specific model of computation, and show that there are functions it cannot compute or problems it cannot decide. We can show, for instance, that not every function can be computed by Turing machines, and not every problem can be decided by Turing machines. We can then appeal to the Church--Turing thesis to conclude that not only are Turing machines not powerful enough to compute every function, but no effective procedure can.

The key to proving such negative results is the fact that we can assign numbers to Turing machines themselves. The easiest way to do this is to enumerate them, perhaps by fixing a specific way to write down Turing machines and their programs, and then listing them in a systematic fashion. Once we see that this can be done, then the existence of Turing-uncomputable functions follows by simple cardinality considerations: the set of functions from \Natsource to \Natsource (in fact, even just from \Natsource to {0,1}\{0, 1\}source) are non-enumerable, but since we can enumerate all the Turing machines, the set of Turing-computable functions is only denumerable.

We can also define specific functions and problems which we can prove to be uncomputable and undecidable, respectively. One such problem is the so-called Halting Problem. Turing machines can be finitely described by listing their instructions. Such a description of a Turing machine, i.e., a Turing machine program, can of course be used as input to another Turing machine. So we can consider Turing machines that decide questions about other Turing machines. One particularly interesting question is this: “Does the given Turing machine eventually halt when started on input nnsource?” It would be nice if there were a Turing machine that could decide this question: think of it as a quality-control Turing machine which ensures that Turing machines don't get caught in infinite loops and such. The interesting fact, which Turing proved, is that there cannot be such a Turing machine. There cannot be a single Turing machine which, when started on input consisting of a description of a Turing machine MMsource and some number nnsource, will always halt with either output 11source or 00source according to whether MMsource machine would have halted when started on input nnsource or not.

Once we have examples of specific undecidable problems we can use them to show that other problems are undecidable, too. For instance, one celebrated undecidable problem is the question, “Is the first-order formula A!Asource valid?”. There is no Turing machine which, given as input a first-order formula A!Asource, is guaranteed to halt with output 11source or 00source according to whether A!Asource is valid or not. Historically, the question of finding a procedure to effectively solve this problem was called simply “the” decision problem; and so we say that the decision problem is unsolvable. Turing and Church proved this result independently at around the same time, so it is also called the Church--Turing Theorem.

Source file content/turing-machines/undecidability/enumerating-tms.tex

Enumerating Turing Machines

Explain

We can show that the set of all Turing machines is enumerable. This follows from the fact that each Turing machine can be finitely described. The set of states and the tape vocabulary are finite sets. The transition function is a partial function from Q×ΣQ \times \Sigmasource to Q×Σ×{L,R,N}Q \times \Sigma \times \{\TMleft, \TMright, \TMstay\}source, and so likewise can be specified by listing its values for the finitely many argument pairs for which it is defined.

This is true as far as it goes, but there is a subtle difference. The definition of Turing machines made no restriction on what elements the set of states and tape alphabet can have. So, e.g., for every real number, there technically is a Turing machine that uses that number as a state. However, the behavior of the Turing machine is independent of which objects serve as states and vocabulary. Consider the two Turing machines in link to figure Variants of the Even machine.

Undecidability figure

Figure containing two behaviorally equivalent Even-machine diagrams with renamed states and tape symbols.

Source transcription

Turing machine state diagram

First Even-machine variant, using states q zero and q one with stroke and blank tape symbols. State diagram. Purpose: Shows the Even-machine transition pattern before renaming, with initial state q zero and state q one. Initial state: state q sub zero. States: state q sub zero, state q sub one. Transition one: from state q sub zero, when reading stroke symbol, write stroke symbol, move right, and enter state q sub one. Transition two: from state q sub one, when reading blank symbol, write blank symbol, move right, and enter state q sub one. Transition three: from state q sub one, when reading stroke symbol, write stroke symbol, move right, and enter state q sub zero. Every displayed state has at least one outgoing transition

Source transcription

[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm, semithick] tikzstyleevery state=[fill=none,draw=black,text=black]

node[initial,state] (A) q0q_0source; node[state] (B) [right of=A] q1q_1source;

path (A) edge [bend left] node TMtransTMstrokeTMstrokeTMright (B) (B) edge [loop above] node TMtransTMblankTMblankTMright (B) edge [bend left] node TMtransTMstrokeTMstrokeTMright (A);

\\

Turing machine state diagram

Second Even-machine variant, using states s and h and capital A in place of the stroke symbol. State diagram. Purpose: Shows the same transition pattern after renaming the states and stroke symbol. Initial state: state s. States: state s, state h. Transition one: from state s, when reading capital A symbol, write capital A symbol, move right, and enter state h. Transition two: from state h, when reading blank symbol, write blank symbol, move right, and enter state h. Transition three: from state h, when reading capital A symbol, write capital A symbol, move right, and enter state s. Every displayed state has at least one outgoing transition

Source transcription

[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm, semithick] tikzstyleevery state=[fill=none,draw=black,text=black]

node[initial,state] (A) sssource; node[state] (B) [right of=A] hhsource;

path (A) edge [bend left] node TMtransAATMright (B) (B) edge [loop above] node TMtransTMblankTMblankTMright (B) edge [bend left] node TMtransAATMright (A);

captionVariants of the Even machine

These two diagrams correspond to two machines, MMsource with the tape alphabet Σ={,0,1}\Sigma = \{\TMendtape,\TMblank,\TMstroke\}source and set of states {q0,q1}\{q_0,q_1\}source, and MM'source with alphabet Σ={,0,A}\Sigma' = \{\TMendtape,\TMblank,A\}source and states {s,h}\{s,h\}source. But their instructions are otherwise the same: MMsource will halt on a sequence of nnsource 1\TMstrokesource's iff nnsource is even, and MM'source will halt on a sequence of nnsource AAsource's iff nnsource is even. All we've done is rename 1\TMstrokesource to AAsource, q0q_0source to sssource, and q1q_1source to hhsource. This example generalizes: we can think of Turing machines as the same as long as one results from the other by such a renaming of symbols and states. In fact, we can simply think of the symbols and states of a Turing machine as positive integers: instead of σ0\sigma_0source think 11source, instead of σ1\sigma_1source think 22source, etc.; \TMendtapesource is 11source, 0\TMblanksource is 22source, etc. In this way, the Even machine becomes the machine depicted in link to figure A standard Even machine.

Undecidability figure

Figure containing the standardized positive-integer encoding of the Even machine.

Source transcription

Turing machine state diagram

Standard Even-machine diagram with states one and two and encoded tape symbols two and three. State diagram. Purpose: Shows the same Even-machine behavior after replacing every state and symbol by a positive-integer code. Initial state: state one. States: state one, state two. Transition one: from state one, when reading three, write three, move right, and enter state two. Transition two: from state two, when reading two, write two, move right, and enter state two. Transition three: from state two, when reading three, write three, move right, and enter state one. Every displayed state has at least one outgoing transition

state diagram transition tablefrom statereadwritemovenext statestate onethreethreemove rightstate twostate twotwotwomove rightstate twostate twothreethreemove rightstate one\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm, semithick] \tikzstyle{every state}=[fill=none,draw=black,text=black] \node[initial,state] (A) {$1$}; \node[state] (B) [right of=A] {$2$}; \path (A) edge [bend left] node {\TMtrans{3}{3}{\TMright}} (B) (B) edge [loop above] node {\TMtrans{2}{2}{\TMright}} (B) edge [bend left] node {\TMtrans{3}{3}{\TMright}} (A); \end{tikzpicture}source

captionA standard Even machine

We might call a Turing machine with states and symbols that are positive integers a standard machine, and only consider standard machines from now on.Footnote: The terminology “standard machine” is not standard.

We wanted to show that the set of Turing machines is enumerable, and with the above considerations in mind, it is enough to show that the set of standard Turing machines is enumerable. Suppose we are given a standard Turing machine M=Q,Σ,q0,δM = \tuple{Q, \Sigma, q_0, \delta}source. How could we describe it using a finite string of positive integers? We'll first list the number of states, the states themselves, the number of symbols, the symbols themselves, and the starting state. (Remember, all of these are positive integers, since MMsource is a standard machine.) What about δ\deltasource? The set of possible arguments, i.e., pairs q,σ\tuple{q,\sigma}source, is finite, since QQsource and Σ\Sigmasource are finite. So the information in δ\deltasource is simply the finite list of all 55source-tuples q,σ,q,σ,d\tuple{q, \sigma, q', \sigma', d}source where δ(q,σ)=q,σ,D\delta(q,\sigma) = \tuple{q', \sigma', D}source, and ddsource is a number that codes the direction DDsource (say, 11source for L\TMleftsource, 22source for R\TMrightsource, and 33source for N\TMstaysource).

In this way, every standard Turing machine can be described by a finite list of positive integers, i.e., as a sequence sM(Z+)*s_M \in (\PosInt)^*source. For instance, the standard Even machine is coded by the sequence

2,1,2Q,3,1,2,3Σ,1,1,3,2,3,2δ(1,3)=2,3,R,2,2,2,2,2δ(2,2)=2,2,R,2,3,1,3,2δ(2,3)=1,3,R.2, \underbrace{1, 2}_Q, 3, \overbrace{1, 2, 3}^\Sigma, 1, \underbrace{1, 3, 2, 3, 2}_{\delta(1,3) = \tuple{2,3,R}}, \overbrace{2, 2, 2, 2, 2}^{\delta(2,2) = \tuple{2,2,R}}, \underbrace{2, 3, 1, 3, 2}_{\delta(2,3) = \tuple{1,3,R}}.source

Undecidability theorem

There are functions from \Natsource to \Natsource which are not Turing computable.

Proof

We know that the set of finite sequences of positive integers (Z+)*(\PosInt)^*source is enumerable (link to exercise on enumerating finite sequences of positive integers). This gives us that the set of descriptions of standard Turing machines, as a subset of (Z+)*(\PosInt)^*source, is itself enumerable. Every Turing computable function \Natsource to \Natsource is computed by some (in fact, many) Turing machines. By renaming its states and symbols to positive integers (in particular, \TMendtapesource as 11source, 0\TMblanksource as 22source, and 1\TMstrokesource as 33source) we can see that every Turing computable function is computed by a standard Turing machine. This means that the set of all Turing computable functions from \Natsource to \Natsource is also enumerable.

On the other hand, the set of all functions from \Natsource to \Natsource is not enumerable (link to exercise showing functions from natural numbers to natural numbers are nonenumerable). If all functions were computable by some Turing machine, we could enumerate the set of all functions by listing all the descriptions of Turing machines that compute them. So there are some functions that are not Turing computable.

Unsolved undecidability exercise

Can you think of a way to describe Turing machines that does not require that the states and alphabet symbols are explicitly listed? You may define your own notion of “standard” machine, but say something about why every Turing machine can be computed by a “standard” machine in your new sense.

Source file content/turing-machines/undecidability/universal-tm.tex

Universal Turing Machines

In link to section Enumerating Turing Machines we discussed how every Turing machine can be described by a finite sequence of integers. This sequence encodes the states, alphabet, start state, and instructions of the Turing machine. We also pointed out that the set of all of these descriptions is enumerable. Since the set of such descriptions is denumerable, this means that there is a surjective function from \Natsource to these descriptions. Such a surjective function can be obtained, for instance, using Cantor's zig-zag method. It gives us a way of enumerating all (descriptions) of Turing machines. If we fix one such enumeration, it now makes sense to talk of the 11sourcest, 22sourcend, dots, eesourceth Turing machine. These numbers are called indices.

Undecidability definition

If MMsource is the eesourceth Turing machine (in our fixed enumeration), we say that eesource is an index of MMsource. We write MeM_esource for the eesourceth Turing machine.

A machine may have more than one index, e.g., two descriptions of MMsource may differ in the order in which we list its instructions, and these different descriptions will have different indices.

Importantly, it is possible to give the enumeration of Turing machine descriptions in such a way that we can effectively compute the description of MMsource from its index, and to effectively compute an index of a machine MMsource from its description. By the Church--Turing thesis, it is then possible to find a Turing machine which recovers the description of the Turing machine with index eesource and writes the corresponding description on its tape as output. The description would be a sequence of blocks of 1\TMstrokesource's (representing the positive integers in the sequence describing MeM_esource).

Given this, it now becomes natural to ask: what functions of Turing machine indices are themselves computable by Turing machines? What properties of Turing machine indices can be decided by Turing machines? An example: the function that maps an index eesource to the number of states the Turing machine with index eesource has, is computable by a Turing machine. Here's what such a Turing machine would do: started on a tape containing a single block of eesource 1\TMstrokesource's, it would first decode eesource into its description. The description is now represented by a sequence of blocks of 1\TMstrokesource's on the tape. Since the first element in this sequence is the number of states. So all that has to be done now is to erase everything but the first block of 1\TMstrokesource's and then halt.

A remarkable result is the following:

Undecidability theorem

There is a universal Turing machine UUsource which, when started on input e,n\tuple{e,n}source

  1. halts iff MeM_esource halts on input nnsource, and

  2. if MeM_esource halts with output mmsource, so does UUsource.

UUsource thus computes the function f:×f\colon \Nat \times \Nat \pto \Natsource given by f(e,n)=mf(e,n) = msource if MeM_esource started on input nnsource halts with output mmsource, and undefined otherwise.

Proof

To actually produce UUsource is basically impossible, since it is an extremely complicated machine. But we can describe in outline how it works, and then invoke the Church--Turing thesis. When it starts, UUsource's tape contains a block of eesource 1\TMstrokesource's followed by a block of nnsource 1\TMstrokesource's. It first “decodes” the index eesource to the right of the input nnsource. This produces a list of numbers (i.e., blocks of 1\TMstrokesource's separated by 0\TMblanksource's) that describes the instructions of machine MeM_esource. UUsource then writes the number of the start state of MeM_esource and the number 11source on the tape to the right of the description of MeM_esource. (Again, these are represented in unary, as blocks of 1\TMstrokesource's.) Next, it copies the input (block of nnsource 1\TMstrokesource's) to the right---but it replaces each 1\TMstrokesource by a block of three 1\TMstrokesource's (remember, the number of the 1\TMstrokesource symbol is 33source, 11source being the number of \TMendtapesource and 22source being the number of 0\TMblanksource). At the left end of this sequence of blocks (separated by 0\TMblanksource symbols on the tape of UUsource), it writes a single 1\TMstrokesource, the code for \TMendtapesource.

UUsource now has on its tape: the index eesource, the number nnsource, the code number of the start state (the “current state”), the number of the initial head position 11source (the “current head position”), and the initial contents of the “tape” (a sequence of blocks of 1\TMstrokesource's representing the code numbers of the symbols of MeM_esource---the “symbols”---separated by 0\TMblanksource's).

It now simulates what MeM_esource would do if started on input nnsource, by doing the following:

  1. Find the number kksource of the “current head position” (at the beginning, that's 11source),

  2. Move to the kksourceth block in the “tape” to see what the “symbol” there is,

  3. Find the instruction matching the current “state” and “symbol,”

  4. Move back to the kksourceth block on the “tape” and replace the “symbol” there with the code number of the symbol MeM_esource would write,

  5. Move the head to where it records the current “state” and replace the number there with the number of the new state,

  6. Move to the place where it records the “tape position” and erase a 1\TMstrokesource or add a 1\TMstrokesource (if the instruction says to move left or right, respectively).

  7. Repeat.Footnote: We're glossing over some subtle difficulties here. E.g., UUsource may need some extra space when it increases the counter where it keeps track of the “current head position”---in that case it will have to move the entire “tape” to the right.

If MeM_esource started on input nnsource never halts, then UUsource also never halts, so its output is undefined.

If in step link to the universal-machine simulation step that finds a matching instruction it turns out that the description of MeM_esource contains no instruction for the current “state”/“symbol” pair, then MeM_esource would halt. If this happens, UUsource erases the part of its tape to the left of the “tape.” For each block of three 1\TMstrokesource's (representing a 1\TMstrokesource on MeM_esource's tape), it writes a 1\TMstrokesource on the left end of its own tape, and successively erases the “tape.” When this is done, UUsource's tape contains a single block of 1\TMstrokesource's of length mmsource.

If UUsource encounters something other than a block of three 1\TMstrokesource's on the “tape,” it immediately halts. Since UUsource's tape in this case does not contain a single block of 1\TMstrokesource's, its output is not a natural number, i.e., f(e,n)f(e,n)source is undefined in this case.

Source file content/turing-machines/undecidability/halting-problem.tex

The Halting Problem

Explain

Assume we have fixed some enumeration of Turing machine descriptions. Each Turing machine thus receives an index: its place in the enumeration M1M_1source, M2M_2source, M3M_3source, dots of Turing machine descriptions.

We know that there must be non-Turing-computable functions: the set of Turing machine descriptions---and hence the set of Turing machines---is enumerable, but the set of all functions from \Natsource to \Natsource is not. But we can find specific examples of non-computable functions as well. One such function is the halting function.

Undecidability definition

[Halting function] The halting function hhsource is defined as

h(e,n)={0if machine~Me does not halt for input n1if machine~Me halts for input nh(e,n) = \begin{cases} \text{0} & \text{if machine~$M_e$ does not halt for input $n$} \\ \text{1} & \text{if machine~$M_e$ halts for input $n$} \end{cases}source

Undecidability definition

[Halting problem] The Halting Problem is the problem of determining (for any eesource, nnsource) whether the Turing machine MeM_esource halts for an input of nnsource strokes.

Explain

We show that hhsource is not Turing-computable by showing that a related function, sssource, is not Turing-computable. This proof relies on the fact that anything that can be computed by a Turing machine can be computed by a disciplined Turing machine (link to section Disciplined Machines), and the fact that two Turing machines can be hooked together to create a single machine (link to section Combining Machines).

Undecidability definition

The function sssource is defined as

s(e)={0if machine~Me does not halt for input e1if machine~Me halts for input es(e) = \begin{cases} \text{0} & \text{if machine~$M_e$ does not halt for input $e$} \\ \text{1} & \text{if machine~$M_e$ halts for input $e$} \end{cases}source

Undecidability lemma

The function sssource is not Turing computable.

Proof

We suppose, for contradiction, that the function sssource is Turing computable. Then there would be a Turing machine SSsource that computes sssource. We may assume, without loss of generality, that when SSsource halts, it does so while scanning the first square (i.e., that it is disciplined). This machine can be “hooked up” to another machine JJsource, which halts if it is started on input 00source (i.e., if it reads 0\TMblanksource in the initial state while scanning the square to the right of the end-of-tape symbol), and otherwise wanders off to the right, never halting. SJS \concat Jsource, the machine created by hooking SSsource to JJsource, is a Turing machine, so it is MeM_esource for some eesource (i.e., it appears somewhere in the enumeration). Start MeM_esource on an input of eesource 1\TMstrokesources. There are two possibilities: either MeM_esource halts or it does not halt.

  1. Suppose MeM_esource halts for an input of eesource 1\TMstrokesources. Then s(e)=1s(e) = 1source. So SSsource, when started on eesource, halts with a single 1\TMstrokesource as output on the tape. Then JJsource starts with a 1\TMstrokesource on the tape. In that case JJsource does not halt. But MeM_esource is the machine SJS \concat Jsource, so it should do exactly what SSsource followed by JJsource would do (i.e., in this case, wander off to the right and never halt). So MeM_esource cannot halt for an input of eesource 1\TMstrokesource's.

  2. Now suppose MeM_esource does not halt for an input of eesource 1\TMstrokesources. Then s(e)=0s(e) = 0source, and SSsource, when started on input eesource, halts with a blank tape. JJsource, when started on a blank tape, immediately halts. Again, MeM_esource does what SSsource followed by JJsource would do, so MeM_esource must halt for an input of eesource 1\TMstrokesource's.

In each case we arrive at a contradiction with our assumption. This shows there cannot be a Turing machine SSsource: sssource is not Turing computable.

Undecidability theorem

[Unsolvability of the Halting Problem] The halting problem is unsolvable, i.e., the function hhsource is not Turing computable.

Proof

Suppose hhsource were Turing computable, say, by a Turing machine HHsource. We could use HHsource to build a Turing machine that computes sssource: First, make a copy of the input (separated by a 0\TMblanksource symbol). Then move back to the beginning, and run HHsource. We can clearly make a machine that does the former (see link to exercise asking for a disciplined copier machine), and if HHsource existed, we would be able to “hook it up” to such a copier machine to get a new machine which would determine if MeM_esource halts on input eesource, i.e., computes sssource. But we've already shown that no such machine can exist. Hence, hhsource is also not Turing computable.

Unsolved undecidability exercise

The Three Halting (3-Halt) problem is the problem of giving a decision procedure to determine whether or not an arbitrarily chosen Turing Machine halts for an input of three 1\TMstrokesource's on an otherwise blank tape. Prove that the 3-Halt problem is unsolvable.

Unsolved undecidability exercise

Show that if the halting problem is solvable for Turing machine and input pairs MeM_esource and nnsource where ene \neq nsource, then it is also solvable for the cases where e=ne = nsource.

Unsolved undecidability exercise

We proved that the halting problem is unsolvable if the input is a number eesource, which identifies a Turing machine MeM_esource via an enumeration of all Turing machines. What if we allow the description of Turing machines from link to section Enumerating Turing Machines directly as input? Can there be a Turing machine which decides the halting problem but takes as input descriptions of Turing machines rather than indices? Explain why or why not.

Unsolved undecidability exercise

Show that the partial function ss'source is defined as

s(e)={1if machine~Me halts for input eundefinedif machine~Me does not halt for input es'(e) = \begin{cases} \text{1} & \text{if machine~$M_e$ halts for input $e$}\\ \text{undefined} & \text{if machine~$M_e$ does not halt for input $e$} \end{cases}source

is Turing computable.

Source file content/turing-machines/undecidability/decision-problem.tex

The Decision Problem

We say that first-order logic is decidable iff there is an effective method for determining whether or not a given sentence is valid. As it turns out, there is no such method: the problem of deciding validity of first-order sentences is unsolvable.

In order to establish this important negative result, we prove that the decision problem cannot be solved by a Turing machine. That is, we show that there is no Turing machine which, whenever it is started on a tape that contains a first-order sentence, eventually halts and outputs either 11source or 00source depending on whether the sentence is valid or not. By the Church--Turing thesis, every function which is computable is Turing computable. So if this “validity function” were effectively computable at all, it would be Turing computable. If it isn't Turing computable, then, it also cannot be effectively computable.

Our strategy for proving that the decision problem is unsolvable is to reduce the halting problem to it. This means the following: We have proved that the function h(e,w)h(e,w)source that halts with output 11source if the Turing machine described by eesource halts on input wwsource and outputs 00source otherwise, is not Turing computable. We will show that if there were a Turing machine that decides validity of first-order sentences, then there is also Turing machine that computes hhsource. Since hhsource cannot be computed by a Turing machine, there cannot be a Turing machine that decides validity either.

The first step in this strategy is to show that for every input wwsource and a Turing machine MMsource, we can effectively describe a sentence T(M,w)!T(M, w)source representing the instruction set of MMsource and the input wwsource and a sentence E(M,w)!E(M, w)source expressing “MMsource eventually halts” such that:

T(M,w)E(M,w)\Entails !T(M, w) \lif !E(M,w)source iff MMsource halts for input wwsource.

The bulk of our proof will consist in describing these sentences T(M,w)!T(M, w)source and E(M,w)!E(M, w)source and in verifying that T(M,w)E(M,w)!T(M, w) \lif !E(M, w)source is valid iff MMsource halts on input wwsource.

Source file content/turing-machines/undecidability/representing-tms.tex

Representing Turing Machines

Explain

In order to represent Turing machines and their behavior by a sentence of first-order logic, we have to define a suitable language. The language consists of two parts: predicate symbols for describing configurations of the machine, and expressions for numbering execution steps (“moments”) and positions on the tape.

We introduce two kinds of predicate symbols, both of them 2-place: For each state qqsource, a predicate symbol Qq\Obj Q_qsource, and for each tape symbol σ\sigmasource, a predicate symbol Sσ\Obj S_\sigmasource. The former allow us to describe the state of MMsource and the position of its tape head, the latter allow us to describe the contents of the tape.

In order to express the positions of the tape head and the number of steps executed, we need a way to express numbers. This is done using a constant symbol 0\Obj 0source, and a 11source-place function \primesource, the successor function. By convention it is written after its argument (and we leave out the parentheses).

For each number nnsource there is a canonical term n¯\num{n}source, the numeral for nnsource, which represents it in LM\Lang L_Msource. 0¯\num{0}source is 0\Obj 0source, 1¯\num{1}source is 0\Obj 0'source, 2¯\num{2}source is 0\Obj 0''source, and so on. More formally:

0¯=0n+1¯=n¯\num{0} & = \Obj 0 \\ \num{n+1} &= \num{n}'source

The term 0¯\num{0}source, i.e., 0\Obj 0source names the leftmost position on the tape as well as the time before the first execution step (the initial configuration). The term 1¯\num{1}source, i.e., 0\Obj 0'source names the square to the right of the leftmost square, and the time after the first execution step, and so on.

We also introduce a predicate symbol <<source to express both the ordering of tape positions (when it means “to the left of”) and execution steps (then it means “before”).

Once we have the language in place, we list the “axioms” of T(M,w)!T(M, w)source, i.e., the sentences which, taken together, describe the behavior of MMsource when run on input wwsource. There will be sentences which lay down conditions on 0\Obj 0source, \primesource, and <<source, sentences that describes the input configuration, and sentences that describe what the configuration of MMsource is after it executes a particular instruction.

Undecidability definition

Given a Turing machine M=Q,Σ,q0,δM = \tuple{Q, \Sigma, q_0, \delta}source, the language LM\Lang L_Msource consists of:

  1. A two-place predicate symbol Qq(x,y)\Obj Q_q(x, y)source for every state qQq \in Qsource. Intuitively, Qq(m¯,n¯)\Obj Q_q(\num{m}, \num{n})source expresses “after nnsource steps, MMsource is in state qqsource scanning the mmsourceth square.”

  2. A two-place predicate symbol Sσ(x,y)\Obj S_\sigma(x, y)source for every symbol σΣ\sigma\in \Sigmasource. Intuitively, Sσ(m¯,n¯)\Obj S_\sigma(\num{m}, \num{n})source expresses “after nnsource steps, the mmsourceth square contains symbol σ\sigmasource.”

  3. A constant symbol 0\Obj 0source

  4. A one-place function symbol \primesource

  5. A two-place predicate symbol <<source

The sentences describing the operation of the Turing machine MMsource on input w=σi1σikw = \sigma_{i_1}\dots\sigma_{i_k}source are the following:

  1. Axioms describing numbers and <<source:

    1. A sentence that says that every number is less than its successor:

      xx<x\lforall[x][x < x']source
    2. A sentence that ensures that <<source is transitive:

      xyz((x<yy<z)x<z)\lforall[x][\lforall[y][\lforall[z][ ((x < y \land y < z) \lif x < z)]]]source
  2. Axioms describing the input configuration:

    1. After 00source steps---before the machine starts---MMsource is in the initial state q0q_0source, scanning square 11source:

      Qq0(1¯,0¯)\Obj Q_{q_0}(\num{1}, \num{0})source
    2. The first k+1k+1source squares contain the symbols \TMendtapesource, σi1\sigma_{i_1}source, dots, σik\sigma_{i_k}source:

      S(0¯,0¯)Sσi1(1¯,0¯)Sσik(k¯,0¯)\Obj S_\TMendtape(\num{0}, \num{0}) \land \Obj S_{\sigma_{i_1}}(\num{1}, \num{0}) \land \dots \land \Obj S_{\sigma_{i_k}}(\num{k}, \num{0})source
    3. Otherwise, the tape is empty:

      x(k¯<xS0(x,0¯))\lforall[x][(\num{k} < x \lif \Obj S_\TMblank(x, \num{0}))]source
  3. Axioms describing the transition from one configuration to the next:

    For the following, let A(x,y)!A(x, y)source be the conjunction of all sentences of the form

    z(((z<xx<z)Sσ(z,y))Sσ(z,y))\lforall[z][ (((z < x \lor x < z) \land \Obj S_\sigma(z, y)) \lif \Obj S_\sigma(z, y'))]source

    where σΣ\sigma \in \Sigmasource. We use A(m¯,n¯)!A(\num{m},\num{n})source to express “other than at square mmsource, the tape after n+1n+1source steps is the same as after nnsource steps.”

    1. For every instruction δ(qi,σ)=qj,σ,R\delta(q_i, \sigma) = \tuple{q_j, \sigma', \TMright}source, the sentence:

      xy((Qqi(x,y)Sσ(x,y))(Qqj(x,y)Sσ(x,y)A(x,y)))& \lforall[x][\lforall[y][( (\Obj Q_{q_i}(x, y) \land \Obj S_{\sigma}(x, y)) \lif {}]] \\ &\qquad (\Obj Q_{q_j}(x', y') \land \Obj S_{\sigma'}(x, y') \land !A(x, y)))source

      This says that if, after yysource steps, the machine is in state qiq_isource scanning square xxsource which contains symbol σ\sigmasource, then after y+1y+1source steps it is scanning square x+1x+1source, is in state qjq_jsource, square xxsource now contains σ\sigma'source, and every square other than xxsource contains the same symbol as it did after yysource steps.

    2. For every instruction δ(qi,σ)=qj,σ,L\delta(q_i, \sigma) = \tuple{q_j, \sigma', \TMleft}source, the sentence:

      xy((Qqi(x,y)Sσ(x,y))(Qqj(x,y)Sσ(x,y)A(x,y)))y((Qqi(0¯,y)Sσ(0¯,y))(Qqj(0¯,y)Sσ(0¯,y)A(0¯,y)))& \lforall[x][\lforall[y][ ((\Obj Q_{q_i}(x', y) \land \Obj S_{\sigma}(x', y)) \lif {}]]\\ & \qquad (\Obj Q_{q_j}(x, y') \land \Obj S_{\sigma'}(x', y') \land !A(x, y))) \land {}\\ & \lforall[y][((\Obj Q_{q_i}(\num{0}, y) \land \Obj S_{\sigma}(\num{0}, y)) \lif {}]\\ & \qquad (\Obj Q_{q_j}(\num{0}, y') \land \Obj S_{\sigma'}(\num{0}, y') \land !A(\num{0}, y)))source

      Take a moment to think about how this works: now we don't start with “if scanning square xxsource dots” but: “if scanning square x+1x+1source dots” A move to the left means that in the next step the machine is scanning square xxsource. But the square that is written on is x+1x+1source. We do it this way since we don't have subtraction or a predecessor function.

      Note that numbers of the form x+1x+1source are 11source, 22source, dots, i.e., this doesn't cover the case where the machine is scanning square 00source and is supposed to move left (which of course it can't---it just stays put). That special case is covered by the second conjunction: it says that if, after yysource steps, the machine is scanning square 00source in state qiq_isource and square 00source contains symbol σ\sigmasource, then after y+1y+1source steps it's still scanning square 00source, is now in state qjq_jsource, the symbol on square 00source is σ\sigma'source, and the squares other than square 00source contain the same symbols they contained ofter yysource steps.

    3. For every instruction δ(qi,σ)=qj,σ,N\delta(q_i, \sigma) = \tuple{q_j, \sigma', \TMstay}source, the sentence:

      xy((Qqi(x,y)Sσ(x,y))(Qqj(x,y)Sσ(x,y)A(x,y)))& \lforall[x][\lforall[y][( (\Obj Q_{q_i}(x, y) \land \Obj S_{\sigma}(x, y)) \lif {}]] \\ &\qquad (\Obj Q_{q_j}(x, y') \land \Obj S_{\sigma'}(x, y') \land !A(x, y)))source

Let T(M,w)!T(M, w)source be the conjunction of all the above sentences for Turing machine MMsource and input wwsource.

In order to express that MMsource eventually halts, we have to find a sentence that says “after some number of steps, the transition function will be undefined.” Let XXsource be the set of all pairs q,σ\tuple{q, \sigma}source such that δ(q,σ)\delta(q, \sigma)source is undefined. Let E(M,w)!E(M, w)source then be the sentence

xy(q,σX(Qq(x,y)Sσ(x,y)))\lexists[x][\lexists[y][(\bigvee_{\tuple{q, \sigma} \in X}(\Obj Q_q(x, y) \land \Obj S_\sigma(x, y)))]]source

If we use a Turing machine with a designated halting state hhsource, it is even easier: then the sentence E(M,w)!E(M, w)source

xyQh(x,y)\lexists[x][\lexists[y][\Obj Q_h(x, y)]]source

expresses that the machine eventually halts.

Undecidability proposition

If m<km < ksource, then T(M,w)m¯<k¯!T(M, w) \Entails \num{m} < \num{k}source

Proof

Exercise.

Unsolved undecidability exercise

Prove link to proposition that represented numerals preserve strict order. (Hint: use induction on kmk-msource).

Source file content/turing-machines/undecidability/verification.tex

Verifying the Representation

Explain

In order to verify that our representation works, we have to prove two things. First, we have to show that if MMsource halts on input wwsource, then T(M,w)E(M,w)!T(M, w) \lif !E(M, w)source is valid. Then, we have to show the converse, i.e., that if T(M,w)E(M,w)!T(M, w) \lif !E(M, w)source is valid, then MMsource does in fact eventually halt when run on input wwsource.

The strategy for proving these is very different. For the first result, we have to show that a sentence of first-order logic (namely, T(M,w)E(M,w)!T(M, w) \lif !E(M, w)source) is valid. The easiest way to do this is to give a derivation. Our proof is supposed to work for all MMsource and wwsource, though, so there isn't really a single sentence for which we have to give a derivation, but infinitely many. So the best we can do is to prove by induction that, whatever MMsource and wwsource look like, and however many steps it takes MMsource to halt on input wwsource, there will be a derivation of T(M,w)E(M,w)!T(M, w) \lif !E(M, w)source.

Naturally, our induction will proceed on the number of steps MMsource takes before it reaches a halting configuration. In our inductive proof, we'll establish that for each step nnsource of the run of MMsource on input wwsource, T(M,w)C(M,w,n)!T(M, w) \Entails !C(M, w, n)source, where C(M,w,n)!C(M, w, n)source correctly describes the configuration of MMsource run on wwsource after nnsource steps. Now if MMsource halts on input wwsource after, say, nnsource steps, C(M,w,n)!C(M, w, n)source will describe a halting configuration. We'll also show that C(M,w,n)E(M,w)!C(M, w, n) \Entails !E(M, w)source, whenever C(M,w,n)!C(M, w, n)source describes a halting configuration. So, if MMsource halts on input wwsource, then for some nnsource, MMsource will be in a halting configuration after nnsource steps. Hence, T(M,w)C(M,w,n)!T(M, w) \Entails !C(M, w, n)source where C(M,w,n)!C(M, w, n)source describes a halting configuration, and since in that case C(M,w,n)E(M,w)!C(M, w, n) \Entails !E(M, w)source, we get that T(M,w)E(M,w)!T(M, w) \Entails !E(M, w)source, i.e., that T(M,w)E(M,w)\Entails !T(M, w) \lif !E(M, w)source.

The strategy for the converse is very different. Here we assume that T(M,w)E(M,w)\Entails !T(M, w) \lif !E(M, w)source and have to prove that MMsource halts on input wwsource. From the hypothesis we get that T(M,w)E(M,w)!T(M, w) \Entails !E(M, w)source, i.e., E(M,w)!E(M, w)source is true in every structure in which T(M,w)!T(M, w)source is true. So we'll describe a structure M\Struct{M}source in which T(M,w)!T(M, w)source is true: its domain will be \Natsource, and the interpretation of all the Qq\Obj Q_qsource and Sσ\Obj S_\sigmasource will be given by the configurations of MMsource during a run on input wwsource. So, e.g., MQq(m¯,n¯)\Sat{M}{\Obj Q_q(\num{m}, \num{n})}source iff MMsource, when run on input wwsource for nnsource steps, is in state qqsource and scanning square mmsource. Now since T(M,w)E(M,w)!T(M, w) \Entails !E(M, w)source by hypothesis, and since MT(M,w)\Sat{M}{!T(M, w)}source by construction, ME(M,w)\Sat{M}{!E(M, w)}source. But ME(M,w)\Sat{M}{!E(M, w)}source iff there is some n|M|=n \in \Domain{M} = \Natsource so that MMsource, run on input wwsource, is in a halting configuration after nnsource steps.

Undecidability definition

Let C(M,w,n)!C(M, w, n)source be the sentence

Qq(m¯,n¯)Sσ0(0¯,n¯)Sσk(k¯,n¯)x(k¯<xS0(x,n¯))\Obj Q_q(\num{m}, \num{n}) \land \Obj S_{\sigma_0}(\num{0}, \num{n}) \land \dots \land \Obj S_{\sigma_k}(\num{k}, \num{n}) \land \lforall[x][(\num{k} < x \lif \Obj S_\TMblank(x, \num{n}))]source

where qqsource is the state of MMsource at time nnsource, MMsource is scanning square mmsource at time nnsource, square iisource contains symbol σi\sigma_isource at time nnsource for 0ik0 \le i \le ksource and kksource is the right-most non-blank square of the tape at time 00source, or the right-most square the tape head has visited after nnsource steps, whichever is greater.

Undecidability lemma

If MMsource run on input wwsource is in a halting configuration after nnsource steps, then C(M,w,n)E(M,w)!C(M, w, n) \Entails !E(M, w)source.

Proof

Suppose that MMsource halts for input wwsource after nnsource steps. There is some state qqsource, square mmsource, and symbol σ\sigmasource such that:

  1. After nnsource steps, MMsource is in state qqsource scanning square mmsource on which σ\sigmasource appears.

  2. The transition function δ(q,σ)\delta(q, \sigma)source is undefined.

C(M,w,n)!C(M, w, n)source is the description of this configuration and will include the clauses Qq(m¯,n¯)\Obj Q_{q}(\num{m}, \num{n})source and Sσ(m¯,n¯)\Obj S_{\sigma}(\num{m}, \num{n})source. These clauses together imply E(M,w)!E(M, w)source:

xy(q,σX(Qq(x,y)Sσ(x,y)))\lexists[x][\lexists[y][(\bigvee_{\tuple{q, \sigma} \in X}(\Obj Q_q(x, y) \land \Obj S_\sigma(x, y)))]]source

since Qq(m¯,n¯)Sσ(m¯,n¯)q,σX(Qq(m¯,n¯)Sσ(m¯,n¯))\Obj Q_{q}(\num{m}, \num{n}) \land \Obj S_{\sigma}(\num{m}, \num{n}) \Entails \bigvee_{\tuple{q, \sigma} \in X} (\Obj Q_q(\num{m}, \num{n}) \land \Obj S_{\sigma}(\num{m}, \num{n}))source, as q,σX\tuple{q,\sigma} \in Xsource.

Explain

So if MMsource halts for input wwsource, then there is some nnsource such that C(M,w,n)E(M,w)!C(M, w, n) \Entails !E(M,w)source. We will now show that for any time nnsource, T(M,w)C(M,w,n)!T(M, w) \Entails !C(M, w, n)source.

Undecidability lemma

For each nnsource, if MMsource has not halted after nnsource steps, T(M,w)C(M,w,n)!T(M, w) \Entails !C(M, w, n)source.

Proof

Induction basis: If n=0n = 0source, then the conjuncts of C(M,w,0)!C(M, w, 0)source are also conjuncts of T(M,w)!T(M, w)source, so entailed by it.

Inductive hypothesis: If MMsource has not halted before the nnsourceth step, then T(M,w)C(M,w,n)!T(M,w) \Entails !C(M, w, n)source. We have to show that (unless C(M,w,n)!C(M, w, n)source describes a halting configuration), T(M,w)C(M,w,n+1)!T(M, w) \Entails !C(M, w, n+1)source.

Suppose 0n0 \le nsource and after nnsource steps, MMsource started on wwsource is in state qqsource scanning square mmsource. Since MMsource does not halt after nnsource steps, there must be an instruction of one of the following three forms in the program of MMsource:

  1. δ(q,σ)=q,σ,R\delta(q, \sigma) = \tuple{q', \sigma', \TMright}source

  2. δ(q,σ)=q,σ,L\delta(q, \sigma) = \tuple{q', \sigma', \TMleft}source

  3. δ(q,σ)=q,σ,N\delta(q, \sigma) = \tuple{q', \sigma', \TMstay}source

We will consider each of these three cases in turn.

  1. Suppose there is an instruction of the form link to right-move case in the configuration induction. By link to definition of the first-order machine-description languagelink to right-move representation sentence, this means that

    xy((Qq(x,y)Sσ(x,y))(Qq(x,y)Sσ(x,y)A(x,y)))is a conjunct of T(M,w). This entails the following !!{sentence} (universal instantiation, m¯ for~x and n¯ for~y):(Qq(m¯,n¯)Sσ(m¯,n¯))(Qq(m¯,n¯)Sσ(m¯,n¯)A(m¯,n¯)).By induction hypothesis, T(M,w)C(M,w,n), i.e.,Qq(m¯,n¯)Sσ0(0¯,n¯)Sσk(k¯,n¯)x(k¯<xS0(x,n¯))Since after n steps, tape square~m contains~σ, the corresponding conjunct is~Sσ(m¯,n¯), so this entails:Qq(m¯,n¯)Sσ(m¯,n¯)We now getQq(m¯,n¯)Sσ(m¯,n¯)Sσ0(0¯,n¯)Sσk(k¯,n¯)x(k¯<xS0(x,n¯))& \lforall[x][\lforall[y][((\Obj Q_{q}(x, y) \land \Obj S_\sigma(x, y)) \lif {}]]\\ & \qquad (\Obj Q_{q'}(x', y') \land \Obj S_{\sigma'}(x, y') \land !A(x, y))) \intertext{is a conjunct of $!T(M,w)$. This entails the following !!{sentence} (universal instantiation, $\num{m}$ for~$x$ and $\num{n}$ for~$y$):} & (\Obj Q_{q}(\num{m}, \num{n}) \land \Obj S_{\sigma}(\num{m}, \num{n})) \lif {}\\ & \qquad (\Obj Q_{q'}(\num{m}', \num{n}') \land \Obj S_{\sigma'}(\num{m}, \num{n}') \land !A(\num{m}, \num{n})). \intertext{By induction hypothesis, $!T(M, w) \Entails !C(M, w, n)$, i.e.,} & \Obj Q_q(\num{m}, \num{n}) \land \Obj S_{\sigma_0}(\num{0}, \num{n}) \land \dots \land \Obj S_{\sigma_k}(\num{k}, \num{n}) \land \\ & \qquad\lforall[x][(\num{k} < x \lif \Obj S_\TMblank(x, \num{n}))]\\ \intertext{Since after $n$ steps, tape square~$m$ contains~$\sigma$, the corresponding conjunct is~$\Obj S_\sigma(\num{m}, \num{n})$, so this entails:} & \Obj Q_{q}(\num{m}, \num{n}) \land \Obj S_{\sigma}(\num{m}, \num{n}) \intertext{We now get} & \Obj Q_{q'}(\num{m}', \num{n}') \land \Obj S_{\sigma'}(\num{m}, \num{n}') \land {}\\ & \qquad\Obj S_{\sigma_0}(\num{0}, \num{n}') \land \dots \land \Obj S_{\sigma_k}(\num{k}, \num{n}') \land {}\\ & \qquad \lforall[x][(\num{k} < x \lif \Obj S_\TMblank(x, \num{n}'))]source

    as follows: The first line comes directly from the consequent of the preceding conditional, by modus ponens. Each conjunct in the middle line---which excludes Sσm(m¯,n¯)\Obj S_{\sigma_m}(\num{m},\num{n}')source---follows from the corresponding conjunct in C(M,w,n)!C(M, w, n)source together with A(m¯,n¯)!A(\num{m}, \num{n})source.

    If m<km < ksource, T(M,w)m¯<k¯!T(M,w) \Proves \num{m} < \num {k}source (link to proposition that represented numerals preserve strict order) and by transitivity of <<source, we have x(k¯<xm¯<x)\lforall[x][(\num{k} < x \lif \num{m} < x)]source. If m=km = ksource, then x(k¯<xm¯<x)\lforall[x][(\num{k} < x \lif \num{m} < x)]source by logic alone. The last line then follows from the corresponding conjunct in C(M,w,n)!C(M, w, n)source, x(k¯<xm¯<x)\lforall[x][(\num{k} < x \lif \num{m} < x)]source, and A(m¯,n¯)!A(\num{m}, \num{n})source. If m<km<ksource, this already is C(M,w,n+1)!C(M, w, n+1)source.

    Now suppose m=km=ksource. In that case, after n+1n+1source steps, the tape head has also visited square k+1k+1source, which now is the right-most square visited. So C(M,w,n+1)!C(M, w, n+1)source has a new conjunct, S0(k¯,n¯)\Obj S_\TMblank(\num{k}',\num{n}')source, and the last conjunct is x(k¯<xS0(x,n¯))\lforall[x][(\num{k}' < x \lif \Obj S_\TMblank(x, \num{n}'))]source. We have to verify that these two sentences are also implied.

    We already have x(k¯<xS0(x,n¯))\lforall[x][(\num{k} < x \lif \Obj S_\TMblank(x, \num{n}'))]source. In particular, this gives us k¯<k¯S0(k¯,n¯)\num{k} < \num{k}' \lif \Obj S_\TMblank(\num{k}', \num{n}')source. From the axiom xx<x\lforall[x][x < x']source we get k¯<k¯\num{k} < \num{k}'source. By modus ponens, S0(k¯,n¯)\Obj S_\TMblank(\num{k}',\num{n}')source follows.

    Also, since T(M,w)k¯<k¯!T(M,w) \Proves \num{k} < \num{k}'source, the axiom for transitivity of <<source gives us x(k¯<xS0(x,n¯))\lforall[x][(\num{k}' < x \lif \Obj S_\TMblank(x, \num{n}'))]source. (We leave the verification of this as an exercise.)

  2. Suppose there is an instruction of the form link to left-move case in the configuration induction. Then, by link to definition of the first-order machine-description languagelink to left-move representation sentence,

    xy((Qq(x,y)Sσ(x,y))(Qq(x,y)Sσ(x,y)A(x,y)))y((Qqi(0¯,y)Sσ(0¯,y))(Qqj(0¯,y)Sσ(0¯,y)A(0¯,y)))is a conjunct of T(M,w). If m>0, then let l=m1 (i.e., m=l+1). The first conjunct of the above !!{sentence} entails the following:(Qq(l¯,n¯)Sσ(l¯,n¯))(Qq(l¯,n¯)Sσ(l¯,n¯)A(l¯,n¯))Otherwise, let l=m=0 and consider the following !!{sentence} entailed by the second conjunct:((Qqi(0¯,n¯)Sσ(0¯,n¯))(Qqj(0¯,n¯)Sσ(0¯,n¯)A(0¯,n¯)))Either sentence impliesQq(l¯,n¯)Sσ(m¯,n¯)Sσ0(0¯,n¯)Sσk(k¯,n¯)x(k¯<xS0(x,n¯))& \lforall[x][\lforall[y][((\Obj Q_{q}(x', y) \land \Obj S_{\sigma}(x', y)) \lif {}]]\\ & \qquad (\Obj Q_{q'}(x, y') \land \Obj S_{\sigma'}(x', y') \land !A(x, y))) \land {}\\ & \lforall[y][((\Obj Q_{q_i}(\num{0}, y) \land \Obj S_{\sigma}(\num{0}, y)) \lif {}]\\ & \qquad (\Obj Q_{q_j}(\num{0}, y') \land \Obj S_{\sigma'}(\num{0}, y') \land !A(\num{0}, y))) \intertext{is a conjunct of $!T(M,w)$. If $m>0$, then let $l = m - 1$ (i.e., $m = l+1$). The first conjunct of the above !!{sentence} entails the following:} & (\Obj Q_{q}(\num{l}', \num{n}) \land \Obj S_{\sigma}(\num{l}', \num{n})) \lif {} \\ & \qquad (\Obj Q_{q'}(\num{l}, \num{n}') \land \Obj S_{\sigma'}(\num{l}', \num{n}') \land !A(\num{l}, \num{n})) \intertext{Otherwise, let $l = m = 0$ and consider the following !!{sentence} entailed by the second conjunct:} & ((\Obj Q_{q_i}(\num{0}, \num{n}) \land \Obj S_{\sigma}(\num{0}, \num{n})) \lif {}\\ & \qquad (\Obj Q_{q_j}(\num{0}, \num{n}') \land \Obj S_{\sigma'}(\num{0}, \num{n}') \land !A(\num{0}, \num{n}))) \intertext{Either sentence implies} & \Obj Q_{q'}(\num{l}, \num{n}') \land \Obj S_{\sigma'}(\num{m}, \num{n}') \land {}\\ &\qquad \Obj S_{\sigma_0}(\num{0}, \num{n}')\land \dots \land \Obj S_{\sigma_k}(\num{k}, \num{n}') \land {} \\ & \qquad \lforall[x][(\num{k} < x \lif \Obj S_\TMblank(x, \num{n}'))]source

    as before. (Note that in the first case, l¯l+1¯m¯\num{l}' \ident \num{l+1} \ident \num{m}source and in the second case l¯0¯\num{l} \ident \num{0}source.) But this just is C(M,w,n+1)!C(M, w, n+1)source.

  3. Case link to stay-put case in the configuration induction is left as an exercise.

We have shown that for any nnsource, T(M,w)C(M,w,n)!T(M, w) \Entails !C(M, w, n)source.

Unsolved undecidability exercise

Complete case link to stay-put case in the configuration induction of the proof of link to configuration representation lemma.

Unsolved undecidability exercise

Give a derivation of Sσi(i¯,n¯)\Obj S_{\sigma_i}(\num{i}, \num{n}')source from Sσi(i¯,n¯)\Obj S_{\sigma_i}(\num{i}, \num{n})source and A(m,n)!A(m, n)source (assuming imi \neq msource, i.e., either i<mi < msource or m<im < isource).

Unsolved undecidability exercise

Give a derivation of x(k¯<xS0(x,n¯))\lforall[x][(\num{k}' < x \lif \Obj S_\TMblank(x, \num{n}'))]source from x(k¯<xS0(x,n¯))\lforall[x][(\num{k} < x \lif \Obj S_\TMblank(x, \num{n}'))]source, xx<x\lforall[x][x < x']source, and xyz((x<yy<z)x<z)\lforall[x][\lforall[y][\lforall[z][ ((x < y \land y < z) \lif x < z)]]]source.)

Undecidability lemma

If MMsource halts on input wwsource, then T(M,w)E(M,w)!T(M, w) \lif !E(M, w)source is valid.

Proof

By link to configuration representation lemma, we know that, for any time nnsource, the description C(M,w,n)!C(M, w, n)source of the configuration of MMsource at time nnsource is entailed by T(M,w)!T(M, w)source. Suppose MMsource halts after kksource steps. At that point, it will be scanning square mmsource, for some mm \in \Natsource. Then C(M,w,k)!C(M, w, k)source describes a halting configuration of MMsource, i.e., it contains as conjuncts both Qq(m¯,k¯)\Obj Q_q(\num{m}, \num{k})source and Sσ(m¯,k¯)\Obj S_\sigma(\num{m}, \num{k})source with δ(q,σ)\delta(q,\sigma)source undefined. Thus, by link to lemma that a halting configuration entails the halting sentence, C(M,w,k)E(M,w)!C(M, w, k) \Entails !E(M, w)source. But since T(M,w)C(M,w,k)!T(M, w) \Entails !C(M, w, k)source, we have T(M,w)E(M,w)!T(M, w) \Entails !E(M, w)source and therefore T(M,w)E(M,w)!T(M, w) \lif !E(M, w)source is valid.

Explain

To complete the verification of our claim, we also have to establish the reverse direction: if T(M,w)E(M,w)!T(M, w) \lif !E(M, w)source is valid, then MMsource does in fact halt when started on input wwsource.

Undecidability lemma

If T(M,w)E(M,w)\Entails !T(M, w) \lif !E(M, w)source, then MMsource halts on input wwsource.

Proof

Consider the LM\Lang L_Msource-structure M\Struct Msource with domain \Natsource which interprets 0\Obj 0source as 00source, \primesource as the successor function, and <<source as the less-than relation, and the predicates Qq\Obj Q_qsource and Sσ\Obj S_\sigmasource as follows:

QqM={m,n:started on~w, after~n steps,M is in state q scanning square~m}SσM={m,n:started on~w, after n steps,square~m of M contains symbol~σ}\Assign{\Obj Q_q}{M} & = \Setabs{\tuple{m, n}}{\begin{array}{ll}\text{started on~$w$, after~$n$ steps,}\\ \text{$M$ is in state $q$ scanning square~$m$}\end{array}} \\ \Assign{\Obj S_\sigma}{M} & = \Setabs{\tuple{m, n}}{\begin{array}{ll} \text{started on~$w$, after $n$ steps,}\\ \text{square~$m$ of $M$ contains symbol~$\sigma$}\end{array}}source

In other words, we construct the structure M\Struct{M}source so that it describes what MMsource started on input wwsource actually does, step by step. Clearly, MT(M,w)\Sat{M}{!T(M, w)}source. If T(M,w)E(M,w)\Entails !T(M, w) \lif !E(M, w)source, then also ME(M,w)\Sat{M}{!E(M, w)}source, i.e.,

Mxy(q,σX(Qq(x,y)Sσ(x,y))).\Sat{M}{\lexists[x][\lexists[y][(\bigvee_{\tuple{q, \sigma} \in X}(\Obj Q_q(x, y) \land \Obj S_\sigma(x, y)))]]}.source

As |M|=\Domain{M} = \Natsource, there must be mmsource, nn \in \Natsource so that MQq(m¯,n¯)Sσ(m¯,n¯)\Sat{M}{\Obj Q_q(\num{m}, \num{n}) \land \Obj S_\sigma(\num{m}, \num{n})}source for some qqsource and σ\sigmasource such that δ(q,σ)\delta(q, \sigma)source is undefined. By the definition of M\Struct Msource, this means that MMsource started on input wwsource after nnsource steps is in state qqsource and reading symbol σ\sigmasource, and the transition function is undefined, i.e., MMsource has halted.

Source file content/turing-machines/undecidability/unsolvability-decision-problem.tex

The Decision Problem is Unsolvable

Undecidability theorem

The decision problem is unsolvable: There is no Turing machine DDsource, which when started on a tape that contains a sentence B!Bsource of first-order logic as input, DDsource eventually halts, and outputs 11source iff B!Bsource is valid and 00source otherwise.

Proof

Suppose the decision problem were solvable, i.e., suppose there were a Turing machine DDsource. Then we could solve the halting problem as follows. We construct a Turing machine EEsource that, given as input the number eesource of Turing machine MeM_esource and input wwsource, computes the corresponding sentence T(Me,w)E(Me,w)!T(M_e, w) \lif !E(M_e, w)source and halts, scanning the leftmost square on the tape. The machine EDE \concat Dsource would then, given input eesource and wwsource, first compute T(Me,w)E(Me,w)!T(M_e, w) \lif !E(M_e, w)source and then run the decision problem machine DDsource on that input. DDsource halts with output 11source iff T(Me,w)E(Me,w)!T(M_e, w) \lif !E(M_e, w)source is valid and outputs 00source otherwise. By link to lemma that validity of the representation implies halting and link to lemma that halting implies validity of the representation, T(Me,w)E(Me,w)!T(M_e, w) \lif !E(M_e, w)source is valid iff MeM_esource halts on input wwsource. Thus, EDE\concat Dsource, given input eesource and wwsource halts with output 11source iff MeM_esource halts on input wwsource and halts with output 00source otherwise. In other words, EDE \concat Dsource would solve the halting problem. But we know, by link to theorem on unsolvability of the Halting Problem, that no such Turing machine can exist.

Undecidability corollary

It is undecidable if an arbitrary sentence of first-order logic is satisfiable.

Proof

Suppose satisfiability were decidable by a Turing machine SSsource. Then we could solve the decision problem as follows: Given a sentence B!Bsource as input, move B!Bsource to the right one square. Return to square 11source and write the symbol ¬\lnotsource.

Now run the Turing machine SSsource. It eventually halts with output either 11source (if ¬B\lnot !Bsource is satisfiable) or 00source (if ¬B\lnot !Bsource is unsatisfiable) on the tape. If there is a 1\TMstrokesource on square 11source, erase it; if square 11source is empty, write a 1\TMstrokesource, then halt.

This Turing machine always halts, and its output is 11source iff ¬B\lnot !Bsource is unsatisfiable and 00source otherwise. Since B!Bsource is valid iff ¬B\lnot !Bsource is unsatisfiable, the machine outputs 11source iff B!Bsource is valid, and 00source otherwise, i.e., it would solve the decision problem.

Explain

So there is no Turing machine which always gives a correct “yes” or “no” answer to the question “Is B!Bsource a valid sentence of first-order logic?” However, there is a Turing machine that always gives a correct “yes” answer---but simply does not halt if the answer is “no.” This follows from the soundness and completeness theorem of first-order logic, and the fact that derivations can be effectively enumerated.

Undecidability theorem

Validity of first-order sentences is semi-decidable: There is a Turing machine EEsource, which when started on a tape that contains a sentence B!Bsource of first-order logic as input, EEsource eventually halts and outputs 11source iff B!Bsource is valid, but does not halt otherwise.

Proof

All possible derivations of first-order logic can be generated, one after another, by an effective algorithm. The machine EEsource does this, and when it finds a derivation that shows that B\Proves !Bsource, it halts with output 11source. By the soundness theorem, if EEsource halts with output 11source, it's because B\Entails !Bsource. By the completeness theorem, if B\Entails !Bsource there is a derivation that shows that B\Proves !Bsource. Since EEsource systematically generates all possible derivations, it will eventually find one that shows B\Proves !Bsource, so will eventually halt with output 11source.

Source file content/turing-machines/undecidability/trakhtenbrot.tex

Trakhtenbrot's Theorem

Explain

In link to section Representing Turing Machines we defined sentences T(M,w)!T(M,w)source and E(M,w)!E(M,w)source for a Turing machine MMsource and input string wwsource. Then we showed in link to lemma that halting implies validity of the representation and link to lemma that validity of the representation implies halting that T(M,w)E(M,w)!T(M,w) \lif !E(M,w)source is valid iff MMsource, started on input wwsource, eventually halts. Since the Halting Problem is undecidable, this implies that validity and satisfiability of sentences of first-order logic is undecidable (references link to theorem that the decision problem is unsolvable and link to corollary that first-order satisfiability is undecidable).

But validity and satisfiability of sentences is defined for arbitrary structures, finite or infinite. You might suspect that it is easier to decide if a sentence is satisfiable in a finite structure (or valid in all finite structures). We can adapt the proof of the unsolvability of the decision problem so that it shows this is not the case.

First, if you go back to the proof of link to lemma that validity of the representation implies halting, you'll see that what we did there is produce a model M\Struct Msource of T(M,w)!T(M,w)source which describes exactly what machine MMsource does when started on input wwsource. The domain of that model was \Natsource, i.e., infinite. But if MMsource actually halts on input wwsource, we can build a finite model M\Struct M'source in the same way. Suppose MMsource started on input wwsource halts after kksource steps. Take as domain |M|\Domain{M'}source the set {0,,n}\{0, \dots, n\}source, where nnsource is the larger of kksource and the length of wwsource, and let

M(x)={x+1if x<nnotherwise,\Assign{\prime}{M'}(x) = \begin{cases} x + 1 &\text{if $x < n$}\\ n &\text{otherwise,} \end{cases}source

and x,y<M\tuple{x,y} \in \Assign{<}{M'}source iff x<yx < ysource or x=y=nx = y = nsource. Otherwise M\Struct{M'}source is defined just like M\Struct{M}source. By the definition of M\Struct{M'}source, just like in the proof of link to lemma that validity of the representation implies halting, MT(M,w)\Sat{M'}{!T(M,w)}source. And since we assumed that MMsource halts on input wwsource, ME(M,w)\Sat{M'}{!E(M,w)}source. So, M\Struct{M'}source is a finite model of T(M,w)E(M,w)!T(M,w) \land !E(M,w)source (note that we've replaced \lifsource with \landsource).

We are halfway to a proof: we've shown that if MMsource halts on input wwsource, then T(M,w)E(M,w)!T(M,w) \land !E(M,w)source has a finite model. Unfortunately, the converse of this does not hold, i.e., there are Turing machines that don't halt on some input wwsource, but T(M,w)E(M,w)!T(M,w) \land !E(M,w)source still has a finite model. For instance, consider the machine MMsource with the single state q0q_0source and instruction δ(q0,0)=q0,0,N\delta(q_0,\TMblank) = \tuple{q_0,\TMblank,\TMstay}source. Started on empty input w=Λw = \emptyseqsource, this machine never halts: it is in an infinite loop, but does not change the tape or move the head. All configurations are the same (same state, same head position, same tape contents). We can define a finite structure M\Struct{M''}source that satisfies T(M,Λ)E(M,Λ)!T(M,\emptyseq) \land !E(M,\emptyseq)source (exercise). We can, however, change T(M,w)!T(M,w)source in a suitable way so that such structures are ruled out.

Unsolved undecidability exercise

Let MMsource be a Turing machine with the single state q0q_0source and single instruction δ(q0,0)=q0,0,N\delta(q_0,\TMblank) = \tuple{q_0,\TMblank,\TMstay}source. Let |M|={0,1,2}\Domain{M''} = \{0, 1, 2\}source, M(0)=M(1)=1\Assign{\prime}{M''}(0) = \Assign{\prime}{M''}(1) = 1source and M(2)=2\Assign{\prime}{M''}(2) = 2source, and <M={0,1,1,1,2,2}\Assign{<}{M''} = \{\tuple{0,1}, \tuple{1,1}, \tuple{2,2}\}source. Define Qq0M\Assign{\Obj Q_{q_0}}{M''}source, S0M\Assign{\Obj S_{\TMblank}}{M''}source, and SM\Assign{\Obj S_{\TMendtape}}{M''}source so that T(M,Λ)!T(M,\emptyseq)source and E(M,Λ)!E(M,\emptyseq)source become true and explain why they are. Hint: Observe that δ(q0,)\delta(q_0, \TMendtape)source is undefined. Ensure that

Qq0(1¯,n¯)S(0¯,n¯)x(0¯<xS0(x,n¯))\quad for all ny(Qq0(0¯,y)S(0¯,y))& \Obj Q_{q_0}(\num{1}, \num{n}) \land \Obj S_{\TMendtape}(\num{0}, \num{n}) \land \lforall[x][(\num{0} < x \lif \Obj S_\TMblank(x, \num{n}))] \text{\quad for all $n \in \Nat$}\\ & \lexists[y][(\Obj Q_{q_0}(\num{0}, y) \land \Obj S_{\TMendtape}(\num{0}, y))]source

are both true in M\Struct{M''}source.

Consider the sentences describing the operation of the Turing machine MMsource on input w=σi1σikw = \sigma_{i_1}\dots\sigma_{i_k}source:

  1. Axioms describing numbers and <<source (just like in the definition of T(M,w)!T(M,w)source in link to section Representing Turing Machines).

  2. Axioms describing the input configuration: just like in the definition of T(M,w)!T(M,w)source.

  3. Axioms describing the transition from one configuration to the next:

    For the following, let A(x,y)!A(x, y)source be as before, and let

    B(y)x(x<yxy).!B(y) \ident \lforall[x][(x < y \lif \eq/[x][y])].source
    1. For every instruction δ(qi,σ)=qj,σ,R\delta(q_i, \sigma) = \tuple{q_j, \sigma', \TMright}source, the sentence:

      xy((Qqi(x,y)Sσ(x,y))(Qqj(x,y)Sσ(x,y)A(x,y)B(y)))& \lforall[x][\lforall[y][( (\Obj Q_{q_i}(x, y) \land \Obj S_{\sigma}(x, y)) \lif {}]] \\ &\qquad (\Obj Q_{q_j}(x', y') \land \Obj S_{\sigma'}(x, y') \land !A(x, y) \land !B(y')))source
    2. For every instruction δ(qi,σ)=qj,σ,L\delta(q_i, \sigma) = \tuple{q_j, \sigma', \TMleft}source, the sentence

      xy((Qqi(x,y)Sσ(x,y))(Qqj(x,y)Sσ(x,y)A(x,y)))y((Qqi(0¯,y)Sσ(0¯,y))(Qqj(0¯,y)Sσ(0¯,y)A(0¯,y)B(y)))& \lforall[x][\lforall[y][ ((\Obj Q_{q_i}(x', y) \land \Obj S_{\sigma}(x', y)) \lif {}]]\\ & \qquad (\Obj Q_{q_j}(x, y') \land \Obj S_{\sigma'}(x', y') \land !A(x, y))) \land {}\\ & \lforall[y][((\Obj Q_{q_i}(\num{0}, y) \land \Obj S_{\sigma}(\num{0}, y)) \lif {}]\\ & \qquad (\Obj Q_{q_j}(\num{0}, y') \land \Obj S_{\sigma'}(\num{0}, y') \land !A(\num{0}, y) \land !B(y')))source
    3. For every instruction δ(qi,σ)=qj,σ,N\delta(q_i, \sigma) = \tuple{q_j, \sigma', \TMstay}source, the sentence:

      xy((Qqi(x,y)Sσ(x,y))(Qqj(x,y)Sσ(x,y)A(x,y)B(y)))& \lforall[x][\lforall[y][( (\Obj Q_{q_i}(x, y) \land \Obj S_{\sigma}(x, y)) \lif {}]] \\ &\qquad (\Obj Q_{q_j}(x, y') \land \Obj S_{\sigma'}(x, y') \land !A(x, y) \land !B(y')))source

    As you can see, the sentences describing the transitions of MMsource are the same as the corresponding sentence in T(M,w)!T(M,w)source, except we add B(y)!B(y')source at the end. B(y)!B(y')source ensures that the number yy'source of the “next” configuration is different from all previous numbers 0\Obj 0source, 0\Obj 0'source, dots.

Let T(M,w)!T'(M, w)source be the conjunction of all the above sentences for Turing machine MMsource and input wwsource.

Undecidability lemma

If MMsource started on input wwsource halts, then T(M,w)E(M,w)!T'(M,w) \land !E(M,w)source has a finite model.

Proof

Let M\Struct{M'}source be as in the proof of link to lemma that validity of the representation implies halting, except

|M|={0,,n},M(x)={x+1if x<nnotherwise,x,y<Miff x<y or x=y=n,\Domain{M'} & = \{0, \dots, n\},\\ \Assign{\prime}{M'}(x) & = \begin{cases} x + 1 &\text{if $x < n$}\\ n &\text{otherwise,} \end{cases} \\ \tuple{x,y} \in \Assign{<}{M'} &\text{iff $x < y$ or $x = y = n$,}source

where n=max(k,len(w))n = \max(k,\len{w})source and kksource is the least number such that MMsource started on input wwsource has halted after kksource steps. We leave the verification that MT(M,w)E(M,w)\Sat{M'}{!T'(M,w) \land !E(M,w)}source as an exercise.

Unsolved undecidability exercise

Complete the proof of link to lemma that halting gives a finite model by proving that MT(M,w)E(M,w)\Sat{M'}{!T'(M,w) \land !E(M,w)}source.

Undecidability lemma

If T(M,w)E(M,w)!T'(M,w) \land !E(M,w)source has a finite model, then MMsource started on input wwsource halts.

Proof

We show the contrapositive. Suppose that MMsource started on wwsource does not halt. If T(M,w)E(M,w)!T'(M,w) \land !E(M,w)source has no model at all, we are done. So assume M\Struct{M}source is a model of T(M,w)E(M,w)!T'(M,w) \land !E(M, w)source. We have to show that it cannot be finite.

We can prove, just like in link to configuration representation lemma, that if MMsource, started on input wwsource, has not halted after nnsource steps, then T(M,w)C(M,w,n)B(n¯)!T'(M,w) \Entails !C(M, w, n) \land !B(\num{n})source. Since MMsource started on input wwsource does not halt, T(M,w)C(M,w,n)B(n¯)!T'(M,w) \Entails !C(M, w, n) \land !B(\num{n})source for all nn \in \Natsource. Note that by link to proposition that represented numerals preserve strict order, T(M,w)k¯<n¯!T'(M,w) \Entails \num{k} < \num{n}source for all k<nk < nsource. Also B(n¯)k¯<n¯k¯n¯!B(\num{n}) \Entails \num{k} < \num{n} \lif \eq/[\num{k}][\num{n}]source. So, Mk¯n¯\Sat{M}{\eq/[\num{k}][\num{n}]}source for all k<nk < nsource, i.e., the infinitely many terms k¯\num{k}source must all have different values in M\Struct{M}source. But this requires that |M|\Domain{M}source be infinite, so M\Struct{M}source cannot be a finite model of T(M,w)E(M,w)!T'(M,w) \land !E(M, w)source.

Unsolved undecidability exercise

Complete the proof of link to lemma that a finite model gives halting by proving that if MMsource, started on input wwsource, has not halted after nnsource steps, then T(M,w)B(n¯)!T'(M,w) \Entails !B(\num{n})source.

Undecidability theorem

[Trakhtenbrot's Theorem] It is undecidable if an arbitrary sentence of first-order logic has a finite model (i.e., is finitely satisfiable).

Proof

Suppose there were a Turing machine FFsource that decides the finite satisfiability problem. Then given any Turing machine MMsource and input wwsource, we could compute the sentence T(M,w)E(M,w)!T'(M,w) \land !E(M,w)source, and use FFsource to decide if it has a finite model. By references link to lemma that halting gives a finite model and link to lemma that a finite model gives halting, it does iff MMsource started on input wwsource halts. So we could use FFsource to solve the halting problem, which we know is unsolvable.

Undecidability corollary

There can be no derivation system that is sound and complete for finite validity, i.e., a derivation system which has B\Proves !Bsource iff MB\Sat{M}{!B}source for every finite structure M\Struct{M}source.

Proof

Exercise.

Unsolved undecidability exercise

Prove link to corollary excluding a sound and complete proof system for finite validity. Observe that B!Bsource is satisfied in every finite structure iff ¬B\lnot !Bsource is not finitely satisfiable. Explain why finite satisfiability is semi-decidable in the sense of link to theorem that first-order validity is semidecidable. Use this to argue that if there were a derivation system for finite validity, then finite satisfiability would be decidable.

Source disclosures