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