SlideShare a Scribd company logo
1 of 38
INTRODUCTION TO
COMPUTER THEORY
Turing Machine (TM) developed by Alan Mathison Turing
Represented By:
Muhammad Wasim(323)
Azmul Haq(203)
WHAT IS TURING MACHINE
• The mathematical models (FAs, TGs and PDAs) can decide
whether a string is accepted or not by them so, these
models are language identifiers. However, there are still
some languages which can not be accepted by them e.g.
there does not exist any FA, TG or PDA accepting any non-
CFLs. Alan Mathison Turing developed the machines called
Turing machines, which accept some non-CFLs as well, in
addition to CFLs.
MCS EVE 2012-14 5/24/2015
2
DEFINITION OF TURING MACHINE
• A Turing machine (TM) consists of the following:
• An alphabet Σ of input letters.
• An input TAPE partitioned into cells, having infinite many locations in
one direction. The input string is placed on the tape starting its first
letter on the cell i , the remaining cells of the TAPE are initially filled
with blanks. (∆’s)
• A tape Head can read the contents of cell on the TAPE in one step. It
can replace the character at any cell and can moved itself to the
next cell to the right or to the left of that it has just read. Initially the
TAPE Head is at the cell i. The TAPE Head can’t move to the left of cell
i. the location of the TAPE Head is denoted by ⌂ .
MCS EVE 2012-14 5/24/2015
3
DEFINITION (CONT…)
• An alphabet Γ of characters that can be printed on the TAPE by the
TAPE Head. Γ may include the letters of Σ. Even the TAPE Head can
print blank ∆, which means to erase some character from the TAPE.
• Finite set of states containing exactly one START state and some
(may be none) HALT states that cause execution to terminate when
the HALT states are entered.
• A program which is the set of rules, which show that which state is to
be entered when a letter is read form the TAPE and what character
is to be printed. This program is shown by the states connected by
directed edges labeled by triplet (letter, letter, direction). The first
letter is what tape head read and second letter is what it printed
before leave the state (may be replaced the letter with the printed
character). The direction tells the tape head whether to move one
cell to the right, R, or one cell to the left, L.MCS EVE 2012-14 5/24/2015
4
DETERMINISM V/S NON-DETERMINISM
• It can be seen that there may not any outgoing edge at certain states
for certain letter to be read from the tape, which creates non-
determinism in TM (just like TGs).
• It may also be seen that unlike TGs at certain states, there can’t be
more than one outgoing edge for certain letter to be read from the
tape.
• The machine crashes if there is no path for a letter to be read from the
tape and corresponding string will be rejected. Machine also crashes if
instruct it to move HEAD to left of the location i.
• To terminate execution of certain input string successfully, a HALT state
must be entered and then the corresponding string will be accepted
by the TM.
MCS EVE 2012-14 5/24/2015
5
REPRESENTATION OF TAPE AND TAPE HEAD
a b a ∆ ∆ ∆ ∆ ∞
i ii iii iv
⌂
TAPE
HEAD
MCS EVE 2012-14 5/24/2015
6
EXAMPLE OF TM
Let input string aba be run over this TM having ∑={a,b} then the
TAPE will look like..
a b a ∆ ∆ ∞
i ii iii iv
⌂
TAPE
HEAD
MCS EVE 2012-14 5/24/2015
7
EXAMPLE (CONT..)
Starting from STATR state, reading a from the TAPE and according to the
TM program, a will be printed i.e. a will replace a and TAPE head will
moved one cell right and TM entered in state 2.
a b a ∆ ∆ ∞
i ii iii iv
⌂
TAPE
HEAD
MCS EVE 2012-14 5/24/2015
8
EXAMPLE (CONT..)
At state 2, reading b from the TAPE and according to the TM program, b
will be printed i.e. b will replace b and TAPE head will moved one cell
right and TM entered in state 3.
a b a ∆ ∆ ∞
i ii iii iv
⌂
TAPE
HEAD
MCS EVE 2012-14 5/24/2015
9
EXAMPLE (CONT..)
At state 3, reading a from the TAPE and according to the TM program, a
will be printed i.e. a will replace a and TAPE head will moved one cell
right and state of TM remain unchanged.
a b a ∆ ∆ ∞
i ii iii iv
⌂
TAPE
HEAD
MCS EVE 2012-14 5/24/2015
10
EXAMPLE (CONT..)
At state 3, reading ⌂ from the TAPE and according to the TM program,
⌂ will be printed i.e. ⌂ will replace ⌂ and TAPE head will moved one cell
right and TM entered into the HALT state which terminate the program.
a b a ∆ ∆ ∞
i ii iii iv
⌂
TAPE
HEAD
MCS EVE 2012-14 5/24/2015
11
EXAMPLE (CONT..)
NON-Determinism: At state 2 there is no path for letter a which creates
non-determinism, if we read a at this state the machine will be crashed.
• The string aba is accepted by this TM. TM reaches at HALT state by
reading ∆. TM must read ∆ to terminate the program then the
string supposed to be accepted. This machine accepts the
language expressed by (a+b)b(a+b)*.
• If TM entered in HALT state before completing the string it doesn't
mean string is accepted.MCS EVE 2012-14 5/24/2015
12
EXAMPLE (CONT..)
• The following example can also be seen as:
1 2 3 3 HALT
aba aba aba aba∆
• This process called execution chain, also called process chain or trace of
execution.
MCS EVE 2012-14 5/24/2015
13
THEOREM
• Theorem:
• Every Regular Language is accepted by some TM.
• Example of EVEN-EVEN Language
MCS EVE 2012-14 5/24/2015
14
AN OTHER EXAMPLE
• We discuss earlier example of Regular Language which is
accepted by some TM.
• Lets see an example of NON-Regular language which is also
accepted by some TM.
• Language L={ anbn : n=1,2,3,….} over ∑={a,b}.
• Language L is non-regular there is no FA exist for this
language but a TM exist which accept the strings
generated from this language and reject those which are
not belong to that language.
MCS EVE 2012-14 5/24/2015
15
EXAMPLE (CONT…)
The conversion of a to A and b to B means that these letters has
been counted and we are going to find next one. A and B use
here as a marker.
Lets run string aabb generated from L to test the TM.
MCS EVE 2012-14 5/24/2015
16
a a b b ∆ ∞
⌂
At START state we read a convert it to A to
indicate it is counted and now move right to
find b the pair of counted a.
At state 2 we read a remain it unchanged go right to find b.
A a b b ∆ ∞
⌂
A a b b ∆ ∞
⌂
At state 2 now we read b change it to B because it is the pair of 1st a and move
left to find more left most a’s to complete the string.
A a B b ∆ ∞
⌂
Place string on TAPE
EXAMPLE (CONT…)
MCS EVE 2012-14 5/24/2015
17
At state 3 we read a remain it unchanged
and move left to find left most a.
At state 4 we read A which means there is no more left most
a’s so remain it unchanged and move right to read a.
A a B b ∆ ∞
⌂
A a B b ∆ ∞
⌂
At SATRT state now we read left most a change it to A and move right to find b
which is its pair.
A A B b ∆ ∞
⌂
A a B b ∆ ∞
⌂
EXAMPLE (CONT…)
MCS EVE 2012-14 5/24/2015
18
At state 2 we read B remain it unchanged
and move right to find b.
At state 2 we read b change it into B and move left to find
more a’s if exist.
A A B b ∆ ∞
⌂
A A B B ∆ ∞
⌂
At state 3 we read B remain it unchanged and move left to find more a’s if exist.
A A B b ∆ ∞
⌂
A A B B ∆ ∞
⌂
EXAMPLE (CONT…)
MCS EVE 2012-14 5/24/2015
19
At state 3 we read A remain it unchanged
and move right to terminate program
because there is no more a’s to scan.
At state 5 we read B two times remain them unchanged
and move right two times to terminate.
A A B B ∆ ∞
⌂
A A B B ∆ ∞
⌂
At state 5 we read ∆ remain it unchanged and right.
A A B B ∆ ∞
⌂
A A B B ∆ ∞
⌂
Now we entered in HALT state which means the
string is accepted by this TM.
EXAMPLE (CONT…)
MCS EVE 2012-14 5/24/2015
20
REMEMBER
• In previous example we take a string aabb which is generated by the
language anbn , we see that string is accepted by the TM that we
construct for language.
• It doesn't means the previous TM is the correct TM for our language.
• The TM which accept the strings from its corresponding language
should must reject those strings which are not belong to its
corresponding language.
• Try the following string yourself and check this is rejected by the TM or
not.
• aaabb must be rejected by the previous TM because it is not generated by its
corresponding language.
MCS EVE 2012-14 5/24/2015
21
ANOTHER EXAMPLE
• Another non-CFG language is language of anbnan over ∑={a,b}
MCS EVE 2012-14 5/24/2015
22
We run aabbaa on this machine to see the
execution..
Here is the tracing way..
STSRT 2 2
aabbaa *abbaa *abbaa
3 3 4
*abbaa *abbaa *abbaa
4 5 5
*abaaa *abaaa *abaaa∆
6 7 8
*abaaa *abaa *aba
8 8 8
*aba *aba *aba
START 2 3
*aba **ba **ba
4 5 5
**ba **aa **aa∆
6 7 8 START
**aa **a ** **∆
MCS EVE 2012-14 5/24/2015
23
ANOTHER EXAMPLE
• Language of palindromes..
MCS EVE 2012-14 5/24/2015
24
ANOTHER EXAMPLE
abbabba
∆bbabba
∆bbabb∆
∆∆babb∆
∆∆bab∆∆
∆∆∆a∆∆∆
∆∆∆a∆∆∆
∆∆∆∆∆∆∆
Take a string which is not a
palindrome and it must b reject
(TM will crash).
MCS EVE 2012-14 5/24/2015
25
MORE ON TURING MACHINES
• INSERT subprogram:
• Sometimes in the running of TM, we may want to insert a character into the string
on the TAPE exactly at the spot where the TAPE HEAD is pointing.
• This means that the newly inserted character will occupy this cell and every right
character on the TAPE will be shifted one cell right. The left character remains
unchanged.
• After insertion we want the TAPE HEAD moved on right of newly inserted
character.
• This subprogram not depend what the TM is doing. It is independent subprogram
can be called in any other TM by specifying the what character to be inserted at
what location.
MCS EVE 2012-14 5/24/2015
26
INSERT SUBPROGRAM(EXAMPLE)
• If the character ‘b’ is inserted at the cell where the TAPE HEAD is pointing as
shown below
then, it is expressed as
The function of subprogram INSERT ‘b’ can be observed from the following
diagram
∞ b X a b b X ∆ ∆∞
⌂
∞ b X a b b X ∆ ∆∞
⌂
INSERT b
∞ b X b a b b X ∆ ∆∞
⌂
MCS EVE 2012-14 5/24/2015
27
INSERT SUBPROGRAM(EXAMPLE)
2
3
4
7
5
6
MCS EVE 2012-14 5/24/2015
28
INSERT SUBPROGRAM(EXAMPLE)
• Let insert ‘b’ at current location of TAPE HEAD as we discuss earlier.. What we
do??
• we insert a character ‘Q’ as a marker then we shift all characters right one cell,
and then move back to ‘Q’ to replace it by ‘b’.
• Remember we take previous TAPE we discussed which have only characters a’s,
b’s, X’s.
• What the states of this subprogram doing??
• We start from state 1. In this state we read ‘a’ (either a, b or X) and then we write ‘Q’
and move TAPE HEAD right one cell.
• Here in previous cell where ‘Q’ is inserted we displaced a character… ‘a’ in this
example.
• We must want to remember what we displaced in inserting the ‘Q’.
• This require some memory to remember….
MCS EVE 2012-14 5/24/2015
29
INSERT SUBPROGRAM(EXAMPLE)
• In previous subprogram diagram state 2,3 and 4 are used as memory to
remember ‘a’, ‘b’ and ‘X’ respectively.
Remember ‘a’ is
displaced
Remember ‘b’ is
displaced
Remember ‘X’ is
displaced
MCS EVE 2012-14 5/24/2015
30
• In our example at state 1 we read ‘a’ and
replaced it with ‘Q’ and then entered in state 2
because ‘a’ is displaced, TAPE HEAD is also
moved one cell right.
• At state 2 we read ‘b’, we remember that we
must place ‘a’ that we displaced, so we write
an ‘a’, but now we realize that we have just
displaced a ‘b’ and entered in state 3 because
state 3 remember the ‘b’ is displaced. The TAPE
HEAD also moves one cell right.
⌂
∞ b X Q b b X ∆ ∆∞
∞ b X Q a b X ∆ ∆∞
⌂
2
3
4
7
5
6
MCS EVE 2012-14 5/24/2015
31
• At state 3 we read ‘b’ we replace it with
‘b’ and remain here, here we again
displaced another ‘b’, the TAPE HEAD
moves one cell right.
• At state 3 we read ‘X’ this time replaced
it with ‘b’ and entered in state 4 because
now we displaced ‘X’, the TAPE HEAD
move one cell right again.
• At state 4 we read ‘∆’ which means the
end of string, so we replace it last
displaced character which was ‘X’, we
entered state 5 now. TAPE HEAD also
move one cell right.
∞ b X Q a b X ∆ ∆∞
∞ b X Q a b b ∆ ∆∞
⌂
∞ b X Q a b b X ∆∞
⌂
⌂
2
3
4
7
5
6
MCS EVE 2012-14 5/24/2015
32
• At state 5 we read ∆ replace it with ∆
and entered in state 6 , move TAPE
HEAD left one cell.
• At state 6 either read a, b or X replace
with itself by moving left and remain at
state 6 until we read ‘Q’ .
• When we read ‘Q’ replace it with ‘b’
because our example is to insert ‘b’
and move the TAPE HEAD one cell right.
REMEMBER: This is independent subprogram
and we suppose only three characters on
the TAPE to reduce the complexity.
⌂
∞ b X b a b b X ∆ ∆∞
2
3
4
7
5
6
MCS EVE 2012-14 5/24/2015
33
MORE ON TURING MACHINE
• DELETE subprogram:
• Sometimes, a character is required to be DELETED on the TAPE exactly at the
spot where the TAPE Head is pointing, so that the other characters on the
right of the TAPE Head are moved one cell left.
• The characters to the left of the pointed cell are also required to remain as
such.
• The subprogram of deletion is independent and can be incorporated at any
time with any TM program specifying what character to be deleted at what
location.
MCS EVE 2012-14 5/24/2015
34
DELETE SUBPROGRAM(EXAMPLE)
• If the character ‘b’ is deleted at the cell where the TAPE HEAD is pointing as
shown below
then, it is expressed as
The function of subprogram DELETE ‘b’ can be observed from the following
diagram
∞ b X a b b X ∆ ∆∞
⌂
∞ b X a b b X ∆ ∆∞
⌂
DELETE b
∞ b X a b b X ∆ ∆ ∆∞
⌂
MCS EVE 2012-14 5/24/2015
35
DELETE SUBPROGRAM(EXAMPLE)
MCS EVE 2012-14 5/24/2015
36
DELETE SUBPROGRAM(EXAMPLE)
• What the states of this subprogram doing??
• We start from state 1. In this state we read ‘a’ (either a, b or X) and then we write ‘∆’
and move TAPE HEAD right until we reach at the end of the TAPE non- ∆.
• At once we read ∆ it means we are at the end of input now.
• Now we move left and replace what we displaced similar to INSERT subprogram
(it work inverse of INSERT subprogram).
• This require some memory to remember…. Similar to INSERT subprogram DELETE
subprogram also have some memory to remember what is displaced at some
location.
MCS EVE 2012-14 5/24/2015
37
MCS EVE 2012-14 5/24/2015
38

