0% found this document useful (0 votes)
79 views10 pages

Flat Unit-6 LM

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views10 pages

Flat Unit-6 LM

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

FORMAL LANGUAGES & AUTOMATA THEORY UNIT VI

UNIT – VI
TURING MACHINE
Objective: To employ with Context Free Grammars and Push-Down Automata
Syllabus:
Turing Machine: Turing Machine-definition, Model of Turing Machine, Design of TM-
examples, Types of Turing Machines (Proofs not required), Computable functions-partial
recursive functions and total recursive functions, Recursively enumerable languages,
Church’s hypothesis.
Computability Theory: Decidability of problems, Universal Turing Machine-definition,
Undecidability of posts correspondence problem-examples, Turing reducibility, Definition
of P and NP problems-examples, NP complete and NP hard problems-definition, examples
Outcome: To design Turing machine for the phrase-structured languages.

Specific Learning Outcomes:


Bloom's
S. No Learning Outcomes Taxonomy
Level
1 Students will be able to define Turing machine Remember
2 Students will be able to construct Turing machine Apply
3 Students will be able to understand the model of Turing Machine Understand
4 Students will be able to classify the types of Turing machine Understand
5 Students will be able to define partial recursive function and total recursive Remember
function
6 Students will be able to define Church's Hypothesis Remember
7 Students will be able to classify the decidable problems and undecidable Understand
problems
8 Students will be able to define Universal Turing machine Remember
9 Students will be able to understand the Posts Correspondence problem Understand
10 Students will be able to classify the P , NP and NP Complete problems Understand

DEPARTMENT OF INFORMATION TECHNOLOGY Page 1


FORMAL LANGUAGES & AUTOMATA THEORY UNIT VI

Turing Machine:
 Turing Machines first described by Alan Turing.
 Turing Machines are simple abstract computational devices intended to help
investigate the extent and limitations of what can be computed.
 Some simple languages like {anbncn}n>=0} is not recognized by either PDA or Finite
Automata.
 Turing Machine is a device that will recognize this language and many more
complicated languages.
 Turing machines are used as language recognizers, languages enumerator and as a
computing machine.

Model of Turing Machine:

..... ..... a1 a2 a3 a4 a5 a6 ..... .....


Read/Write Head
Finite Control

Turing machine can be thought of as finite control connected to a Read/Write head.


It has one tape which is divided into a number of cells.
Each cell can store only one symbol.
The input to and the output from the finite state automaton are affected by the
Read/Write head which can examine one cell at a time.
 In one move the machine examine the present symbol under the R/W head on the
tape and the present state of an automaton to determine.
 A new symbol to be written on the tape in the cell under the R/W head.
 A motion of the R/W head along the tape either the head moves one cell left(L),
or cell right(R).
 the next state of the automaton and
 whether to halt or not.
Formal Definition: A Turing machine M is a 7 Tuple, namely (Q,∑, δ,Γ,F,Z0,q0) where
Q=Finite set of states.
∑=Finite set of Input alphabet
Γ=Finite set of tape alphabet
q0=Initial state
F=Finite set of final state F ⊆ Q
B=Blank symbol B∈ Γ
δ=Transition function δ: (q X x) --> Q X Γ*

DEPARTMENT OF INFORMATION TECHNOLOGY Page 2


FORMAL LANGUAGES & AUTOMATA THEORY UNIT VI

Acceptance by Turing Machine:


The acceptability of a string is decided by the reachability from the initial state to
some final state. So the final states are also called the accepting states.
Representation of Turing Machine:
Turing machine employing can be desired by:
1. Instantaneous description using move relation
2. Transition table.
3. Transition Diagram.
ID of Turing Machine:
An ID of Turing machine M is a string αβγ, where β is the present state of M, the
entire input string is split as αγ, the first symbol of γ is the current symbol α under the R/W
head and γ has all the subsequent symbols of the input string formed by all the symbols to
the left of α.
Transition Table:
We give the definition of δ in the form of a table called the transition table
if δ(q, α)=( γ, α,β) we write αβγ under the α-column and in q-row.
α-current cell
β-movement -Right or Left
γ-next state or new state
Transition Diagram:

Designing of Turing Machines:

1. Design a Turing Machine that accepts L={anbn|n>=1}


Solution:
We require the following moves:
L={ab,aabb,aaabbb,aaaabbbb,....................}
a) If the left most symbol in the given input string W is a, replace it by B and move right
till we encounter a leftmost 1 in W. Change it to B and move backwards until we
encounter B(Blank symbol).
b) Repeat (a) with the leftmost a. If we move back and forth and no a or b remains,
move to a final state.
c) For the string in the form anbn, the resulting state has to be non-final.

