SlideShare une entreprise Scribd logo
1  sur  21
PUSH DOWN
AUTOMATA
M RATNAKAR BABU
Asst.Prof. CSE
Prerequisite
• The basic relationship between CFG and R.E is that the CFG can be
constructed for every R.E.
• But more than that CFG can also be written for non regular languages like
0n1n.
• Thus we can say that regular expressions are the subset of CFG.
• For every R.E we can be drawn F.A., But F.A. is not sufficient to draw the
CFG.
• For better understanding of PDA we must know about Stack and its
operations.
Push Down Automata
• The PDA will have input tape, finite control and stack.
TOS Z0
Stack
• The input tape is divided in many cells.
• The finite control has some pointer which points to the current
symbol which is to be read.
• At the end of the input $ or  blank symbol is placed to identify the
end of input.
• Here Stack will be used to store the items temporarily.
A A B B $   
Finite
Control
Definition of a PDA
• A pushdown automaton (PDA) is a seven-tuple:
M = (Q, Σ, Г, δ, q0, z0, F)
Q A finite set of states
Σ A finite input alphabet
Г A finite stack alphabet
q0 The initial/starting state, q0 is in Q
z0 A starting stack symbol, is in Г // need not always remain at the bottom of
stack
F A set of final/accepting states, which is a subset of Q
δ A transition function, where
For DPDA δ: Q x (Σ U {ε}) x Г –> finite subsets of Q x Г*
For NDPDA δ: Q x (Σ U {ε}) x Г –> finite subsets of 2Q x Г*
Push Down Automata
• Any language which is accepted by a F.A. can also accepted by PDA.
• PDA can also accepts the class of languages which are not accepted by F.A.,
Thus PDA is much more superior to F.A.
Example: Design a PDA for accepting the Language L= {anbn|n>=1}.
Solution:
The above given language is in which equal number of a’s are followed
by equal number of b’s.
Logic for PDA:
1. Push all a’s onto the stack
2. On reading every single b pop one a from the stack.
3. If the input string is reached end and the stack is empty then the string is
accepted by the PDA.
PDA
Q0
Q1 Q2
(b,a/Ꜫ)
(a,a/aa)
(a,z0/az0) (b,a/Ꜫ)
($, z0/z0)
Example(2)
• The Description for the PDA can
be given as follows.
(q0,a,z0)=(q0,az0)
(q0,a,a)=(q0,aa)
(q0,b,a)=(q1,Ꜫ)
(q1,b,a)=(q1,Ꜫ)
(q1,$, z0)=(q2,Ꜫ)
Where q0 is start state and q2 is
accept state.
• Simulation of PDA for the input string
aaabbb as follows
(q0,aaabbb,z0) Ͱ(q0,aabbb$,az0)
Ͱ(q0,abbb$,aaz0)
Ͱ(q0,bbb$,aaaz0)
Ͱ(q1,bb$,aaz0)
Ͱ(q1,b$,az0)
Ͱ(q1,$, z0)
Ͱ(q2, Ꜫ)
Accept State
Hence the string is accepted by the PDA.
Excercise1: Design a PDA that accept a string of well formed
parenthesis. Consider the parenthesis is a (,),[,],{,}.
Excercise2: Construct PDA for the language L={anb2n|n>=1}.
Conversion of CFG to PDA
• For the conversion of CFG to PDA the necessary condition is that the
first symbol on R.H.S. production must be a terminal symbol.
• Rule1: For non terminal symbol, add following rule
(q, Ꜫ,A)=(q,)
Where the production rule is A-> 
• Rule 2: For each terminal symbol, add the following rule.
(q, a,a)=(q, Ꜫ) for every terminal symbol.
Example: Construct PDA for the given CFG
S->0BB
B->0S|1S|0 and test whether 0104 is accepted by this PDA
• Let PDA
A={{q},{0,1},{S,B,0,1}, ,q,S,F}
The Production rules  can be written as:
R1: (q, Ꜫ,S) = {(q,0BB)}
R2: (q, Ꜫ,B) = {(q,0S),(q,1S),(q,0)}
R3: (q, 0,0) = {(q, Ꜫ)}
R4: (q, 1,1) = {(q, Ꜫ)}
Example(2):
• Testing 0104 i.e. 010000 against PDA
(q,010000,S) Ͱ(q,010000,0BB) Since R1
Ͱ(q,10000,BB) Since R3
Ͱ(q,10000,1SB) Since R2
Ͱ(q,0000,SB) Since R4
Ͱ(q,0000,0BBB) Since R1
Ͱ(q,000,BBB) Since R3
Ͱ(q,000,0BB) Since R2
Ͱ(q,00,BB) Since R3
Ͱ(q,00,0B) Since R2
Ͱ(q,0, B) Since R3
Ͱ(q,0,0) Since R2
Ͱ(q, Ꜫ) Since R3
ACCEPT
Excercise1: Construct the PDA for the given CFG.
S->0A
A->0AB|1
B->1
Excercise1: Construct the PDA for the given CFG.
S->aSA|bSB|a|b
A->a
B->b
Construction of CFG from PDA
• Algorithm for getting production rules of CFG:
Rule1: The start symbol production can be
S->[q0,Z0,q]
Where q indicates the next state an q0 is a start state.
Rule2: If there exists a move of PDA
(q,a,Z)={(q’, Ꜫ)}
then the production rule can be written as:
(q,Z,q’)->a
Rule3: If there exists a move of PDA as
(q,a,Z)={(q’,Z1,Z2,…..Zn)}
Then the production rule of CFG can be written as
(q,a,Z)->a[q1,Z1,q2 ] [q2,Z2,q3 ] [q3,Z3,q4 ]….. [qm,Zm,qm+1 ].
Example: The PDA is given below A=({q0, q1 },{0,1},{S,A},, q0, S,φ)
Where  is given as follows:
(q0, 1,S)={(q0, AS)}
(q0, Ꜫ,S)={(q0, Ꜫ)}
(q0, 1,A)={(q0, AA)}
(q0, 0,A)={(q1, A)}
(q1, 1,A)={(q1, Ꜫ)}
(q1, 0,S)={(q0, S)}
Construct the CFG equivalent to this PDA.
Example(2):
• Solution:
Let we will construct a CFG
G=(V,T,P,S)
Here, T={0,1}, V={S U [q0,A,q0 ],[q0,A,q1 ],[q0,S,q0 ],[q0,S,q1 ],
[q1,A,q1 ], [q1,A,q0 ], [q1,S,q1 ], [q1,S,q0 ]}
Now let up build the production rules as:
Using rule1 from the algorithm
P1: S->[q0,S,q0 ]
P2: S->[q0,S,q1 ]
Using rule3 of algorithm for the (q0, 1,S)={(q0, AS)} we get,
P3: [q0,S,q0 ]->1[q0,A,q0 ][q0,S,q0 ]
P4: [q0,S,q0 ]->1[q0,A,q1 ][q1,S,q0 ]
P5: [q0,S,q1 ]->1[q0,A,q0 ][q0,S,q1 ]
P6: [q0,S,q1 ]->1[q0,A,q1 ][q1,S,q1 ]
Example(3):
Now for (q0, Ꜫ,S)={(q0, Ꜫ)} using rule2 of algorithm we get
P7: [q0,S,q0 ]-> Ꜫ
Similarly for (q0, 1,A)={(q0, AA)} Using rule3 we get
P8:[q0,A,q0 ]->1[q0,A,q0 ][q0,A,q0 ]
P9:[q0,A,q0 ]->1[q0,A,q1 ][q1,A,q0 ]
P10:[q0,A,q1 ]->1[q0,A,q0 ][q0,A,q1 ]
P11:[q0,A,q1 ]->1[q0,A,q1 ][q1,A,q1 ]
Similarly for (q0, 0,A)={(q1, A)} gives
P12:[q0,A,q0 ]->0[q1,A,q0 ]
P13:[q0,A,q1 ]->0[q1,A,q1 ]
(q1, 1,A)={(q1, Ꜫ)} Gives
P14:[q1,A,q1 ]->1
(q1, 0,S)={(q0, S)}
P15: [q1,S,q0 ]->0[q0,S,q0 ]
P16:[q1,S,q1 ]->0[q0,S,q1 ]
Exercise: Find the CFG corresponding to PDA whose transition
mapping is as follows:
(S, a , X) = (s, AX)
(S, b , A) = (s, AA)
(S, a , A) = (s, Ꜫ)
Summary
• From this session we learned what is Push Down Automata.
• How to Construct PDA.
• Conversion of CFG to PDA.
• And Conversion of PDA to CFG.
Next Class
• In the Next Session we will Concentrate on importance of Normal
forms .
• Types of Normal Forms.
END For NOW
Continue in next class
Given PDA:
(S, a , X) = (s, AX)
(S, b , A) = (s, AA)
(S, a , A) = (s, Ꜫ)
Solution: Now we will apply conversion algorithm for each transition and obtain
the production rules:
For (S, a , X) = (s, AX)
P1: (S,X,s)->a(S A S)(S X s ) |a(S A s)(s X s )
P2: (S,X,S)->a(S A S)(S X S ) | a(S A s)(s X S )
For (S, b , A) = (s, AA)
P3: (S, A, s)->b(S A S)(S A s ) | b(S A s)(s A s)
P4: (S, A, S)->b(S A S)(S A S) | b(S A s)(s A S)
For (S, a , A) = (s, Ꜫ)
P5: (S, A, s)-> a
Hence , P1,P2,P3,P4 and P5 are productions in CFG.
BACK