More Related Content

What's hot

Turing Machine
Turing MachineTuring Machine
Turing MachineRajendran
 
Concurrency control
Concurrency  controlConcurrency  control
Concurrency controlJaved Khan
 
Turing machine seminar report
Turing machine seminar reportTuring machine seminar report
Turing machine seminar reportYashwant Dagar
 
Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automatahafizhamza0322
 
Two-way Deterministic Finite Automata
Two-way Deterministic Finite AutomataTwo-way Deterministic Finite Automata
Two-way Deterministic Finite AutomataHafsa.Naseem
 
Computer Oragnization Flipflops
Computer Oragnization FlipflopsComputer Oragnization Flipflops
Computer Oragnization FlipflopsVanitha Chandru
 
Turing Machine
Turing MachineTuring Machine
Turing MachineAyAn KhAn
 
context free language
context free languagecontext free language
context free languagekhush_boo31
 
Turing machine - theory of computation
Turing machine - theory of computationTuring machine - theory of computation
Turing machine - theory of computationRubaya Mim
 
NFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramNFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramAbdullah Jan
 
protocols of concurrency control
protocols of concurrency controlprotocols of concurrency control
protocols of concurrency controlMOHIT DADU
 

What's hot (20)

Push down automata
Push down automataPush down automata
Push down automata
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Concurrency control
Concurrency  controlConcurrency  control
Concurrency control
 
