COMS W3261 CS Theory
Lecture 12: Turing Machines
1. 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
a1a2 … an
appears on the input tape with the tape head reading a1
and the finite control in a designated initial state.
The symbols of the input string appear to the right of
a1 in contiguous squares of
the input tape.
An infinite number of blank symbols are on the input tape
to the left of a1 and to the right of
an.
- 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
a1a2 … an
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, Σ, Γ, δ, q0, 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.
- q0 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
X1X2 …
Xi-1 qXiXi+1 … Xn.
This ID says M is in state q reading
the tape symbol Xi.
To the left of Xi
is the string of tape symbols
X1X2 … Xi-1.
To the right of Xi
is the string of tape symbols
Xi+1 … Xn.
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 X1X2 … XnqB.
- Suppose M is in the ID
X1X2 … Xi-1 qXiXi+1 … Xn.
Moves by M are modeled by the following changes to the ID:
- If δ(q, Xi) contains
(p, Y, L),
M can move to the ID
- X1X2 …
Xi-2 pXi-1Y
Xi+1 … Xn.
- If i = 1, then M moves before the blank to the left of
X1 in which case the ID becomes
- pBYX2 … Xn.
- If i = n and Y = B, then M replaces
Xn by
a blank and the ID becomes
- X1X2 …
Xn-2 pXn-1.
- If δ(q, Xi) contains
(p, Y, R), M can move to the ID
- X1X2 …
Xi-1YpXi+1 … Xn.
- If i = n, then M moves to the blank to the right
of Xn
in which case the ID becomes
- X1X2 …
Xn-1YpB.
- If i = 1 and Y = B, then M replaces X1 by
a blank and the ID becomes
- pX2 … Xn.
- L(M), the language accepted by M, is the set of strings
w in Σ*
such that q0w |–* α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 {0n1n | n ≥ 1 }.
2. Algorithms and Recursive Languages
- 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.
3. Some History
- 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
- 6x3yz2 +
3xy2 - x3 - 10 = 0
over the variables 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.
- 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.
4. Models of Computation Equivalent to Turing Machines
- 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.
5. Practice Problems
- 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.
6. Reading
aho@cs.columbia.edu
verma@cs.columbia.edu