You are on page 1of 8

Automata Theory and Computability (18CS54) Module 4

Global Academy of Technology


RR Nagar, Bengaluru – 560098
Department of Computer Science and Engineering
(Accredited by NBA 2019-2022)

V Semester
Automata Theory and Computability (18CS54)
[As per Choice Based Credit System (CBCS) Scheme]

MODULE - 4

Turing Machines

Turing Machine is a modified version of PDA and more powerful than PDA. Instead of using stack
as in PDA, Turing Machine uses the tape to store the symbols. Turing Machine is a generalized
machine which can recognize all types of languages via Regular Languages, Context Free Languages
etc.
A Turing Machine (TM) is a mathematical model which consists of an infinite length tape divided
into cells on which input is given.
It consists of a head which reads the input tape. A state register stores the state of the Turing machine.
After reading an input symbol, it is replaced with another symbol, its internal state is changed, and it
moves from one cell to the right or left. If the TM reaches the final state, the input string is accepted,
otherwise rejected.

Definition :
A TM can be formally described as a 7-tuple machine.
M = (Q, ∑, , d, q0, B, F)
Where
Q = set of finite states
∑ = set of input alphabets
 = set of tape symbols
d = Transition Function Q x t to Q x t x (L,R)
q0= Start state
B = Special symbol indicating blank character
FQ = Set of Final states

Turing Machine Model


Tape :
• It is used to store the information and is divided into cells.
• Each cell can store the information of only one symbol.
• The string to be scanned will be stored from left most position on the tape.
• The string to be scanned should end with blanks.
• The tape is assumed to be infinite both the sides.

By Vanishree M L, Dept. of CSE, GAT pg. 1


Automata Theory and Computability (18CS54) Module 4

Read-write head :
It can read a symbol from where it is pointing to and it can write into the tape to where it points to.
Control Unit :
The reading from the tape or writing into the tape is determined by the control unit.
The different moves performed by the machine depend upon the current scanned symbol and current
state.

Various actions performed by the machine are


1. Change of state
2. Symbol pointing to by read-write head can be replaced by another symbol.
3. Read-write head may move either towards left or right.

1. Obtain a Turing Machine to accept the Language L = {0n 1n | n≥1 }

Valid strings :
n=1 w = 01
n=2 w = 0011
n=3 w = 000111
n=4 w = 00001111

Invalid strings :
w = 011
w = 001

General Procedure :
Let q0 be the start state and let the read-write head points to the first symbol of the string to be
scanned.
1. Replace the left most 0 by X and change the state to q1 and then move the read-write head
towards right to obtain the corresponding 1.
2. Search for the leftmost 1 and replace it by symbol Y and move towards left to obtain the
leftmost 0 again.
These 2 steps can be repeated until blank symbol is obtained.

If B is found, write the same symbol and move one step right and accept the string.

By Vanishree M L, Dept. of CSE, GAT pg. 2


Automata Theory and Computability (18CS54) Module 4

….. 0 0 0 1 1 1 B …..

X X X Y Y Y B

Transition Diagram

M = (Q, ∑, , d, q0, B, F)
Where
Q = set of finite states = {q0, q1, q2, q3, q4}
∑ = set of input alphabets = {0, 1}
 = set of tape symbols = {0, 1, X, Y, B}
d = Transition Function Q x t to Q x t x (L,R)
q0= Start state
B = Special symbol indicating blank character
FQ = Set of Final states ={q4}

Transition Table
 Tape Symbols

States 0 1 X Y B

→q0 (q1, X, R) - - (q3, Y, R) -

q1 (q1, 0, R) (q2, Y, L) - (q1, Y, R) -

q2 (q2, 0, L) - (q0, X, R) (q2, Y, L) -

q3 - - - (q3, Y, R) (q4, B, R)

*q4 - - - - -

By Vanishree M L, Dept. of CSE, GAT pg. 3


Automata Theory and Computability (18CS54) Module 4

Instantaneous Description

Unlike the ID described in PDA, the ID in TM depends upon


1. Whole string (not on the string to be scanned)
2. Current state of the machine

Definition of ID
ID of TM is defined as : q
• q is the current state of the TM
• The given string is divided into substring  and  such that the given string is obtained by
concatenating  and .
• Initial ID is denoted by q where q is the start state and read-write head points to the first
symbol of  from left.
• Final ID is denoted by string qB where q is the final state and read-write head points to
the blank symbol B.

ID for the string 0011


Initial ID q00011
|- Xq1011
|- X0q111
|- Xq20Y1
|- q2X0Y1
|- Xq00Y1
|- XXq1Y1
|- XXYq11
|- XXq2YY
|- Xq2XYY
|- XXq0YY
|- XXYq3Y
|- XXYYq3B
|- XXYYBq4
(Final ID)

2. Obtain a Turing Machine to accept the Language L = {0n 1n 2n | n≥1 }

By Vanishree M L, Dept. of CSE, GAT pg. 4


Automata Theory and Computability (18CS54) Module 4

 Tape Symbols
