SlideShare ist ein Scribd-Unternehmen logo
1 von 26
THEORY OF AUTOMATAAND
FORMAL LANGUAGES
UNIT-IV
ABHIMANYU MISHRA
ASSISTANT PROF.(CSE)
JETGI
Abhimanyu Mishra(CSE) JETGI12/31/2016
PUSHDOWN AUTOMATA INTRODUCTION
“The pushdown automata is essentially a finite automata with control of both
an input tape and a stack to store what it has read. A stack is “FIRST IN FIRST
OUT” list, that is, symbols can be entered or removed only at the top of the
list. When a new symbol is entered at the top, the symbol previously at the top
becomes second and so on”.
Basically a pushdown automaton is −
"Finite state machine" + "a stack“
A pushdown automaton has three components −
(i) an input tape,
(ii) a control unit
(iii) a stack with infinite size.
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Diagram
a b c b a c ……………..
Input Tape
a
c
b
a
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Finite Control
DEFINATION OF PUSHDOWN AUTOMATA
A pushdown automata is a system, which is mathematically defined as
follows:
P = ( Q,∑,┌,δ,s,F)
Where Q : non-empty finite set of states
∑ : non-empty finite set of input symbols
┌ : is finite set of pushdown symbols
s : is the initial state, s ∈ Q
F : is the set of final states and F Q
δ : It is a transition function or transition relation.
12/31/2016 Abhimanyu Mishra(CSE) JETGI
THERE ARE TWO DIFFERENT WAYS TO DEFINE PDA
ACCEPTABILITY.
(i) Final State Acceptability
In final state acceptability, a PDA accepts a string when, after reading the
entire string, the PDA is in a final state. From the starting state, we can make
moves that end up in a final state with any stack values. The stack values are
irrelevant as long as we end up in a final state.
For a PDA (Q,∑,┌,δ,s, F) the language accepted by the set of final states F is −
L(PDA) = {w | (q0, w, I) ⊢* (q, ε, x), q ∈ F}
for any input stack string x
12/31/2016 Abhimanyu Mishra(CSE) JETGI
(ii) Empty Stack Acceptability
Here a PDA accepts a string when, after reading the entire string, the PDA has
emptied its stack.
For a PDA (Q, ∑,┌,δ,s, F), the language accepted by the empty stack is −
L(PDA) = {w | (q0, w, I) ⊢* (q, ε, ε), q ∈ Q}
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Example: Design a PDA which accepts the language
L ={ w ∈{a,b}*/w has equal no of a’ and b’s}
Now let us assume that PDA be P
P = (Q,∑,┌,δ,s,F)
Q = { s,q,f}
∑ = {a,b}
┌ = {a,b,c}
F = {f} , and δ is as follows
Now let us assume stack have c value in initial in stack,
12/31/2016 Abhimanyu Mishra(CSE) JETGI
(i) ((s, ∈, ∈),(q,c))
(ii) ((q,a,c),(q,ac))
(iii) (q,a,a),(q,aa))
(iv) ((q,a,b),(q, ∈))
(v) ((q,b,c),(q,bc))
(vi) ((q,b,b),(q,bb))
(vii) ((q,b,a),(q, ∈))
(viii) ((q, ∈,c),(f, ∈))
Now if PDA reads symbol ’a’ from the input tape and if stack is empty or has
‘a’ on the stack top then push ‘a’ into the stack, Now if reads ‘a’ from input and
‘b’ is on top of the stack then. It simply pops the symbol ‘b’ and pushes
nothing.
So final state is defined as, PDA is in state f and stack is empty
12/31/2016 Abhimanyu Mishra(CSE) JETGI
PUSHDOWN AUTOMATAAND CONTEXT-FREE-GRAMMARS
It should be clear now that PDA can recognize any language for which there
exists a CFG. “ That is class of language accepts by pushdown automata is
exactly the class of context-free languages”.
(i) Algorithm to find PDA corresponding to a given CFG
(ii)Algorithm to find CFG corresponding to a given PDA
12/31/2016 Abhimanyu Mishra(CSE) JETGI
(I) ALGORITHM TO FIND PDA CORRESPONDING TO A GIVEN
CFG
Input : A CFG, G = (Vn,Vt,P,S)
Output: Equivalent PDA, P= (Q, ∑, ┌, δ, q0, F)
Steps:
(i) Convert of the production of CFG to GNF
(ii) The PDA has only one state q0
(iii) The start symbol of CFG will be the start symbol in the PDA
(iv) All non-terminals of the CFG will be the stack symbols of the PDA
and all the terminals of the CFG will be the input symbols of the
PDA.
(v) For each production in the form A → aX where a is terminal and
A, X are combination of terminal and non-terminals make a
transition δ (q, a, A).
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Example
Construct a PDA from the following CFG.
G = ({S, X}, {a, b}, P, S)
where the productions are −
S → XS | ε , A → aXb | Ab | ab
Solution
Let the equivalent PDA,
P = ({q}, {a, b}, {a, b, X, S}, δ, q, S)
where δ −
δ (q, ε , S) = {(q, XS), (q, ε )}
δ(q, ε , X) = {(q, aXb), (q, Xb), (q, ab)}
δ(q, a, a) = {(q, ε )}
δ(q, 1, 1) = {(q, ε )}
12/31/2016 Abhimanyu Mishra(CSE) JETGI
(II) ALGORITHM TO FIND CFG CORRESPONDING TO A GIVEN
PDA
Input : A CFG, G = (Vn,Vt,P,S)
Output : Equivalent PDA, P = (Q, ∑, ┌, δ, q0, F)such that the non-
terminals of the grammar G will be {Xwx | w,x ∈ Q} and the start
state will be Aq0,F.
Steps:
(i) For every w, x, y, z ∈ Q, m ∈┌ and a, b ∈ ∑, if δ (w, a, ε) contains (y,
m) and (z, b, m) contains (x, ε), add the production rule Xwx → a
Xyzb in grammar G.
(ii) For every w, x, y, z ∈ Q, add the production rule Xwx → XwyXyx in
grammar G.
(iii) For w ∈ Q, add the production rule Xww → ε in grammar G.
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Example:
Design a PDA for the following CFG, G = (Vn,Vt,P,S) with Vn ={S}, Vt
={(,)} and P is defined δ as follows
S → (S) | ε|SS
Solution:
Lets corresponding PDA will be
P = (Q, ∑, ┌, δ, q0, F)
Q={p,q}
∑ = {(,)}
┌ = (S,(,)} that is terminal and non-terminal in grammar
S =p
F = {q}, and δ is as,
12/31/2016 Abhimanyu Mishra(CSE) JETGI
(1) ((p, ε , ε) , {(q, S))
(2) ((q, ε , S) ,{(q, ε )) because S → ∈ is a rule of CFG
(3) ((q, ε, S) ,(q, SS))
(4) ((q, ε,S) , (q, (S))
(5) ((q, (,(),(q, ε))
(6) (((q,),)),(q,(q,ε)) for each a ∈ Vt
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Now apply these transition relation on the string w=( )( )
12/31/2016 Abhimanyu Mishra(CSE) JETGI
S.N State Unread
input
Stack Transiti
on used
1 q ( ) ( ) ∈ -
2 q ( ) ( ) S (1)
3 q ( ) ( ) SS (3)
4 q ( ) ( ) (S)SS (4)
5 q ) ( ) S)S (5)
6 q )( ) )S (2)
7 q ( ) S (6)
8 q ( ) (S) (4)
9 q ) S) (5)
10 q ) ) (2)
11 q ∈ ∈ (6)
Example: Consider the following PDA and construct equivalent CFG
1. ((q0,a,$) →(q0,a$))
2. ((q0,b,$) →(q0,b$))
3. ((q0,a,a) →(q0,aa))
4. ((q0,b,b) →(q0,bb))
5. ((q0,a,b) →(q0,ab))
6. ((q0,b,a) →(q0,ba))
7. ((q0,c,$) →(q1,$))
8. ((q0,c,a) →(q1,a))
9. ((q1,c,b) →(q1,b))
10. ((q1,a,a) →(q1, ∈))
11. ((q1,b,b) →(q1, ∈))
12. ((q1, ∈,$) →(q1, ∈))
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Sol: CFG using above construction production rule is as follows:
S→[q0 $ q0 ]/ [q0 $ q1 ] rule (i)
[q0 a q0 ] → a
[q0 b q1 ] → b
[q1 $ q1 ] → ∈ rule(ii)
Now remaining productions are:-
[q0 $ q0 ] → a [q0 a q0 ]/ [q0 $ q0 ]
[q0 $ q1 ] → a [q0 a q0 ]/ [q0 $ q1 ]
[q0 $ q1 ] → a [q0 a q1 ]/ [q1 $ q1 ]
[q0 $ q1 ] → b [q0 b q0 ]/ [q0 $ q0 ]
[q0 $ q1 ]→ b [q0 b q0 ]/ [q0 $ q1 ]
[q0 $ q1 ] → b [q0 b q1 ]/ [q1 $ q1 ]
12/31/2016 Abhimanyu Mishra(CSE) JETGI
[q0 a q0 ] → a [q0 a q0 ]/ [q0 a q0 ]
[q0 a q1 ] → a [q0 a q0 ]/ [q0 a q1 ]
[q0 a q1 ] → a [q0 a q1 ]/ [q1 a q1 ]
[q0 a q0 ] → b [q0 b q0 ]/ [q0 a q0 ]
[q0 a q1 ] → b [q0 b q0 ]/ [q0 a q0 ]
[q0 a q1 ] → b [q0 b q1 ]/ [q1 a q1 ]
[q0 b q0 ] → a [q0 a q0 ]/ [q0 b q0 ]
[q0 b q1 ] → a [q0 a q0 ]/ [q0 b q1 ]
[q0 b q1 ] → a [q0 a q1 ]/ [q1 b q1 ]
12/31/2016 Abhimanyu Mishra(CSE) JETGI
[q0 b q0 ] → b [q0 b q0 ]/ [q0 b q0 ]
[q0 b q0 ] → b [q0 b q0 ]/ [q0 b q1 ]
[q0 b q0 ] → b [q0 b q1 ]/ [q1 $ q1 ]
[q0 $ q1 ] → c [q0 b q1 ]
[q0 a q1 ] → c [q1 a q1 ]
[q0 b q0 ] → c [q1 b q1 ]
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Problems?
1. Construct PDA for language L = {(ab)n /n>=1}.
2. Construct a PDA to accept the language L = { set of all words in a and
b with an even numbers of a’s}.
3. Construct a PDA for the regular expression
r = 0*1+
12/31/2016 Abhimanyu Mishra(CSE) JETGI
TWO STACK PDA
A two-stack PDA is a sixtuple (Q, , , , q0, F), where Q, , , q0, and F are
the same as in a one-stack PDA. The transition function as follow:
: Q  (  {  })  (  {  })  (  {  })  to the set of all subsets
of Q  (  {  })  (  {  })
The two stacks of the PDA are independent.
one stack: two stack:
A/B A/B/C
Two-Stack PDA accepts any language that accepted by a Turing Machine.
12/31/2016 Abhimanyu Mishra(CSE) JETGI
TWO STACK PDA
(i) A Turing machine can accept languages not accepted
by any PDA with one stack.
(ii) The strength of pushdown automata can be increased by
adding other stacks.
(iii) Actually, a PDA with two stacks have the same computation
control as a Turing Machine.
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Diagram of TWO STACK PDA
INPUT TAPE
TAPE HEAD HEAD MOVES
STACK 1 STACK 2
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Finite Control
Theorem 8.13 (Hopcroft and Ullman [1])
If a language L is accepted by a Turing machine, L is accepted by a Two-
Stack machine.
The idea is that the first stack can hold what is to the left of the head, while the
second stack holds what is to the right of the head, neglecting all the infinite
blank symbols beyond the leftmost and rightmost of the head.
The proof is taken from (Hopcroft and Ullman [1])
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Let’s L be L(M) for some one tape TM M, two-stack machine S, simulating a
one-tape TM M as the following:
S begins with a bottom-of-stack marker on each stack, this marker considered
the start symbol for the stacks, and must not appear elsewhere on the stacks.
The marker indicates that the stack is empty.
The proof is taken from (Hopcroft and Ullman [1])
12/31/2016 Abhimanyu Mishra(CSE) JETGI
Suppose that w$ is on the input of S. S copies the input w onto its first stack,
and stops to copy when reading the end marker on the input.
S pops each symbol in turn from its first stack and pushes it onto its second stack.
The first stack of S is empty. The second stack holds w, with the left end of w is
at the top.
12/31/2016 Abhimanyu Mishra(CSE) JETGI