Automata Theory - Turing machine
Automata Theory - Turing machineAutomata Theory - Turing machine
Automata Theory - Turing machine
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Lesson 08
Lesson 08Lesson 08
Lesson 08
 
Turing machine seminar report
Turing machine seminar reportTuring machine seminar report
Turing machine seminar report
 
Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automata
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Two-way Deterministic Finite Automata
Two-way Deterministic Finite AutomataTwo-way Deterministic Finite Automata
Two-way Deterministic Finite Automata
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Multi Head, Multi Tape Turing Machine
Multi Head, Multi Tape Turing MachineMulti Head, Multi Tape Turing Machine
Multi Head, Multi Tape Turing Machine
 
Computer Oragnization Flipflops
Computer Oragnization FlipflopsComputer Oragnization Flipflops
Computer Oragnization Flipflops
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
context free language
context free languagecontext free language
context free language
 
Turing machine - theory of computation
Turing machine - theory of computationTuring machine - theory of computation
Turing machine - theory of computation
 
Undecidabality
UndecidabalityUndecidabality
Undecidabality
 
Deadlock in database
Deadlock in databaseDeadlock in database
Deadlock in database
 
NFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramNFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition Diagram
 
protocols of concurrency control
protocols of concurrency controlprotocols of concurrency control
protocols of concurrency control
 