Contenu connexe

Tendances

Push down automata
Push down automataPush down automata
Push down automataSomya Bagai
 
Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Akila Krishnamoorthy
 
AUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESAUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESsuthi
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automatadeepinderbedi
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite AutomataRatnakar Mikkili
 
3.1,2,3 pushdown automata definition, moves & id
3.1,2,3 pushdown automata   definition, moves & id3.1,2,3 pushdown automata   definition, moves & id
3.1,2,3 pushdown automata definition, moves & idSampath Kumar S
 
Nondeterministic Finite Automata
Nondeterministic Finite AutomataNondeterministic Finite Automata
Nondeterministic Finite AutomataAdel Al-Ofairi
 
Turing Machine
Turing MachineTuring Machine
Turing MachineRajendran
 
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
 
Theory of Computation Basic Concepts and Grammar
Theory of Computation Basic Concepts and GrammarTheory of Computation Basic Concepts and Grammar
Theory of Computation Basic Concepts and GrammarRushabh2428
 
push down automata
 push down automata push down automata
push down automatanadiatariq6
 
2.8 normal forms gnf & problems
2.8 normal forms   gnf & problems2.8 normal forms   gnf & problems
2.8 normal forms gnf & problemsSampath Kumar S
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal languageRabia Khalid
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFAMaulik Togadiya
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Animesh Chaturvedi
 