Weitere ähnliche Inhalte

Was ist angesagt?

Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Abhimanyu Mishra
 
Lexical analyzer generator lex
Lexical analyzer generator lexLexical analyzer generator lex
Lexical analyzer generator lexAnusuya123
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languagesparmeet834
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Srimatre K
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of LanguageDipankar Boruah
 
Job sequencing with deadline
Job sequencing with deadlineJob sequencing with deadline
Job sequencing with deadlineArafat Hossan
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy methodhodcsencet
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite AutomataRatnakar Mikkili
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using BacktrackingAbhishek Singh
 
Cs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersCs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersappasami
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4shah zeb
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4shah zeb
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFAMaulik Togadiya
 
Push down automata
Push down automataPush down automata
Push down automataSomya Bagai
 
Lecture optimal binary search tree
Lecture optimal binary search tree Lecture optimal binary search tree
Lecture optimal binary search tree Divya Ks
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generationVipul Naik
 

Was ist angesagt? (20)

Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1
 
Lexical analyzer generator lex
Lexical analyzer generator lexLexical analyzer generator lex
Lexical analyzer generator lex
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
push down automata
push down automatapush down automata
push down automata
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
 
Job sequencing with deadline
Job sequencing with deadlineJob sequencing with deadline
Job sequencing with deadline
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Automata theory
Automata theoryAutomata theory
Automata theory
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
 