Viewers also liked

Turing machine Introduction
Turing machine IntroductionTuring machine Introduction
Turing machine IntroductionAram Rafeq
 
Introduction to the theory of computation
Introduction to the theory of computationIntroduction to the theory of computation
Introduction to the theory of computationprasadmvreddy
 
Church Turing Thesis
Church Turing ThesisChurch Turing Thesis
Church Turing ThesisHemant Sharma
 
Variants of Turing Machine
Variants of Turing MachineVariants of Turing Machine
Variants of Turing MachineRajendran
 
Turing Machine
Turing MachineTuring Machine
Turing MachineRajendran
 
Deciability (automata presentation)
Deciability (automata presentation)Deciability (automata presentation)
Deciability (automata presentation)Sagar Kumar
 
Turing machine(automata )
Turing machine(automata )Turing machine(automata )
Turing machine(automata )inam ullah khan
 
Lathe machining presentation
Lathe machining presentationLathe machining presentation
Lathe machining presentationAZIZCO
 
presentation on lathe machine
presentation on lathe machinepresentation on lathe machine
presentation on lathe machinekashyap8960
 

Viewers also liked (14)

Turing machines
Turing machinesTuring machines
Turing machines
 
Turing machine Introduction
Turing machine IntroductionTuring machine Introduction
Turing machine Introduction
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Introduction to the theory of computation
Introduction to the theory of computationIntroduction to the theory of computation
Introduction to the theory of computation
 
Church Turing Thesis
Church Turing ThesisChurch Turing Thesis
Church Turing Thesis
 
Introduction to Turing Machine
Introduction to Turing MachineIntroduction to Turing Machine
Introduction to Turing Machine
 
Variants of Turing Machine
Variants of Turing MachineVariants of Turing Machine
Variants of Turing Machine
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Ch3
Ch3Ch3
Ch3
 
Deciability (automata presentation)
Deciability (automata presentation)Deciability (automata presentation)
Deciability (automata presentation)
 
Turing machine(automata )
Turing machine(automata )Turing machine(automata )
Turing machine(automata )
 
Lathe machining presentation
Lathe machining presentationLathe machining presentation
Lathe machining presentation
 
presentation on lathe machine
presentation on lathe machinepresentation on lathe machine
presentation on lathe machine
 
Turing machine
Turing machineTuring machine
Turing machine
 

