SlideShare a Scribd company logo
1 of 24
Download to read offline
PUSH DOWN AUTOMATA(PDA)
DEFINATION 
PDA is used to accept CFG language. PDA is an FA together with Stack. Stack have access to unlimited amount of memory.
Thetapeis divided into finitely many cells. 
Each cell contains a symbol in an alphabet Σ. 
δwhich definednext stateortransition. 
A is the initial top symbol of stack which is 
Finite. 
Input Tape 
Stack 
Finite 
Control 
δ 
P 
State 
a 
l 
p 
h 
b 
t 
e 
A 
Top symbol 
Of Stack 
a
PDA consisting of 7 tuples 
1.Qis a finite set of state 
2.Σ(Sigma)is a finite set of input alphabet 
3.Γ(Gamma)is a finite set of stack alphabet 
4.δ(Delta)is a transitionfunction 
5.qₒis the start state 
6.Ais the initial stack symbol 
7.Fis the set of accepting states
TRANSITION AND OPERATION IN PDA 
a , bc 
Meaning that if we see an “a” in the input string and the stack contains the symbol “b” on top then we remove the “b” and add “c”. 
q0 
q1 
a,bc
•1stOperation: 
When we will on q0 state and read 
“a” and “b” is the top symbol in 
Stack then “b” will replace with “c”. 
When “b” will be replaced with “c” then we will on state q1. 
q0 
q1 
a,bc 
a 
b 
h 
e 
& 
input 
top 
Replace 
h 
e 
& 
c 
stack
•2ndOperation: 
Whenwewillonq0stateandread 
“a”and“ε(empty)”overthestack 
thenwewillput“c”overthere. 
When “c” will be putted then we will on state q1. 
If we want to push anything in the stack then we will used Push Operation. 
Push 
a 
input 
b 
top 
stack 
h 
e 
& 
q0 
q1 
a,εc 
b 
h 
e 
& 
c
•3rdOperation: 
When we will on q0 state and read 
“a” and “b” is the top symbol in 
stack then we will drop “b”. 
When “b” will be dropped then we will on state q1. 
q0 
q1 
a,bε 
a 
input 
b 
top 
h 
e 
& 
Pop 
h 
e 
&
•4thOperation: 
•When we will on q0 state and read 
“a” and there is “ε(empty)” than 
there will be no change in stack. 
q0 
q1 
a,ε ε 
a 
input 
b 
top 
h 
e 
& 
b 
h 
e 
& 
No Change
a a a b b b 
q0 q1 q2 q3 
ε, ε & 
a, ε a 
b, a ε 
b, a ε 
ε, & ε 
• When PDA Accept: 
• The computation path ends in the accept state. 
• All the inputs is consumed. 
Σ*=aaabbb 
PDA for {a b : n  0} n n
a a a b b b 
q0 q1 q2 q3 
ε, ε & 
a, ε a 
b, a ε 
b, a ε 
ε, & ε 
& 
Push Operation
a a a b b b 
q0 q1 q2 q3 
ε, ε & 
a, ε a 
b, a ε 
b, a ε 
ε, & ε 
& 
a 
Push Operation
a a a b b b 
q0 q1 q2 q3 
ε, ε & 
a, ε a 
b, a ε 
b, a ε 
ε, & ε 
& 
a 
a 
Push Operation
a a a b b b 
q0 q1 q2 q3 
ε, ε & 
a, ε a 
b, a ε 
b, a ε 
ε, & ε 
Push Operation & 
a 
a 
a
a a a b b b 
q0 q1 q2 q3 
ε, ε & 
a, ε a 
b, a ε 
b, a ε 
ε, & ε 
& 
a 
a 
Pop Operation
a a a b b b 
q0 q1 q2 q3 
ε, ε & 
a, ε a 
b, a ε 
b, a ε 
ε, & ε 
& 
a 
Pop Operation
a a a b b b 
q0 q1 q2 q3 
ε, ε & 
a, ε a 
b, a ε 
b, a ε 
ε, & ε 
Pop Operation &
a a a b b b 
q0 q1 q2 q3 
ε, ε & 
a, ε a 
b, a ε 
b, a ε 
ε, & ε 
Replace Operation
q2 
q2 
• 2nd Example: 
a b 
q0 q1 q2 q3 
a a a a b b b b 
a , Z aZ 
Z 
4 4 
a , a aa 
b , a ε 
b , a ε 
ε , Z Z 
q1 aaaabbb 
aZ aaaaZ 
q1 aaaabbbb q2 aaaabbbb 
aaaZ 
q3 aaaabbbb 
Z
• When PDA Reject: 
• Either end in a non-accepting state. 
• If there is no possible transition under the 
current input and stack symbols. 
q0 q1 q2 q3 
ε, ε & 
a, ε a 
b, a ε 
b, a ε 
ε, & ε 
a a b 
PDA for{ a b : n  0} n n 
Σ*=aab
q0 
q1 
q2 
q3 
ε,ε& 
a,εa 
b,aε 
b,aε 
ε,& ε 
& 
Push Operation 
a 
a 
b
q0 
q1 
q2 
q3 
ε,ε& 
a,εa 
b,aε 
b,aε 
ε,& ε 
& 
Push Operation 
a 
a 
b 
a
q0 
q1 
q2 
q3 
ε,ε& 
a,εa 
b,aε 
b,aε 
ε,& ε 
& 
Push Operation 
a 
a 
b 
a 
a
q0 
q1 
q2 
q3 
ε,ε& 
a,εa 
b,aε 
b,aε 
ε,& ε 
& 
a 
a 
b 
a 
Σ*=aab is rejected because there is no more possible transition. (no more input alphabet)

