Chapter05 TM
Chapter05 TM
5.1 Overview
▪ So far we have discussed some fundamental ideas, the concepts of
regular and context-free languages and their association with finite
automata and pushdown automata.
▪ The regular languages form a proper subset of the context-free
languages and, therefore, that pushdown automata are more powerful
than finite automata.
▪ The context-free languages, while fundamental to the study of
programming languages, are limited in scope.
▪ Some simple languages, such as {anbncn}, is not context-free.
▪ This prompts us to look beyond context-free languages and investigate
how one might define new language families that include these
examples.
▪ A Turing Machine, which is a very simple structure, turns out to be
very powerful and lets us solve many problems that cannot be solved
with a pushdown automaton.
▪ Turing machines are the most general types of automata, in principle
as powerful as any computer.
5.2 Standard Turing Machine
▪ Although we can envision a variety of automata with complex and
sophisticated storage devices, a Turing machine’s storage is actually
quite simple.
▪ It can be visualized as a single, one-dimensional array of cells, each of
which can hold a single symbol.
▪ This array extends indefinitely in both directions and is therefore
capable of holding an unlimited amount of information.
▪ The information can be read and changed in any order.
▪ We call such a storage device a tape.
Definition of a Turing Machine
▪ A Turing machine is an automaton whose temporary storage is a tape.
▪ This tape is divided into cells, each of which is capable of holding one
symbol.
▪ Associated with the tape is a read-write head that can travel right or
left on the tape and that can read and write a single symbol on each
move.
▪ A Turing machine will have neither an input file nor any special output
mechanism.
▪ Whatever input and output is necessary will be done on the machine’s
tape.
Turing Machine Pushdown Automata
Finite Automata
A Turing machine M is defined by
M = (Q, Σ, Γ, δ, q0, B, F),
where
Q is the set of internal states,
Σ is the input alphabet,
Γ is a finite set of symbols called the tape alphabet,
δ is the transition function,
B ∈ Γ is a special symbol called the blank,
q0 ∈ Q is the initial state,
F ⊆ Q is the set of final states.
…cont’d
▪ Σ ⊆ Γ−{B}, that is, that the input alphabet is a subset of the tape
alphabet, not including the blank.
▪ The transition function δ is defined as
δ : Q × Γ → Q × Γ × {L, R} .
▪ The arguments of δ are the current state of the control unit and the
current tape symbol being read.
▪ The result is a new state of the control unit, a new tape symbol, which
replaces the old one, and a move symbol, L or R.
▪ The move symbol indicates whether the read-write head moves left or
right one cell after the new symbol has been written on the tape.
…cont’d
▪ Example – the following figure shows the situation before and after
the move
δ (q0, a)=(q1, d, R).
The situation (a) before the move and (b) after the move.
…cont’d
▪ We can think of a Turing machine as a rather simple computer.
▪ It has a processing unit, which has a finite memory, and in its tape, it
has a secondary storage of unlimited capacity.
▪ The instructions that such a computer can carry out are very limited: It
can sense a symbol on its tape and use the result to decide what to do
next.
▪ The only actions the machine can perform are to rewrite the current
symbol, to change the state of the control, and to move the read-write
head.
▪ As always, the automaton starts in the given initial state with some
information on the tape.
…cont’d
▪ It then goes through a sequence of steps controlled by the transition
function δ.
▪ During this process, the contents of any cell on the tape may be
examined and changed many times.
▪ Eventually, the whole process may terminate, which we achieve in a
Turing machine by putting it into a halt state.
▪ A Turing machine is said to halt whenever it reaches a configuration
for which δ is not defined
▪ No transitions are defined for any final state, so the Turing machine
will halt whenever it enters a final state.
…cont’d
▪ Example: Consider the Turing machine defined by
Q = {q0, q1} ,
Σ = {a, b} ,
Γ = {a, b, B} ,
F = {q1} ,
and
δ (q0, a)=(q0, b, R),
δ (q0, b)=(q0, b, R),
δ (q0, B)=(q1, B, L).
…cont’d
▪ If this Turing machine is started in state q0 with the symbol a under the
read-write head, the applicable transition rule is δ (q0, a)=(q0, b, R).
Therefore, the read-write head will replace the a with a b, then move
right on the tape. The machine will remain in state q0. Any subsequent
a will also be replaced with a b, but b’s will not be modified. When the
machine encounters the first blank, it will move left one cell, then halt
in final state q1.
A sequence of moves
…cont’d
▪ As before, we can use transition graphs to represent Turing machines.
Now we label the edges of the graph with three items: the current tape
symbol, the symbol that replaces it, and the direction in which the
read-write head is to move
…cont’d
▪ Since one can make several different definitions of a Turing machine,
it is worthwhile to summarize the main features of our model, which
we will call a standard Turing machine:
▪ The Turing machine has a tape that is unbounded in both
directions, allowing any number of left and right moves.
▪ The Turing machine is deterministic in the sense that δ defines at
most one move for each configuration.
▪ There is no special input file. We assume that at the initial time the
tape has some specified content. Some of this may be considered
input. Similarly, there is no special output device. Whenever the
machine halts, some or all of the contents of the tape may be
viewed as output.
Instantaneous Description of TM
▪ The most convenient way to exhibit a sequence of configurations of a
Turing machine uses the idea of an instantaneous description.
▪ Any configuration is completely determined by the current state of the
control unit, the contents of the tape, and the position of the read-write
head.
We will use the notation in which
x1qx2
or
a1a2 ··· ak−1qakak+1 ··· an
is the instantaneous description of a machine in state q with the tape
depicted in following Figure.
▪ The symbols a1, ..., an show the tape contents, while q defines the state
of the control unit. The position of the read-write head is over the cell
containing the symbol immediately following q.
▪ The instantaneous description gives only a finite amount of
information to the right and left of the read-write head.
…cont’d
▪ The unspecified part of the tape is assumed to contain all blanks;
normally such blanks are irrelevant and are not shown explicitly in the
instantaneous description.
▪ If the position of blanks is relevant to the discussion, however, the
blank symbol may appear in the instantaneous description.
▪ For example, the instantaneous description qBw indicates that the
read-write head is on the cell to the immediate left of the first symbol
of w and that this cell contains a blank.
…cont’d
▪ The pictures drawn in the following Figure correspond to the sequence
of instantaneous descriptions q0aa, bq0a, bbq0 , bq1b.