Similar to Intro Turing Machines

Pushdown-Automata_L1.ppt
Pushdown-Automata_L1.pptPushdown-Automata_L1.ppt
Pushdown-Automata_L1.pptShayanAli68
 
10. switch case
10. switch case10. switch case
10. switch caseWay2itech
 
Winter 9 Decidability.pptx
Winter 9 Decidability.pptxWinter 9 Decidability.pptx
Winter 9 Decidability.pptxHarisPrince
 
Free Ebooks Download ! Edhole
Free Ebooks Download ! EdholeFree Ebooks Download ! Edhole
Free Ebooks Download ! EdholeEdhole.com
 
Pushdown AutomataChapter 12Recognizing Context-F.docx
Pushdown AutomataChapter 12Recognizing Context-F.docxPushdown AutomataChapter 12Recognizing Context-F.docx
Pushdown AutomataChapter 12Recognizing Context-F.docxwoodruffeloisa
 
Pattern Matching using Computational and Automata Theory
Pattern Matching using Computational and Automata TheoryPattern Matching using Computational and Automata Theory
Pattern Matching using Computational and Automata TheoryIRJET Journal
 
closure properties of regular language.pptx
closure properties of regular language.pptxclosure properties of regular language.pptx
closure properties of regular language.pptxThirumoorthy64
 
Loop in C Properties & Applications
Loop in C Properties & ApplicationsLoop in C Properties & Applications
Loop in C Properties & ApplicationsEmroz Sardar
 
Theory of automata and formal language lab manual
Theory of automata and formal language lab manualTheory of automata and formal language lab manual
Theory of automata and formal language lab manualNitesh Dubey
 
Unit 2 assembly language programming
Unit 2   assembly language programmingUnit 2   assembly language programming
Unit 2 assembly language programmingKartik Sharma
 
a simple idealized machine used to recognize patterns within input taken from...
a simple idealized machine used to recognize patterns within input taken from...a simple idealized machine used to recognize patterns within input taken from...
a simple idealized machine used to recognize patterns within input taken from...NALESVPMEngg
 
MidtermI-review.pptx
MidtermI-review.pptxMidtermI-review.pptx
MidtermI-review.pptxamara jyothi
 
Winter 11 Tutorial Reducibility.pptx
Winter 11 Tutorial Reducibility.pptxWinter 11 Tutorial Reducibility.pptx
Winter 11 Tutorial Reducibility.pptxHarisPrince
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptxssuser47f7f2
 

Similar to Intro Turing Machines (20)

Pushdown-Automata_L1.ppt
Pushdown-Automata_L1.pptPushdown-Automata_L1.ppt
Pushdown-Automata_L1.ppt
 
Post Machine
Post MachinePost Machine
Post Machine
 
10. switch case
10. switch case10. switch case
10. switch case
 
Winter 9 Decidability.pptx
Winter 9 Decidability.pptxWinter 9 Decidability.pptx
Winter 9 Decidability.pptx
 
Free Ebooks Download ! Edhole
Free Ebooks Download ! EdholeFree Ebooks Download ! Edhole
Free Ebooks Download ! Edhole
 
Pushdown AutomataChapter 12Recognizing Context-F.docx
Pushdown AutomataChapter 12Recognizing Context-F.docxPushdown AutomataChapter 12Recognizing Context-F.docx
Pushdown AutomataChapter 12Recognizing Context-F.docx
 
Pattern Matching using Computational and Automata Theory
Pattern Matching using Computational and Automata TheoryPattern Matching using Computational and Automata Theory
Pattern Matching using Computational and Automata Theory
 
closure properties of regular language.pptx
closure properties of regular language.pptxclosure properties of regular language.pptx
closure properties of regular language.pptx
 
Unit iv
Unit ivUnit iv
Unit iv
 
Assignment8
Assignment8Assignment8
Assignment8
 
07 top-down-parsing
07 top-down-parsing07 top-down-parsing
07 top-down-parsing
 
Loop in C Properties & Applications
Loop in C Properties & ApplicationsLoop in C Properties & Applications
Loop in C Properties & Applications
 
Theory of automata and formal language lab manual
Theory of automata and formal language lab manualTheory of automata and formal language lab manual
Theory of automata and formal language lab manual
 
Pushdown autometa
Pushdown autometaPushdown autometa
Pushdown autometa
 
Unit 2 assembly language programming
Unit 2   assembly language programmingUnit 2   assembly language programming
Unit 2 assembly language programming
 
a simple idealized machine used to recognize patterns within input taken from...
a simple idealized machine used to recognize patterns within input taken from...a simple idealized machine used to recognize patterns within input taken from...
a simple idealized machine used to recognize patterns within input taken from...
 
MidtermI-review.pptx
MidtermI-review.pptxMidtermI-review.pptx
MidtermI-review.pptx
 
Winter 11 Tutorial Reducibility.pptx
Winter 11 Tutorial Reducibility.pptxWinter 11 Tutorial Reducibility.pptx
Winter 11 Tutorial Reducibility.pptx
 
22 Jop Oct 08
22 Jop Oct 0822 Jop Oct 08
22 Jop Oct 08
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptx
 

Recently uploaded

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 

Recently uploaded (20)

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 