Tendances (20)

Push down automata
Push down automataPush down automata
Push down automata
 
Turing machine
Turing machineTuring machine
Turing machine
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)
 
AUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESAUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTES
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Turing machine-TOC
Turing machine-TOCTuring machine-TOC
Turing machine-TOC
 
3.1,2,3 pushdown automata definition, moves & id
3.1,2,3 pushdown automata   definition, moves & id3.1,2,3 pushdown automata   definition, moves & id
3.1,2,3 pushdown automata definition, moves & id
 
Nondeterministic Finite Automata
Nondeterministic Finite AutomataNondeterministic Finite Automata
Nondeterministic Finite Automata
 
Turing machines
Turing machinesTuring machines
Turing machines
 
FInite Automata
FInite AutomataFInite Automata
FInite Automata
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
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
 
Theory of Computation Basic Concepts and Grammar
Theory of Computation Basic Concepts and GrammarTheory of Computation Basic Concepts and Grammar
Theory of Computation Basic Concepts and Grammar
 
push down automata
 push down automata push down automata
push down automata
 
2.8 normal forms gnf & problems
2.8 normal forms   gnf & problems2.8 normal forms   gnf & problems
2.8 normal forms gnf & problems
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 

Similaire à Push down automata

Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examplesankitamakin
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examplesankitamakin
 
Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3Srimatre K
 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaTheory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaRushabh2428
 
FiniteAutomata (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).pptssuser47f7f2
 
FiniteAutomata.ppt
FiniteAutomata.pptFiniteAutomata.ppt
FiniteAutomata.pptRohitPaul71
 
Theory of automata
Theory of automataTheory of automata
Theory of automataArslan905905
 