More Related Content

What's hot (20)

Lecture 07 08 syntax analysis-4
Lecture 07 08 syntax analysis-4Lecture 07 08 syntax analysis-4
Lecture 07 08 syntax analysis-4
 
Ch06
Ch06Ch06
Ch06
 
Topdown parsing
Topdown parsingTopdown parsing
Topdown parsing
 
Introduction to Compiler Development
Introduction to Compiler DevelopmentIntroduction to Compiler Development
Introduction to Compiler Development
 
Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2
 
Pcd(Mca)
Pcd(Mca)Pcd(Mca)
Pcd(Mca)
 
Automata Theory - Turing machine
Automata Theory - Turing machineAutomata Theory - Turing machine
Automata Theory - Turing machine
 
Clojure presentation
Clojure presentationClojure presentation
Clojure presentation
 
First and follow set
First and follow setFirst and follow set
First and follow set
 
Theory of Computation Unit 4
Theory of Computation Unit 4Theory of Computation Unit 4
Theory of Computation Unit 4
 
Bottomupparser
BottomupparserBottomupparser
Bottomupparser
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysis
 
LL(1) parsing
LL(1) parsingLL(1) parsing
LL(1) parsing
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
Mba admission in india
Mba admission in indiaMba admission in india
Mba admission in india
 
Automata
AutomataAutomata
Automata
 
Top down parsing(sid) (1)
Top down parsing(sid) (1)Top down parsing(sid) (1)
Top down parsing(sid) (1)
 
Nfa vs dfa
Nfa vs dfaNfa vs dfa
Nfa vs dfa
 
Theory of computation / Post’s Correspondence Problems (PCP)
Theory of computation / Post’s Correspondence Problems (PCP)Theory of computation / Post’s Correspondence Problems (PCP)
Theory of computation / Post’s Correspondence Problems (PCP)
 

Viewers also liked

Viewers also liked (6)

Class8
 Class8 Class8
Class8
 
Pushdown autometa
Pushdown autometaPushdown autometa
Pushdown autometa
 
Pda
PdaPda
Pda
 
Push down automata
Push down automataPush down automata
Push down automata
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
Push Down Automata (PDA)
Push Down Automata (PDA)Push Down Automata (PDA)
Push Down Automata (PDA)
 

