Ch.4 Turing Machines
Ch.4 Turing Machines
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
• Here we study a new device which can
recognize these and many more complicated
languages.
• These machines are called Turing Machines,
named after the inventor
Allan Turing(1912-54).
• These are more general than automata we
studied earlier.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
The basic appearance is similar to that of
automata.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
• The formal definition of a TM and their
operations are in the same mathematical
style as those used for FA and PDA.
• TM is not simply one more class of
automata to be replaced by a more
powerful type.
• We see that as primitive as TM seem to
be, attempts to strengthen them do not
have any effect.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Ex: Even we augment this TM model with
RA memory like what we have in any
computer will not increase the power of a
TM.
• So any fancier machine can be converted
into a TM with analogous functionality.
• Hence any computation carried out by a
fancier machine can be actually be carried
out by a TM.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Hence the TM seem to form a stable and maximal
class of computational devices, in terms of
computations they can perform.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
• TM has : Finite control, Tape, and a R/W
head
Note: The tape has a left end but no right end (extends
infinitely).
To prevent the machine moving its head off the left end,
we assume that the left most end/cell of the tape is
marked with a special symbol.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
• All the TMs are so designed that, when the head
reads ∆ it immediately moves to the right.
• We use distinct symbols , and to denote
head movements. We also assume that the two
symbols are not part of any alphabet.
• We give input to the TM by inscribing the string
on the tape.
• The rest of the tape is initially contains blanks
denoted by U.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
• The machine is free to alter its input in any
way as it needs.
• It can also write on the blank portion of the
tape to the right.
• The RW head can move by only one
square to the left or right at a time.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Formal definition
Such that
(b) For all q€ K-H, and a€∑, if δ(q,a)= (p,b) then b≠∆
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
If q € K-H, and a€∑, and δ(q,a)= (p,b) then then M when in
state q and scanning symbol a, will enter state p, and
(1) If b is symbol in ∑, M will rewrite currently scanned symbol a
with b.
or
(2) If b is or , M will move its in the direction of b
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
• We shall adopt a notation similar to that of
the automata we have seen earlier (states
and arrows representing the transitions).
• Here in this case things that are joined are
TMs themselves.
• In other terms we use a hierarchical
notation, in which more complex machines
are built from simpler machines.
• We shall define a set of basic machines
and rules to combine them.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Symbol-writing machines:
Head-moving machines:
alphabet a € (∑ U{, } – {∆})
Ma= ({s,h}, ∑, δ, s, {h})
Where for each b € ∑– {∆} , δ(s,b)= (h,a)
δ(s,∆) is still (s,)
Only thing this machine does is to perform action a-
writing a if a € ∑ , moving in the direction indicated
by a if a € {,} and then to immediate halt.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
We abbreviate symbol-writing machine Ma with a
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Rules for combining machines
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
We fix some conventions for the use of TMs:
1. The input string, with no blanks in it, is written
to the right of the leftmost symbol ∆, with a
blank to its left and a blank to its right.
2. The head is positioned at the tape square
containing the blank between ∆ and the input.
3. The machine starts operating in its initial state.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Ex: If M= ( K, ∑ , δ, s, H ) is a TM
and w€ (∑ - {U, , ∆})
Then initial configuration= (s, ∆Uw)
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Let M= ( K, ∑ , δ, s, H ) be a TM such that H={y, n}
consists of two distinguished halting states
(y for “yes”, and n for “no”)
Any configuration whose state component is y is
called as an accepting configuration.
A halting configuration whose state component n is
called a rejecting configuration.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
We say that M accepts string w€ (∑ - {U, , ∆})*
If (s, ∆Uw) yields an accepting configuration
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
The Turing Machine M decides a language L
1. if it accepts or
2. Rejects it
That is a TM decides a language L if, when started
with input w, it always halts
No guarantees are given about wrong input.
A language L is recursive if there is a TM that
decides it.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
L={anbncn: n≥0}
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Let M= ( K, ∑ , δ, s, {h} ) be a TM,
∑0 subset of (∑ - {U, , ∆}) be an alphabet let w€ ∑0 *
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Let M= ( K, ∑ , δ, s, {h} ) be a TM,
∑0 subset of (∑ - {U, , ∆}) be an alphabet
And let L is subset of ∑0 *
We say that M semidecisde L if for any w€ ∑0 *
if and only if M halts on input w.
A language L is recursively enumerable if and only if
there is a TM M that semidecides L.
If a L is recursive, then it is also recursively enumerable.
If a L is recursive, then it is complement is also.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Extensions of the Turing
Machine
It is clear that Turing machines can perform fairly
powerful computations.
We shall consider the effect of extending the TM
model in various directions.
We shall see that in each case the additional
features do not add to the classes of computable
functions or decidable languages : the “new,
improved model” of the TM in each instance be
simulated by the standard model.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Turing Machines with multiple
tapes
We can think of a TMs that have several tapes.
Each tape is connected to the finite control by
means of a R/W head( one on each tape).
The machine can in one step read the symbols
scanned by all its heads and then depending on
those symbols and its current state, write some of
those scanned squares and move some of heads to
the right or left, in addition to changing state.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
For any fixed integer k≥1, a k-tape Turing machine is
a Turing machine equipped as above with k tapes
and with corresponding heads.
Thus a standard TM with single tape can be seen as
a k-tape TM, where k=1.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Let M= ( K, ∑ , δ, s, H) be a k-tape TM, where k≥1
Where
K, ∑, s, and H have as in the definition of the
ordinary TM, and δ, transition function is a function
from
(K-H) X ∑k KX(∑ U{, })k
Ex: δ(q, (a1,.., ak))= (p, (b1,.., bk))
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Ex: to transform ∆UwU into ∆UwUwU
1. Move the heads on both tapes to the right, copying
each symbol on the first tape onto the second tape,
until a blank is found on the first tape. The square of
the second tape should be left blank.
2. Move the head on the second tape to the left until a
blank is found.
3. Again move the heads on both tapes to the right, this
time copying symbols from the second tape onto the
first one.
4. Halt when a blank is found on the second tape.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Two-way infinite tapes
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Two-dimensional tape
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
summary
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
R3
k
Program counter
R2
R1
Registers
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Random Access Turing
Machines
1. A RATM has a fixed number of registers and one-
way infinite tape (memory).
2. Each register and each tape square is capable of
containing an arbitrary natural number.
3. The TM acts on its tape squares and registers as
dictated by a fixed program- the analog of the
transition function of ordinary TMs.
4. The program of a RATM is a sequence of
instructions.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
5. Initially the register values are 0, the program counter is
k =1, and the tape content encode the input string.
6. Then the machine executes the first instruction of its
program. This will change the contents of the registers
or of the tape squares, the value of program counter k,
an integer indicating the next instruction to be
executed.
7. Register R0 is an accumulator
8. This will continue until halt instruction is executed.
9. When halt is executed, then the k=0
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Kind of instructions allowed are
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Description
The description of a RA TM is a pair
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Non-deterministic Turing
Machines
Another important feature of TM is non-determinism.
In case of FA, it is allowed to act non-deterministically,
without increase in it power.
But the non-deterministic PDA are more powerful than
deterministic ones.
We can also imagine Turing machines that act
non-deterministically.
Such machines might have, on certain combination of state
and scanned symbol, more than one possible choice of
behavior.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Non-deterministic Turing
Machines
A deterministic TM is ( K, ∑ , δ, s, H )
Where δ is a function from (K-H) X ∑ to KX(∑ U{, })
A non-deterministic Turing machine is a quintuple
M= ( K, ∑ , ∆, s, H ) where K, ∑ ,s, and H are as for
standard TM
∆ is subset of
((K-H) X ∑ ) X (KX(∑ U{, }))
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Grammars (Unrestricted
Grammars)
The class of language generated by Grammars is precisely
the class of recursively enumerable ones.
A language is generated by a Grammar if and only if it is
recursively enumerable.
The left-hand side of a rule may consist of more than one
NT with terminals; but at least with on NT
Final product is a string of terminals.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus
Grammars (Unrestricted
Grammars)
The class of language generated by Grammars is precisely
the class of recursively enumerable ones.
A language is generated by a Grammar if and only if it is
recursively enumerable.
The left-hand side of a rule may consist of more than one
NT with terminals; but at least with on NT
Final product is a string of terminals.
CSC / CSF 351 Theory of Computation Dr.R.Gururaj BITS Pilani, Hyderabad Campus