SlideShare a Scribd company logo
Lec14_TuringMachines 2PDA (1).pdf thooooo
 Definition
 Example
 Subprogram INSERT
 EQUAL
 Subprogram DELETE
2
The mathematical models (FAs, TGs, PDAs) that have been
discussed so far can decide whether a string is accepted
or not by them i.e. these models are language identifiers.
However, there are still some languages which can’t be
accepted by them e.g. there does not exist any FA or 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.
3
The Language Hierarchy
a*
anbncn ?
Context-Free Languages
anbn
Regular Languages
4
wwR
ww ?
a*b*
a*
anbncn
Context-Free Languages
anbn
Regular Languages
wwR
ww
a*b*
Languages accepted by
Turing Machines
5
Definition: A Turing machine (TM) consists of the
following
1. An alphabet Σ of input letters.
2. 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 rest of the TAPE is initially filled
with blanks (∆’s).
6
3. A tape Head that can read the contents of cell on
the TAPE in one step and it can replace the
character at the cell and can reposition itself to
the next cell to the right or to the left of that it
has just read.
. . .
∆
a
b
a
iv
iii
ii
i
TAPE Head
Input TAPE
7
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
.
4. 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.
8
5. 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.
6. 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)
9
It may be noted that in the triplet on any edge
(a, b, R) the first letter, a , is the character the
TAPE Head reads from the cell to which it is
pointing. The second letter, b , is what the
TAPE Head prints the cell before it leaves. The
third letter, R , signifies the direction the TAPE
Head whether to move one cell to the right, R,
or one cell to the left, L. Following is a note
10
It may be noted that there may not be any outgoing
edge at certain state for certain letter to be read
from the TAPE, which creates non-determinism in
Turing machines. It may also be noted that at
certain state, there can’t be more than one out-
going edges for certain letter to be read from the
TAPE. The machine crashes if there is not a path for
a letter to be read from the TAPE and the
corresponding string is supposed to be rejected.
11
To terminate execution of certain input string
successfully, a HALT state must be entered and
the corresponding string is supposed to be
accepted by the TM. The machine also crashes
when the TAPE Head is instructed to move one
cell to the left of cell i.
Following is an example of TM
12
Consider the following Turing machine
Let the input string aba be run over this TM
(a,a,R)
3
1 START 4 HALT
(b,b,R)
(b,b,R)
(b,b,R)
(a,a,R)
(∆, ∆,R)
2
13
Example continued …
Starting from the START state, reading a form the
TAPE and according to the TM program, a will be
printed i.e. a will be replaced by a and the TAPE
Head will be moved one cell to the right.
. . .
∆
a
b
a
iv
iii
ii
i
TAPE Head
Input TAPE
14
Chapter 19: Turing Machines
3
(a,a,R)
(b,b,R)
∆
∆
(a,a,R)
(b,b,R)
2
(b,b,R)
START 1 HALT 4
(∆,∆,R)
a …
b a ∆
1 → 2 → 3 → 3 → HALT
aba aba aba abaΔ
a …
b a ∆
…
a b a
∆
1
5
1
6
◼ Theorem. For every regular language, there is a Turing
machine that accepts it.
Proof: We transform a finite automaton to a Turing
machine.
◼ The start state of the finite automaton is the start state of the
Turing machine.
◼ Add a halt state to the Turing machine, and one transition from
every final state of the finite automaton to the new halt state.
(Erase all the + symbols.) Label the new transitions
(∆,∆,R).
◼ Change each label a of the finite automaton to (a,a,R), and
similarly for all other letters of Σ.
2
(b,b,R)
3 4
(b,b,R)
(a,a,R)
(b,b,R)
(b,b,R)
(a,a,R) (a,a,R) (a,a,R)
START 1
HALT
(∆,∆,R)
Example: EVEN-EVEN
1 START
9 HALT
(∆, ∆,R) (a,*,R)
(*,*,R)
(a,a,L)
(b,b,L) (a, ∆,L) (a, ∆,L)
(∆, ∆,L)
(a,a,R)
(b,a,R)
(a,a,L)
(b,b,R)
(b,b,R)
(a,a,R)
6
2 3 4
5
7
8
Example
Consider the following TM
18
anbnan
The string aaabbbaaa can be observed to be
accepted by the above TM. It can also be
observed that the above TM accepts the non-
CFL {anbnan}.
19
20
Must have double ‘aa’
1. Those with a double a. They are accepted by the TM.
2. Those without aa that end in a. They crash.
3. Those without aa that end in b. They loop forever.
21
DEFINITION
Every Turing machine T over the alphabet divides the set of strings into three
classes:
1. ACCEPT(T) is the set of all strings leading to a HALT state. This is also
called the language accepted by T.
2. REJECT(T) is the set of all strings that crash during execution by moving left
from cell i or by being in a state that has no exit edge that wants to read the
character the TAPE HEAD is reading.
3. LOOP(T) is the set of all other strings, that is, strings that loop forever while
running on T.
Sometimes, a character is required to be
inserted on the TAPE exactly at the spot where
the TAPE Head is pointing, so that the
character occupies the required cell and the
other characters on the TAPE are moved one
cell right. The characters to the left of the
pointed cell are also required to remain as
such.
22
In the situation stated above, the part of TM
program that executes the process of insertion
does not affect the function that the TM is
performing. The subprogram of insertion is
independent and can be incorporated at any
time with any TM program specifying what
character to be inserted at what location. The
subprogram of insertion can be expressed as
23
INSERT a
INSERT b
INSERT #
The above diagrams show that the characters a,b
and # are to be inserted, respectively. Following is
an example showing how does the subprogram
INSERT perform its function
24
If the letter b is inserted at the cell where the
TAPE Head is pointing as shown below
then, it is expressed as
∆. . .
∆
X
b
b
a
X
b
. . .
INSERT b
∆. . .
∆
X
b
b
a
X
b
. . .
25
The function of subprogram INSERT b can be
observed from the following diagram
Following is the INSERT subprogram
∆. . .
∆
X
b
b
a
b
X
b
. . .
26
Keeping in view the same example of inserting
b at specified location, to determine the
required subprogram, first Q will be inserted as
marker at the required location, so that the
TAPE Head must be able to locate the proper
cell to the right of the insertion cell. The whole
subprogram INSERT is given as
27
Out
In 1
2
3
4 5
6
7 (a,a,L)
(b,b,L)
(X,X,L)
(∆,a,R)
(∆, ∆,L)
(∆,X,R)
(∆, b,R)
(∆, b,R)
(b,Q,R)
(a,Q,R)
(a,a,R)
(a,X,R)
(X,a,R)
(a,b,R)
(b,a,R)
(b,b,R)
(X,b,R)
(b,X,R)
(X,X,R)
(Q, b,R)
28
It is supposed that machine is at state 1, when b is
to be inserted. All three possibilities of reading a, b
or X are considered by introducing the states 2, 3
and 4 respectively. These states remember what
letter displaced during the insertion of Q.
Consider the same location where b is to be
inserted
29
After reading a from the TAPE, the program
replaces a by Q and the TAPE Head will be
moved one step right. Here the state 2 is
entered. Reading b at state 2, b will be replaced
by a and state 3 will be entered. At state 3 b is
read which is not replaced by any character and
the state 3 will not be left.
∆. . .
∆
X
b
b
a
X
b
. . .
30
At state 3, the next letter to be read is X, which will be
replaced by b and the state 4 will be entered. At state
4, ∆ will be read, which will be replaced by X and state
5 will be entered. At state 5 ∆ will be read and without
any change state 6 will be entered, while TAPE Head
will be moved one step left. The state 6 makes no
change whatever (except Q) is read at that state.
However at each step, the TAPE Head is moved one
step left. Finally, Q is read which is replaced by b and
the TAPE Head is moved to one step right.
31
7
6
START
HALT
8
(X,X,R)
(b,b,R)
9
(D,D,L)
(a,X,L) (#,#,R)
INSERT #
10
(X,X,L)
(b,b,L)
(X,X,L)
(a,a,L)
(X,X,R)
(a,a,R)
(b,X,L)
(#,#,R)
(#,#,R)
(X,X,L)
32
Hence, the required situation of the TAPE can
be shown as
∆. . .
∆
X
b
b
a
X
b
. . .
33
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.
34
In the situation stated above, the part of TM
program that executes the process of deletion
does not affect the function that the TM is
performing. 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. The
subprogram of deletion can be expressed as
35
If the letter a is to be deleted from the string
bcabbc, shown below
then, it is expressed as
∆. . .
∆
c
b
b
a
c
b
. . .
DELETE
∆. . .
∆
c
b
b
a
c
b
. . .
36
The function of subprogram DELETE can be
observed from the following diagram
Following is the DELETE subprogram
. .
.
∆
∆
c
b
b
c
b
. . .
37
(c, ∆,R)
(b, ∆,R)
(b,a,L)
(∆, ∆,L)
(a,a,R)
(b,b,R)
(c,c,R)
(c, ∆,L)
(c,b,L)
(b,c,L)
(a,b,L)
(a,a,L)
(∆,a,R) (∆,c,R)
(∆,b,R)
(c,a,L)
(a,c,L)
(b,b,L)
(b, ∆,L)
(c,c,L)
In
Out
1 2 3
5
4 6
7
(a, ∆,R)
38
(a, ∆,L)
The process of deletion of letter a from the
string bcabbc can easily be checked, giving the
TAPE situation as shown below
. .
.
∆
∆
c
b
b
c
b
. . .
39
40
anbn
41
OddPalindrome / EvenPalindrome
42
Even a’s
43
Even-Even
44
45
The language this TM accepts is DOUBLEWORD, the set of all words of the
form ww where w is a nonnull string in {a, b}*.
DOUBLEWORD = {aa bb aaaa abab baba bbbb aaaaaa aabaab . . }
Double Word Problem
Sample Problems
46
 Let us define a two-stack pushdown automaton
as follows
M = (K, , , D, s, F)
 K is a finite set of states,
  is an alphabet (the input symbols),
  is an alphabet (the stack symbols),
 s  K is the start state,
 F  K is the set of final states, and
 Finite set of transition from one state to
another state
47
 As we have two stacks for storage purpose, so
change the name of POP and PUSH stack
accordingly.
 POP1 will pop from the first stack
 POP2 will pop from the second stack
 PUSH1 will push into first stack
 PUSH2 will push into second stack
48
 Guess the
Language
 anbnan
49
 Run
aabba
a
50
Minsky’s Theorem
Theorem:
Any language accepted by a 2PDA can be
accepted by some TM and any language
accepted by a TM can also accepted by 2PDA.
Proof :
2PDA has 3 locations for storage
1. Stack1
2. Stack2
3. Input Tape
51
52
Future Topics
• NPDA
• Post Machines
• Conversion from one machine to the other

More Related Content

PPTX
Turing Machine
PPTX
Turing machine-TOC
PPTX
Unit iv
DOCX
theory of computation notes for school of engineering
PDF
TuringMachines.pdf
PPTX
03-FiniteAutomata.pptx
PDF
Theory of automata and formal language lab manual
PPTX
a7f0bc7785844884c4de624f61ce5978_MIT18_404f20_lec4.pptx
Turing Machine
Turing machine-TOC
Unit iv
theory of computation notes for school of engineering
TuringMachines.pdf
03-FiniteAutomata.pptx
Theory of automata and formal language lab manual
a7f0bc7785844884c4de624f61ce5978_MIT18_404f20_lec4.pptx

Similar to Lec14_TuringMachines 2PDA (1).pdf thooooo (20)

PDF
Theory of computation and automata
PDF
Theory of computation and automata
PPTX
PUSH DOWN AUTOMATA VS TURING MACHINE
PPT
02. chapter 3 lexical analysis
PPT
2-stack-Push Down Automata(PDA)_TOComp.ppt
DOCX
Introduction to Finite Automata .docx
PDF
Ltxcrib
PDF
Finite Automata
PPTX
Winter 8 TM.pptx
PDF
Free Ebooks Download ! Edhole
PDF
flat unit1
PDF
Volume 2-issue-6-2205-2207
PDF
Volume 2-issue-6-2205-2207
PPT
Pushdown-Automata_L1.ppt
PDF
Turing machines
PPT
2_4 Finite Automata.ppt
PPTX
Lecture 4 final FINITE AUTOMATA FOR THEORY OF COMPUTATION
PPTX
Lecture 4diuedhiuhiudhiqwuhiuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu fin...
PPTX
Unit 2 Pumping lemma Unit 2 Pumping lemma
PPT
Nfa vs dfa
Theory of computation and automata
Theory of computation and automata
PUSH DOWN AUTOMATA VS TURING MACHINE
02. chapter 3 lexical analysis
2-stack-Push Down Automata(PDA)_TOComp.ppt
Introduction to Finite Automata .docx
Ltxcrib
Finite Automata
Winter 8 TM.pptx
Free Ebooks Download ! Edhole
flat unit1
Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207
Pushdown-Automata_L1.ppt
Turing machines
2_4 Finite Automata.ppt
Lecture 4 final FINITE AUTOMATA FOR THEORY OF COMPUTATION
Lecture 4diuedhiuhiudhiqwuhiuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu fin...
Unit 2 Pumping lemma Unit 2 Pumping lemma
Nfa vs dfa
Ad

Recently uploaded (20)

PPTX
UNIT 4 Total Quality Management .pptx
PDF
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
PDF
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PDF
86236642-Electric-Loco-Shed.pdf jfkduklg
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
Artificial Intelligence
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PPT
Occupational Health and Safety Management System
PPTX
UNIT - 3 Total quality Management .pptx
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PPTX
Current and future trends in Computer Vision.pptx
UNIT 4 Total Quality Management .pptx
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
Exploratory_Data_Analysis_Fundamentals.pdf
86236642-Electric-Loco-Shed.pdf jfkduklg
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
III.4.1.2_The_Space_Environment.p pdffdf
Artificial Intelligence
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
Occupational Health and Safety Management System
UNIT - 3 Total quality Management .pptx
Categorization of Factors Affecting Classification Algorithms Selection
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
Current and future trends in Computer Vision.pptx
Ad

Lec14_TuringMachines 2PDA (1).pdf thooooo

  • 2.  Definition  Example  Subprogram INSERT  EQUAL  Subprogram DELETE 2
  • 3. The mathematical models (FAs, TGs, PDAs) that have been discussed so far can decide whether a string is accepted or not by them i.e. these models are language identifiers. However, there are still some languages which can’t be accepted by them e.g. there does not exist any FA or 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. 3
  • 4. The Language Hierarchy a* anbncn ? Context-Free Languages anbn Regular Languages 4 wwR ww ? a*b*
  • 6. Definition: A Turing machine (TM) consists of the following 1. An alphabet Σ of input letters. 2. 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 rest of the TAPE is initially filled with blanks (∆’s). 6
  • 7. 3. A tape Head that can read the contents of cell on the TAPE in one step and it can replace the character at the cell and can reposition itself to the next cell to the right or to the left of that it has just read. . . . ∆ a b a iv iii ii i TAPE Head Input TAPE 7
  • 8. 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 . 4. 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. 8
  • 9. 5. 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. 6. 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) 9
  • 10. It may be noted that in the triplet on any edge (a, b, R) the first letter, a , is the character the TAPE Head reads from the cell to which it is pointing. The second letter, b , is what the TAPE Head prints the cell before it leaves. The third letter, R , signifies the direction the TAPE Head whether to move one cell to the right, R, or one cell to the left, L. Following is a note 10
  • 11. It may be noted that there may not be any outgoing edge at certain state for certain letter to be read from the TAPE, which creates non-determinism in Turing machines. It may also be noted that at certain state, there can’t be more than one out- going edges for certain letter to be read from the TAPE. The machine crashes if there is not a path for a letter to be read from the TAPE and the corresponding string is supposed to be rejected. 11
  • 12. To terminate execution of certain input string successfully, a HALT state must be entered and the corresponding string is supposed to be accepted by the TM. The machine also crashes when the TAPE Head is instructed to move one cell to the left of cell i. Following is an example of TM 12
  • 13. Consider the following Turing machine Let the input string aba be run over this TM (a,a,R) 3 1 START 4 HALT (b,b,R) (b,b,R) (b,b,R) (a,a,R) (∆, ∆,R) 2 13
  • 14. Example continued … Starting from the START state, reading a form the TAPE and according to the TM program, a will be printed i.e. a will be replaced by a and the TAPE Head will be moved one cell to the right. . . . ∆ a b a iv iii ii i TAPE Head Input TAPE 14
  • 15. Chapter 19: Turing Machines 3 (a,a,R) (b,b,R) ∆ ∆ (a,a,R) (b,b,R) 2 (b,b,R) START 1 HALT 4 (∆,∆,R) a … b a ∆ 1 → 2 → 3 → 3 → HALT aba aba aba abaΔ a … b a ∆ … a b a ∆ 1 5
  • 16. 1 6 ◼ Theorem. For every regular language, there is a Turing machine that accepts it. Proof: We transform a finite automaton to a Turing machine. ◼ The start state of the finite automaton is the start state of the Turing machine. ◼ Add a halt state to the Turing machine, and one transition from every final state of the finite automaton to the new halt state. (Erase all the + symbols.) Label the new transitions (∆,∆,R). ◼ Change each label a of the finite automaton to (a,a,R), and similarly for all other letters of Σ.
  • 17. 2 (b,b,R) 3 4 (b,b,R) (a,a,R) (b,b,R) (b,b,R) (a,a,R) (a,a,R) (a,a,R) START 1 HALT (∆,∆,R) Example: EVEN-EVEN
  • 18. 1 START 9 HALT (∆, ∆,R) (a,*,R) (*,*,R) (a,a,L) (b,b,L) (a, ∆,L) (a, ∆,L) (∆, ∆,L) (a,a,R) (b,a,R) (a,a,L) (b,b,R) (b,b,R) (a,a,R) 6 2 3 4 5 7 8 Example Consider the following TM 18 anbnan
  • 19. The string aaabbbaaa can be observed to be accepted by the above TM. It can also be observed that the above TM accepts the non- CFL {anbnan}. 19
  • 20. 20 Must have double ‘aa’ 1. Those with a double a. They are accepted by the TM. 2. Those without aa that end in a. They crash. 3. Those without aa that end in b. They loop forever.
  • 21. 21 DEFINITION Every Turing machine T over the alphabet divides the set of strings into three classes: 1. ACCEPT(T) is the set of all strings leading to a HALT state. This is also called the language accepted by T. 2. REJECT(T) is the set of all strings that crash during execution by moving left from cell i or by being in a state that has no exit edge that wants to read the character the TAPE HEAD is reading. 3. LOOP(T) is the set of all other strings, that is, strings that loop forever while running on T.
  • 22. Sometimes, a character is required to be inserted on the TAPE exactly at the spot where the TAPE Head is pointing, so that the character occupies the required cell and the other characters on the TAPE are moved one cell right. The characters to the left of the pointed cell are also required to remain as such. 22
  • 23. In the situation stated above, the part of TM program that executes the process of insertion does not affect the function that the TM is performing. The subprogram of insertion is independent and can be incorporated at any time with any TM program specifying what character to be inserted at what location. The subprogram of insertion can be expressed as 23
  • 24. INSERT a INSERT b INSERT # The above diagrams show that the characters a,b and # are to be inserted, respectively. Following is an example showing how does the subprogram INSERT perform its function 24
  • 25. If the letter b is inserted at the cell where the TAPE Head is pointing as shown below then, it is expressed as ∆. . . ∆ X b b a X b . . . INSERT b ∆. . . ∆ X b b a X b . . . 25
  • 26. The function of subprogram INSERT b can be observed from the following diagram Following is the INSERT subprogram ∆. . . ∆ X b b a b X b . . . 26
  • 27. Keeping in view the same example of inserting b at specified location, to determine the required subprogram, first Q will be inserted as marker at the required location, so that the TAPE Head must be able to locate the proper cell to the right of the insertion cell. The whole subprogram INSERT is given as 27
  • 28. Out In 1 2 3 4 5 6 7 (a,a,L) (b,b,L) (X,X,L) (∆,a,R) (∆, ∆,L) (∆,X,R) (∆, b,R) (∆, b,R) (b,Q,R) (a,Q,R) (a,a,R) (a,X,R) (X,a,R) (a,b,R) (b,a,R) (b,b,R) (X,b,R) (b,X,R) (X,X,R) (Q, b,R) 28
  • 29. It is supposed that machine is at state 1, when b is to be inserted. All three possibilities of reading a, b or X are considered by introducing the states 2, 3 and 4 respectively. These states remember what letter displaced during the insertion of Q. Consider the same location where b is to be inserted 29
  • 30. After reading a from the TAPE, the program replaces a by Q and the TAPE Head will be moved one step right. Here the state 2 is entered. Reading b at state 2, b will be replaced by a and state 3 will be entered. At state 3 b is read which is not replaced by any character and the state 3 will not be left. ∆. . . ∆ X b b a X b . . . 30
  • 31. At state 3, the next letter to be read is X, which will be replaced by b and the state 4 will be entered. At state 4, ∆ will be read, which will be replaced by X and state 5 will be entered. At state 5 ∆ will be read and without any change state 6 will be entered, while TAPE Head will be moved one step left. The state 6 makes no change whatever (except Q) is read at that state. However at each step, the TAPE Head is moved one step left. Finally, Q is read which is replaced by b and the TAPE Head is moved to one step right. 31
  • 33. Hence, the required situation of the TAPE can be shown as ∆. . . ∆ X b b a X b . . . 33
  • 34. 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. 34
  • 35. In the situation stated above, the part of TM program that executes the process of deletion does not affect the function that the TM is performing. 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. The subprogram of deletion can be expressed as 35
  • 36. If the letter a is to be deleted from the string bcabbc, shown below then, it is expressed as ∆. . . ∆ c b b a c b . . . DELETE ∆. . . ∆ c b b a c b . . . 36
  • 37. The function of subprogram DELETE can be observed from the following diagram Following is the DELETE subprogram . . . ∆ ∆ c b b c b . . . 37
  • 38. (c, ∆,R) (b, ∆,R) (b,a,L) (∆, ∆,L) (a,a,R) (b,b,R) (c,c,R) (c, ∆,L) (c,b,L) (b,c,L) (a,b,L) (a,a,L) (∆,a,R) (∆,c,R) (∆,b,R) (c,a,L) (a,c,L) (b,b,L) (b, ∆,L) (c,c,L) In Out 1 2 3 5 4 6 7 (a, ∆,R) 38 (a, ∆,L)
  • 39. The process of deletion of letter a from the string bcabbc can easily be checked, giving the TAPE situation as shown below . . . ∆ ∆ c b b c b . . . 39
  • 40. 40
  • 45. 45 The language this TM accepts is DOUBLEWORD, the set of all words of the form ww where w is a nonnull string in {a, b}*. DOUBLEWORD = {aa bb aaaa abab baba bbbb aaaaaa aabaab . . } Double Word Problem
  • 47.  Let us define a two-stack pushdown automaton as follows M = (K, , , D, s, F)  K is a finite set of states,   is an alphabet (the input symbols),   is an alphabet (the stack symbols),  s  K is the start state,  F  K is the set of final states, and  Finite set of transition from one state to another state 47
  • 48.  As we have two stacks for storage purpose, so change the name of POP and PUSH stack accordingly.  POP1 will pop from the first stack  POP2 will pop from the second stack  PUSH1 will push into first stack  PUSH2 will push into second stack 48
  • 51. Minsky’s Theorem Theorem: Any language accepted by a 2PDA can be accepted by some TM and any language accepted by a TM can also accepted by 2PDA. Proof : 2PDA has 3 locations for storage 1. Stack1 2. Stack2 3. Input Tape 51
  • 52. 52 Future Topics • NPDA • Post Machines • Conversion from one machine to the other