SlideShare a Scribd company logo
Push Down Automata(PDA)
Model of PDA
• Push Down Automaton :"Finite state machine" + "a stack"
• A pushdown automaton has three components −
• input tape,
• control unit, and
• stack with infinite size.
• The stack head scans the top symbol of the stack.
• A stack does two operations −
• Push − a new symbol is added at the top.
• Pop − the top symbol is read and removed.
Def: PDA
• A PDA can be formally described as a 7-tuple
(Q, ∑, Γ, δ, q0, Z0 , F)
• Q-finite number of states
• ∑ -input alphabet
• Γ -stack symbols
• δ -transition function: Q × (∑ ∪ {ε}) × Γ Q × Γ*
• Ex: δ(q0,a, Z0 ) =(q1,aZ0 )
• Q0 initial state (q0 ∈ Q)
• Z0 is the initial stack top symbol (Z0 ∈ Γ)
• F is a set of accepting states (F ∈ Q)
Graphical Representation of PDA
Instantaneous Description of PDA
• Instantaneous Description (ID) is an informal notation of how
a PDA “computes” a input string and make a decision that
string is accepted or rejected.
• It is denoted by a triple (q, w, γ) where;
• q is the current state
• w is the unread part of the input string or the remaining input
alphabets
• γ is the current contents of the PDA stack
Ex 1:Write down the IDs or moves for
input string w = “aabb” of PDA as
M = ({q0, q1}, {a, b}, {a, b, Z0}, δ, q0, Z0,
{q1}), where δ is defined by following rules:
δ(q0, a, Z0) = {(q0, aZ0)} Push
δ(q0, a, a) = {(q0, aa)} Push
δ(q0, b, a) = {(q1, ε)} Pop
δ(q1, b, a) = {(q1, ε)} Pop
Also check string w is accepted by PDA or
not?
• Solution: Instantaneous Description for string
w = “aabb”
• (q0, aabb, Z0)
• |- (q0, abb, aZ0)
• |- (q0, bb, aaZ0)
• |- (q1, b, aZ0)
• |- (q1, ε, Z0)
• Finally the input tape is empty or input string
w is completed, PDA stack is empty and PDA
has reached a final state. So the string ‘w’
is accepted.
δ(q0, a, Z0) = {(q0, aZ0)} Push
δ(q0, a, a) = {(q0, aa)} Push
δ(q0, b, a) = {(q1, ε)} Pop
δ(q1, b, a) = {(q1, ε)} Pop
Example 2: Write down the Ids for input string w = “aaabb” of the above PDA.
Also check it is accepted by PDA or not?
• (q0, aaabb, Z0)
• |- (q0, aabb, aZ0)
• |- (q0, abb, aaZ0)
• |- (q0, bb, aaaZ0)
• |- (q1, b, aaZ0)
• |- (q1, ε, aZ0)
• |- There is no defined move
• So the pushdown automaton stops at this move and the string is not
accepted because the input tape is empty or input string w is completed
but the PDA stack is not empty. So the string ‘w’ is not accepted.
Note: The above method is also called testing of a string using final state method
δ(q0, a, Z0) = {(q0, aZ0)} Push
δ(q0, a, a) = {(q0, aa)} Push
δ(q0, b, a) = {(q1, ε)} Pop
δ(q1, b, a) = {(q1, ε)} Pop
Language Acceptance by PDA
• Method-1: Acceptance by final state
method(Ids Method)
• Method-2: Stack Empty Method
Ex: Design a PDA to recognize the language
L={wcwr: w ∈ (a+b)* }
Test the string w=aabbcbbaa is accepted by
final state method
Test the string w=aabbcbbaa is accepted by
Stack Empty Method
step1: a b b a c a b b a
current state=q0 Z0
operation=push(
a)
step2: a b b a c a b b a
a
current state=q0 Z0
operation=push(
b)
step3: a b b a c a b b a b
a
current state=q0 Z0
operation=push(
b)
step 4: a b b a c a b b a b
b
current state=q0 a
operation=push(
a) Z0
step 5: a b b a c a b b a a
b
current state=q0 b
operation= no
push a
no pop Z0
step 6: a b b a c a b b a a
b
current state=q1 b
operation=pop() a
Z0
step 7: a b b a c a b b a
b
current state=q1 b
operation=pop() a
Z0
step 8: a b b a c a b b a
current state=q1 b
operation=pop() a
Z0
step 9: a b b a c a b b a
current state=q1
operation=pop() a
Z0
step 10: a b b a c a b b a
current state=q1
string is empty
stack is empty Z0
Therefore String is accepted
Design a PDA which accepts L={anbn: n>=1}.
Check whether the strings I) aaabb II) aabbb and III)aaabbb are
accepted or not using i) Final state method ii) Stack Method
step
1: a a a b b
current state=q0 Z0
operation=push(a)
step
2: a a a b b
a
current state=q0 Z0
operation=push(a)
step3: a a a b b a
a
current
state=q0 Z0
operation=pus
h(a)
step 4: a a a b b a
a
current
state=q0 a
operation=pop
() Z0
step 5: a a a b b
current
state=q1 a
operation=
pop() a
Z0
step 6: a a a b b
current
state=q1
Input string:
empty a
Z0
String is rejected
Stack Method
• Design a PDA which accepts only odd no of a’s defined
over {a,b}. Check whether the string baababababbbbbaa
is accepted or not using final state and stack methods
• Construct a PDA for the language L={anb2n: n>=1}. Check
whether the string aabbbb is accepted or not by the given
language using i) Final state method ii) Stack Method
• Construct a PDA for the language L={an cb2n: n>=1}. Check
the string aaacbbbbbbb
• Construct a PDA for the language L={a2nbn: n>=1}. Check
the string aaaacbb
• Design a PDA for well formed Parenthesis (),[],{}
• Design PDA for a language L={w/w is in (a+b)* and
na(w)=nb(w) }
• Design PDA for a language L={w/w is in
(a+b)* and na(w)>nb(w) }
• Design PDA for a language L={w/w is in
(a+b)* and na(w)<nb(w)}
Types of PDA
• DPDA
• Previously constructed PDAs are DPDAs
• NPDA
• Ex1: Design a PDA to recognize the language
L={wwr: w ∈ (a+b)* }
• Ex2: construct PDA for language L containing
all the strings which are palindrome over {a,b}
Two stack PDA
• A two stack PDA can be formally described as a 9-tuple
(Q, ∑, Γ, Γ1, δ, q0, Z1 , Z2 , F)
• Q-finite number of states
• ∑ -input alphabet
• Γ –stack1 symbols
• Γ1 –stack2 symbols
• δ -transition function: Q × (∑ ∪ {ε}) × Γ x Γ1  (Q, Γ, Γ1 )
• δ(q0,a, Z1 , Z2 ) =(q1,aZ1 , Z2)
• Q0 initial state (q0 ∈ Q)
• Z1 is the initial stack1 top symbol (Z1∈ Γ)
• Z2 is the initial stack2 top symbol (Z2∈ Γ1)
• F is a set of accepting states (F ∈ Q)
Ex: Design a two stack PDA which accepts L={anbn cn : n>=1}.
Construction of PDA from CFG (or) CFG to PDA Conversion
• Step 1 − Convert the productions of the CFG into GNF.
• Step 2 − The PDA will have only one state {q}.
• Step 3 − The start symbol of CFG will be the start symbol in the PDA.
• Step 4 − 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.
• Step 5 − For each production in the form A → aX make a transition δ (q, a,
A)=(q,X).
• Step 6- For each production in the form A → a make a transition δ (q, a,
A)=(q, ε).
Ex: Convert the following CFG in to PDA
SaAA, AaS/bS/a
• The grammar is in GNF
• For SaAA: δ (q, a, S)=(q,AA).
• For AaS : δ (q, a, A)=(q,S).
• For AbS : δ (q, b, A)=(q,S)
• For Aa : δ (q, a, A)=(q, ε).
• The Equivalent PDA:
δ (q, a, S)=(q,AA).
δ (q, a, A)=(q,S).
δ (q, b, A)=(q,S)
δ (q, a, A)=(q, ε)
For A → aX : δ (q, a, A)=(q,X).
For A → a :δ (q, a, A)=(q, ε).
• Ia/b
• SaA
• AaABC/bB/a
• Bb
• Cc
• SaBB
• BbS/c