Cs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersCs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papers
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
Push down automata
Push down automataPush down automata
Push down automata
 
Lecture optimal binary search tree
Lecture optimal binary search tree Lecture optimal binary search tree
Lecture optimal binary search tree
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generation
 
L3 cfg
L3 cfgL3 cfg
L3 cfg
 

Andere mochten auch

Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3Abhimanyu Mishra
 
PUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEPUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEAbhishek Shivhare
 
Context free presentation
Context free presentationContext free presentation
Context free presentationTelma Ventura
 
Push Down Automata (PDA)
Push Down Automata (PDA)Push Down Automata (PDA)
Push Down Automata (PDA)dhea zafarina
 
Seminar on Quantum Automata and Languages
Seminar on Quantum Automata and LanguagesSeminar on Quantum Automata and Languages
Seminar on Quantum Automata and Languagesranjanphu
 
Pushdown Automata - Materi 8 - TBO
Pushdown Automata - Materi 8 - TBOPushdown Automata - Materi 8 - TBO
Pushdown Automata - Materi 8 - TBOahmad haidaroh
 
Automata languages and computation
Automata languages and computationAutomata languages and computation
Automata languages and computationKarthik Velou
 
Class8
 Class8 Class8
Class8issbp
 
Introduction to Automata Theory, Languages and Computation
Introduction to Automata Theory, Languages and ComputationIntroduction to Automata Theory, Languages and Computation
Introduction to Automata Theory, Languages and ComputationHarisree Sudarsan
 
CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationDrishti Bhalla
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryTsegazeab Asgedom
 
Os2 2
Os2 2Os2 2
Os2 2issbp
 
Lecture 7: Definite Clause Grammars
Lecture 7: Definite Clause GrammarsLecture 7: Definite Clause Grammars
Lecture 7: Definite Clause GrammarsCS, NcState
 
Os4 2
Os4 2Os4 2
Os4 2issbp
 
Class5
 Class5 Class5
Class5issbp
 
Ch11 input output systems
Ch11 input output systemsCh11 input output systems
Ch11 input output systemsissbp
 

Andere mochten auch (20)

Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3Theory of Automata and formal languages Unit 3
Theory of Automata and formal languages Unit 3
 
PUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEPUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINE
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automata
 
Context free presentation
Context free presentationContext free presentation
Context free presentation
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
 
Push Down Automata (PDA)
Push Down Automata (PDA)Push Down Automata (PDA)
Push Down Automata (PDA)
 
Seminar on Quantum Automata and Languages
Seminar on Quantum Automata and LanguagesSeminar on Quantum Automata and Languages
Seminar on Quantum Automata and Languages
 
Pushdown Automata - Materi 8 - TBO
Pushdown Automata - Materi 8 - TBOPushdown Automata - Materi 8 - TBO
Pushdown Automata - Materi 8 - TBO
 
Automata languages and computation
Automata languages and computationAutomata languages and computation
Automata languages and computation
 
Class8
 Class8 Class8
Class8
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
 
Introduction to Automata Theory, Languages and Computation
Introduction to Automata Theory, Languages and ComputationIntroduction to Automata Theory, Languages and Computation
Introduction to Automata Theory, Languages and Computation
 
CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of Computation
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Os2 2
Os2 2Os2 2
Os2 2
 
Lecture 7: Definite Clause Grammars
Lecture 7: Definite Clause GrammarsLecture 7: Definite Clause Grammars
Lecture 7: Definite Clause Grammars
 
Os4 2
Os4 2Os4 2
Os4 2
 
Class5
 Class5 Class5
