THEORY OF AUTOMATA AND
FORMAL LANGUAGES
UNIT-V
ABHIMANYU MISHRA
ASSISTANT PROF.(CSE)
JETGI
Abhimanyu Mishra(CSE) JETGI12/31/2016
Turing Machine Introduction
A Turing Machine is an acquiescent device which admits the languages (recursively enumerable set) 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
12/31/2016 Abhimanyu Mishra(CSE) JETGI
A TM can be formally described as a 7-tuple (Q, X, ∑, δ, q0, B, F) where −
(i) Q is a finite set of states
(ii) X is the tape alphabet
(iii) ∑ is the input alphabet
(iv) δ is a transition function; δ : Q × X → Q × X × {Left_shift, Right_shift}.
(v) q0 is the initial state
(vi) B is the blank symbol
(vii) F is the set of final states
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Time and Space Complexity of a Turing Machine
For a Turing machine, the time complexity refers to the measure of the number
of times the tape moves when the machine is initialized for some input
symbols and the space complexity is the number of cells of the tape written.
Time complexity all reasonable functions −
T(n) = O(n log n)
TM's space complexity −
S(n) = O(n)
12/31/2016 Abhimanyu Mishra(CSE) JETGI
A TM accepts a language if it enters into a final state for any input string w. A language is recursively enumerable (generated by Type-0 grammar) if it is accepted by a Turing machine.
A TM decides a language if it accepts it and enters into a rejecting state for any input not in the language. A language is recursive if it is decided by a Turing machine.
There may be some cases where a TM does not stop. Such TM accepts the language, but it does not decide it
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Designing a Turing Machine
The basic guidelines of designing a Turing machine have been explained below with the help of a couple of examples.
Design a TM to recognize all strings consisting of an odd number of α’s.
Solution
The Turing machine M can be constructed by the following moves −
Let q1 be the initial state.
If M is in q1; on scanning α, it enters the state q2 and writes B (blank).
If M is in q2; on scanning α, it enters the state q1 and writes B (blank).
From the above moves, we can see that M enters the state q1 if it scans an even number of α’s, and it enters the state q2 if it scans an odd number of α’s. Hence q2 is the only accepting state.
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Hence,M = {{q1, q2}, {1}, {1, B}, δ, q1, B, {q2}}
Tape alphabet symbol Present State ‘q1’ Present State ‘q2’
a BRq2 BRq1
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Non-Deterministic Turing Machine
In a Non-Deterministic Turing Machine, for every state and symbol, there are a
group of actions the TM can have. So, here the transitions are not
deterministic. The computation of a non-deterministic Turing Machine is a tree
of configurations that can be reached from the start configuration.
An input is accepted if there is at least one node of the tree which is an accept
configuration, otherwise it is not accepted. If all branches of the computational
tree halt on all inputs, the non-deterministic Turing Machine is called
a Decider and if for some input, all branches are rejected, the input is also
rejected.
12/31/2016 Abhimanyu Mishra(CSE) JETGI
A non-deterministic Turing machine can be formally defined as a 6-tuple (Q,
X, ∑, δ, q0, B, F) where −
(i) Q is a finite set of states
(ii) X is the tape alphabet
(iii) ∑ is the input alphabet
(iv) δ is a transition function;
(v) δ : Q × X → P(Q × X × {Left_shift, Right_shift}).
(vi) q0 is the initial state
(vii) B is the blank symbol
(viii) F is the set of final states
12/31/2016 Abhimanyu Mishra(CSE) JETGI
A Turing Machine with a semi-infinite tape has a left end but no right end. The
left end is limited with an end marker.
En
12/31/2016 Abhimanyu Mishra(CSE) JETGI
HEAD
It is a two-track tape −
Upper track − It represents the cells to the right of the initial head position.
Lower track − It represents the cells to the left of the initial head position in
reverse order.
The infinite length input string is initially written on the tape in contiguous
tape cells.
The machine starts from the initial state q0 and the head scans from the left end
marker ‘End’. In each step, it reads the symbol on the tape under its head. It
writes a new symbol on that tape cell and then it moves the head either into left
or right one tape cell. A transition function determines the actions to be taken.
12/31/2016 Abhimanyu Mishra(CSE) JETGI
The infinite length input string is initially written on the tape in contiguous tape cells.
The machine starts from the initial state q0 and the head scans from the left end marker
‘End’. In each step, it reads the symbol on the tape under its head. It writes a new
symbol on that tape cell and then it moves the head either into left or right one tape cell.
A transition function determines the actions to be taken.
It has two special states called accept state and reject state. If at any point of time it
enters into the accepted state, the input is accepted and if it enters into the reject state,
the input is rejected by the TM. In some cases, it continues to run infinitely without
being accepted or rejected for some certain input symbols.
12/31/2016 Abhimanyu Mishra(CSE) JETGI
A linear bounded automaton is a multi-track non-deterministic Turing machine
with a tape of some bounded finite length.
Length = function (Length of the initial input string, constant c)
Here,
Memory information ≤ c × Input information
The computation is restricted to the constant bounded area. The input alphabet
contains two special symbols which serve as left end markers and right end
markers which mean the transitions neither move to the left of the left end
marker nor to the right of the right end marker of the tape.
12/31/2016 Abhimanyu Mishra(CSE) JETGI
A linear bounded automaton can be defined as an 8-tuple (Q, X, ∑, q0, ML,
MR, δ, F) where −
(i) Q is a finite set of states
(ii) X is the tape alphabet
(iii) ∑ is the input alphabet
(iv) q0 is the initial state
(v) ML is the left end marker
(vi) MR is the right end marker where MR≠ ML
(vii) δ is a transition function which maps each pair (state, tape symbol) to
(state, tape symbol, Constant ‘c’) where c can be 0 or +1 or -1
(viii) F is the set of final states
12/31/2016 Abhimanyu Mishra(CSE) JETGI
RECURSIVELY ENUMERABLE AND RECURSIVE
LANGUAGES
When a Turing machine executes an input, there are four possible outcomes of
execution. Then TM
(i) Halts and accepts the input
(ii) Halts and rejects the input
(iii) Never halts(fall into loop)
(iv) Crash
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Theorem: If a language L is recursive, then it is recursively
enumerable languages
• Proof: A language is recursively enumerable if there exists a Turing
machine that accepts every string of the language and a language is
recursive if there is a TM that accepts every string of the language and does
accept strings that are not in the language.
• So, every recursive language is also recursively enumerable. Hence,
statement of the theorem is true.
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Turing Machine as Enumerators
A TURING MACHINE(TM) is said to be generating or enumerating if we are
able to produce each word of any language L separated by blank symbol. The
order of the strings is not important and any string may be repeated indefinitely
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Theorem: If any language L is generated by TURING MACHINE,
then L is accepted by some other Turing machine
Proof:
Let Tm1 be a Turing machine which generates L. Now let us construct another
Turing machine Tm2 which accepts L and Tm2 is having two tapes. The Tm2
saves any input on the extra tape before beginning its generation process. The
Tm2 simulates Tm1,except that every time# is written on output tape the
simulation on Tm1 pauses while Tm2 compare its input string with the string
listed just before #.
L(Tm2) = L(Tm1)
12/31/2016 Abhimanyu Mishra(CSE) JETGI
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Recursively Enumerable Languages
Recursive Languages
NON RECURSIVELY ENUMERABLE LANGUAGES
CHURCH’ S Thesis
“Church’s thesis can not be a theorem in mathematics because ideas such as
“can ever be defined by humans” and “algorithm that people can taught to
perform” are not part of any known mathematics. There are no axioms that
deal with “PEOPLE””
12/31/2016 Abhimanyu Mishra(CSE) JETGI
UNIVERSAL TURING MACHINES
Universal Turing machines “U” takes arguments, a description of a machine
Tm, “Tm” and a description of an input string w,”w’. We want U to have the
following property : U halts on input “Tm” “w” if and only if Tm halts on
input w.
U(“m” “w”) = “m(w)”
If is the functional notation of universal Turing machine
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Example: Consider the Turing machine m = (Q,∑, δ,S) where Q = { S, q,h}
∑={ #,b,a}, and δ is given in following table
States Symbol δ
S a (q,#)
S # (h,#)
S b (S,R)
q a (S,a)
q # (S,R)
q b (q,R)
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Solution:
Since there are three states, three symbols in ∑, we have k=2 and l=3. these are
the smallest integers, the states and symbols are represented as follows:
12/31/2016 Abhimanyu Mishra(CSE) JETGI
State/Symbol Representation
S q00
q q01
h q11
# a000
b a001
L a010
R a011
a a100
Thus representation of baa#a is
“baa#a” = a001a100a100a000a100
The representing “ Tm” of the Turing machine Tm is the following strings:
“Tm” =
(q00,a100,q01,a000),(q000,q11,a000),(q00,a001,q00,a011)(q01,a100,q00,q00,
a011),(q01,a000,a000,q00,q00,a011),(q01,a001,q01,011)
Graphical representation
Tm Input W
Universal Turing Machine
12/31/2016 Abhimanyu Mishra(CSE) JETGI
THE HALTING PROBLEM
“ To determine for an arbitrary given Turing machine Tm and input w,
Whether Tm will eventually halt on input w”.
UNDECIDABILITY/DECIDABILITY
“ A problem whose language is recursive is said to be decidable” Otherwise
problem is undecidable. That is, a problem is undecidable if there exist no
algorithm that takes as input an instance of the problem and determine whether
the answer to that instance is “YES” or “NO”.
12/31/2016 Abhimanyu Mishra(CSE) JETGI
THANKS
12/31/2016 Abhimanyu Mishra(CSE) JETGI