Title: Pushdown Automata PDAs
1Pushdown AutomataPDAs
2Pushdown Automaton -- PDA
Input String
Stack
States
3Initial Stack Symbol
Stack
Stack
bottom
special symbol
4The States
Pop symbol
Input symbol
Push symbol
5input
stack
top
6input
stack
top
7input
stack
top
8input
stack
top
9Non-Determinism
10NPDA Non-Deterministic PDA
Example
11Execution Example
Time 0
Input
Stack
current state
12Time 1
Input
Stack
13Time 2
Input
Stack
14Time 3
Input
Stack
15Time 4
Input
Stack
16Time 5
Input
Stack
17Time 6
Input
Stack
18Time 7
Input
Stack
19Time 8
Input
Stack
accept
20A string is accepted if
- All the input is consumed
- The last state is a final state
We do not care about the stack contents
21The input string is accepted by the NPDA
22In general,
is the language accepted by the NPDA
23Another NPDA example
NPDA
24(No Transcript)
25Execution Example
Time 0
Input
Stack
26Time 1
Input
Stack
27Time 2
Input
Stack
28Time 3
Input
Stack
29Time 4
Input
Stack
30Time 5
Input
Stack
31Time 6
Input
Stack
accept
32Pushing Strings
Pop symbol
Input symbol
Push string
33Example
input
pushed string
stack
top
34Another NPDA example
NPDA
35(No Transcript)
36Execution
Time 0
Input
Stack
current state
37Time 1
Input
Stack
38Time 3
Input
Stack
39Time 4
Input
Stack
40Time 5
Input
Stack
41Time 6
Input
Stack
42Time 7
Input
Stack
43Time 8
Input
Stack
accept
44Formalities for NPDAs
45Transition function
46Transition function
47Formal Definition
Non-Deterministic Pushdown Automaton
NPDA
Final states
States
Input alphabet
Stack start symbol
Transition function
Stack alphabet
48Instantaneous Description
Current state
Current stack contents
Remaining input
49Example
Instantaneous Description
Input
Time 4
Stack
50Example
Instantaneous Description
Input
Time 5
Stack
51We write
(Time 4)
(Time 5)
52A computation
53For convenience we write
54Formal Definition
Language of NPDA
Start state
Final state
55Example
thus
NPDA
56thus
NPDA
57Therefore
NPDA
58Converting Context-Free Grammarsto NPDAs
59An example grammar
What is the equivalent NPDA?
60Grammar
NPDA
61The NPDA simulates leftmost derivations of the
grammar
L(grammar) L(NPDA)
62Grammar
A leftmost derivation
63NPDA execution
Time 0
Input
Stack
current state
64Time 1
Input
Stack
65Time 2
Input
Stack
66Time 3
Input
Stack
67Time 4
Input
Stack
68Time 5
Input
Stack
69Time 6
Input
Stack
70Time 7
Input
Stack
71Time 8
Input
Stack
72Time 9
Input
Stack
73Time 10
Input
Stack
accept
74In general
Given any grammar
We can construct a NPDA
With
75Constructing NPDA from grammar
For any production
For any terminal
76Grammar generates string
if and only if
NPDA accepts
77Therefore
For any context-free language there is an
NPDA that accepts the same language