Class5
 
Os6
Os6Os6
Os6
 
Ch11 input output systems
Ch11 input output systemsCh11 input output systems
Ch11 input output systems
 

Ähnlich wie PUSHDOWN AUTOMATA AND CONTEXT-FREE GRAMMARS (39

Cs6503 theory of computation november december 2015 be cse anna university q...
Cs6503 theory of computation november december 2015  be cse anna university q...Cs6503 theory of computation november december 2015  be cse anna university q...
Cs6503 theory of computation november december 2015 be cse anna university q...appasami
 
Cs6503 theory of computation may june 2016 be cse anna university question paper
Cs6503 theory of computation may june 2016 be cse anna university question paperCs6503 theory of computation may june 2016 be cse anna university question paper
Cs6503 theory of computation may june 2016 be cse anna university question paperappasami
 
Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016appasami
 
Assignment 3 push down automata final
Assignment 3 push down automata finalAssignment 3 push down automata final
Assignment 3 push down automata finalPawan Goel
 
Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Abhimanyu Mishra
 
Overlap Layout Consensus assembly
Overlap Layout Consensus assemblyOverlap Layout Consensus assembly
Overlap Layout Consensus assemblyZhuyi Xue
 
ZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their ApplicationsZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their ApplicationsAlex Pruden
 
Compiler worksheet
Compiler worksheetCompiler worksheet
Compiler worksheetArthyR3
 
Introduction to MapReduce
Introduction to MapReduceIntroduction to MapReduce
Introduction to MapReduceHassan A-j
 
TOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfTOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfAdiseshaK
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfAdiseshaK
 

Ähnlich wie PUSHDOWN AUTOMATA AND CONTEXT-FREE GRAMMARS (39 (20)

Cs6503 theory of computation november december 2015 be cse anna university q...
Cs6503 theory of computation november december 2015  be cse anna university q...Cs6503 theory of computation november december 2015  be cse anna university q...
Cs6503 theory of computation november december 2015 be cse anna university q...
 
Cs6503 theory of computation may june 2016 be cse anna university question paper
Cs6503 theory of computation may june 2016 be cse anna university question paperCs6503 theory of computation may june 2016 be cse anna university question paper
Cs6503 theory of computation may june 2016 be cse anna university question paper
 
SASA 2016
SASA 2016SASA 2016
SASA 2016
 
Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016
 
Assignment 3 push down automata final
Assignment 3 push down automata finalAssignment 3 push down automata final
Assignment 3 push down automata final
 
Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2
 
UNIT III.docx
UNIT III.docxUNIT III.docx
UNIT III.docx
 
Gate-Cs 2009
Gate-Cs 2009Gate-Cs 2009
Gate-Cs 2009
 
Daa unit 5
Daa unit 5Daa unit 5
Daa unit 5
 
Gate-Cs 2006
Gate-Cs 2006Gate-Cs 2006
Gate-Cs 2006
 
Overlap Layout Consensus assembly
Overlap Layout Consensus assemblyOverlap Layout Consensus assembly
Overlap Layout Consensus assembly
 
ZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their ApplicationsZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their Applications
 
report
reportreport
report
 
Compiler worksheet
Compiler worksheetCompiler worksheet
Compiler worksheet
 
Introduction to MapReduce
Introduction to MapReduceIntroduction to MapReduce
Introduction to MapReduce
 
Cs gate-2011
Cs gate-2011Cs gate-2011
Cs gate-2011
 
Cs gate-2011
Cs gate-2011Cs gate-2011
Cs gate-2011
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdf
 
TOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfTOC Solutions-Adi.pdf
TOC Solutions-Adi.pdf
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdf
 

Mehr von Abhimanyu Mishra (18)

Cd unit i
Cd unit iCd unit i
Cd unit i
 
Presentation1(JIT gnomio)
Presentation1(JIT gnomio)Presentation1(JIT gnomio)
Presentation1(JIT gnomio)
 
Sta unit 5(abimanyu)
Sta unit 5(abimanyu)Sta unit 5(abimanyu)
Sta unit 5(abimanyu)
 
Sta unit 3(abimanyu)
Sta unit 3(abimanyu)Sta unit 3(abimanyu)
Sta unit 3(abimanyu)
 
Sta unit 4(abimanyu)
Sta unit 4(abimanyu)Sta unit 4(abimanyu)
Sta unit 4(abimanyu)
 
Sta unit 3(abimanyu)
Sta unit 3(abimanyu)Sta unit 3(abimanyu)
Sta unit 3(abimanyu)
 
Sta unit 2(abimanyu)
Sta unit 2(abimanyu)Sta unit 2(abimanyu)
Sta unit 2(abimanyu)
 
Unit1
Unit1Unit1
Unit1
 
Daa unit 4
Daa unit 4Daa unit 4
Daa unit 4
 
Daa unit 3
Daa unit 3Daa unit 3
Daa unit 3
 
Daa unit 2
Daa unit 2Daa unit 2
Daa unit 2
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Software Engineering unit 5
Software Engineering unit 5Software Engineering unit 5
Software Engineering unit 5
 
Software Engineering unit 4
Software Engineering unit 4Software Engineering unit 4
Software Engineering unit 4
 
Software Engineering unit 3
Software Engineering unit 3Software Engineering unit 3
Software Engineering unit 3
 
Software Engineering unit 2
Software Engineering unit 2Software Engineering unit 2
Software Engineering unit 2
 
Software Engineering Unit 1
Software Engineering Unit 1Software Engineering Unit 1
Software Engineering Unit 1
 
Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5
 

Kürzlich hochgeladen

Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 

Kürzlich hochgeladen (20)

Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 

PUSHDOWN AUTOMATA AND CONTEXT-FREE GRAMMARS (39

  • 1. THEORY OF AUTOMATAAND FORMAL LANGUAGES UNIT-IV ABHIMANYU MISHRA ASSISTANT PROF.(CSE) JETGI Abhimanyu Mishra(CSE) JETGI12/31/2016
  • 2. PUSHDOWN AUTOMATA INTRODUCTION “The pushdown automata is essentially a finite automata with control of both an input tape and a stack to store what it has read. A stack is “FIRST IN FIRST OUT” list, that is, symbols can be entered or removed only at the top of the list. When a new symbol is entered at the top, the symbol previously at the top becomes second and so on”. Basically a pushdown automaton is − "Finite state machine" + "a stack“ A pushdown automaton has three components − (i) an input tape, (ii) a control unit (iii) a stack with infinite size. 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 3. Diagram a b c b a c …………….. Input Tape a c b a 12/31/2016 Abhimanyu Mishra(CSE) JETGI Finite Control
  • 4. DEFINATION OF PUSHDOWN AUTOMATA A pushdown automata is a system, which is mathematically defined as follows: P = ( Q,∑,┌,δ,s,F) Where Q : non-empty finite set of states ∑ : non-empty finite set of input symbols ┌ : is finite set of pushdown symbols s : is the initial state, s ∈ Q F : is the set of final states and F Q δ : It is a transition function or transition relation. 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 5. THERE ARE TWO DIFFERENT WAYS TO DEFINE PDA ACCEPTABILITY. (i) Final State Acceptability In final state acceptability, a PDA accepts a string when, after reading the entire string, the PDA is in a final state. From the starting state, we can make moves that end up in a final state with any stack values. The stack values are irrelevant as long as we end up in a final state. For a PDA (Q,∑,┌,δ,s, F) the language accepted by the set of final states F is − L(PDA) = {w | (q0, w, I) ⊢* (q, ε, x), q ∈ F} for any input stack string x 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 6. (ii) Empty Stack Acceptability Here a PDA accepts a string when, after reading the entire string, the PDA has emptied its stack. For a PDA (Q, ∑,┌,δ,s, F), the language accepted by the empty stack is − L(PDA) = {w | (q0, w, I) ⊢* (q, ε, ε), q ∈ Q} 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 7. Example: Design a PDA which accepts the language L ={ w ∈{a,b}*/w has equal no of a’ and b’s} Now let us assume that PDA be P P = (Q,∑,┌,δ,s,F) Q = { s,q,f} ∑ = {a,b} ┌ = {a,b,c} F = {f} , and δ is as follows Now let us assume stack have c value in initial in stack, 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 8. (i) ((s, ∈, ∈),(q,c)) (ii) ((q,a,c),(q,ac)) (iii) (q,a,a),(q,aa)) (iv) ((q,a,b),(q, ∈)) (v) ((q,b,c),(q,bc)) (vi) ((q,b,b),(q,bb)) (vii) ((q,b,a),(q, ∈)) (viii) ((q, ∈,c),(f, ∈)) Now if PDA reads symbol ’a’ from the input tape and if stack is empty or has ‘a’ on the stack top then push ‘a’ into the stack, Now if reads ‘a’ from input and ‘b’ is on top of the stack then. It simply pops the symbol ‘b’ and pushes nothing. So final state is defined as, PDA is in state f and stack is empty 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 9. PUSHDOWN AUTOMATAAND CONTEXT-FREE-GRAMMARS It should be clear now that PDA can recognize any language for which there exists a CFG. “ That is class of language accepts by pushdown automata is exactly the class of context-free languages”. (i) Algorithm to find PDA corresponding to a given CFG (ii)Algorithm to find CFG corresponding to a given PDA 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 10. (I) ALGORITHM TO FIND PDA CORRESPONDING TO A GIVEN CFG Input : A CFG, G = (Vn,Vt,P,S) Output: Equivalent PDA, P= (Q, ∑, ┌, δ, q0, F) Steps: (i) Convert of the production of CFG to GNF (ii) The PDA has only one state q0 (iii) The start symbol of CFG will be the start symbol in the PDA (iv) All non-terminals of the CFG will be the stack symbols of the PDA and all the terminals of the CFG will be the input symbols of the PDA. (v) For each production in the form A → aX where a is terminal and A, X are combination of terminal and non-terminals make a transition δ (q, a, A). 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 11. Example Construct a PDA from the following CFG. G = ({S, X}, {a, b}, P, S) where the productions are − S → XS | ε , A → aXb | Ab | ab Solution Let the equivalent PDA, P = ({q}, {a, b}, {a, b, X, S}, δ, q, S) where δ − δ (q, ε , S) = {(q, XS), (q, ε )} δ(q, ε , X) = {(q, aXb), (q, Xb), (q, ab)} δ(q, a, a) = {(q, ε )} δ(q, 1, 1) = {(q, ε )} 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 12. (II) ALGORITHM TO FIND CFG CORRESPONDING TO A GIVEN PDA Input : A CFG, G = (Vn,Vt,P,S) Output : Equivalent PDA, P = (Q, ∑, ┌, δ, q0, F)such that the non- terminals of the grammar G will be {Xwx | w,x ∈ Q} and the start state will be Aq0,F. Steps: (i) For every w, x, y, z ∈ Q, m ∈┌ and a, b ∈ ∑, if δ (w, a, ε) contains (y, m) and (z, b, m) contains (x, ε), add the production rule Xwx → a Xyzb in grammar G. (ii) For every w, x, y, z ∈ Q, add the production rule Xwx → XwyXyx in grammar G. (iii) For w ∈ Q, add the production rule Xww → ε in grammar G. 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 13. Example: Design a PDA for the following CFG, G = (Vn,Vt,P,S) with Vn ={S}, Vt ={(,)} and P is defined δ as follows S → (S) | ε|SS Solution: Lets corresponding PDA will be P = (Q, ∑, ┌, δ, q0, F) Q={p,q} ∑ = {(,)} ┌ = (S,(,)} that is terminal and non-terminal in grammar S =p F = {q}, and δ is as, 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 14. (1) ((p, ε , ε) , {(q, S)) (2) ((q, ε , S) ,{(q, ε )) because S → ∈ is a rule of CFG (3) ((q, ε, S) ,(q, SS)) (4) ((q, ε,S) , (q, (S)) (5) ((q, (,(),(q, ε)) (6) (((q,),)),(q,(q,ε)) for each a ∈ Vt 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 15. Now apply these transition relation on the string w=( )( ) 12/31/2016 Abhimanyu Mishra(CSE) JETGI S.N State Unread input Stack Transiti on used 1 q ( ) ( ) ∈ - 2 q ( ) ( ) S (1) 3 q ( ) ( ) SS (3) 4 q ( ) ( ) (S)SS (4) 5 q ) ( ) S)S (5) 6 q )( ) )S (2) 7 q ( ) S (6) 8 q ( ) (S) (4) 9 q ) S) (5) 10 q ) ) (2) 11 q ∈ ∈ (6)
  • 16. Example: Consider the following PDA and construct equivalent CFG 1. ((q0,a,$) →(q0,a$)) 2. ((q0,b,$) →(q0,b$)) 3. ((q0,a,a) →(q0,aa)) 4. ((q0,b,b) →(q0,bb)) 5. ((q0,a,b) →(q0,ab)) 6. ((q0,b,a) →(q0,ba)) 7. ((q0,c,$) →(q1,$)) 8. ((q0,c,a) →(q1,a)) 9. ((q1,c,b) →(q1,b)) 10. ((q1,a,a) →(q1, ∈)) 11. ((q1,b,b) →(q1, ∈)) 12. ((q1, ∈,$) →(q1, ∈)) 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 17. Sol: CFG using above construction production rule is as follows: S→[q0 $ q0 ]/ [q0 $ q1 ] rule (i) [q0 a q0 ] → a [q0 b q1 ] → b [q1 $ q1 ] → ∈ rule(ii) Now remaining productions are:- [q0 $ q0 ] → a [q0 a q0 ]/ [q0 $ q0 ] [q0 $ q1 ] → a [q0 a q0 ]/ [q0 $ q1 ] [q0 $ q1 ] → a [q0 a q1 ]/ [q1 $ q1 ] [q0 $ q1 ] → b [q0 b q0 ]/ [q0 $ q0 ] [q0 $ q1 ]→ b [q0 b q0 ]/ [q0 $ q1 ] [q0 $ q1 ] → b [q0 b q1 ]/ [q1 $ q1 ] 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 18. [q0 a q0 ] → a [q0 a q0 ]/ [q0 a q0 ] [q0 a q1 ] → a [q0 a q0 ]/ [q0 a q1 ] [q0 a q1 ] → a [q0 a q1 ]/ [q1 a q1 ] [q0 a q0 ] → b [q0 b q0 ]/ [q0 a q0 ] [q0 a q1 ] → b [q0 b q0 ]/ [q0 a q0 ] [q0 a q1 ] → b [q0 b q1 ]/ [q1 a q1 ] [q0 b q0 ] → a [q0 a q0 ]/ [q0 b q0 ] [q0 b q1 ] → a [q0 a q0 ]/ [q0 b q1 ] [q0 b q1 ] → a [q0 a q1 ]/ [q1 b q1 ] 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 19. [q0 b q0 ] → b [q0 b q0 ]/ [q0 b q0 ] [q0 b q0 ] → b [q0 b q0 ]/ [q0 b q1 ] [q0 b q0 ] → b [q0 b q1 ]/ [q1 $ q1 ] [q0 $ q1 ] → c [q0 b q1 ] [q0 a q1 ] → c [q1 a q1 ] [q0 b q0 ] → c [q1 b q1 ] 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 20. Problems? 1. Construct PDA for language L = {(ab)n /n>=1}. 2. Construct a PDA to accept the language L = { set of all words in a and b with an even numbers of a’s}. 3. Construct a PDA for the regular expression r = 0*1+ 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 21. TWO STACK PDA A two-stack PDA is a sixtuple (Q, , , , q0, F), where Q, , , q0, and F are the same as in a one-stack PDA. The transition function as follow: : Q  (  {  })  (  {  })  (  {  })  to the set of all subsets of Q  (  {  })  (  {  }) The two stacks of the PDA are independent. one stack: two stack: A/B A/B/C Two-Stack PDA accepts any language that accepted by a Turing Machine. 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 22. TWO STACK PDA (i) A Turing machine can accept languages not accepted by any PDA with one stack. (ii) The strength of pushdown automata can be increased by adding other stacks. (iii) Actually, a PDA with two stacks have the same computation control as a Turing Machine. 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 23. Diagram of TWO STACK PDA INPUT TAPE TAPE HEAD HEAD MOVES STACK 1 STACK 2 12/31/2016 Abhimanyu Mishra(CSE) JETGI Finite Control
  • 24. Theorem 8.13 (Hopcroft and Ullman [1]) If a language L is accepted by a Turing machine, L is accepted by a Two- Stack machine. The idea is that the first stack can hold what is to the left of the head, while the second stack holds what is to the right of the head, neglecting all the infinite blank symbols beyond the leftmost and rightmost of the head. The proof is taken from (Hopcroft and Ullman [1]) 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 25. Let’s L be L(M) for some one tape TM M, two-stack machine S, simulating a one-tape TM M as the following: S begins with a bottom-of-stack marker on each stack, this marker considered the start symbol for the stacks, and must not appear elsewhere on the stacks. The marker indicates that the stack is empty. The proof is taken from (Hopcroft and Ullman [1]) 12/31/2016 Abhimanyu Mishra(CSE) JETGI
  • 26. Suppose that w$ is on the input of S. S copies the input w onto its first stack, and stops to copy when reading the end marker on the input. S pops each symbol in turn from its first stack and pushes it onto its second stack. The first stack of S is empty. The second stack holds w, with the left end of w is at the top. 12/31/2016 Abhimanyu Mishra(CSE) JETGI