Flat Unit 4
Flat Unit 4
UNIT-4
Turing Machine
Dr. K. Dhanasekaran
School of Computing
Department of Data Science and Business Systems
SRMIST KTR Campus, Chennai
Turing Machine-Definition
⚫ A Turing Machine accepts the recursively enumerable
language generated by type 0 grammars.
⚫ It was invented in 1936 by Alan Turing.
⚫ 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.
Turing Machine-Formal Definition
⚫ A TM can be formally described as a 7-tuple
(Q, X, ∑, δ, q0, B, F) where −
⚫ Q is a finite set of states
⚫ X is the tape alphabet
⚫ ∑ is the input alphabet
⚫ δ is a transition function;
δ : Q × X → Q × X × {Left_shift, Right_shift}.
⚫ q0 is the initial state
⚫ B is the blank symbol
⚫ F is the set of final states
Example of Turing machine
⚫ Turing machine M = (Q, X, ∑, δ, q0, B, F) with
⚫ Q = {q0, q1, q2, qf}
⚫ X = {a, b}
⚫ ∑ = {1}
⚫ q0 = {q0} Tape Present State Present State Present State
⚫ B = blank symbol alphabet ‘q0’ ‘q1’ ‘q2’
symbol
⚫ F = {qf }
a 1Rq1 1Lq0 1Lqf
⚫ δ is given by −
b 1Lq2 1Rq1 1Rqf
⚫ A k-track Turing machine(for some k>0) has k-tracks and one R/W
head that reads and writes all of them one by one.
⚫ Like a TM, This also has a finite control (or head) pointing to a
particular cell.
Example
Both TM and M- TM are having the same power
Multi-tape Turing Machine
⚫ It has multiple tapes and controlled by a single head.
⚫ For a given state and input symbol has atleast one choice
to move (finite number of choices for the next move), at
each state it has several choices of path that it might
follow for a given input string.
⚫ In one step all the heads sense the scanned symbols and
move or write independently.
Here, q0 shows the initial state and q1, q2, q3, q4, q5are the transition states and q6
shows the final state.
And X, 0, C are the variables used for subtraction and R, L shows right and left.
Exercise
⚫ Problem-2: Draw a Turing machine which subtract two
numbers m and n, where m is greater then n.
Turing machine for multiplication
⚫ Problem: Draw a turing machine which multiply two
numbers.
Turing machine for multiplication
⚫ Steps:
⚫ Step-1. First ignore 0’s, C and go to right & then if B found convert it into C and go
to left.
⚫ Step-2. Then ignore 0’s and go left & then convert C into C and go right.
⚫ Step-3. Then convert all X into X and go right if 0 found convert it into X and go to
left otherwise if C found convert it into B and go to right and stop the machine.
⚫ Step-4. If then X found convert it into X and go left then C into C and left then Y
into Y and left.
⚫ Step-5. Then if B found convert it into B and right then if Y into 0 and right or if C
into C and right and go to step 3 and repeat the process otherwise if 0 found after 4th
step then convert it into Y and right then Y into Y and right then C into C and right
then 0 into 0 or X into X and right then C into C and right then 0 into 0 and right
then B into 0 and left then 0 into 0 and left then C into C and left then 0 into 0 or X
into X and left then C into C and left.
⚫ Step-6. Then repeat the 5th step.
Turing machine for multiplication
Here, q0 shows the initial state and q1, q2, ….., q10, q11are the transition states and
q12shows the final state.
And X, Y, 0, C are the variables used for multiplication and R, L shows right and left.
Closure properties of Turing machines
Closure properties of Turing machines
Closure properties of Turing machines
Closure properties of Turing machines
Closure properties of Turing machines
How turing machine can be used as enumerator
⚫ A Turing machine can produce all the strings of the
language accepted by that particular Turing machine. We
call such a Turing machine an enumerator.