More Related Content

What's hot

Pda
PdaPda
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysisraosir123
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
Marina Santini
 
Software architecture
Software architectureSoftware architecture
Software architecture
Ahmad Raza Aslam
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.
mohanrathod18
 
COMPILER DESIGN
COMPILER DESIGNCOMPILER DESIGN
COMPILER DESIGN
Vetukurivenkatashiva
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)
Naman Joshi
 
Software review
Software reviewSoftware review
Software review
amjad_09
 
Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler Design
Akhil Kaushik
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
Mohammad Ilyas Malik
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
deepinderbedi
 
Real Time Systems
Real Time SystemsReal Time Systems
Real Time Systems
Deepak John
 
Transport layer interface
Transport layer interface Transport layer interface
Transport layer interface
CEC Landran
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
Mukesh Tekwani
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
Ratnakar Mikkili
 
States, state graphs and transition testing
States, state graphs and transition testingStates, state graphs and transition testing
States, state graphs and transition testing
ABHISHEK KUMAR
 
Kleene's theorem
Kleene's theoremKleene's theorem
Kleene's theorem
Mobeen Mustafa
 
Scope - Static and Dynamic
Scope - Static and DynamicScope - Static and Dynamic
Scope - Static and Dynamic
Sneh Pahilwani
 
