








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Introduction to Turing Machine
Typology: Summaries
1 / 14
This page cannot be seen from the preview
Don't miss anything!









Grammars o RGs: RLs: FSA o CFGs: CFLs: PDA Turing Machine In 1936 British mathematician Alan Turing proposed the idea of a machine that could process equations without human direction. The machine (now known as a Turing machine) resembled an automatic typewriter that used symbols for math and logic instead of letters. Turing intended the device to be a “universal machine” that could be used to duplicate or represent the function of any other existing machine. Turing’s machine was the theoretical precursor to the modern digital computer. The Turing machine model is still used by modern computational theorists. o 1936 by Alan Turing o Recognizer and compute o Fore runner for digital computers
Has tape infinite to right and divided into cells
Each cell accepts a symbol at a time from the input alphabet Has tape head that moves right/left one cell at a time of scanning The scanned symbol might be replaced or left as it is.
Cell
Tape Head
i. q = F, TM halts. ii. q 2 = λ , the tape head is on B If δ(q , B) = (ql^ , b , R), then M enters state ql^ replacing B by b and moving right.
and moving left.
i. δ (q , ai) = (q^1 , b , R) is a move, then
ii. δ (q , ai) = (q1l, c , L) is a move, then
In general a move from one configuration to another is denoted by: a) q 1 qq 2 |▬ q^11 q^1 q^12 single move b) q 1 qq 2 |▬* q^11 qq^12 zero or more moves c) q 1 qq 2 |▬+ q^11 q^1 q^12 at least one move
Q = {qo , q 1 , q 2 , q 3 } = {a} r = {a , B} F = {q 2 } δ is given by the following table
Tape Symbol State δ (q , x ) a q 0 (q 1 , a , R) a q 1 (q 2 , a , R) B q 1 (q 3 , a , R) B q 3 (q 1 , a , R)
Check whether the following strings are accepted a) w = a
≡ q 0 aB |▬ a q 1 B |▬ a a q 3 B |▬ a a a q 3 B |▬ a a a ……q 3 B w = a is not accepted b) q 0 aaB |▬ aq 1 aB |▬ aaq 2 B (q 2 is final state) w = aa is accepted c) q 0 abaB |▬ aq 1 baB (q 1 , b) is not defined M hangs, δ (q 1 , b) is undefined
Which is equivalent to δ (q , a) = (q1 , y , L )
a B B (^) …
a / y , L
q 0
q q 1
Represents a state
Represents Initial States
Represents Halt States Transition and Label as follows
To perform the above one:
State a b x y B q 0 ( q 1 , x , R ) - - ( q 3 , y , R ) - q 1 ( q 1 , a , R ) ( q 2 , y , L ) - ( q 1 , y , R ) - q 2 ( q 2 , a , L ) - ( q 0 , x , R ) ( q 2 , y , L ) - q 3 - - - ( q 3 , y , R ) ( q 4 , B , L ) q 4 - - - - -
Demonistration
a a a a a b b b b b B B B B...
x a a a a y b b b b B B B B...
State Diagram
Check the following for acceptance by TM a) w = aabb q 0 aabbB |▬ xq 1 abbB |▬ xaq 1 bbB |▬ xq 2 aybB |▬ q 2 xaybB |▬ xq 0 aybB |▬ xxq 1 ybB |▬ xxyq 1 bB |▬ xxq 2 yyB |▬ xq 2 xyyB |▬ xxq 0 yyB |▬ xxyq 3 yB |▬ xxyyq 3 B |▬ xxyq 4 yB Hence w = aabb is accepted by TM Exercises b) w = aaabb c) w = aab
Let M 1 ,M 2 be two TMs
(M 1 simulates until normal halts and then simulate M 2 )
(Simulates M 1 until it Scans a or b then M 2 Simulates)
a,b
a/a,L
b/y,L^ y/y,L y/y,R a/a,R
y/y,R
y/y,R
q 0 q 1 q 2
q 3
a/x,R
q 4
x/x,R
Apply SL SL
Apply SL into the following a) BcdaB |▬ BcdaB |▬ ccdab |▬ cddaB |▬ cdaaB |▬ cdaBB b) BcdaB No string on the right of B so we should: LBSL (Search Blank left and apply SL) The result is the same as above cdaB b) Shift right (SR) : Shifts a non-blank string from left of the current position to the right.
SR
Apply LBSLxRByL to the following: BaBcda B Solution: BaBcda B |▬ Ba B cdaB……………LB |▬ Bacda B B…………….SL |▬ Bacda x B…………….x |▬ Bacdax B ……………..RB |▬ Bacdax y ……………..y |▬ Bacda x y……………...L
B B a b c B x y B B a b c B B x y B
B a b c B B B a b c B
→R rB^ L r R
The Erase Machine ( E ): Erases non-blank string BwB B
E
Backup Machine (B): The B transform BUBWB ,U and W are non-empty, into BWB.
B
B : → L^2 B E S^3 L
Copy machine ( C ): The C transforms BWB into BWBWB
C
C : LBR BR^2 BrL^2 Br
Example: Revisit the machine the accepts the language L= { anbn^ | n>1} Convert the TM using building blocks primitives Solution
B a b c B B B B …….
B a b B c d e B ……. (^) B c d e B …..
B a b B B B a b B a b B
y
a a,y^ b^ a,y x
y
rB
Stop
x R y^ L
3- Multiple Tapes A k-tape, TM has k heads, i.e. M = ( Q , , r , δ , q 0 , B , F ) δ (Q x rK^ → Q x rk^ x {L , R}K Example : Let k = 2 B a 1 a 2 B B B
x 1 x 2 x 3 B B B
To simulate a 2-tape TM on a single tape Use 4 tracks, 2 tracks for each tape, the first track represent the tape symbols the second track the head for the tape Track Track Track Track
δ(q 0 ,(a2 , x 1 )) or δ (q 0 , az , x 1 ) δ(q0 , a 2 , x 1 ) = (q2 ,c 1 , c 3 , L , R) (The currently scanned symbols a 2 ,x 1 are replaced by c 1 and c 3 respectively moving left and right) Thus multiple tapes also don’t increase the power of TM.
4- Non- deterministic TM (NDTM) A NDTM M = (Q , , r , δ , q 0 , B , F ) Where Q ,,r,δ,q 0 ,B and F are similarly define in DTM. But δ: Q x r → 2 Qxrx{L,R} A language accepted by NDTM M is denoted by L (M) is given by L(M)={w Є * | q 0 w |▬ q 1 fq 2 , f Є F, q 1 and q 2 Є r*} Let M be a NDTM, we want to simulate on a DTM D.
B a 1 a 2 B B B B 1 B B x 1 x 2 x 3 B B 1 B B B B
q 0
Head is a 2
Head is x 1
D will have three tapes: Tape 1: Contains the input Tape 2: Possible sequence of transition of M Tape 3: Working tape (the input from tape 1 is copied on this and the simulation is carried out using tape 2) If the simulation leads to a halt state of M so is D. Otherwise, erase the content of tape 2 and generate another sequence and simulate tape 3. Repeat this until M halts, Hence, L(M) = L(D). Example: If the TM has Transitions δ(q 0 ,a)={(q1,b,R),(q 2 ,c,L)} It is non deterministic. The moves q 0 aaa |▬ bq 1 aa and q 0 aaa |▬ q 2 Bcaa are both possible