Turing Machine
Turing Machine
com
Automata Theory: Turing Machine
Finite
Control
… B X1 X2 … Xi … Xn B
The tape is marked off into squares, each of which can hold one symbol from the
alphabet. If square has no symbol in it, then it contains blank. We think, reading and
writing as being done by a tape head. A single move of TM is determined by the current
state and current tape symbol and consist of three things.
1. Replacing the symbol in the current square by another, possibly different symbol.
2. Moving the tape head one square right or left or leaving it where it is.
3. Moving from the current state to another, possibly different state.
HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory: Turing Machine
HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory: Turing Machine
reflects the change of state from q to p and the symbol Xi is replaces with Y then tape
head is positional at i-1(next scan is Xi-1)
2. If i =n, Y=B, then M moves to the state p and the symbol B written over Xn joins
the infinite sequence of trailing blanks which does not appear in next ID as
X1 X 2 ....X n−1qXn ├ X 1 X 2 .... X n − 2 pX n −1
(b) if δ (q, X i ) = ( p, Y , R) i.e next move is rightward . then
X 1 X 2 .... X i −1 qX i X i +1n ... X n ├ X 1 X 2 .... X i −1YpX i +1 .... X n which reflects that symbol Xi is
replaced with Y and the head has moved to cell i+1 .
1. If i = n, then i+1 cell holds blank which is not part of previous ID
X 1 X 2 .... X n −1 pX n ├ X 1 X 2 .... X n −1YpB
2. If i =1, Y=B, then the symbol B written over Xi joins the infinite sequence of
leading blanks and does not appear in next ID qX 1 X 2 .... X n ├ pX 2 X 3 .... X n
HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory: Turing Machine
Y/Y ←
0/Y ← 0/0 ←
0/X→
q0 q1 q2
Y/Y→
X/X→
q3
Y/Y→
B/B→
q4
The set of languages that can be accepted using TM are called recursively
enumerable Languages or RE languages.
HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory: Turing Machine
The Turing Machines are designed to perform at least the following three roles.
1. As a language recognizer: TM can be used for accepting a language like Finite
Automata and pushdown automata(PDA).
The string w is presented in to the form BwB, where B is a blank symbol, and
placed on to the tape, the head of Turing Machine is positioned at a blank symbol which
immediately follows by the string w.
Definition:
HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory: Turing Machine
Example: Design a TM which compute the function f(x) = x +1 for each x that
belongs to the set of natural numbers.
Solution: Given function f(x) = x + 1. Here we represent input x on the tape by a number
of 1's on the tape.
Similarly output can be seen by the number of 1s on the tape when machine halts.
Q B 1
q0 (q0,1,N) (qa,1,R)
qa - -
HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory Turing Machine
Introduction of Turing Machine -2
Storage in the state: In Turing machine, any state represents the position in the computation .
But a state can also be used to hold a finite amount of data. The finite control of machine consists
of a state q and some data portion. In this case a state is considered as a tuple – (state,data).
Following Figure illustrates the model.
Finite
Control
A B
δ is defined by:
δ ([q, A], X ) = ([q1 , X ], Y , R) means q is the state and data portion of q is A. The symbol scanned
on the tape is copied into the second component of the state and moves right entering state q1 and
replacing tape symbol by Y.
Turing Machine with Multiple Tracks:
The tape of Turing machine can be considered as having multiple tracks. Each track can
hold one symbol and the tape alphabet of TM consists of tuples with one component for each
track. Following figure illustrates multiple track TM.
Finite
Control
Track 1 X
Track 2 Y
Track 3 Z
Subroutine: A Complex Turing machine can be thought as built from a collection of interacting
components like a general program. Such components of Turing machine are called subroutines.
A Turing Machine subroutine is a set of states that performs some useful processes and can be
called in to another machine for the part of that computation.
HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory Turing Machine
Extension of TM:
Modern computing devices are based on the foundation of TM computation models.
To simulate the real computers a TM can be viewed as multi-tape machine in which there are
more than one tape. Adding extra tape adds no power to the computational model only the ability
to accept the language is concerned.
1. Multi-tape Turing Machine:
• A multi-tape Turing machine consists of finite control and finite number of tapes.
Each tape is divided into cells and each cell can hold any symbol of finite tape
alphabets.
• TM has separate R/W head for each tape.
• The set of tape symbols includes a blank symbol( B) as in single tape machine.
• The tape symbol has a subset called input symbols i.e. we can say Σ ⊆ Γ .
Finite
Control
Tape 1 ….. ….
Tape 2
Tape 3
A multi-tape TM
In Multi-tape TM, Initially,
1. Input (Finite sequence of input symbols) w is placed on the first tape.
2. All other cell of the tapes hold blanks
3. TM is in the initial state – q0
4. The head of the first tape is at the left end of the input.
5. All other tape heads are at some arbitrary cell since all other tape except first tape
consists completely blank.
A move of multi-tape TM depends on the state and the symbol scanned by each of the tape head.
In one move the multi-tape TM does the following.
1. The control enters in a new state, which may be same previous state.
2. On each tape, a new symbol is written on the cell scanned, these symbol may be same as
the symbol previously there.
3. Each of the tape head make a move either left or right or remains stationary. Different
head may move different direction independently i.e. if head of first tape moves leftward
,at the same time other head can move another directions or remains stationary.
The formal notation of multi-tape TM is the generalization of one-tape TM. The initial
configuration(initial ID) of multi-tape TM with n-tapes is represented as:
(q0 ,ax, B,B,……..,B) – n+1 tuple. Where w = ax is an input string and head of first
tape is scanning first symbol of w.
HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory Turing Machine
The notation of configuration at any instant of TM can be generalized as: (n+1) tuple for n-
tape TM.
(q, x1a1y1 , x2a2y2 , ……………………., xnanyn) Where each xis are the portion of string on
tapes before current head position, each ais are the symbol currently scanning in each tapes
and each yis are the portion of string in tapes just rightward the current head position. q is
the control state
Proof:
o Let L is a language accepted by a n-tape TM T1 = (Q1 , Σ, Γ1 , δ1 , q1 , B, F1 ) . We simulate
T1 with one-tape Turing Machine T2 = (Q2 , Σ, Γ2 , δ 2 , q2 , B, F2 ) considering there are 2n
tracks in the tape of T2.
o Let us assume that n = 2 then for n>2 is generalization of this case.
o Now total no of tracks in T2 will be 2*2 = 4.The second and fourth tracks of T2 hold the
contents of first and second tapes of T1 and track 1 holds the head position of tape 1 and
track 3 holds the head position of tape 2 of T1 as in figure below.
Finite
Control
Finite Data
Track 1 X
Track 2 A1 A2 …….. Ai …. Aj ……
Track 3 X
Track 4 B1 B2 ……….. Bi …. Bj ….
HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory Turing Machine
♦ The addition of non-determinism to Turing machines does not alter the definition of
Turing-computable.
HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory Turing Machine
Unrestricted Grammars: An unrestricted Grammar (also called phrase-structure
Grammar) is a 4-tuple G = (V,T,P,S) where V and T are disjoint sets of variables and terminals
respectively, S ∈ V is start symbol and P is a set of productions of the form α → β
Where α , β ∈ (V ∪ T ) * and α contatains at least one variable.
The productions are of the form.
αAβ → αγβ or αAβ → γ
An unrestricted Grammar are used to describe the languages that are not context-free. In fact the
languages described by unrestricted grammar can be accepted by a TM. Hence they are
recursively enumerable.
HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory Turing Machine
Church- Turing Thesis
It is a mathematically un-provable hypothesis abut the computability. This hypothesis
simplify states that – "Any algorithmic procedure that can be carried out at all (by human, a team
of human or a computer ) can be carried out by a TM."
This statement was first formulated by Alonzo Church a logician, in 1930s and it is
referred to as Church Thesis or Church-Turing thesis. It is not a mathematically precise
statement so un-provable . Later the invention of Turing Machine has accumulated enough
evidence to accept this hypothesis. Following are the some of evidences.
1. In nature, a human normally works with 2D paper sheet, not 1D tape. The transfer of
attention is not adjacent block like TM. However transferring attention from one place to
another during computation can be simulated by Turing Machine as one human step by
multiple stapes.
2. Various extensions of Turing Machine Model has been suggested to make computation
efficient like doubly infinite tape, a tape with multiple tracks, multi-tape , non-
determinism etc. In each case the computational power reserved.
3. Other theoretical model have been suggested that are closer to modern computers in their
operation.( e.g. simple programming type language, grammars and others)
4. Since the introduction of the TM , no one has suggested any type of computation that
ought to be included in the category of "Algorithmic Procedure".
After adopting Church-Turing Thesis, we are giving a precise meaning of the term:
An algorithm is a procedure that can be executed on a Turing Machine.
HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory Universal Turing Machine
A Turing machine can, simulate a computer that had been loaded with an arbitrary
program . I.e. A – TM can be used as a “stored program computer ” taking its program as well as
data from one or more tapes on which it is placed .
Modern computer are completely flexible in which the task it performs is to execute the
instructions stored in its memory , and can represent an algorithm for computation . Turing
describes a “Universal Computing Machine ” that can be defined as:
Definition : A Universal Turing machine Tu is a TM whose input consist of program and a
data set for the program to process. The program takes the from of a string specifying some other
(special – purpose) TM T1 and the data set is second string w interpreted as input to T1. Tu then
simulates the processing of w by T1.
Encoding of TM:
For the representation of any arbitrary TM T1, and an input string w over an arbitrary alphabet
as strings e(T1) , e(w) over some fixed alphabet , a notational system should be formulated .
Encoding the TM T1 and input string w in to e (T1) and e (w) , it must not destroy any
information , for the encoding of TM , we use the alphabet {0,1} although the TM may have a
much larger alphabet .
For encoding , we start by assigning positive integers to each state , each tape symbol and
each of three directions S,L and R in the TM we want to encode. We assume two fixed infinite
sets Q = { q1,q2,…………} and S = { a1, a2, ………} so that for any TM
T1 = (Q1 , Σ, Γ, δ , q 0 , B, F ) , we have Q1 ⊆ Q and Γ ⊆ S .
Hence once we have a subscript attached to every possible state and tape symbols, we can
represent a state or a symbol by a string of 0’s of the appropriate length. 1’s are used as
separators.
The Encoding Function e
First, associate to each tape symbol, to each state and to each of the three directions , a string of
0’s. Let
s(B) = 0
s(ai) = 0i+1 for each ai ∈ S
i+2
s(qi) = 0 for each qi ∈ S
s(S) = 0
s(L) = 00
s(R) = 000
Then each move of TM , described by formula
δ ( q, a ) = ( p, b, D ) is encoded as
e(m) =s(q)1s(a)1s(p)1s(b)1s(D)1
and for any TM T, with initial state q, T is encoded as:
e(T ) = s (q )1e(m1 )1e(m2 )1...................1e(mk )1
1 -HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory Universal Turing Machine
Where m1 , m2 ,.........mk are the distinct moves of T arranged in some arbitrary order.
Finally, any string w = w1 w2 w3 ............wk , for each wk ∈ S is encoded as:
e( w) = 1s ( w1 )1s ( w2 )1...................1s ( wk )1
♦ -The 1 at beginning of e(w) included so that a composite string of the form e(T)e(w),
there is no doubt for the stoppage of e(T) since separated by three 1’s. Since no valid
code for TM contains three 1’s in a row, we can be sure that the first occurrence of 111
separates the code for TM T1and input w.
♦ Also encoding of s(a) of a symbol a ∈ S is different from the encoding e(a) of the one
character string a.
♦ There may be any possible codes for a TM T1. The codes for the TM for n transitions
may be listed in any of n! orders.
Encoding :
s(q1 ) = 000
s(q 2 ) = 0000
s (q3 ) = 00000
s(a1 ) = 00 considering a1 = a and a2 = b
s(a 2 ) = 000
s( B) = 0
s(S ) = 0
s ( L) = 00
s ( R ) = 000
Now e(m1 ) = s (q1 )1s (b)1s (q3 )1s (a)1s ( R)1 = 000100010000010010001
2 -HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory Universal Turing Machine
e(m4 ) = s (q3 )1s ( B)1s (q3 )1s (b)1s ( L)1 = 000001010000010001001
=0001000100010000010010001100000100100010001000110000010001000010010001100
00010100000100010011
for this machine the input (T,w) where w= ab , the code will be,
Finite Control
M w
Tape of M 001000010010001………………….
State of M 000…..
Scratch
A Sketch of Universal TM
3 -HGC
For more notes visit https://collegenote.pythonanywhere.com
Automata Theory Universal Turing Machine
4 -HGC