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