Escolar Documentos
Profissional Documentos
Cultura Documentos
Science (COSC-3302),
Lecture 5 (prepared after
Chapter 5 of Martins 2011
Stefan Andrei
textbook)
04/22/16
Course topics
1.1. Mathematical Tools and Techniques (Chapter 1)
1.2. Finite Automata and the Languages they Accept (Chapter 2)
1.3. Regular Expressions, Nondeterminism, and Kleenes Theorem (Chapter 3)
Exam 1
2.1. Context-Free Languages (Chapter 4)
2.2. Pushdown Automata (Chapter 5)
2.3. Context-Free and Non-Context-Free Languages (Chapter 6)
Exam 2
3.1. Turing Machines (Chapter 7)
3.2. Recursively Enumerable Languages (Chapter 8)
3.3. Undecidable Problems (Chapter 9)
3.4. Computable Functions (Chapter 10)
3.5. Introduction to Computational Complexity (Chapter 11)
Exam 3
04/22/16
Overview of Previous
Lecture
Context-Free Languages
1.
2.
3.
4.
5.
04/22/16
Pushdown Automata
1.
2.
3.
4.
5.
04/22/16
04/22/16
04/22/16
04/22/16
04/22/16
04/22/16
04/22/16
10
04/22/16
11
State
Input
Stack
top
Move(s)
q0
Z0
(q1, aZ0)
q1
(q1, aa)
q1
(q2, )
q2
(q2, )
q2
Z0
(q3, Z0)
04/22/16
none
12
Get a star: Prove that (q0, anbn, Z0) 2n+1 times (q3, ,
Z0).
04/22/16
13
Deterministic Pushdown
Automata
Definition 5.10: A pushdown automaton
2.
04/22/16
14
Deterministic Pushdown
Automata (contd.)
2.
3.
04/22/16
15
Deterministic Pushdown
Automata (contd.)
State
Input
Stack
top
Move
q0
Z0
(q1, [Z0)
q1
(q1, [[)
q1
(q1, )
q1
Z0
(q0, Z0)
none
16
Deterministic Pushdown
Automata (contd.)
04/22/16
17
Deterministic Pushdown
Automata (contd.)
Two typical lines from the transition table are
1.
(q0, a, Z0) = {(q0, aZ0), (q1, Z0)}
2.
In both lines, the first move is the right one if the input
symbol a is still in the first half of the string.
The second move is the right one if the a is the middle
symbol in an (odd-length) palindrome.
M decides which move to make by guessing.
The other guess it can make is that it has reached the
middle of an even-length palindrome.
18
where is:
1.
2.
3.
4.
5.
6.
7.
8.
9.
04/22/16
10.
11.
(q1, a, a) = {(q1, )}
12.
(q1, b, b) = {(q1, )}
19
04/22/16
20
04/22/16
21
1.
2.
3.
4.
(q1, , ) = {(q2, )}
5.
(q2, a, A) = {(q2, )}
6.
(q2, b, B) = {(q2, )}
7.
04/22/16
22
Modd_pal = ({q0, q1, q2, q3}, {a, b}, {A, B, Z0}, q0, Z0,
{q3}, ), where is:
1.
2.
3.
4.
(q2, a, A) = {(q2, )}
5.
(q2, b, B) = {(q2, )}
6.
04/22/16
23
2.
3.
4.
(q1, , ) = {(q2, )}
5.
(q2, a, A) = {(q2, )}
6.
(q2, b, B) = {(q2, )}
7.
04/22/16
24
(q1, , S) = {(q1, aSa), (q1, bSb), (q1, a), (q1, b), (q1,
)}
(q1, a, a) = {(q1, )}
(q1, b, b) = {(q1, )}
04/22/16
25
Deterministic Pushdown
Automata (contd.)
04/22/16
26
Deterministic Pushdown
Automata (contd.)
04/22/16
27
Deterministic Pushdown
Automata (contd.)
04/22/16
28
Deterministic Pushdown
Automata (contd.)
04/22/16
29
04/22/16
30
04/22/16
31
04/22/16
32
04/22/16
33
04/22/16
34
04/22/16
35
(contd.)
Definition 5.22: Let G=(V, , S, P) be a CFG.
04/22/16
36
Theorem 5.23: If G is a CFG, then the nondeterministic bottom-up PDA NB(G) accepts
L(G).
04/22/16
37
04/22/16
38
04/22/16
39
04/22/16
40
anbn
1.
2.
3.
4.
5.
04/22/16
a, a) = {(q1,
b, a) = {(q2,
b, a) = {(q2,
, Z0) = {(q0,
to nine productions:
1.
2.
3.
4.
5.
6.
7.
8.
9.
41
M
= ({q , q , q }, {a,
anbn
1.
2.
3.
4.
5.
04/22/16
a, a) = {(q1,
b, a) = {(q2,
b, a) = {(q2,
, Z0) = {(q0,
1.
2.
3.
4.
5.
6.
7.
8.
9.
42
anbn
1.
2.
3.
4.
5.
04/22/16
a, a) = {(q1,
one production:
1.
1.
b, a) = {(q2,
1.
b, a) = {(q2,
, Z0) = {(q0,
1.
[q1, a, q2] b
43
Parsing
04/22/16
44
Parsing (contd.)
04/22/16
45
3.
4.
5.
2.
1.
S
[S]
[SS]
04/22/16
46
Parsing (contd.)
04/22/16
47
04/22/16
48
Parsing (contd.)
04/22/16
49
Parsing (contd.)
State
Input
Stack top
Move(s)
q0
Z0
(q1, SZ0)
q1
(q1, S1$)
q1
S1
2 choices
q1
(q1, )
q1
(q1, )
q1
(q1, )
q1
Z0
(q2, )
04/22/16
50
Parsing (contd.)
Input
Stack top
Move
q1
S1
(q1,[, [S1]S1)
q1,[
(q1, )
q1
S1
(q1,], )
q1,]
(q1, )
q1
S1
(q1,$, )
q1,$
(q1, )
04/22/16
51
Parsing (contd.)
04/22/16
52
Summary
Pushdown Automata
1.
2.
3.
4.
5.
04/22/16
53
Reading suggestions
04/22/16
54
Coming up next
04/22/16
55
04/22/16
56