Toc Unit Iv
Toc Unit Iv
Toc Unit Iv
TURING MACHINES
TURING MACHINE
Ø In the previous units, we have discussed several sets of languages, and now we
come to a bigger class of languages namely the recursively enumerable
languages.
Ø The model of computation that - recognizes them is called the 'Turing Machine'
named after the famous mathematician Alan Turing who proposed it in 1936.
Ø The Turing Machine is the most powerful model of computation that exists and
we can also prove that the present day digital computers ability to compute is not
powerful than that of a Turing Machine.
Ø Hence, if it can be shown that a Turing machine cannot solve a problem, then
there does not exist an algorithm which can reply a 'yes' or 'no' to the problem.
Ø A Turing Machine unlike the PDA consists of a tape of infinite length. The tape is
divided into cells, each of which can hold only one symbol of the 'tape alphabet'.
Ø The Turing Machine has a head which is capable of reading a symbol from the
tape, or writing any symbol on the tape. The head remains pointing to only one cell
of the tape at a time, and it is said to be reading the symbol present on the cell.
Ø It can be seen that the tape has a beginning but extends to infinity on the
right. The symbols a1, a2, ….belong to the tape alphabet.
n = 1n i.. 11111111….1
eg 5 = 111111=15
6 = 111111 = 16
For eq: 53 can be written as 15 B 13 . If this is the i/p to the it is written on the tape
as
M=(Q.Σ,Γ,δ, 0 q ,B, F) ,
Where
Q is the finite set of states,
Γ is the finite set of allowable tape symbol,
B, a symbol of Γ, is the blank,
Σ,a subset of Γ not including B, is the set of input symbol,
δ is the next move function, a mapping from Q X Γ to Q X Γ X{L,R}
q0 in Q is the star state,
F Q ⊆ is the set of final states.
Ø Since the notion of instantaneous description must already be familiar to you
all (as used in the case of PDA), the same can be extended to a Turing Machine
also.
Ø We assume that Q and Γ are disjoint to avoid confusion. Finally, the tape
head is assumed to be scanning the leftmost symbol of α2, or α2=ε, the head is
scanning a blank.
Ø If I=1, then there is no next ID, As the tape head is not allowed to fall off the
left end of the tape.
However , if any suffix of Xi-1 YXi+1…Xn is completely blank , that suffix is deleted.
Note that in the case i-1= n, the string X1…Xn is empty, and the right side is longer
than the left side.
we say that the second results from the first by one move.
Ø If one ID results from another be some finite number of moves, including zero
moves they are related by the symbol . We drop the subscript M from
• The Turing Machine reach any other state other than the halting state and may
remain stationary for all inputs.
• The Turing Machine could enter an infinite loop, in which case we cannot decide
whether the given input string has been accepted or not. Because, at any point of
time we cannot decide if the Turing Machine has entered an infinite loop or not, as
it may reach the halting state any moment.
Hence, the languages recognizable by a TM are divided into two depending upon
the behaviour of the TMs constructed for recognizing it.
• Any language L1 (M1) (i.e., the language L1 correspondingly to the TM M1) is said
to be recursively enumerable if there is atleast one word belonging to L, which
makes the TM to enter into an “infinite loop”.
Ø Till this point of time, we have seen the TM as a recogniser of any recursive
language for which it is constructed, but it can be used to compute functions (Draw
similarly to C functions) which accept integers as inputs and return an integer.
Ø The input parameters are given to the TM in the form of input symbols on the
tape with each integer encoded in unary and separated by another special symbol.
Ø The TM’s head, during computation reads the input symbols present on the
tape
Ø and comes to a halt after writing the output onto the tape cells.
A(n,0)=n+1
A(0,m+1)=A(1,n)
A(n+1,m+1)=A(A(n,m+1),n)
Ø The memory of the Turing Machine, or in other words, the Turing Machine
remembers the symbol it read previously only by virtue of the state in which it is.
Hence the labeling of the Turing Machine states can be changed accordingly.
Ø A slight variant of the TM that we have seen is the multi track TM. In this type
of TM, the one-way infinite tape containing cells that store upto 1 symbol at a time
is modified to store more than 1 symbol.
Ø This is done by dividing the tape into several tracks, and each track acts as a
separate tape and contains a symbol in its cell. Therefore a k-track TM can
contain upto “k” symbols in each of its cell.
Ø In actual practice, when more than one symbol has to be stored in a single
cell, an addition of a new symbol in the next track, causes the previous symbol to
be encoded into a new symbol.
The input is over the alphabet Σ={0,1} and is of the form B0i10jBBB…. The output is
of the form B0i+jBBB….
Ø The logic used in the above diagram is to read a symbol at the beginning of
the string, store it in the finite control of the Turing Machine and check for the same
symbol at the end of the string.
Ø If it finds the same symbol then it deletes it and returns to the beginning to
delete the first symbol, otherwise the turing machine reaches a non-halting state to
remain there.
4. Construct a Turing Machine which halts only if the parenthesis in the input
string is balanced. The input alphabet Σ={X, [, ]}
SUBROUTINES
Ø A Turing Machine can perform the function of any of the sub-routines that we
may write as a part of our computer program, including recursive functions.
Ø As its name implies, the tape is infinite to the left as well as to the right. We
denoted an ID of such a device as for the one-way infinite TM.
Ø We imagine, however, that there is an infinite of blank cells to both the left
and right of the current nonblank portion of the tape.
Proof:
Ø There are 2 parts to this proof. First, let us prove that a two-way infinite tape
can simulate a one-way infinite tape, which is easy. In order to do this, the 2-way
infinite tape will mark the cell to the left of the starting position of its head; thereby
effectively detaching the tape from the machine.
Ø After this, it will simulate the 1-way Turing Machine. During simulation, if it
reaches the marked area, it is equivalent to the head of the 1-way TM “falling” off
the tape, and the input will be rejected.
Ø In the second part of the proof we shall prove that the 1-way infinite tape TM
can simulate the 2-way infinite tape TM.
Ø In order to do this, we assume that the 1-way infinite tape TM has 2-tracks. In
the second track of the 1-way TM, those symbols that lie to the initial head position
of the 2-way infinite TM are copied in the reverse order.
Ø The 2-way infinite tape TM can be simulated by the 1-way TM in the following
manner:
• Whenever the 2-way tape TM reads to the right of the initial position of the head,
the 1-way TM reads the upper track of the tape in the same direction as that of the
2-way tape TM.
• Whenever the 2-way tape TM reads to the left of the initial position of the head,
the 1-way TM reads the lower track of the tape in the opposite direction as that of
the 2-way tape TM. This is done because the symbols are written in the reverse
direction.
Let us give the exact construction details of the 1-way tape as under:
Let M1 be the 1-way infinite tape having 2-tracks, and M2 be the 2-way infinite tape
Turing Machine.
The 2-way infinite tape Turing Machine with initial position at A0.
Ø The first cell of M1’s tape holds the symbol φ in the lower track, indicating that
is left most cell. The finite control of M1 tells whether M2 would be scanning a
symbol appearing on the upper or on the lower track of M1.
Ø The input symbol of M1 are symbol with a blank on the lower track and an
input symbol of M2 on the upper track. Such a symbol can be identified with the
corresponding input symbol of M2.
Note that the second component will indicate whether M1 is working on the
upper (U for up) or lower (D for down) track. The tape symbols in Γ1 are all objects
of the from [X,Y],
We define δ1 as follows.
If M2 moves right on its first move, M1 prints ⊄ in the lower track to mark the end
of tape, sets its second component of state to U, and move right.
The first component of M1’s state holds the state of M2. On the upper track ,M1
prints the symbol X that is printed be M2.
(a) buts sets the second component of its state to D and moves right. Again, ¢
printed in the lower track to make left end of the tape.
simulates a move of M2 on the cell initially scanned by M2. M1 will always move
right in this situation.
PART – A
1. Define Turing Machine.
2. What are the operations of Turing machine?
3. A function is computable if it can be computed by a Turing machine. Justify.
4. Give formal definition of Turing machine.
5. Define Turing machine as acceptors.
6. Define Turing machine as Transducers.
7. Define Computable languages and functions.
8. Construct a TM M for successor function.
9. Construct TM M for zero function.
10. Construct TM M that compute the constant function.
11. Construct TM M that computes the concatenation function.
12. Construct TM M for a language L={anbn,n>=0}
13. Define Storage in finite control.
14. Define Multiple Tracks.
15. Define Checking off symbols.
16. Define Subroutines.
17. Define two way infinite tape.
PART – B
1. Design a TM that manipulates Addition function.
2. Design a TM that manipulates Subtraction function.
3. Design a TM that manipulates Multiplication function.
4. Construct TM that accepts all palindromes over {a,b}
5. Design TM M, that copies the given string W.
6. Design TM M, that accepts all string contains a substring aba
7. Design TM M, that accepts string over {1} containing even no of 1’s