Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Finite Automata
(part b)
Windmills in Holland
1
Outline
(part a --- in another PPT)
2.0 Introduction
2.1 An Informal Picture of Finite Automata
2.2 Deterministic Finite automata
2.3 Nondeterministic Finite Automata
(part b --- in this PPT)
2.4 An Application: Text Search
2.5 Finite Automata with Epsilon-Transitions
2
Keyword
K
Inverted indexing
Page p2
Page pn
a, b
a
1
Start
$20
4
a, b
$20
3
4
a
1
Start
12
$20
13
a
13
4
$20
1234
$20
$20
123
5
a, b
a
1
Start
$2
4
0
a
1
a, b
$2
3
0
a, b
a, b
Start
12
13
4
$20
a, b
$20
13
= set of all
printable ASCII
characters
$20
4
1
Start
Figure 2.16 (Note: there are two final states; red parts are
necessary and missing in the textbook; correct your textbook!!!)
$20
8
Fig. 2.10
q0
q0
q1
Stuck!
q1
q0
q0
q0
q1
q2 Stuck!
q2
Accept!
q0
p
every other NFA states reachable from q0 by following every subpath
which is a suffix ( ) of x, like ajaj+1am.
$2
4
0
1
e
Start
e
w
12
$2
8
0
b
146
135
3
Start
15
18
17
16
b
11
How to derive transitions --e.g., (1) for x=b, state 34, state 56,
so state 135146
(2) for x=e, state 3, state 5, but state 15,
so state 13515
12
135
3
146
e
1
Start
15
16
17
18
13
0, 1, , 9
start
q0
, + , -
q1
q2
q3
q5
0, 1, , 9
Figure 2.18
0, 1, , 9
q4
16
$2
4
9
Start
17
q0
q1
q2
q3
q4
q5
0, 1, , 9
{q1}
{q5}
{q1}
{q2}
{q3}
{q1, q4}
{q3}
{q3}
21
22
23
Example 2.19
ECLOSE(1) = {1, 2, 3, 4, 6}
ECLOSE({3, 5}) = ECLOSE(3)ECLOSE(5) = {3,
6}{5, 7} = {3, 5, 6, 7}
24
:
Basis: (q, ) = ECLOSE(q).
Induction: if w = xa, then (q, w) is computed as:
If (q, x) = {p1, p2, , pk} and
k
i1
U(pi, a)) .
then (q, w) = ECLOSE({r1, r2, , rm})=ECLOSE( i
1
25
(q, x)=
{ p1
p2
.
.
.
pk}
a
a
a
{ r1
r2
.
.
.
rm}
ECLOSE
{ r1,
r2, ,
rm}
26
q0
Figure 2.18
, + , -
q1
0, 1, , 9
q2
0, 1, , 9
q3
q5
q4
27
29
U (pi, a))
= ECLOSE( i
1
0, 1, , 9
start
q0
, + , -
q1
q2
0, 1, , 9
q4
Start state qD = ECLOSE(q0) = {q0, q1}
D({q0, q1}, +) = ECLOSE(E(q0, +)E(q1, +))
= ECLOSE({q1}) = ECLOSE({q1}) = {q1}, ...
0, 1, , 9
q3
q5
.
Figure 2.18
31
{q0,
q1}
+,-
{q1, q4}
{q1
}
{q2}
Figure 2.22
32
0, 1, , 9
start
q0
, + , -
q1
q2
0, 1, , 9
q3
q5
0, 1, , 9
q4
Figure 2.18
33
{q0,
q1}
+,-
{q1
}
{q1, q4}
0, 1, , 9
.
{q2}
34
0, 1, , 9
start
q0
, + , -
q1
q2
0, 1, , 9
q3
q5
0, 1, , 9
q4
Figure 2.18
35
0, 1, , 9
start
{q0,
q1}
+,-
{q1
}
{q1, q4}
0, 1, , 9
.
{q2}
36
0, 1, , 9
start
q0
, + , -
q1
q2
0, 1, , 9
q3
q5
0, 1, , 9
q4
Figure 2.18
0, 1, , 9
start
{q0,
q1}
+,-
{q1
}
{q1, q4}
0, 1, , 9
0, 1, 9
.
{q2}
0, 1, 9
{q3, q5}
38
0, 1, , 9
0, 1, , 9
start
q0
, + , -
q1
q2
0, 1, , 9
q3
q5
0, 1, , 9
q4
Figure 2.18
39
0, 1, , 9
start
{q0,
q1}
+,-
{q1
}
{q1, q4}
0, 1, , 9
0, 1, 9
.
{q2}
0, 1, 9
{q3, q5}
0, 1, , 9
40
0, 1, , 9
0, 1, , 9
start
{q0,
q1}
+,-
{q1
}
{q1, q4}
0, 1, , 9 +, -
+, -
+, -, .
0, 1, 9
+, -, .
+, -, .
{q2}
all symbols
0, 1, , 9
{q3, q5}
42
2.6 A Review
3 Types of Automata
DFA
NFA ( -NFA )
-NFA
-NFA
equivalent
DFA
-NFA
43