Intro Turing Machines

  • 1. INTRODUCTION TO COMPUTER THEORY Turing Machine (TM) developed by Alan Mathison Turing Represented By: Muhammad Wasim(323) Azmul Haq(203)
  • 2. WHAT IS TURING MACHINE • The mathematical models (FAs, TGs and PDAs) can decide whether a string is accepted or not by them so, these models are language identifiers. However, there are still some languages which can not be accepted by them e.g. there does not exist any FA, TG or PDA accepting any non- CFLs. Alan Mathison Turing developed the machines called Turing machines, which accept some non-CFLs as well, in addition to CFLs. MCS EVE 2012-14 5/24/2015 2
  • 3. DEFINITION OF TURING MACHINE • A Turing machine (TM) consists of the following: • An alphabet Σ of input letters. • An input TAPE partitioned into cells, having infinite many locations in one direction. The input string is placed on the tape starting its first letter on the cell i , the remaining cells of the TAPE are initially filled with blanks. (∆’s) • A tape Head can read the contents of cell on the TAPE in one step. It can replace the character at any cell and can moved itself to the next cell to the right or to the left of that it has just read. Initially the TAPE Head is at the cell i. The TAPE Head can’t move to the left of cell i. the location of the TAPE Head is denoted by ⌂ . MCS EVE 2012-14 5/24/2015 3
  • 4. DEFINITION (CONT…) • An alphabet Γ of characters that can be printed on the TAPE by the TAPE Head. Γ may include the letters of Σ. Even the TAPE Head can print blank ∆, which means to erase some character from the TAPE. • Finite set of states containing exactly one START state and some (may be none) HALT states that cause execution to terminate when the HALT states are entered. • A program which is the set of rules, which show that which state is to be entered when a letter is read form the TAPE and what character is to be printed. This program is shown by the states connected by directed edges labeled by triplet (letter, letter, direction). The first letter is what tape head read and second letter is what it printed before leave the state (may be replaced the letter with the printed character). The direction tells the tape head whether to move one cell to the right, R, or one cell to the left, L.MCS EVE 2012-14 5/24/2015 4
  • 5. DETERMINISM V/S NON-DETERMINISM • It can be seen that there may not any outgoing edge at certain states for certain letter to be read from the tape, which creates non- determinism in TM (just like TGs). • It may also be seen that unlike TGs at certain states, there can’t be more than one outgoing edge for certain letter to be read from the tape. • The machine crashes if there is no path for a letter to be read from the tape and corresponding string will be rejected. Machine also crashes if instruct it to move HEAD to left of the location i. • To terminate execution of certain input string successfully, a HALT state must be entered and then the corresponding string will be accepted by the TM. MCS EVE 2012-14 5/24/2015 5
  • 6. REPRESENTATION OF TAPE AND TAPE HEAD a b a ∆ ∆ ∆ ∆ ∞ i ii iii iv ⌂ TAPE HEAD MCS EVE 2012-14 5/24/2015 6
  • 7. EXAMPLE OF TM Let input string aba be run over this TM having ∑={a,b} then the TAPE will look like.. a b a ∆ ∆ ∞ i ii iii iv ⌂ TAPE HEAD MCS EVE 2012-14 5/24/2015 7
  • 8. EXAMPLE (CONT..) Starting from STATR state, reading a from the TAPE and according to the TM program, a will be printed i.e. a will replace a and TAPE head will moved one cell right and TM entered in state 2. a b a ∆ ∆ ∞ i ii iii iv ⌂ TAPE HEAD MCS EVE 2012-14 5/24/2015 8
  • 9. EXAMPLE (CONT..) At state 2, reading b from the TAPE and according to the TM program, b will be printed i.e. b will replace b and TAPE head will moved one cell right and TM entered in state 3. a b a ∆ ∆ ∞ i ii iii iv ⌂ TAPE HEAD MCS EVE 2012-14 5/24/2015 9
  • 10. EXAMPLE (CONT..) At state 3, reading a from the TAPE and according to the TM program, a will be printed i.e. a will replace a and TAPE head will moved one cell right and state of TM remain unchanged. a b a ∆ ∆ ∞ i ii iii iv ⌂ TAPE HEAD MCS EVE 2012-14 5/24/2015 10
  • 11. EXAMPLE (CONT..) At state 3, reading ⌂ from the TAPE and according to the TM program, ⌂ will be printed i.e. ⌂ will replace ⌂ and TAPE head will moved one cell right and TM entered into the HALT state which terminate the program. a b a ∆ ∆ ∞ i ii iii iv ⌂ TAPE HEAD MCS EVE 2012-14 5/24/2015 11
  • 12. EXAMPLE (CONT..) NON-Determinism: At state 2 there is no path for letter a which creates non-determinism, if we read a at this state the machine will be crashed. • The string aba is accepted by this TM. TM reaches at HALT state by reading ∆. TM must read ∆ to terminate the program then the string supposed to be accepted. This machine accepts the language expressed by (a+b)b(a+b)*. • If TM entered in HALT state before completing the string it doesn't mean string is accepted.MCS EVE 2012-14 5/24/2015 12
  • 13. EXAMPLE (CONT..) • The following example can also be seen as: 1 2 3 3 HALT aba aba aba aba∆ • This process called execution chain, also called process chain or trace of execution. MCS EVE 2012-14 5/24/2015 13
  • 14. THEOREM • Theorem: • Every Regular Language is accepted by some TM. • Example of EVEN-EVEN Language MCS EVE 2012-14 5/24/2015 14
  • 15. AN OTHER EXAMPLE • We discuss earlier example of Regular Language which is accepted by some TM. • Lets see an example of NON-Regular language which is also accepted by some TM. • Language L={ anbn : n=1,2,3,….} over ∑={a,b}. • Language L is non-regular there is no FA exist for this language but a TM exist which accept the strings generated from this language and reject those which are not belong to that language. MCS EVE 2012-14 5/24/2015 15
  • 16. EXAMPLE (CONT…) The conversion of a to A and b to B means that these letters has been counted and we are going to find next one. A and B use here as a marker. Lets run string aabb generated from L to test the TM. MCS EVE 2012-14 5/24/2015 16
  • 17. a a b b ∆ ∞ ⌂ At START state we read a convert it to A to indicate it is counted and now move right to find b the pair of counted a. At state 2 we read a remain it unchanged go right to find b. A a b b ∆ ∞ ⌂ A a b b ∆ ∞ ⌂ At state 2 now we read b change it to B because it is the pair of 1st a and move left to find more left most a’s to complete the string. A a B b ∆ ∞ ⌂ Place string on TAPE EXAMPLE (CONT…) MCS EVE 2012-14 5/24/2015 17
  • 18. At state 3 we read a remain it unchanged and move left to find left most a. At state 4 we read A which means there is no more left most a’s so remain it unchanged and move right to read a. A a B b ∆ ∞ ⌂ A a B b ∆ ∞ ⌂ At SATRT state now we read left most a change it to A and move right to find b which is its pair. A A B b ∆ ∞ ⌂ A a B b ∆ ∞ ⌂ EXAMPLE (CONT…) MCS EVE 2012-14 5/24/2015 18
  • 19. At state 2 we read B remain it unchanged and move right to find b. At state 2 we read b change it into B and move left to find more a’s if exist. A A B b ∆ ∞ ⌂ A A B B ∆ ∞ ⌂ At state 3 we read B remain it unchanged and move left to find more a’s if exist. A A B b ∆ ∞ ⌂ A A B B ∆ ∞ ⌂ EXAMPLE (CONT…) MCS EVE 2012-14 5/24/2015 19
  • 20. At state 3 we read A remain it unchanged and move right to terminate program because there is no more a’s to scan. At state 5 we read B two times remain them unchanged and move right two times to terminate. A A B B ∆ ∞ ⌂ A A B B ∆ ∞ ⌂ At state 5 we read ∆ remain it unchanged and right. A A B B ∆ ∞ ⌂ A A B B ∆ ∞ ⌂ Now we entered in HALT state which means the string is accepted by this TM. EXAMPLE (CONT…) MCS EVE 2012-14 5/24/2015 20
  • 21. REMEMBER • In previous example we take a string aabb which is generated by the language anbn , we see that string is accepted by the TM that we construct for language. • It doesn't means the previous TM is the correct TM for our language. • The TM which accept the strings from its corresponding language should must reject those strings which are not belong to its corresponding language. • Try the following string yourself and check this is rejected by the TM or not. • aaabb must be rejected by the previous TM because it is not generated by its corresponding language. MCS EVE 2012-14 5/24/2015 21
  • 22. ANOTHER EXAMPLE • Another non-CFG language is language of anbnan over ∑={a,b} MCS EVE 2012-14 5/24/2015 22
  • 23. We run aabbaa on this machine to see the execution.. Here is the tracing way.. STSRT 2 2 aabbaa *abbaa *abbaa 3 3 4 *abbaa *abbaa *abbaa 4 5 5 *abaaa *abaaa *abaaa∆ 6 7 8 *abaaa *abaa *aba 8 8 8 *aba *aba *aba START 2 3 *aba **ba **ba 4 5 5 **ba **aa **aa∆ 6 7 8 START **aa **a ** **∆ MCS EVE 2012-14 5/24/2015 23
  • 24. ANOTHER EXAMPLE • Language of palindromes.. MCS EVE 2012-14 5/24/2015 24
  • 25. ANOTHER EXAMPLE abbabba ∆bbabba ∆bbabb∆ ∆∆babb∆ ∆∆bab∆∆ ∆∆∆a∆∆∆ ∆∆∆a∆∆∆ ∆∆∆∆∆∆∆ Take a string which is not a palindrome and it must b reject (TM will crash). MCS EVE 2012-14 5/24/2015 25
  • 26. MORE ON TURING MACHINES • INSERT subprogram: • Sometimes in the running of TM, we may want to insert a character into the string on the TAPE exactly at the spot where the TAPE HEAD is pointing. • This means that the newly inserted character will occupy this cell and every right character on the TAPE will be shifted one cell right. The left character remains unchanged. • After insertion we want the TAPE HEAD moved on right of newly inserted character. • This subprogram not depend what the TM is doing. It is independent subprogram can be called in any other TM by specifying the what character to be inserted at what location. MCS EVE 2012-14 5/24/2015 26
  • 27. INSERT SUBPROGRAM(EXAMPLE) • If the character ‘b’ is inserted at the cell where the TAPE HEAD is pointing as shown below then, it is expressed as The function of subprogram INSERT ‘b’ can be observed from the following diagram ∞ b X a b b X ∆ ∆∞ ⌂ ∞ b X a b b X ∆ ∆∞ ⌂ INSERT b ∞ b X b a b b X ∆ ∆∞ ⌂ MCS EVE 2012-14 5/24/2015 27
  • 29. INSERT SUBPROGRAM(EXAMPLE) • Let insert ‘b’ at current location of TAPE HEAD as we discuss earlier.. What we do?? • we insert a character ‘Q’ as a marker then we shift all characters right one cell, and then move back to ‘Q’ to replace it by ‘b’. • Remember we take previous TAPE we discussed which have only characters a’s, b’s, X’s. • What the states of this subprogram doing?? • We start from state 1. In this state we read ‘a’ (either a, b or X) and then we write ‘Q’ and move TAPE HEAD right one cell. • Here in previous cell where ‘Q’ is inserted we displaced a character… ‘a’ in this example. • We must want to remember what we displaced in inserting the ‘Q’. • This require some memory to remember…. MCS EVE 2012-14 5/24/2015 29
  • 30. INSERT SUBPROGRAM(EXAMPLE) • In previous subprogram diagram state 2,3 and 4 are used as memory to remember ‘a’, ‘b’ and ‘X’ respectively. Remember ‘a’ is displaced Remember ‘b’ is displaced Remember ‘X’ is displaced MCS EVE 2012-14 5/24/2015 30
  • 31. • In our example at state 1 we read ‘a’ and replaced it with ‘Q’ and then entered in state 2 because ‘a’ is displaced, TAPE HEAD is also moved one cell right. • At state 2 we read ‘b’, we remember that we must place ‘a’ that we displaced, so we write an ‘a’, but now we realize that we have just displaced a ‘b’ and entered in state 3 because state 3 remember the ‘b’ is displaced. The TAPE HEAD also moves one cell right. ⌂ ∞ b X Q b b X ∆ ∆∞ ∞ b X Q a b X ∆ ∆∞ ⌂ 2 3 4 7 5 6 MCS EVE 2012-14 5/24/2015 31
  • 32. • At state 3 we read ‘b’ we replace it with ‘b’ and remain here, here we again displaced another ‘b’, the TAPE HEAD moves one cell right. • At state 3 we read ‘X’ this time replaced it with ‘b’ and entered in state 4 because now we displaced ‘X’, the TAPE HEAD move one cell right again. • At state 4 we read ‘∆’ which means the end of string, so we replace it last displaced character which was ‘X’, we entered state 5 now. TAPE HEAD also move one cell right. ∞ b X Q a b X ∆ ∆∞ ∞ b X Q a b b ∆ ∆∞ ⌂ ∞ b X Q a b b X ∆∞ ⌂ ⌂ 2 3 4 7 5 6 MCS EVE 2012-14 5/24/2015 32
  • 33. • At state 5 we read ∆ replace it with ∆ and entered in state 6 , move TAPE HEAD left one cell. • At state 6 either read a, b or X replace with itself by moving left and remain at state 6 until we read ‘Q’ . • When we read ‘Q’ replace it with ‘b’ because our example is to insert ‘b’ and move the TAPE HEAD one cell right. REMEMBER: This is independent subprogram and we suppose only three characters on the TAPE to reduce the complexity. ⌂ ∞ b X b a b b X ∆ ∆∞ 2 3 4 7 5 6 MCS EVE 2012-14 5/24/2015 33
  • 34. MORE ON TURING MACHINE • DELETE subprogram: • Sometimes, a character is required to be DELETED on the TAPE exactly at the spot where the TAPE Head is pointing, so that the other characters on the right of the TAPE Head are moved one cell left. • The characters to the left of the pointed cell are also required to remain as such. • The subprogram of deletion is independent and can be incorporated at any time with any TM program specifying what character to be deleted at what location. MCS EVE 2012-14 5/24/2015 34
  • 35. DELETE SUBPROGRAM(EXAMPLE) • If the character ‘b’ is deleted at the cell where the TAPE HEAD is pointing as shown below then, it is expressed as The function of subprogram DELETE ‘b’ can be observed from the following diagram ∞ b X a b b X ∆ ∆∞ ⌂ ∞ b X a b b X ∆ ∆∞ ⌂ DELETE b ∞ b X a b b X ∆ ∆ ∆∞ ⌂ MCS EVE 2012-14 5/24/2015 35
  • 36. DELETE SUBPROGRAM(EXAMPLE) MCS EVE 2012-14 5/24/2015 36
  • 37. DELETE SUBPROGRAM(EXAMPLE) • What the states of this subprogram doing?? • We start from state 1. In this state we read ‘a’ (either a, b or X) and then we write ‘∆’ and move TAPE HEAD right until we reach at the end of the TAPE non- ∆. • At once we read ∆ it means we are at the end of input now. • Now we move left and replace what we displaced similar to INSERT subprogram (it work inverse of INSERT subprogram). • This require some memory to remember…. Similar to INSERT subprogram DELETE subprogram also have some memory to remember what is displaced at some location. MCS EVE 2012-14 5/24/2015 37
  • 38. MCS EVE 2012-14 5/24/2015 38

Editor's Notes

  1. azmizryk@gmail.com