Note: indicates Blank symbol(B)

DEPARTMENT OF INFORMATION TECHNOLOGY Page 3


FORMAL LANGUAGES & AUTOMATA THEORY UNIT VI
Tuple Representation:
Q=Finite set of states={q0,q1,q2,q3}
∑=Finite set of Input alphabet=*a,b+
Γ=Finite set of tape alphabet ={a,b,B( ) }
q0=Initial state= q0
F=Finite set of final state ={ q3}
B=Blank symbol B∈ Γ
δ=Transition function
2. Design a Turing Machine which accepts all the palindrome Strings over the alphabet {a,b}

Turing Machine As Computational Machine:


A TM M compute a function f if, when given input w in the domain of f, the machine halts in
its accept state with f(w) written the tape. To use Turing machine as a computation
machine it is required to place the integer numbers as 0 m. Suppose it is required to add two
numbers, i.e f(m,n)=m+n then the numbers m and n are to be placed on the tape as 0 m10n
where 1 is the separator for the numbers m and n. Once processing is completed and the
Turing machine halts then tape would have the contents as 0 (m+n) which is the required
result of computation.
3. Design a TM to add two numbers a and b.

Transitions are as follows:


δ(q0,0)=(q0,0,R)
δ(q0,1)=(q1,0,R)
δ(q1,0)=(q1,0,R)
δ(q1,B)=(q2,B,L)
δ(q2,0)=(q3,B,R)

DEPARTMENT OF INFORMATION TECHNOLOGY Page 4


FORMAL LANGUAGES & AUTOMATA THEORY UNIT VI
4.Design a TM for finding 1's complement of a given binary number.

Types of Turing Machines:


There are several types of Turing Machines. They are
1. Nondeterministic Turing Machine
2. Turing Machine with Two-Dimensional Tapes.
3. Turing Machines with Multiple Tapes
4. Turing Machines with Multiple Heads.
5. Turing Machines with Infinite Tape.
1. Nondeterministic Turing Machine:
A Nondeterministic Turing Machine is a Turing machine which like NFA, at any
current state and for the tape symbol it is reading there may be different possible
actions to be performed.
One action could be just change of state without modifying the cell content, ir
change of the state with change of the cell content or change both state and cell
content. In all action means the combination of writing a symbol on the tape, moving
the tape head going to the next state.
Example L=*WW|W∈*a,b++
2. Turing Machine with Two-Dimensional Tapes.
 Turing machine with two dimensional tape is a kind of TM that has one finite
control, one read-write head and one two dimensional tape.
 The cell in the tape is two dimensional that is the tape has the top end and the
left en but extends indefinitely to the right and down
 It is divided into rows of small squares.

Fig: Two Dimensional Tape

DEPARTMENT OF INFORMATION TECHNOLOGY Page 5


FORMAL LANGUAGES & AUTOMATA THEORY UNIT VI
3. Turing Machines with Multiple Tapes:

 A multi-tape TM is like an ordinary TM with several tapes.


 Each tape has its own head for reading and writing.
 Initially the input appears on tape 1, and others are blank.
 The transition function is changed to allow for reading, writing, and moving the
heads on all tapes simultaneously. Formally,
δ :Q × Γk → Q × Γk ×{L, R}k ,
where k is the number of tapes.
 The expression δ (q, a1 ,..., ak ) = ( r , b1 ,..., bk , L, R ,..., L) means that, if the machine is
in state q and heads 1 through k are reading symbols a1 trough ak , the machine
goes to state r, writes symbols b1 through and movbeks each head to the left or
right as specified.

 Multi-tape TMs appear to be more powerful than ordinary TMs, but we will show
that they are equivalent in power.
4. Turing Machine with Multiple Heads:
 This is a kind of Turing Machines that have one finite control and one tape but more
than one read-write heads.
 In each state only one of the head is allowed to read and write.
 The transition function is partial function
δ:QX*H1,H2,.......Hn+X*ΓU*B++--> (QU*h+,*ΓU*B+)X*R,L,S+
5. Turing Machine Infinite Tape:
 This is a kind of Turing machines that have one finite control and one tape which
extends infinitely in both directions.
 It turns out that this type of Turing machines are only as powerful as one tape
Turing machine whose tape has a left end.
Recursive and Recursively Enumerable Languages:
 There are three possible outcomes executing a Turing machine over a given input.
The Turing Machine may
 Halt and accept the input
 Halt and reject the input
 Never Halt
 A language is recursive if there exists a Turing Machine that accepts every string of the
