SlideShare a Scribd company logo
1 of 77
Fall 2006 Costas Busch - RPI 1
Pushdown Automata
PDAs
Fall 2006 Costas Busch - RPI 2
Pushdown Automaton -- PDA
Input String
Stack
States
Fall 2006 Costas Busch - RPI 3
Initial Stack Symbol
Stack
$
Stack
z
bottom special symbol
stack
head
top
Appears at time 0
Fall 2006 Costas Busch - RPI 4
The States
q1 q2
a, b  c
Input
symbol
Pop
symbol
Push
symbol
Fall 2006 Costas Busch - RPI 5
q1 q2
a, b  c
a 
b top
input
stack
a 
Replace
e
h
$
e
h
$
c
Fall 2006 Costas Busch - RPI 6
q1 q2
a,   c
a  a 
Push
b
e
h
$
e
h
$
b
c
top
input
stack
Fall 2006 Costas Busch - RPI 7
q1 q2
a, b  
a  a 
Pop
b
e
h
$
e
h
$
top
input
stack
Fall 2006 Costas Busch - RPI 8
q1 q2
a,   
a  a 
No Change
b
e
h
$
e
h
$
btop
input
stack
Fall 2006 Costas Busch - RPI 9
q1 q2
cba ,
a 
Pop
top
input
stack
Pop from Empty Stack
Automaton halts!
If the automaton attempts to pop from
empty stack then it halts and rejects input
Fall 2006 Costas Busch - RPI 10
Non-Determinism
q1
q2a, b  c
q3
a, b  c
q1 q2
, b  c
transition
PDAs are non-deterministic
Allowed non-deterministic transitions
Fall 2006 Costas Busch - RPI 11
Example PDA
,   
a,   a
b, a  q0 q1 q2 q3
b, a  
, $  $
PDA :M }0:{)(  nbaML nn
Fall 2006 Costas Busch - RPI 12
,   
a,   a
b, a  q0 q1 q2 q3
b, a  
, $  $
}0:{)(  nbaML nn
Basic Idea:
1. Push the a’s
on the stack
2. Match the b’s on input
with a’s on stack
3. Match
found
Fall 2006 Costas Busch - RPI 13
a,   a
b, a  
0q q1 q2 q3
Execution Example:
Input
a a a b b b
current
state
b, a  
Time 0
,    , $  $
Stack
$
Fall 2006 Costas Busch - RPI 14
a,   a
b, a  q0 q1 q2 q3
Input
a a a b b b
b, a  
Time 1
,    , $  $
Stack
$
Fall 2006 Costas Busch - RPI 15
a,   a
b, a  q0 q1 q2 q3
Input
Stack
a a a b b b
$
a
b, a  
Time 2
,    , $  $
Fall 2006 Costas Busch - RPI 16
a,   a
b, a  q0 q1 q2 q3
Input
Stack
a a a b b b
$
a
a
b, a  
Time 3
,    , $  $
Fall 2006 Costas Busch - RPI 17
a,   a
b, a  q0 q1 q2 q3
Input
Stack
a a a b b b
$
a
a
a
b, a  
Time 4
,    , $  $
Fall 2006 Costas Busch - RPI 18
a,   a
b, a  q0 q1 q2 q3
Input
a a a b b b
Stack
$
a
a
a
b, a  
Time 5
,    , $  $
Fall 2006 Costas Busch - RPI 19
a,   a
b, a  q0 q1 q2 q3
Input
a a a b b b
$
a
Stack
b, a  
Time 6
,    , $  $
a
Fall 2006 Costas Busch - RPI 20
a,   a
b, a  q0 q1 q2 q3
Input
a a a b b b
$
Stack
b, a  
Time 7
,    , $  $
a
Fall 2006 Costas Busch - RPI 21
a,   a
b, a  q0 q1 q2 q3
Input
a a a b b b
b, a  
Time 8
accept
,    , $  $
$
Stack
Fall 2006 Costas Busch - RPI 22
A string is accepted if there is
a computation such that:
All the input is consumed
AND
The last state is an accepting state
we do not care about the stack contents
at the end of the accepting computation
Fall 2006 Costas Busch - RPI 23
0q
a,   a
b, a  q1 q2 q3
Rejection Example:
Input
a a b
current
state
b, a  
Time 0
,    , $  $
Stack
$
Fall 2006 Costas Busch - RPI 24
0q
a,   a
b, a  q1 q2 q3
Rejection Example:
Input
a a b
current
state
b, a  
Time 1
,    , $  $
Stack
$
Fall 2006 Costas Busch - RPI 25
0q
a,   a
b, a  q1 q2 q3
Rejection Example:
Input
a a b
current
state
b, a  
Time 2
,    , $  $
Stack
$
a
Fall 2006 Costas Busch - RPI 26
0q
a,   a
b, a  q1 q2 q3
Rejection Example:
Input
a a b
current
state
b, a  
Time 3
,    , $  $
Stack
$
a
a
Fall 2006 Costas Busch - RPI 27
0q
a,   a
b, a  q1 q2 q3
Rejection Example:
Input
a a b
current
state
b, a  
Time 4
,    , $  $
Stack
$
a
a
Fall 2006 Costas Busch - RPI 28
0q
a,   a
b, a  q1 q2 q3
Rejection Example:
Input
a a b
current
state
b, a  
Time 4
,    , $  $
Stack
$
a
a
reject
Fall 2006 Costas Busch - RPI 29
The string is rejected by the PDAaab
a,   a
b, a  q0 q1 q2 q3
b, a  
,    , $  $
There is no accepting computation for aab
Fall 2006 Costas Busch - RPI 30
Another PDA example
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
PDA :M }},{:{)( 
 bavvvML R
Fall 2006 Costas Busch - RPI 31
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
}},{:{)( 
 bavvvML R
Basic Idea:
1. Push v
on stack
2. Guess
middle
of input
3. Match on input
with v on stack
R
v
4. Match
found
Fall 2006 Costas Busch - RPI 32
Execution Example:
Input
Time 0
Stack
$
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
a ab b
Fall 2006 Costas Busch - RPI 33
Input
a ab
Time 1
Stack
$
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
ab
Fall 2006 Costas Busch - RPI 34
Input
Time 2
Stack
$
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
a
a ab b
b
Fall 2006 Costas Busch - RPI 35
Input
Time 3
Stack
$
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
a
a ab b
b
Guess the middle
of string
Fall 2006 Costas Busch - RPI 36
Input
Time 4
Stack
$
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
a
a ab b
b
Fall 2006 Costas Busch - RPI 37
Input
Time 5
Stack
$
, $  $
1q q2
bb
aa




,
,
,   q0




bb
aa
,
,
a ab b a
Fall 2006 Costas Busch - RPI 38
Input
Time 6
Stack
$
, $  $q1
bb
aa




,
,
,   q0




bb
aa
,
,
a ab b
accept
q2
Fall 2006 Costas Busch - RPI 39
Rejection Example:
Input
Time 0
Stack
$
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
a b b b
Fall 2006 Costas Busch - RPI 40
Input
Time 1
Stack
$
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
a
a b b b
Fall 2006 Costas Busch - RPI 41
Input
Time 2
Stack
$
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
a
b
a b b b
Fall 2006 Costas Busch - RPI 42
Input
Time 3
Stack
$
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
a
b
Guess the middle
of string
a b b b
Fall 2006 Costas Busch - RPI 43
Input
Time 4
Stack
$
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
a
b
a b b b
Fall 2006 Costas Busch - RPI 44
Input
Time 5
Stack
$
, $  $
1q q2
bb
aa




,
,
,   q0




bb
aa
,
,
a
a b b b
There is no possible transition.
Input is not
consumed
Fall 2006 Costas Busch - RPI 45
Another computation on same string:
Input Time 0
Stack
$
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
a b b b
Fall 2006 Costas Busch - RPI 46
Input
Time 1
Stack
$
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
a
a b b b
Fall 2006 Costas Busch - RPI 47
Input
Time 2
Stack
$
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
a
b
a b b b
Fall 2006 Costas Busch - RPI 48
Input
Time 3
Stack
$
a
b
a b b b
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
b
Fall 2006 Costas Busch - RPI 49
Input
Time 4
Stack
a b b b
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
$
a
b
b
b
Fall 2006 Costas Busch - RPI 50
Input
Time 5
Stack
a b b b
$
a
b
b
b
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
No accept state
is reached
Fall 2006 Costas Busch - RPI 51
, $  $q1
q2
bb
aa




,
,
,   q0




bb
aa
,
,
There is no computation
that accepts string abbb
)(MLabbb
Fall 2006 Costas Busch - RPI 52
Pushing & Popping Strings
q1 q2
21, wwa 
Input
symbol
Push
string
Pop
string
Fall 2006 Costas Busch - RPI 53
q1 q2
cdfeba ,
aL L
b
top
input
stack
aL L
Replace
e
h h
e
c
d
f
push
string
Example:
$ $
e
pop
string
top
Fall 2006 Costas Busch - RPI 54
q1 q2
cdfeba ,
q1
q2
ea, ba,
fa ,
 ,
da , ca ,
pop
push
Equivalent
transitions
Fall 2006 Costas Busch - RPI 55
Another PDA example
$$, q1 q2
a, $  0$
a, 0  00
a,1 
b, $ 1$
b,1 11
b, 0  
PDA M
)}()(:},{{)( *
wnwnbawML ba 
Fall 2006 Costas Busch - RPI 56
Time 0
Input
a ab b b
current
state
a
$
Stack
$$, q1 q2
a, $  0$
a, 0  00
a,1 
b, $ 1$
b,1 11
b, 0  
Execution Example:
Fall 2006 Costas Busch - RPI 57
Time 1
Input
a ab b b a
$
Stack
0
$$, q1 q2
a, $  0$
a, 0  00
a,1 
b, $ 1$
b,1 11
b, 0  
Fall 2006 Costas Busch - RPI 58
Time 3
Input
a bb b a
$
Stack
a
$
$$, q1 q2
a, $  0$
a, 0  00
a,1 
b, $ 1$
b,1 11
b, 0  
0
Fall 2006 Costas Busch - RPI 59
Time 4
Input
a bb b a
$
Stack
a
1
$$, q1 q2
a, $  0$
a, 0  00
a,1 
b, $ 1$
b,1 11
b, 0  
Fall 2006 Costas Busch - RPI 60
Time 5
Input
a bb b a
$
Stack
a
1
1
$$, q1 q2
a, $  0$
a, 0  00
a,1 
b, $ 1$
b,1 11
b, 0  
Fall 2006 Costas Busch - RPI 61
Time 6
Input
a bb b a
$
Stack
a
1
$$, q1 q2
a, $  0$
a, 0  00
a,1 
b, $ 1$
b,1 11
b, 0  
1
Fall 2006 Costas Busch - RPI 62
Time 7
Input
a bb b a
$
Stack
a
1
$$, q1 q2
a, $  0$
a, 0  00
a,1 
b, $ 1$
b,1 11
b, 0  
Fall 2006 Costas Busch - RPI 63
Time 8
Input
a bb b a a
$
Stack
$$, q1 q2
a, $  0$
a, 0  00
a,1 
b, $ 1$
b,1 11
b, 0  
accept
Fall 2006 Costas Busch - RPI 64
Formalities for PDAs
Fall 2006 Costas Busch - RPI 65
q1 q2
21, wwa 
)},{(),,( 2211 wqwaq 
Transition function:
Fall 2006 Costas Busch - RPI 66
q1
q221, wwa 
q3
31, wwa 
)},(),,{(),,( 332211 wqwqwaq 
Transition function:
Fall 2006 Costas Busch - RPI 67
Formal Definition
Pushdown Automaton (PDA)
),,,δ,Γ,Σ,( 0 FzqQM 
States
Input
alphabet
Stack
alphabet
Transition
function
Accept
states
Stack
start
symbol
Initial
state
Fall 2006 Costas Busch - RPI 68
Instantaneous Description
),,( suq
Current
state
Remaining
input
Current
stack
contents
Fall 2006 Costas Busch - RPI 69
a,   a
b, a  q0 q1 q2 q3
Input
Stack
a a a b b b
$
a
a
b, a  
Time 4:
,    , $  $
Example: Instantaneous Description
$),,( 1 aaabbbq
a
Fall 2006 Costas Busch - RPI 70
a,   a
b, a  q0 q1 q2 q3
Input
Stack
a a a b b b
$
a
a
b, a  
Time 5:
,    , $  $
Example: Instantaneous Description
$),,( 2 aabbq
a
Fall 2006 Costas Busch - RPI 71
We write:
$),,($),,( 21 aabbqaaabbbq 
Time 4 Time 5
Fall 2006 Costas Busch - RPI 72
a,   a
b, a  q0 q1 q2 q3
b, a  
,    , $  $
,$),(,$),($),,($),,(
$),,($),,($),,(
,$),(,$),(
3222
111
10
 qqabqaabbq
aaabbbqaaabbbqaaabbbq
aaabbbqaaabbbq



A computation:
Fall 2006 Costas Busch - RPI 73
,$),(,$),($),,($),,(
$),,($),,($),,(
,$),(,$),(
3222
111
10
 qqabqaabbq
aaabbbqaaabbbqaaabbbq
aaabbbqaaabbbq



For convenience we write:
,$),(,$),( 30 qaaabbbq


Fall 2006 Costas Busch - RPI 74
Language of PDA
Language accepted by PDA :M
)},,(),,(:{)( 0 sqzwqwML f


 
Initial state Accept state
)(ML
Fall 2006 Costas Busch - RPI 75
Example:
,$),(,$),( 30 qaaabbbq


a,   a
b, a  q0 q1 q2 q3
b, a  
,    , $  $
PDA :M
)(MLaaabbb
Fall 2006 Costas Busch - RPI 76
,$),(,$),( 30 qbaq nn


a,   a
b, a  q0 q1 q2 q3
b, a  
,    , $  $
)(MLba nn

PDA :M
Fall 2006 Costas Busch - RPI 77
a,   a
b, a  q0 q1 q2 q3
b, a  
,    , $  $
PDA :M
}0:{)(  nbaML nnTherefore:

More Related Content

More from parmeet834

Problemes chap1 toc
Problemes chap1 tocProblemes chap1 toc
Problemes chap1 tocparmeet834
 
Nondeterministic Finite Automata
Nondeterministic Finite Automata Nondeterministic Finite Automata
Nondeterministic Finite Automata parmeet834
 
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...parmeet834
 
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
 Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S... Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...parmeet834
 
Graph representation of DFA’s Da
Graph representation of DFA’s DaGraph representation of DFA’s Da
Graph representation of DFA’s Daparmeet834
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automataparmeet834
 
Assignment Theory of computation TOC
Assignment Theory of computation TOCAssignment Theory of computation TOC
Assignment Theory of computation TOCparmeet834
 
5 decidability theory of computation
5 decidability theory of computation 5 decidability theory of computation
5 decidability theory of computation parmeet834
 
Turing Machines (TM)
Turing Machines (TM)Turing Machines (TM)
Turing Machines (TM)parmeet834
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languagesparmeet834
 
Finite Automata
Finite AutomataFinite Automata
Finite Automataparmeet834
 
1 introduction
1 introduction1 introduction
1 introductionparmeet834
 

More from parmeet834 (14)

DFA
DFA DFA
DFA
 
Problemes chap1 toc
Problemes chap1 tocProblemes chap1 toc
Problemes chap1 toc
 
Nondeterministic Finite Automata
Nondeterministic Finite Automata Nondeterministic Finite Automata
Nondeterministic Finite Automata
 
Hwsoln03 toc
Hwsoln03 tocHwsoln03 toc
Hwsoln03 toc
 
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
 
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
 Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S... Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
Introduction to the Theory of Computation, Winter 2003 A. Hevia and J. Mao S...
 
Graph representation of DFA’s Da
Graph representation of DFA’s DaGraph representation of DFA’s Da
Graph representation of DFA’s Da
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automata
 
Assignment Theory of computation TOC
Assignment Theory of computation TOCAssignment Theory of computation TOC
Assignment Theory of computation TOC
 
5 decidability theory of computation
5 decidability theory of computation 5 decidability theory of computation
5 decidability theory of computation
 
Turing Machines (TM)
Turing Machines (TM)Turing Machines (TM)
Turing Machines (TM)
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
1 introduction
1 introduction1 introduction
1 introduction
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 

Pushdown Automata

  • 1. Fall 2006 Costas Busch - RPI 1 Pushdown Automata PDAs
  • 2. Fall 2006 Costas Busch - RPI 2 Pushdown Automaton -- PDA Input String Stack States
  • 3. Fall 2006 Costas Busch - RPI 3 Initial Stack Symbol Stack $ Stack z bottom special symbol stack head top Appears at time 0
  • 4. Fall 2006 Costas Busch - RPI 4 The States q1 q2 a, b  c Input symbol Pop symbol Push symbol
  • 5. Fall 2006 Costas Busch - RPI 5 q1 q2 a, b  c a  b top input stack a  Replace e h $ e h $ c
  • 6. Fall 2006 Costas Busch - RPI 6 q1 q2 a,   c a  a  Push b e h $ e h $ b c top input stack
  • 7. Fall 2006 Costas Busch - RPI 7 q1 q2 a, b   a  a  Pop b e h $ e h $ top input stack
  • 8. Fall 2006 Costas Busch - RPI 8 q1 q2 a,    a  a  No Change b e h $ e h $ btop input stack
  • 9. Fall 2006 Costas Busch - RPI 9 q1 q2 cba , a  Pop top input stack Pop from Empty Stack Automaton halts! If the automaton attempts to pop from empty stack then it halts and rejects input
  • 10. Fall 2006 Costas Busch - RPI 10 Non-Determinism q1 q2a, b  c q3 a, b  c q1 q2 , b  c transition PDAs are non-deterministic Allowed non-deterministic transitions
  • 11. Fall 2006 Costas Busch - RPI 11 Example PDA ,    a,   a b, a  q0 q1 q2 q3 b, a   , $  $ PDA :M }0:{)(  nbaML nn
  • 12. Fall 2006 Costas Busch - RPI 12 ,    a,   a b, a  q0 q1 q2 q3 b, a   , $  $ }0:{)(  nbaML nn Basic Idea: 1. Push the a’s on the stack 2. Match the b’s on input with a’s on stack 3. Match found
  • 13. Fall 2006 Costas Busch - RPI 13 a,   a b, a   0q q1 q2 q3 Execution Example: Input a a a b b b current state b, a   Time 0 ,    , $  $ Stack $
  • 14. Fall 2006 Costas Busch - RPI 14 a,   a b, a  q0 q1 q2 q3 Input a a a b b b b, a   Time 1 ,    , $  $ Stack $
  • 15. Fall 2006 Costas Busch - RPI 15 a,   a b, a  q0 q1 q2 q3 Input Stack a a a b b b $ a b, a   Time 2 ,    , $  $
  • 16. Fall 2006 Costas Busch - RPI 16 a,   a b, a  q0 q1 q2 q3 Input Stack a a a b b b $ a a b, a   Time 3 ,    , $  $
  • 17. Fall 2006 Costas Busch - RPI 17 a,   a b, a  q0 q1 q2 q3 Input Stack a a a b b b $ a a a b, a   Time 4 ,    , $  $
  • 18. Fall 2006 Costas Busch - RPI 18 a,   a b, a  q0 q1 q2 q3 Input a a a b b b Stack $ a a a b, a   Time 5 ,    , $  $
  • 19. Fall 2006 Costas Busch - RPI 19 a,   a b, a  q0 q1 q2 q3 Input a a a b b b $ a Stack b, a   Time 6 ,    , $  $ a
  • 20. Fall 2006 Costas Busch - RPI 20 a,   a b, a  q0 q1 q2 q3 Input a a a b b b $ Stack b, a   Time 7 ,    , $  $ a
  • 21. Fall 2006 Costas Busch - RPI 21 a,   a b, a  q0 q1 q2 q3 Input a a a b b b b, a   Time 8 accept ,    , $  $ $ Stack
  • 22. Fall 2006 Costas Busch - RPI 22 A string is accepted if there is a computation such that: All the input is consumed AND The last state is an accepting state we do not care about the stack contents at the end of the accepting computation
  • 23. Fall 2006 Costas Busch - RPI 23 0q a,   a b, a  q1 q2 q3 Rejection Example: Input a a b current state b, a   Time 0 ,    , $  $ Stack $
  • 24. Fall 2006 Costas Busch - RPI 24 0q a,   a b, a  q1 q2 q3 Rejection Example: Input a a b current state b, a   Time 1 ,    , $  $ Stack $
  • 25. Fall 2006 Costas Busch - RPI 25 0q a,   a b, a  q1 q2 q3 Rejection Example: Input a a b current state b, a   Time 2 ,    , $  $ Stack $ a
  • 26. Fall 2006 Costas Busch - RPI 26 0q a,   a b, a  q1 q2 q3 Rejection Example: Input a a b current state b, a   Time 3 ,    , $  $ Stack $ a a
  • 27. Fall 2006 Costas Busch - RPI 27 0q a,   a b, a  q1 q2 q3 Rejection Example: Input a a b current state b, a   Time 4 ,    , $  $ Stack $ a a
  • 28. Fall 2006 Costas Busch - RPI 28 0q a,   a b, a  q1 q2 q3 Rejection Example: Input a a b current state b, a   Time 4 ,    , $  $ Stack $ a a reject
  • 29. Fall 2006 Costas Busch - RPI 29 The string is rejected by the PDAaab a,   a b, a  q0 q1 q2 q3 b, a   ,    , $  $ There is no accepting computation for aab
  • 30. Fall 2006 Costas Busch - RPI 30 Another PDA example , $  $q1 q2 bb aa     , , ,   q0     bb aa , , PDA :M }},{:{)(   bavvvML R
  • 31. Fall 2006 Costas Busch - RPI 31 , $  $q1 q2 bb aa     , , ,   q0     bb aa , , }},{:{)(   bavvvML R Basic Idea: 1. Push v on stack 2. Guess middle of input 3. Match on input with v on stack R v 4. Match found
  • 32. Fall 2006 Costas Busch - RPI 32 Execution Example: Input Time 0 Stack $ , $  $q1 q2 bb aa     , , ,   q0     bb aa , , a ab b
  • 33. Fall 2006 Costas Busch - RPI 33 Input a ab Time 1 Stack $ , $  $q1 q2 bb aa     , , ,   q0     bb aa , , ab
  • 34. Fall 2006 Costas Busch - RPI 34 Input Time 2 Stack $ , $  $q1 q2 bb aa     , , ,   q0     bb aa , , a a ab b b
  • 35. Fall 2006 Costas Busch - RPI 35 Input Time 3 Stack $ , $  $q1 q2 bb aa     , , ,   q0     bb aa , , a a ab b b Guess the middle of string
  • 36. Fall 2006 Costas Busch - RPI 36 Input Time 4 Stack $ , $  $q1 q2 bb aa     , , ,   q0     bb aa , , a a ab b b
  • 37. Fall 2006 Costas Busch - RPI 37 Input Time 5 Stack $ , $  $ 1q q2 bb aa     , , ,   q0     bb aa , , a ab b a
  • 38. Fall 2006 Costas Busch - RPI 38 Input Time 6 Stack $ , $  $q1 bb aa     , , ,   q0     bb aa , , a ab b accept q2
  • 39. Fall 2006 Costas Busch - RPI 39 Rejection Example: Input Time 0 Stack $ , $  $q1 q2 bb aa     , , ,   q0     bb aa , , a b b b
  • 40. Fall 2006 Costas Busch - RPI 40 Input Time 1 Stack $ , $  $q1 q2 bb aa     , , ,   q0     bb aa , , a a b b b
  • 41. Fall 2006 Costas Busch - RPI 41 Input Time 2 Stack $ , $  $q1 q2 bb aa     , , ,   q0     bb aa , , a b a b b b
  • 42. Fall 2006 Costas Busch - RPI 42 Input Time 3 Stack $ , $  $q1 q2 bb aa     , , ,   q0     bb aa , , a b Guess the middle of string a b b b
  • 43. Fall 2006 Costas Busch - RPI 43 Input Time 4 Stack $ , $  $q1 q2 bb aa     , , ,   q0     bb aa , , a b a b b b
  • 44. Fall 2006 Costas Busch - RPI 44 Input Time 5 Stack $ , $  $ 1q q2 bb aa     , , ,   q0     bb aa , , a a b b b There is no possible transition. Input is not consumed
  • 45. Fall 2006 Costas Busch - RPI 45 Another computation on same string: Input Time 0 Stack $ , $  $q1 q2 bb aa     , , ,   q0     bb aa , , a b b b
  • 46. Fall 2006 Costas Busch - RPI 46 Input Time 1 Stack $ , $  $q1 q2 bb aa     , , ,   q0     bb aa , , a a b b b
  • 47. Fall 2006 Costas Busch - RPI 47 Input Time 2 Stack $ , $  $q1 q2 bb aa     , , ,   q0     bb aa , , a b a b b b
  • 48. Fall 2006 Costas Busch - RPI 48 Input Time 3 Stack $ a b a b b b , $  $q1 q2 bb aa     , , ,   q0     bb aa , , b
  • 49. Fall 2006 Costas Busch - RPI 49 Input Time 4 Stack a b b b , $  $q1 q2 bb aa     , , ,   q0     bb aa , , $ a b b b
  • 50. Fall 2006 Costas Busch - RPI 50 Input Time 5 Stack a b b b $ a b b b , $  $q1 q2 bb aa     , , ,   q0     bb aa , , No accept state is reached
  • 51. Fall 2006 Costas Busch - RPI 51 , $  $q1 q2 bb aa     , , ,   q0     bb aa , , There is no computation that accepts string abbb )(MLabbb
  • 52. Fall 2006 Costas Busch - RPI 52 Pushing & Popping Strings q1 q2 21, wwa  Input symbol Push string Pop string
  • 53. Fall 2006 Costas Busch - RPI 53 q1 q2 cdfeba , aL L b top input stack aL L Replace e h h e c d f push string Example: $ $ e pop string top
  • 54. Fall 2006 Costas Busch - RPI 54 q1 q2 cdfeba , q1 q2 ea, ba, fa ,  , da , ca , pop push Equivalent transitions
  • 55. Fall 2006 Costas Busch - RPI 55 Another PDA example $$, q1 q2 a, $  0$ a, 0  00 a,1  b, $ 1$ b,1 11 b, 0   PDA M )}()(:},{{)( * wnwnbawML ba 
  • 56. Fall 2006 Costas Busch - RPI 56 Time 0 Input a ab b b current state a $ Stack $$, q1 q2 a, $  0$ a, 0  00 a,1  b, $ 1$ b,1 11 b, 0   Execution Example:
  • 57. Fall 2006 Costas Busch - RPI 57 Time 1 Input a ab b b a $ Stack 0 $$, q1 q2 a, $  0$ a, 0  00 a,1  b, $ 1$ b,1 11 b, 0  
  • 58. Fall 2006 Costas Busch - RPI 58 Time 3 Input a bb b a $ Stack a $ $$, q1 q2 a, $  0$ a, 0  00 a,1  b, $ 1$ b,1 11 b, 0   0
  • 59. Fall 2006 Costas Busch - RPI 59 Time 4 Input a bb b a $ Stack a 1 $$, q1 q2 a, $  0$ a, 0  00 a,1  b, $ 1$ b,1 11 b, 0  
  • 60. Fall 2006 Costas Busch - RPI 60 Time 5 Input a bb b a $ Stack a 1 1 $$, q1 q2 a, $  0$ a, 0  00 a,1  b, $ 1$ b,1 11 b, 0  
  • 61. Fall 2006 Costas Busch - RPI 61 Time 6 Input a bb b a $ Stack a 1 $$, q1 q2 a, $  0$ a, 0  00 a,1  b, $ 1$ b,1 11 b, 0   1
  • 62. Fall 2006 Costas Busch - RPI 62 Time 7 Input a bb b a $ Stack a 1 $$, q1 q2 a, $  0$ a, 0  00 a,1  b, $ 1$ b,1 11 b, 0  
  • 63. Fall 2006 Costas Busch - RPI 63 Time 8 Input a bb b a a $ Stack $$, q1 q2 a, $  0$ a, 0  00 a,1  b, $ 1$ b,1 11 b, 0   accept
  • 64. Fall 2006 Costas Busch - RPI 64 Formalities for PDAs
  • 65. Fall 2006 Costas Busch - RPI 65 q1 q2 21, wwa  )},{(),,( 2211 wqwaq  Transition function:
  • 66. Fall 2006 Costas Busch - RPI 66 q1 q221, wwa  q3 31, wwa  )},(),,{(),,( 332211 wqwqwaq  Transition function:
  • 67. Fall 2006 Costas Busch - RPI 67 Formal Definition Pushdown Automaton (PDA) ),,,δ,Γ,Σ,( 0 FzqQM  States Input alphabet Stack alphabet Transition function Accept states Stack start symbol Initial state
  • 68. Fall 2006 Costas Busch - RPI 68 Instantaneous Description ),,( suq Current state Remaining input Current stack contents
  • 69. Fall 2006 Costas Busch - RPI 69 a,   a b, a  q0 q1 q2 q3 Input Stack a a a b b b $ a a b, a   Time 4: ,    , $  $ Example: Instantaneous Description $),,( 1 aaabbbq a
  • 70. Fall 2006 Costas Busch - RPI 70 a,   a b, a  q0 q1 q2 q3 Input Stack a a a b b b $ a a b, a   Time 5: ,    , $  $ Example: Instantaneous Description $),,( 2 aabbq a
  • 71. Fall 2006 Costas Busch - RPI 71 We write: $),,($),,( 21 aabbqaaabbbq  Time 4 Time 5
  • 72. Fall 2006 Costas Busch - RPI 72 a,   a b, a  q0 q1 q2 q3 b, a   ,    , $  $ ,$),(,$),($),,($),,( $),,($),,($),,( ,$),(,$),( 3222 111 10  qqabqaabbq aaabbbqaaabbbqaaabbbq aaabbbqaaabbbq    A computation:
  • 73. Fall 2006 Costas Busch - RPI 73 ,$),(,$),($),,($),,( $),,($),,($),,( ,$),(,$),( 3222 111 10  qqabqaabbq aaabbbqaaabbbqaaabbbq aaabbbqaaabbbq    For convenience we write: ,$),(,$),( 30 qaaabbbq  
  • 74. Fall 2006 Costas Busch - RPI 74 Language of PDA Language accepted by PDA :M )},,(),,(:{)( 0 sqzwqwML f     Initial state Accept state )(ML
  • 75. Fall 2006 Costas Busch - RPI 75 Example: ,$),(,$),( 30 qaaabbbq   a,   a b, a  q0 q1 q2 q3 b, a   ,    , $  $ PDA :M )(MLaaabbb
  • 76. Fall 2006 Costas Busch - RPI 76 ,$),(,$),( 30 qbaq nn   a,   a b, a  q0 q1 q2 q3 b, a   ,    , $  $ )(MLba nn  PDA :M
  • 77. Fall 2006 Costas Busch - RPI 77 a,   a b, a  q0 q1 q2 q3 b, a   ,    , $  $ PDA :M }0:{)(  nbaML nnTherefore: