Lecture 12: Turing Machines

- The Turing machine is the most fundamental model of computation. It defines what we mean by the term "computable."
- A Turing machine is a generalization of a finite automaton.
At any moment in time, it can be pictured as a finite-state control with
a tape head reading a symbol on a square of its infinite input tape.
Initially, a finite length input string
*a*_{1}*a*_{2}…*a*_{n}appears on the input tape with the tape head reading a_{1}and the finite control in a designated initial state. The symbols of the input string appear to the right of*a*_{1}in contiguous squares of the input tape. An infinite number of blank symbols are on the input tape to the left of*a*_{1}and to the right of*a*_{n}. - At the beginning of a move, a Turing machine reads the symbol on the square of the input tape under the tape head and consults the transition function (its "program") stored in its finite-state control. During the move it makes a state transition, replaces the symbol on the input tape with another tape symbol, and shifts the tape head one square to the left or one square to the right. If it has not entered a halting state, the Turing machine then makes another move.
- After a finite (but perhaps very large) number of moves the Turing
machine may enter a final state and halt, in which case it is said to accept the
input string
*a*_{1}*a*_{2}…*a*_{n}that was originally on the input tape. However, the Turing machine may instead enter a nonfinal state and halt, or it may make an infinite sequence of moves without ever entering a final state. In both these cases it does not accept the original input string. - More formally, a nondeterministic Turing machine
*M*has seven components: (*Q*, Σ, Γ, δ,*q*_{0}, B,*F*) *Q*is the finite set of states of the finite control.- Σ is the finite set of input symbols.
- Γ is the finite set of tape symbols; Σ is a subset of Γ.
- δ is the transition function. It maps
(
*Q*× Γ) to subsets of (*Q*× Γ × {L, R}). If δ(*q*,*X*) contains (*p*,*Y*,*D*) and*M*is in state*q*reading the symbol*X*on the input tape, then*M*can - go from state
*q*to state*p*, - replace the symbol
*X*on the input tape by the symbol*Y*, and - move its input head one square in the direction
*D*where*D*can be either L (for left) or R (for right). *M*is*deterministic*if there is at most one element in δ(*q*,*X*) for any state*q*and tape symbol*X*. Unless otherwise qualified, the term "Turing machine" will signify a deterministic Turing machine.*q*_{0}is the start state.- B is the blank symbol. B is in Γ but not in Σ.
*F*, a subset of*Q*, is the set of final accepting states. We assume there are no transitions from a final state so that when*M*enters a final state it halts.- During a sequence of moves
we can represent the configuration of
*M*by an instantaneous description (ID) of the form*X*_{1}*X*_{2}…*X*_{i-1}*qX*_{i}*X*_{i+1}…*X*_{n}. This ID says*M*is in state*q*reading the tape symbol*X*_{i}. To the left of*X*_{i}is the string of tape symbols*X*_{1}X_{2}…*X*_{i-1}. To the right of*X*_{i}is the string of tape symbols*X*_{i+1}…*X*_{n}. We do not show blanks on the input tape unless necessary. - The read head may be one input square past the right end of the
nonblank symbols the input tape
reading a blank in which case
*M*is in the ID*X*_{1}*X*_{2}…*X*_{n}*q*B. - Suppose
*M*is in the ID*X*_{1}*X*_{2}…*X*_{i-1}*qX*_{i}*X*_{i+1}…*X*_{n}. Moves by*M*are modeled by the following changes to the ID: - If δ(
*q*,*X*_{i}) contains (*p*,*Y*, L),*M*can move to the ID -
*X*_{1}*X*_{2}…*X*_{i-2}*pX*_{i-1}*Y**X*_{i+1}…*X*_{n}. - If
*i*= 1, then*M*moves before the blank to the left of*X*_{1}in which case the ID becomes -
*p*B*YX*_{2}…*X*_{n}. - If
*i*=*n*and*Y*= B, then*M*replaces*X*_{n}by a blank and the ID becomes -
*X*_{1}*X*_{2}…*X*_{n-2}*pX*_{n-1}. - If δ(
*q*,*X*_{i}) contains (*p*,*Y*, R),*M*can move to the ID -
*X*_{1}*X*_{2}…*X*_{i-1}*YpX*_{i+1}…*X*_{n}. - If
*i*=*n*, then*M*moves to the blank to the right of*X*_{n}in which case the ID becomes -
*X*_{1}*X*_{2}…*X*_{n-1}*Yp*B. - If
*i*= 1 and*Y*= B, then*M*replaces*X*_{1}by a blank and the ID becomes -
*pX*_{2}…*X*_{n}. - L(
*M*), the language accepted by*M*, is the set of strings*w*in Σ* such that*q*_{0}*w*|–* α*p*β for some state*p*in*F*. - We say that a language
*L*is*recursively enumerable*if*L*= L(*M*) for some Turing machine*M*. Some authors use the term*Turing-recognizable*for a recursively enumerable language. - See Example 8.2, p. 329, HMU for a TM that accepts
the language {0
^{n}1^{n}|*n*≥ 1 }.

