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

Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDAAshish Duggal
 
Moore and mealy machines
Moore and mealy machinesMoore and mealy machines
Moore and mealy machinesAYESHA JAVED
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardAnimesh Chaturvedi
 
AI Greedy & A* Informed Search Strategies by Example
AI Greedy & A* Informed Search Strategies by ExampleAI Greedy & A* Informed Search Strategies by Example
AI Greedy & A* Informed Search Strategies by ExampleAhmed Gad
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsShiraz316
 
Working principle of Turing machine
Working principle of Turing machineWorking principle of Turing machine
Working principle of Turing machineKaran Thakkar
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite AutomataRatnakar Mikkili
 
Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prologHarry Potter
 
Problem Formulation in Artificial Inteligence Projects
Problem Formulation in Artificial Inteligence ProjectsProblem Formulation in Artificial Inteligence Projects
Problem Formulation in Artificial Inteligence ProjectsDr. C.V. Suresh Babu
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)Naman Joshi
 
Push down automata
Push down automataPush down automata
Push down automataSomya Bagai
 
Mealy and moore machine
Mealy and moore machineMealy and moore machine
Mealy and moore machineEhatsham Riaz
 

What's hot (20)

Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
 
PDA (pushdown automaton)
PDA (pushdown automaton)PDA (pushdown automaton)
PDA (pushdown automaton)
 
Moore and mealy machines
Moore and mealy machinesMoore and mealy machines
Moore and mealy machines
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
 
AI Greedy & A* Informed Search Strategies by Example
AI Greedy & A* Informed Search Strategies by ExampleAI Greedy & A* Informed Search Strategies by Example
AI Greedy & A* Informed Search Strategies by Example
 
Merge sort algorithm
Merge sort algorithmMerge sort algorithm
Merge sort algorithm
 
Parsing LL(1), SLR, LR(1)
Parsing LL(1), SLR, LR(1)Parsing LL(1), SLR, LR(1)
Parsing LL(1), SLR, LR(1)
 
Merge Sort
Merge SortMerge Sort
Merge Sort
 
And or graph
And or graphAnd or graph
And or graph
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Finite automata
Finite automataFinite automata
Finite automata
 
Working principle of Turing machine
Working principle of Turing machineWorking principle of Turing machine
Working principle of Turing machine
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prolog
 
Problem Formulation in Artificial Inteligence Projects
Problem Formulation in Artificial Inteligence ProjectsProblem Formulation in Artificial Inteligence Projects
Problem Formulation in Artificial Inteligence Projects
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)
 
Push down automata
Push down automataPush down automata
Push down automata
 
Closure properties
Closure propertiesClosure properties
Closure properties
 
Mealy and moore machine
Mealy and moore machineMealy and moore machine
Mealy and moore machine
 

Similar to Pda

Theory of automata
Theory of automataTheory of automata
Theory of automataArslan905905
 
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
 
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
 
Lec 3 ---- dfa
Lec 3  ---- dfaLec 3  ---- dfa
Lec 3 ---- dfaAbdul Aziz
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examplesankitamakin
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examplesankitamakin
 
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 DiagramAbdullah Jan
 
Presentation (2).pptx
Presentation (2).pptxPresentation (2).pptx
Presentation (2).pptxAkhilJoseph63
 
PUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEPUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEAbhishek Shivhare
 
FiniteAutomata (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).pptssuser47f7f2
 
FiniteAutomata.ppt
FiniteAutomata.pptFiniteAutomata.ppt
FiniteAutomata.pptRohitPaul71
 
Computer Organization1CS1400Feng JiangBoolean al.docx
Computer Organization1CS1400Feng JiangBoolean al.docxComputer Organization1CS1400Feng JiangBoolean al.docx
Computer Organization1CS1400Feng JiangBoolean al.docxladonnacamplin
 
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
 

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
 
push down automata
push down automatapush down automata
push down automata
 
Pda
PdaPda
Pda
 
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
 
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 (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).ppt
 
FiniteAutomata.ppt
FiniteAutomata.pptFiniteAutomata.ppt
FiniteAutomata.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
 

Recently uploaded

How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonhttgc7rh9c
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of PlayPooky Knightsmith
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxCeline George
 

Recently uploaded (20)

How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 

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