Sdlc model
Sdlc modelSdlc model
Sdlc model
Dhilsath Fathima
 
Time andspacecomplexity
Time andspacecomplexityTime andspacecomplexity
Time andspacecomplexity
LAKSHMITHARUN PONNAM
 

What's hot (20)

Pda
PdaPda
Pda
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
 
Software architecture
Software architectureSoftware architecture
Software architecture
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.
 
COMPILER DESIGN
COMPILER DESIGNCOMPILER DESIGN
COMPILER DESIGN
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)
 
Software review
Software reviewSoftware review
Software review
 
Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler Design
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
Real Time Systems
Real Time SystemsReal Time Systems
Real Time Systems
 
Transport layer interface
Transport layer interface Transport layer interface
Transport layer interface
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
States, state graphs and transition testing
States, state graphs and transition testingStates, state graphs and transition testing
States, state graphs and transition testing
 
Kleene's theorem
Kleene's theoremKleene's theorem
Kleene's theorem
 
Scope - Static and Dynamic
Scope - Static and DynamicScope - Static and Dynamic
Scope - Static and Dynamic
 
Sdlc model
Sdlc modelSdlc model
Sdlc model
 
Time andspacecomplexity
Time andspacecomplexityTime andspacecomplexity
Time andspacecomplexity
 

Similar to Pda

Theory of automata
Theory of automataTheory of automata
Theory of automata
Arslan905905
 
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
 
PDA (1) (1).pptx
PDA (1) (1).pptxPDA (1) (1).pptx
PDA (1) (1).pptx
nandan543979
 
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
Srimatre K
 
Lecture12_16717_Lecture1.ppt
Lecture12_16717_Lecture1.pptLecture12_16717_Lecture1.ppt
Lecture12_16717_Lecture1.ppt
Venneladonthireddy1
 
PDA (pushdown automaton)
PDA (pushdown automaton)PDA (pushdown automaton)
PDA (pushdown automaton)
Захір Райхан
 
Lec 3 ---- dfa
Lec 3  ---- dfaLec 3  ---- dfa
Lec 3 ---- dfa
Abdul Aziz
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examplesankitamakin
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
ankitamakin
 
NFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramNFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition Diagram
Abdullah Jan
 
Presentation (2).pptx
Presentation (2).pptxPresentation (2).pptx
Presentation (2).pptx
AkhilJoseph63
 
PUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEPUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINE
Abhishek Shivhare
 
Model checking
Model checkingModel checking
Model checking
Ming-Hsiang Huang
 
FiniteAutomata.ppt
FiniteAutomata.pptFiniteAutomata.ppt
FiniteAutomata.ppt
RohitPaul71
 
FiniteAutomata (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).ppt
ssuser47f7f2
 
CS 5th.pptx
CS 5th.pptxCS 5th.pptx
CS 5th.pptx
MadniFareed1
 
Computer Organization1CS1400Feng JiangBoolean al.docx
Computer Organization1CS1400Feng JiangBoolean al.docxComputer Organization1CS1400Feng JiangBoolean al.docx
Computer Organization1CS1400Feng JiangBoolean al.docx
ladonnacamplin
 
Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)
Frankie Jones
 
Deterministic finite automata
Deterministic finite automata Deterministic finite automata
Deterministic finite automata
Muhammad Love Kian
 
3306565.ppt
3306565.ppt3306565.ppt
3306565.ppt
JP Chicano
 

Similar to Pda (20)

Theory of automata
Theory of automataTheory of automata
Theory of 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)
 
PDA (1) (1).pptx
PDA (1) (1).pptxPDA (1) (1).pptx
PDA (1) (1).pptx
 
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
 
Lecture12_16717_Lecture1.ppt
Lecture12_16717_Lecture1.pptLecture12_16717_Lecture1.ppt
Lecture12_16717_Lecture1.ppt
 
PDA (pushdown automaton)
PDA (pushdown automaton)PDA (pushdown automaton)
PDA (pushdown automaton)
 
Lec 3 ---- dfa
Lec 3  ---- dfaLec 3  ---- dfa
Lec 3 ---- dfa
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
NFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramNFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition Diagram
 