Phttp://www.cw360ms.com/pmsurveyresults/index.aspda

  • 2. DEFINATION PDA is used to accept CFG language. PDA is an FA together with Stack. Stack have access to unlimited amount of memory.
  • 3. Thetapeis divided into finitely many cells. Each cell contains a symbol in an alphabet Σ. δwhich definednext stateortransition. A is the initial top symbol of stack which is Finite. Input Tape Stack Finite Control δ P State a l p h b t e A Top symbol Of Stack a
  • 4. PDA consisting of 7 tuples 1.Qis a finite set of state 2.Σ(Sigma)is a finite set of input alphabet 3.Γ(Gamma)is a finite set of stack alphabet 4.δ(Delta)is a transitionfunction 5.qₒis the start state 6.Ais the initial stack symbol 7.Fis the set of accepting states
  • 5. TRANSITION AND OPERATION IN PDA a , bc Meaning that if we see an “a” in the input string and the stack contains the symbol “b” on top then we remove the “b” and add “c”. q0 q1 a,bc
  • 6. •1stOperation: When we will on q0 state and read “a” and “b” is the top symbol in Stack then “b” will replace with “c”. When “b” will be replaced with “c” then we will on state q1. q0 q1 a,bc a b h e & input top Replace h e & c stack
  • 7. •2ndOperation: Whenwewillonq0stateandread “a”and“ε(empty)”overthestack thenwewillput“c”overthere. When “c” will be putted then we will on state q1. If we want to push anything in the stack then we will used Push Operation. Push a input b top stack h e & q0 q1 a,εc b h e & c
  • 8. •3rdOperation: When we will on q0 state and read “a” and “b” is the top symbol in stack then we will drop “b”. When “b” will be dropped then we will on state q1. q0 q1 a,bε a input b top h e & Pop h e &
  • 9. •4thOperation: •When we will on q0 state and read “a” and there is “ε(empty)” than there will be no change in stack. q0 q1 a,ε ε a input b top h e & b h e & No Change
  • 10. a a a b b b q0 q1 q2 q3 ε, ε & a, ε a b, a ε b, a ε ε, & ε • When PDA Accept: • The computation path ends in the accept state. • All the inputs is consumed. Σ*=aaabbb PDA for {a b : n  0} n n
  • 11. a a a b b b q0 q1 q2 q3 ε, ε & a, ε a b, a ε b, a ε ε, & ε & Push Operation
  • 12. a a a b b b q0 q1 q2 q3 ε, ε & a, ε a b, a ε b, a ε ε, & ε & a Push Operation
  • 13. a a a b b b q0 q1 q2 q3 ε, ε & a, ε a b, a ε b, a ε ε, & ε & a a Push Operation
  • 14. a a a b b b q0 q1 q2 q3 ε, ε & a, ε a b, a ε b, a ε ε, & ε Push Operation & a a a
  • 15. a a a b b b q0 q1 q2 q3 ε, ε & a, ε a b, a ε b, a ε ε, & ε & a a Pop Operation
  • 16. a a a b b b q0 q1 q2 q3 ε, ε & a, ε a b, a ε b, a ε ε, & ε & a Pop Operation
  • 17. a a a b b b q0 q1 q2 q3 ε, ε & a, ε a b, a ε b, a ε ε, & ε Pop Operation &
  • 18. a a a b b b q0 q1 q2 q3 ε, ε & a, ε a b, a ε b, a ε ε, & ε Replace Operation
  • 19. q2 q2 • 2nd Example: a b q0 q1 q2 q3 a a a a b b b b a , Z aZ Z 4 4 a , a aa b , a ε b , a ε ε , Z Z q1 aaaabbb aZ aaaaZ q1 aaaabbbb q2 aaaabbbb aaaZ q3 aaaabbbb Z
  • 20. • When PDA Reject: • Either end in a non-accepting state. • If there is no possible transition under the current input and stack symbols. q0 q1 q2 q3 ε, ε & a, ε a b, a ε b, a ε ε, & ε a a b PDA for{ a b : n  0} n n Σ*=aab
  • 21. q0 q1 q2 q3 ε,ε& a,εa b,aε b,aε ε,& ε & Push Operation a a b
  • 22. q0 q1 q2 q3 ε,ε& a,εa b,aε b,aε ε,& ε & Push Operation a a b a
  • 23. q0 q1 q2 q3 ε,ε& a,εa b,aε b,aε ε,& ε & Push Operation a a b a a
  • 24. q0 q1 q2 q3 ε,ε& a,εa b,aε b,aε ε,& ε & a a b a Σ*=aab is rejected because there is no more possible transition. (no more input alphabet)