- We say that a language
*L*is*recursive*if*L*= L(*M*) for some Turing machine*M*such that: - If
*w*is in*L*, then*M*accepts*w*and therefore halts. - If
*w*is not in*L*, then*M*eventually halts but never enters an accepting state. - A Turing machine that halts on all inputs either in an accepting or
nonaccepting state provides a precise definition for the term
*algorithm*. This formalizes our intuitive notion of an algorithm as a collection of simple instructions for carrying out some task. - A language
*L*is said to be*decidable*if it is a recursive language. Some authors use the term*Turing-decidable*for a decidable language. - A language
*L*is said to be*undecidable*if it is not a recursive language.

- Hilbert's problems
- In 1900, David Hilbert, the eminent mathematician of his day, presented a famous list of twenty-three problems at the International Congress of Mathematicians in Paris.
- Hilbert's tenth problem was to devise a process according to which it can be determined by a finite number of operations whether a polynomial with integer coefficients (Diophantine equation) has an integral root.
- For example, the polynomial Diophantine equation
- 6
over the variables*x*^{3}*y**z*^{2}+ 3*x**y*^{2}-*x*^{3}- 10 = 0*x*,*y*, and*z*has an integral root at*x*= 5,*y*= 3, and*z*= 0. The root is said to be integral because all variables are assigned integer values. - 6
- In 1931 Kurt Gödel published his famous incompleteness theorems which basically said that in any reasonable system of formalizing the notion of provability in number theory, some true statements are unprovable. This shattered Hilbert's dream of finding a complete and consistent set of axioms for all of mathematics (Hilbert's second problem).
- In 1936 Alonzo Church wrote a paper in which he devised a notation called the lambda calculus to define algorithms. The lambda calculus is the basis for the programming language Lisp.
- In 1936 Alan Turing wrote a paper ("On computable numbers with an application to the Entscheidungsproblem", Proc. London Math. Society) in which he defined Turing machines and showed that the halting problem for Turing machines is undecidable.
- The machine
*M*in Alan Turing's paper accepted by just halting -- there is no final state. Let H(*M*) be the set of inputs*w*on which his machine halts. Turing showed that the set of pairs (*M*,*w*) such that*w*is in H(*M*) is recursively enumerable but not recursive. - The Church-Turing thesis hypothesizes that any function that can be computed (an "effectively computable function") can be computed on a Turing machine.
- In 1970, Yuri Matiyasevich showed that no algorithm exists for testing whether a Diophantine equation has integral roots.

- Many variants of Turing machines have been defined such as:
- Turing machines with a semi-infinite input tape.
- Multitape Turing machines.
- Turing machines with tapes having multiple tracks.
- Nondeterministic Turing machines.
- All these machines are equivalent to our definition of a deterministic Turing machine.
- Other universal models of computation:
- Chomsky type 0 grammars. A type 0 grammar is like a context-free grammar (V, T, P, S) except that productions can be of the form α → β where α is a string of nonterminals and terminals with at least one nonterminal and β is any string of nonterminals and nonterminals.
- The lambda calculus.
- Pushdown automata with two or more stacks.
- Two-counter machines.
- Random access machines.
- Most programming languages.
- Real computers with an arbitrary amount of memory.
- Again, all these models are computationally equivalent to our definition of a deterministic Turing machine.

- Design a Turing machine that accepts all strings of
*a*'s and*b*'s with an equal number of*a*'s and*b*'s. Show the sequence of moves your Turing machine makes on the input*aabb*. - HMU, Exercise 8.2.5.

- HMU: Chapter 8

aho@cs.columbia.edu verma@cs.columbia.edu