Presentation (2).pptx
Presentation (2).pptxPresentation (2).pptx
Presentation (2).pptx
 
PUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEPUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINE
 
Model checking
Model checkingModel checking
Model checking
 
FiniteAutomata.ppt
FiniteAutomata.pptFiniteAutomata.ppt
FiniteAutomata.ppt
 
FiniteAutomata (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).ppt
 
CS 5th.pptx
CS 5th.pptxCS 5th.pptx
CS 5th.pptx
 
Computer Organization1CS1400Feng JiangBoolean al.docx
Computer Organization1CS1400Feng JiangBoolean al.docxComputer Organization1CS1400Feng JiangBoolean al.docx
Computer Organization1CS1400Feng JiangBoolean al.docx
 
Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)
 
Deterministic finite automata
Deterministic finite automata Deterministic finite automata
Deterministic finite automata
 
3306565.ppt
3306565.ppt3306565.ppt
3306565.ppt
 

Recently uploaded

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 

Recently uploaded (20)

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 

Pda

  • 2. Model of PDA • Push Down Automaton :"Finite state machine" + "a stack"
  • 3. • A pushdown automaton has three components − • input tape, • control unit, and • stack with infinite size. • The stack head scans the top symbol of the stack. • A stack does two operations − • Push − a new symbol is added at the top. • Pop − the top symbol is read and removed.
  • 4. Def: PDA • A PDA can be formally described as a 7-tuple (Q, ∑, Γ, δ, q0, Z0 , F) • Q-finite number of states • ∑ -input alphabet • Γ -stack symbols • δ -transition function: Q × (∑ ∪ {ε}) × Γ Q × Γ* • Ex: δ(q0,a, Z0 ) =(q1,aZ0 ) • Q0 initial state (q0 ∈ Q) • Z0 is the initial stack top symbol (Z0 ∈ Γ) • F is a set of accepting states (F ∈ Q)
  • 6.
  • 7. Instantaneous Description of PDA • Instantaneous Description (ID) is an informal notation of how a PDA “computes” a input string and make a decision that string is accepted or rejected. • It is denoted by a triple (q, w, γ) where; • q is the current state • w is the unread part of the input string or the remaining input alphabets • γ is the current contents of the PDA stack
  • 8. Ex 1:Write down the IDs or moves for input string w = “aabb” of PDA as M = ({q0, q1}, {a, b}, {a, b, Z0}, δ, q0, Z0, {q1}), where δ is defined by following rules: δ(q0, a, Z0) = {(q0, aZ0)} Push δ(q0, a, a) = {(q0, aa)} Push δ(q0, b, a) = {(q1, ε)} Pop δ(q1, b, a) = {(q1, ε)} Pop Also check string w is accepted by PDA or not?
  • 9. • Solution: Instantaneous Description for string w = “aabb” • (q0, aabb, Z0) • |- (q0, abb, aZ0) • |- (q0, bb, aaZ0) • |- (q1, b, aZ0) • |- (q1, ε, Z0) • Finally the input tape is empty or input string w is completed, PDA stack is empty and PDA has reached a final state. So the string ‘w’ is accepted. δ(q0, a, Z0) = {(q0, aZ0)} Push δ(q0, a, a) = {(q0, aa)} Push δ(q0, b, a) = {(q1, ε)} Pop δ(q1, b, a) = {(q1, ε)} Pop
  • 10. Example 2: Write down the Ids for input string w = “aaabb” of the above PDA. Also check it is accepted by PDA or not? • (q0, aaabb, Z0) • |- (q0, aabb, aZ0) • |- (q0, abb, aaZ0) • |- (q0, bb, aaaZ0) • |- (q1, b, aaZ0) • |- (q1, ε, aZ0) • |- There is no defined move • So the pushdown automaton stops at this move and the string is not accepted because the input tape is empty or input string w is completed but the PDA stack is not empty. So the string ‘w’ is not accepted. Note: The above method is also called testing of a string using final state method δ(q0, a, Z0) = {(q0, aZ0)} Push δ(q0, a, a) = {(q0, aa)} Push δ(q0, b, a) = {(q1, ε)} Pop δ(q1, b, a) = {(q1, ε)} Pop
  • 11. Language Acceptance by PDA • Method-1: Acceptance by final state method(Ids Method) • Method-2: Stack Empty Method
  • 12. Ex: Design a PDA to recognize the language L={wcwr: w ∈ (a+b)* }
  • 13. Test the string w=aabbcbbaa is accepted by final state method
  • 14. Test the string w=aabbcbbaa is accepted by Stack Empty Method
  • 15. step1: a b b a c a b b a current state=q0 Z0 operation=push( a) step2: a b b a c a b b a a current state=q0 Z0 operation=push( b) step3: a b b a c a b b a b a current state=q0 Z0 operation=push( b) step 4: a b b a c a b b a b b current state=q0 a operation=push( a) Z0 step 5: a b b a c a b b a a b current state=q0 b operation= no push a no pop Z0 step 6: a b b a c a b b a a b current state=q1 b operation=pop() a Z0 step 7: a b b a c a b b a b current state=q1 b operation=pop() a Z0 step 8: a b b a c a b b a current state=q1 b operation=pop() a Z0 step 9: a b b a c a b b a current state=q1 operation=pop() a Z0 step 10: a b b a c a b b a current state=q1 string is empty stack is empty Z0 Therefore String is accepted
  • 16. Design a PDA which accepts L={anbn: n>=1}. Check whether the strings I) aaabb II) aabbb and III)aaabbb are accepted or not using i) Final state method ii) Stack Method
  • 17.
  • 18. step 1: a a a b b current state=q0 Z0 operation=push(a) step 2: a a a b b a current state=q0 Z0 operation=push(a) step3: a a a b b a a current state=q0 Z0 operation=pus h(a) step 4: a a a b b a a current state=q0 a operation=pop () Z0 step 5: a a a b b current state=q1 a operation= pop() a Z0 step 6: a a a b b current state=q1 Input string: empty a Z0 String is rejected Stack Method
  • 19. • Design a PDA which accepts only odd no of a’s defined over {a,b}. Check whether the string baababababbbbbaa is accepted or not using final state and stack methods • Construct a PDA for the language L={anb2n: n>=1}. Check whether the string aabbbb is accepted or not by the given language using i) Final state method ii) Stack Method • Construct a PDA for the language L={an cb2n: n>=1}. Check the string aaacbbbbbbb • Construct a PDA for the language L={a2nbn: n>=1}. Check the string aaaacbb • Design a PDA for well formed Parenthesis (),[],{} • Design PDA for a language L={w/w is in (a+b)* and na(w)=nb(w) }
  • 20. • Design PDA for a language L={w/w is in (a+b)* and na(w)>nb(w) } • Design PDA for a language L={w/w is in (a+b)* and na(w)<nb(w)}
  • 21. Types of PDA • DPDA • Previously constructed PDAs are DPDAs • NPDA • Ex1: Design a PDA to recognize the language L={wwr: w ∈ (a+b)* } • Ex2: construct PDA for language L containing all the strings which are palindrome over {a,b}
  • 22. Two stack PDA • A two stack PDA can be formally described as a 9-tuple (Q, ∑, Γ, Γ1, δ, q0, Z1 , Z2 , F) • Q-finite number of states • ∑ -input alphabet • Γ –stack1 symbols • Γ1 –stack2 symbols • δ -transition function: Q × (∑ ∪ {ε}) × Γ x Γ1  (Q, Γ, Γ1 ) • δ(q0,a, Z1 , Z2 ) =(q1,aZ1 , Z2) • Q0 initial state (q0 ∈ Q) • Z1 is the initial stack1 top symbol (Z1∈ Γ) • Z2 is the initial stack2 top symbol (Z2∈ Γ1) • F is a set of accepting states (F ∈ Q) Ex: Design a two stack PDA which accepts L={anbn cn : n>=1}.
  • 23. Construction of PDA from CFG (or) CFG to PDA Conversion • Step 1 − Convert the productions of the CFG into GNF. • Step 2 − The PDA will have only one state {q}. • Step 3 − The start symbol of CFG will be the start symbol in the PDA. • Step 4 − 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. • Step 5 − For each production in the form A → aX make a transition δ (q, a, A)=(q,X). • Step 6- For each production in the form A → a make a transition δ (q, a, A)=(q, ε).
  • 24. Ex: Convert the following CFG in to PDA SaAA, AaS/bS/a • The grammar is in GNF • For SaAA: δ (q, a, S)=(q,AA). • For AaS : δ (q, a, A)=(q,S). • For AbS : δ (q, b, A)=(q,S) • For Aa : δ (q, a, A)=(q, ε). • The Equivalent PDA: δ (q, a, S)=(q,AA). δ (q, a, A)=(q,S). δ (q, b, A)=(q,S) δ (q, a, A)=(q, ε) For A → aX : δ (q, a, A)=(q,X). For A → a :δ (q, a, A)=(q, ε).
  • 25. • Ia/b • SaA • AaABC/bB/a • Bb • Cc