SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

Moore and mealy machines
Moore and mealy machinesMoore and mealy machines
Moore and mealy machinesAYESHA JAVED
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Animesh Chaturvedi
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingR Islam
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysisDattatray Gandhmal
 
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
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compilerIffat Anjum
 
Theory of Computation Lecture Notes
Theory of Computation Lecture NotesTheory of Computation Lecture Notes
Theory of Computation Lecture NotesFellowBuddy.com
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMRajendran
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
Symbol table management and error handling in compiler design
Symbol table management and error handling in compiler designSymbol table management and error handling in compiler design
Symbol table management and error handling in compiler designSwati Chauhan
 
Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Srimatre K
 
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra Sahil Kumar
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFAMaulik Togadiya
 

What's hot (20)

Moore and mealy machines
Moore and mealy machinesMoore and mealy machines
Moore and mealy machines
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsing
 
Automata theory
Automata theoryAutomata theory
Automata theory
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
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
 
NFA & DFA
NFA & DFANFA & DFA
NFA & DFA
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Semantic analysis
Semantic analysisSemantic analysis
Semantic analysis
 
Theory of computation Lec3 dfa
Theory of computation Lec3 dfaTheory of computation Lec3 dfa
Theory of computation Lec3 dfa
 
Theory of Computation Lecture Notes
Theory of Computation Lecture NotesTheory of Computation Lecture Notes
Theory of Computation Lecture Notes
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEM
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Symbol table management and error handling in compiler design
Symbol table management and error handling in compiler designSymbol table management and error handling in compiler design
Symbol table management and error handling in compiler design
 
Ch2 finite automaton
Ch2 finite automatonCh2 finite automaton
Ch2 finite automaton
 
COMPILER DESIGN- Syntax Directed Translation
COMPILER DESIGN- Syntax Directed TranslationCOMPILER DESIGN- Syntax Directed Translation
COMPILER DESIGN- Syntax Directed Translation
 
Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5
 
First and follow set
First and follow setFirst and follow set
First and follow set
 
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 

Viewers also liked

PUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEPUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEAbhishek Shivhare
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal languageRabia Khalid
 
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
 
Push down automata
Push down automataPush down automata
Push down automataSomya Bagai
 
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
 

Viewers also liked (20)

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
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
 
Context free presentation
Context free presentationContext free presentation
Context free presentation
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
 
pushdown automata
pushdown automatapushdown automata
pushdown 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
 
Push down automata
Push down automataPush down automata
Push down automata
 
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
 

Similar to Theory of automata and formal languages Unit 4

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
 
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
 
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
 

Similar to Theory of automata and formal languages Unit 4 (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
 
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
 
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
 
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
 

More from Abhimanyu Mishra (17)

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
 

Recently uploaded

Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxMuhammadAsimMuhammad6
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfsumitt6_25730773
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...ppkakm
 
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesLinux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesRashidFaridChishti
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxpritamlangde
 
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...vershagrag
 
fitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptfitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptAfnanAhmad53
 
Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementDr. Deepak Mudgal
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesChandrakantDivate1
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 

Recently uploaded (20)

Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...
 
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesLinux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
 
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
 
fitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptfitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .ppt
 
Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth Reinforcement
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To Curves
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 

Theory of automata and formal languages Unit 4

  • 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