language and reject every string (over the same alphabet) that is not in the language.
Note: If a language L is recursive then its compliment L' must also be recursive

DEPARTMENT OF INFORMATION TECHNOLOGY Page 6


FORMAL LANGUAGES & AUTOMATA THEORY UNIT VI
 A language is recursively enumerable if there exists a Turing machine that accepts
every strings of the language, and does not accepts strings that are not in the languages.
o Strings that are not in the language may be rejected or may cause the Turing
machine to go into an infinite loop.
 Every recursive languages is also recursively enumerable. It is not Obvious whether
every recursively enumerable languages is also recursive.
Church's Hypothesis:
Church's Hypothesis states that any algorithmic procedure that can be carried out
by a human or computer, can also be carried out by Turing Machine.
A Problem can be solved by an algorithm if and only if it can be solved by Turing
Machine.
Important of Church's Hypothesis:
1. First we will provide certain problems which can't be solved using TM.
2. If Church thesis is true this implies that problem cannot be solved by any computer
or any programming language we might every develop.
3. Thus in studying the capabilities and limitations of Turing machine we are indeed
studying the fundamental capabilities and limitations of any computational device
we might even construct.
Computability Theory:
Decidability of Problems:
In general life, we have several problems and some of these have solutions also, but
some have not.
Simply we say a problem is decidable if there is a solution otherwise undecidable.
Example: 1.Does the sun rise in the east?(YES)
2.Will tomorrow be a rainy day?(No Answer)
Decidable Problems:
A Problem is said to be decidable if
 Its language is recursive or
 It has a solution
Halting Problem:
The halting problem is a decision problem which is informally stated as follow:
Given a description of an algorithm and description of its initial arguments, determine
whether the algorithm when executed with these arguments, ever halts. The alternative is
that given algorithm runs forever without halting.
Alan Turing Proved in 1936 there is no general method or algorithm which can
solve the Halting Problem for all possible inputs.
Universal Turing Machine:
The church Turing thesis conjectured that anything that can be done on any existing
digital computer can also be done by a TM. To prove this conjuncture A.M.Turing was able
to construct a single TM which is the theoretical analogue of a general purpose digital
computer. This machine is called a Universal Turing Machine(UTM). He showed that the
UTM is capable of initiating the operations of any other TM, that it, it is reprogrammable
Tm. We can define this machine in more formal ways as follows:

DEPARTMENT OF INFORMATION TECHNOLOGY Page 7


FORMAL LANGUAGES & AUTOMATA THEORY UNIT VI
A Universal Turing Machine is a TM that can take as input an arbitrary TM T A with an
arbitrary input for TA and then perform the execution of TA on its input.
To construct a UTM, we thus require three essentials
a. a uniform method to describe or encode any TM into a string over a finite symbol
set, I
b. a similar method of encoding any input string for a TM into a string over I, and
c. a set of TM programs that describe the TMs basic cycle of operations.
Posts Correspondence Problem:
The POST correspondence problem(PCP) was first introduced by Emil Post in 1946.
The problem over an alphabet ∑ belongs to a class of Yes/No problems and is stated
as follows:
Consider two lists x=(x1,x2,x3,.......xn), y=(y1,y2,y3,.....yn) of non-empty strings over an
alphabet ∑=*0,1+. The PCP is to determine whether or not there exist i1,i2,....im where
1<=ij<=n, such that xi1.......xim=yi1.......yim
Example:
Does the PCP with two lists x=(b,bab3,ba) and y=(b3,ba,a) have solution?
The Solution is (2113)
bab3 b b ba= bab3 b b ba

Assignment-Cum-Tutorial Questions
SECTION A: Objective Questions
1. Which of the following is not primitive recursive but partially recursive [ ]
a) Carnot's function b) Ricmann function
c) Bounded function d) Ackermann's function
2. Turing machine (TM) is more powerful than FMS because [ ]
a) tape movement is confined to one direction b) it has no finite state
c) it has the capability to remember arbitrarily long sequences of input symbols
d) none of these
3. Turing machine was invented by: [ ]
a) Alan Turing b) Turing man
c) Turing taring d) None of these
4. Turing machine is more powerful than: [ ]
a) Finite automata b) Push down automata
c) Both (a) and (b) d) None of these
5. Problem A is NP complete iff [ ]
a) A is NP hard b) A is NP
c) Both (a) and (b) d) A is in complexity class of NP
6. Which of the following problem is NP-complete? [ ]
a) Travelling sales person problem b) 3-coloring
c) set partitioning d) all the above