States 0 1 2 X Y Z B
→q0 (q1, X, R) - - - (q4, Y, R) - -
q1 (q1, 0, R) (q2, Y, R) - - (q1, Y, R) - -
q2 - (q2, 1, R) (q3, Z, L) - - (q2, Z, R) -
q3 (q3, 0, L) (q3, 1, L) - (q0, X, R) (q3, Y, L) (q3, Z, L) -
q4 - - - - (q4, Y, R) (q5, Z, R) -
q5 - - - - - (q5, Z, R) (q6, B, R)
*q6 - - - - - - -

3. Obtain Turing Machine to accept Language containing 0s and 1s and has the substring 001.

This is a Regular Expression. Hence draw DFSM first.


DFSM for substring 001

Transition Table of TM

 0 1 B
→q0 (q1, 0, R) (q0, 1, R) -
q1 (q2, 0, R) (q0, 1, R) -
q2 (q2, 0, R) (q3, 1, R) -
q3 (q3, 0, R) (q3, 1, R) (q4, B, R)
*q4 - - -

Transition Diagram of TM

By Vanishree M L, Dept. of CSE, GAT pg. 5


Automata Theory and Computability (18CS54) Module 4

4. Obtain Turing Machine to accept Language L = { w | w is even, S = {a, b}* }

DFSM for w even

 a b
→q0 q1 q1
q1 q0 q0

Transition Table of TM

 a b B
→q0 (q1, a, R) (q1, b, R) (q2, b, R)
q1 (q0, a, R) (q0, b, R) -
q2 - - -

Transition Diagram of TM

Variants of Turing Machine

1. Multitape Turing Machines

A multitape TM has a finite set Q of states, an initial state qo , a subset F of Q called the set of final
states, a set P of tape symbols, a new symbol b, not in P called the blank symbol.
There are k tapes. each divided into cells. The first tape holds the input string w. Initially. all the other
tapes hold the blank symbol. Initially the head of the first tape (input tape) is at the left end of the
input w. All the other heads can be placed at any cell initially.
 is a partial function from Q x k into Q x k x {L, R, S}k. We use implementation description to
define . Figure 9.8 represents a multitape TM.A move depends on the current state and k tape
symbols under k tape heads.

By Vanishree M L, Dept. of CSE, GAT pg. 6


Automata Theory and Computability (18CS54) Module 4

In a typical move:
(i) M enters a new state.
(ii) On each tape. a new symbol is written in the cell under the head.
(iii) Each tape head moves to the left or right or remains stationary. The heads move independently:
some move to the left, some to the right and the remaining heads do not move.
The initial ill has the initial state q0, the input string win the first tape(input tape), empty strings of b's
in the remaining k - 1 tapes.

2 Nondeterministic Machines

In the case of standard Turing machines, (q1,a) was defined as an element of Qx x {L, R}.
In a nondeterministic TM,(q1, a) is defined as a subset of Q x x {L, R}.

Definition 9.5 A nondeterministic Turing machine is a 7-tuple (Q, ,,, qo, b, F) where
1. Q is a finite nonempty set of states
2. r is a finite nonempty set of tape symbols
3. b E r is called the blank symbol
4. L is a nonempty subset of 1. called the set of input symbols.
5. qo is the initial state
6. F  Q is the set of final states
7.  is a partial function from Q x r into the power set of Q x x {L, R}.

The Model of Linear Bounded Automaton

This model is important because (a) the set of context-sensitive languages is accepted by the model.
and (b) the infinite storage is restricted in size but not in accessibility to the storage in comparison
with the Turing machine model. Itis called the linear bounded automaton (LBA) because a linear
function is used to restrict (to bound) the length of the tape. In this section we define the model of
linear bounded automaton and develop the relation between the linear bounded automata and context-
sensitive languages. It should be noted that the study of context-sensitive languages is important from

By Vanishree M L, Dept. of CSE, GAT pg. 7


Automata Theory and Computability (18CS54) Module 4

practical point of view because many compiler languages lie between context-sensitive and context-
free languages.
A linear bounded automaton is a non deterministic Turing machine which has a single tape whose
length is not infinite but bounded by a linear function of the length of the input string. The models
can be described formally by the following set format:
M = (Q, , , , q0, b, ¢, S, F)
All the symbols have the same meaning as in the basic model of Turing machines with the difference
that the input alphabet L contains two special symbols ¢ and $. ¢ is called the left-end marker which
is entered in the leftmost cell of the input tape and prevents the RIW head from getting off the left
end of the tape. $ is called the right-end marker which is entered in the rightmost cell of the input tape
and prevents the RIW head from getting off the rightend of the tape. Both the end markers should not
appear on any other cell within the input tape, and the RIW head should not print any other symbol
over both the end markers. Let us consider the input string w with II-vi = 11 - 2. The input string w
can be recognized by an LBA if it can also be recognized by a Turing machine using no more than
kn cells of input tape, where k is a constant specified in the description of LBA. The value of k does
not depend on the input string but is purely a property of the machine. Whenever we process any
string in LBA, we shall assume that the input string is enclosed within the end markers ¢ and $.

The above model of LBA can be represented by the block diagram of Fig. 9.11.There are two tapes:
one is called the input tape, and the other, working tape. On the input tape the head never prints and
never moves to the left. On the working tape the head can modify the contents in any way, without
any restriction.

By Vanishree M L, Dept. of CSE, GAT pg. 8

You might also like