Asymptotic Notations.pptx
Asymptotic Notations.pptxAsymptotic Notations.pptx
Asymptotic Notations.pptxSunilWork1
 
Arima model (time series)
Arima model (time series)Arima model (time series)
Arima model (time series)Kumar P
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automataeugenesri
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automataparmeet834
 
Chapter 2 limits of DFA NDFA.ppt
Chapter 2  limits of DFA  NDFA.pptChapter 2  limits of DFA  NDFA.ppt
Chapter 2 limits of DFA NDFA.pptArwaKhallouf
 

Similaire à Push down automata (20)

Pda
PdaPda
Pda
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3
 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaTheory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
 
Dfa
DfaDfa
Dfa
 
FiniteAutomata (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).ppt
 
FiniteAutomata.ppt
FiniteAutomata.pptFiniteAutomata.ppt
FiniteAutomata.ppt
 
Lecture7x.ppt
Lecture7x.pptLecture7x.ppt
Lecture7x.ppt
 
Theory of automata
Theory of automataTheory of automata
Theory of automata
 
flat unit1
flat unit1flat unit1
flat unit1
 
PDA (1) (1).pptx
PDA (1) (1).pptxPDA (1) (1).pptx
PDA (1) (1).pptx
 
Lex analysis
Lex analysisLex analysis
Lex analysis
 
Asymptotic Notations.pptx
Asymptotic Notations.pptxAsymptotic Notations.pptx
Asymptotic Notations.pptx
 
Finite automata
Finite automataFinite automata
Finite automata
 
Arima model (time series)
Arima model (time series)Arima model (time series)
Arima model (time series)
 
Unit iv
Unit ivUnit iv
Unit iv
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automata
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automata
 
Chapter 2 limits of DFA NDFA.ppt
Chapter 2  limits of DFA  NDFA.pptChapter 2  limits of DFA  NDFA.ppt
Chapter 2 limits of DFA NDFA.ppt
 

Plus de Ratnakar Mikkili

AI-State Space Representation.pptx
AI-State Space Representation.pptxAI-State Space Representation.pptx
AI-State Space Representation.pptxRatnakar Mikkili
 
AI-State Space Representation.pptx
AI-State Space Representation.pptxAI-State Space Representation.pptx
AI-State Space Representation.pptxRatnakar Mikkili
 
Artificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxArtificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxRatnakar Mikkili
 
Artificial Intelligence_Environment.pptx
Artificial Intelligence_Environment.pptxArtificial Intelligence_Environment.pptx
Artificial Intelligence_Environment.pptxRatnakar Mikkili
 
2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt2_2Specification of Tokens.ppt
2_2Specification of Tokens.pptRatnakar Mikkili
 

Plus de Ratnakar Mikkili (8)

AI-State Space Representation.pptx
AI-State Space Representation.pptxAI-State Space Representation.pptx
AI-State Space Representation.pptx
 
AI-State Space Representation.pptx
AI-State Space Representation.pptxAI-State Space Representation.pptx
AI-State Space Representation.pptx
 
Artificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxArtificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptx
 
Artificial Intelligence_Environment.pptx
Artificial Intelligence_Environment.pptxArtificial Intelligence_Environment.pptx
Artificial Intelligence_Environment.pptx
 
2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt
 
2_4 Finite Automata.ppt
2_4 Finite Automata.ppt2_4 Finite Automata.ppt
2_4 Finite Automata.ppt
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 

Dernier

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
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 

Dernier (20)

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
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 