DEPARTMENT OF INFORMATION TECHNOLOGY Page 8


FORMAL LANGUAGES & AUTOMATA THEORY UNIT VI
7. The language accepted by a Turing Machine are _____________________.
8. ___________________languages are subset of recursive languages.
9. _______________________are those problems that can be solved by a Turing Machine in
polynomial time.
10. If P=NP then NP-complete problem is in__________________________.

11. Consider the following language L = {anbncndn|n ≥ 1+ L is [ ]


a) CFL but not regular b) CSL but not CFL
c) regular d) type 0 language but not type 1
12. Which of the following denotes Chomsky hierarchy? [ ]
a) REG ⊂ CFL ⊂ CSL ⊂ type0 b) CFL ⊂ REG ⊂ type0 ⊂ CSL
c) CSL ⊂ type0 ⊂ REG ⊂ CFL d) CSL ⊂ CFL ⊂ REG ⊂ type0
13. Next move function δ of a Turing machine M = (Q, Σ , Γ, δ, q0, B, F) is [ ]
a mapping
a) δ : Q x Σ --> Q x Γ b) δ : Q x Γ ---> Q x Σ x {L, R}
c) δ : Q x Σ ---> Q x Γ x {L, R} d) δ : Q x Γ ---> Q x Γ x {L, R}
14. The union of two recursively enumerable languages is: [ ]
a) Recursively Enumerable b) Recursive
c) Both a and b d) None of these
15. The complement of Recursive is [ ]
a) Can't say b) Recursive
c) non-recursive d) none of these
16. If two lists are x={b,bab3,ba} and y={b3,ba,a} the solution of PCP [ ]
problem is[ ]
a) 1,2,3,3 b) 2,1,1,3
c) 2,1,1,1,3 d) No solution
17. If PCP is decidable then MPCP is [ ]
a) Can't Say b) Decidable
c) Undecidable d) None of these
18. PCP is [ ]
a) Sometimes undecidable b) Decidable
c)Undecidable d)None of these
19. The verification of syntax of statement is done faster with TM than with PDA
(True/False)
20. Which of the following statements are true? [ ]
a) The union of two recursive languages is recursive
b) The infinite union of recursive languages is recursive.
c) The language {an |n prime } is not regular.
d) Regular sets are closed under infinite union and so are DCFLs

DEPARTMENT OF INFORMATION TECHNOLOGY Page 9


FORMAL LANGUAGES & AUTOMATA THEORY UNIT VI
SECTION B: Descriptive questions
1. Define Turing Machine. With a neat sketch explain the working of a Turing machine.
2. List out the various types of Turing Machines.
3. Explain about Posts Correspondence problem.
4. Define Decidable and undecidable Problems with examples
5. Define Halting Problem
6. Define P , NP and NP Complete Problems with examples
7. Explain Instantaneous description of a Turing machine with examples
8. Define Church's Hypothesis.
9. Define Turing Reducibility
10. Define Modified version of PCP
11. Design a TM for the language L={anbncn|n>=1}
12. Design a TM for addition of two numbers
13. Design a TM for subtraction of two numbers
14. Design a TM for language L={WWR|W∈(a,b)*+
15. Design a TM for palindrome strings over {a,b}.
16. Design a Turing machine where the number of a's number of b's are equal or the
languages is defined as L={w|na(w)=nb(w)}
17. Design a TM for 2's complement of given binary representation.
18. Find whether there is a solution for the following PCP instance.
A={b3,ab2} B={b3 ,bab3}
19. Find whether there is a solution for the following PCP instance.
A={b,bab3,ba} B={b3 ,ba,a}
20. Find whether there is a solution for the following PCP instance.
A={1,10111,10} B={111,10,0}
SECTION C: GATE questions
1. Given a Turing machine M over the input alphabet Σ, any state q of M GATE 2001
And a word w ∈Σ*, does the computation of M on w visit the state q?
Which of the following statements about X is correct?
a) X is decidable
b) X is undecidable but partially decidable
c) X is undecidable and not even partially decidable
d) X is not a decision problem
2. Which of the following statements is/are FALSE? GATE 2013
(1) For every non-deterministic Turing machine, there exists an equivalent
deterministic Turing machine.
(2) Turing recognizable languages are closed under union and complementation.
(3) Turing decidable languages are closed under intersection and complementation
(4) Turing recognizable languages are closed under union and intersection.
A) 1 and 4 only B) 1 and 3 only
C) 2 only D) 3 only

DEPARTMENT OF INFORMATION TECHNOLOGY Page 10

You might also like