Push down automata

  • 1. PUSH DOWN AUTOMATA M RATNAKAR BABU Asst.Prof. CSE
  • 2. Prerequisite • The basic relationship between CFG and R.E is that the CFG can be constructed for every R.E. • But more than that CFG can also be written for non regular languages like 0n1n. • Thus we can say that regular expressions are the subset of CFG. • For every R.E we can be drawn F.A., But F.A. is not sufficient to draw the CFG. • For better understanding of PDA we must know about Stack and its operations.
  • 3. Push Down Automata • The PDA will have input tape, finite control and stack. TOS Z0 Stack • The input tape is divided in many cells. • The finite control has some pointer which points to the current symbol which is to be read. • At the end of the input $ or  blank symbol is placed to identify the end of input. • Here Stack will be used to store the items temporarily. A A B B $    Finite Control
  • 4. Definition of a PDA • A pushdown automaton (PDA) is a seven-tuple: M = (Q, Σ, Г, δ, q0, z0, F) Q A finite set of states Σ A finite input alphabet Г A finite stack alphabet q0 The initial/starting state, q0 is in Q z0 A starting stack symbol, is in Г // need not always remain at the bottom of stack F A set of final/accepting states, which is a subset of Q δ A transition function, where For DPDA δ: Q x (Σ U {ε}) x Г –> finite subsets of Q x Г* For NDPDA δ: Q x (Σ U {ε}) x Г –> finite subsets of 2Q x Г*
  • 5. Push Down Automata • Any language which is accepted by a F.A. can also accepted by PDA. • PDA can also accepts the class of languages which are not accepted by F.A., Thus PDA is much more superior to F.A. Example: Design a PDA for accepting the Language L= {anbn|n>=1}. Solution: The above given language is in which equal number of a’s are followed by equal number of b’s. Logic for PDA: 1. Push all a’s onto the stack 2. On reading every single b pop one a from the stack. 3. If the input string is reached end and the stack is empty then the string is accepted by the PDA.
  • 7. Example(2) • The Description for the PDA can be given as follows. (q0,a,z0)=(q0,az0) (q0,a,a)=(q0,aa) (q0,b,a)=(q1,Ꜫ) (q1,b,a)=(q1,Ꜫ) (q1,$, z0)=(q2,Ꜫ) Where q0 is start state and q2 is accept state. • Simulation of PDA for the input string aaabbb as follows (q0,aaabbb,z0) Ͱ(q0,aabbb$,az0) Ͱ(q0,abbb$,aaz0) Ͱ(q0,bbb$,aaaz0) Ͱ(q1,bb$,aaz0) Ͱ(q1,b$,az0) Ͱ(q1,$, z0) Ͱ(q2, Ꜫ) Accept State Hence the string is accepted by the PDA.
  • 8. Excercise1: Design a PDA that accept a string of well formed parenthesis. Consider the parenthesis is a (,),[,],{,}. Excercise2: Construct PDA for the language L={anb2n|n>=1}.
  • 9. Conversion of CFG to PDA • For the conversion of CFG to PDA the necessary condition is that the first symbol on R.H.S. production must be a terminal symbol. • Rule1: For non terminal symbol, add following rule (q, Ꜫ,A)=(q,) Where the production rule is A->  • Rule 2: For each terminal symbol, add the following rule. (q, a,a)=(q, Ꜫ) for every terminal symbol.
  • 10. Example: Construct PDA for the given CFG S->0BB B->0S|1S|0 and test whether 0104 is accepted by this PDA • Let PDA A={{q},{0,1},{S,B,0,1}, ,q,S,F} The Production rules  can be written as: R1: (q, Ꜫ,S) = {(q,0BB)} R2: (q, Ꜫ,B) = {(q,0S),(q,1S),(q,0)} R3: (q, 0,0) = {(q, Ꜫ)} R4: (q, 1,1) = {(q, Ꜫ)}
  • 11. Example(2): • Testing 0104 i.e. 010000 against PDA (q,010000,S) Ͱ(q,010000,0BB) Since R1 Ͱ(q,10000,BB) Since R3 Ͱ(q,10000,1SB) Since R2 Ͱ(q,0000,SB) Since R4 Ͱ(q,0000,0BBB) Since R1 Ͱ(q,000,BBB) Since R3 Ͱ(q,000,0BB) Since R2 Ͱ(q,00,BB) Since R3 Ͱ(q,00,0B) Since R2 Ͱ(q,0, B) Since R3 Ͱ(q,0,0) Since R2 Ͱ(q, Ꜫ) Since R3 ACCEPT
  • 12. Excercise1: Construct the PDA for the given CFG. S->0A A->0AB|1 B->1 Excercise1: Construct the PDA for the given CFG. S->aSA|bSB|a|b A->a B->b
  • 13. Construction of CFG from PDA • Algorithm for getting production rules of CFG: Rule1: The start symbol production can be S->[q0,Z0,q] Where q indicates the next state an q0 is a start state. Rule2: If there exists a move of PDA (q,a,Z)={(q’, Ꜫ)} then the production rule can be written as: (q,Z,q’)->a Rule3: If there exists a move of PDA as (q,a,Z)={(q’,Z1,Z2,…..Zn)} Then the production rule of CFG can be written as (q,a,Z)->a[q1,Z1,q2 ] [q2,Z2,q3 ] [q3,Z3,q4 ]….. [qm,Zm,qm+1 ].
  • 14. Example: The PDA is given below A=({q0, q1 },{0,1},{S,A},, q0, S,φ) Where  is given as follows: (q0, 1,S)={(q0, AS)} (q0, Ꜫ,S)={(q0, Ꜫ)} (q0, 1,A)={(q0, AA)} (q0, 0,A)={(q1, A)} (q1, 1,A)={(q1, Ꜫ)} (q1, 0,S)={(q0, S)} Construct the CFG equivalent to this PDA.
  • 15. Example(2): • Solution: Let we will construct a CFG G=(V,T,P,S) Here, T={0,1}, V={S U [q0,A,q0 ],[q0,A,q1 ],[q0,S,q0 ],[q0,S,q1 ], [q1,A,q1 ], [q1,A,q0 ], [q1,S,q1 ], [q1,S,q0 ]} Now let up build the production rules as: Using rule1 from the algorithm P1: S->[q0,S,q0 ] P2: S->[q0,S,q1 ] Using rule3 of algorithm for the (q0, 1,S)={(q0, AS)} we get, P3: [q0,S,q0 ]->1[q0,A,q0 ][q0,S,q0 ] P4: [q0,S,q0 ]->1[q0,A,q1 ][q1,S,q0 ] P5: [q0,S,q1 ]->1[q0,A,q0 ][q0,S,q1 ] P6: [q0,S,q1 ]->1[q0,A,q1 ][q1,S,q1 ]
  • 16. Example(3): Now for (q0, Ꜫ,S)={(q0, Ꜫ)} using rule2 of algorithm we get P7: [q0,S,q0 ]-> Ꜫ Similarly for (q0, 1,A)={(q0, AA)} Using rule3 we get P8:[q0,A,q0 ]->1[q0,A,q0 ][q0,A,q0 ] P9:[q0,A,q0 ]->1[q0,A,q1 ][q1,A,q0 ] P10:[q0,A,q1 ]->1[q0,A,q0 ][q0,A,q1 ] P11:[q0,A,q1 ]->1[q0,A,q1 ][q1,A,q1 ] Similarly for (q0, 0,A)={(q1, A)} gives P12:[q0,A,q0 ]->0[q1,A,q0 ] P13:[q0,A,q1 ]->0[q1,A,q1 ] (q1, 1,A)={(q1, Ꜫ)} Gives P14:[q1,A,q1 ]->1 (q1, 0,S)={(q0, S)} P15: [q1,S,q0 ]->0[q0,S,q0 ] P16:[q1,S,q1 ]->0[q0,S,q1 ]
  • 17. Exercise: Find the CFG corresponding to PDA whose transition mapping is as follows: (S, a , X) = (s, AX) (S, b , A) = (s, AA) (S, a , A) = (s, Ꜫ)
  • 18. Summary • From this session we learned what is Push Down Automata. • How to Construct PDA. • Conversion of CFG to PDA. • And Conversion of PDA to CFG.
  • 19. Next Class • In the Next Session we will Concentrate on importance of Normal forms . • Types of Normal Forms.
  • 20. END For NOW Continue in next class
  • 21. Given PDA: (S, a , X) = (s, AX) (S, b , A) = (s, AA) (S, a , A) = (s, Ꜫ) Solution: Now we will apply conversion algorithm for each transition and obtain the production rules: For (S, a , X) = (s, AX) P1: (S,X,s)->a(S A S)(S X s ) |a(S A s)(s X s ) P2: (S,X,S)->a(S A S)(S X S ) | a(S A s)(s X S ) For (S, b , A) = (s, AA) P3: (S, A, s)->b(S A S)(S A s ) | b(S A s)(s A s) P4: (S, A, S)->b(S A S)(S A S) | b(S A s)(s A S) For (S, a , A) = (s, Ꜫ) P5: (S, A, s)-> a Hence , P1,P2,P3,P4 and P5 are productions in CFG. BACK