Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Non Determinism
http://cis.k.hosei.ac.jp/~yukita/
q1
q2
q3
0, 1
q1
q2
q3
q1
q3
q2
q2
q2
q2
Task 01
DFA
1. Implement M1 with your favorite
programming language.
2. GUI
Language of M1
The language of machine M , written as L( M ),
is the set of all strings that machine M accepts.
We can say that M recognizes A.
L( M 1 ) {w | w contains at least one 1 and
an even number of 0s follow the last 1}
0, <RESET>
q0
ET
S
RE
<
2,
1
q1
>
2
2
q2
1, <RESET>
3. is described as
q0
q1
R
q0
q0
0
q0
q1
1
q1
q2
2
q2
q0
q2
q0
q2
q0
q1
Informal Description of M5
M5 keeps a running count of the sum of
the numerical symbols it reads, modulo 3.
Every time it receives the <RESET>
symbol it resets the count to 0.
M5 accepts if the sum is 0, modulo 3.
10
11
0, 1
q0
q00
q001
13
Example 1.11
Let the alphabet be {a, b, , z}.
Let A {good, bad} and B {boy, girl}. Then, we have
A B {good, bad, boy, girl},
A B {goodboy, goodgirl, badboy, badgirl}, and
A* { , good, bad, goodgood, goodbad, badbad,
goodgoodgood, good goodbad, goodbadgood,
goodbadbad, }.
15
16
Proof of Th 1.12
17
Construction of M
1. Q Q1 Q2 {( r1 , r2 ) | r1 Q1 and r2 Q2 }.
2. We can assume that M 1 and M 2 have the same
alphabet . (Why?)
3. (r1 , r2 ) Q, a ; ((r1 , r2 ), a ) (1 (r1 , a ), 2 (r2 , a ))
4. q0 (q1 , q2 ).
5. F ( F1 Q2 ) (Q1 F2 ) {( r1 , r2 ) | r1 F1 or r2 F2 }.
Proof of Th 1.12
18
Correctness
You should check the following.
1. For any string recognized by M1 is
recognized by M.
2. For any string recognized by M2 is
recognized by M.
3. For any string recognized by M is
recognized by M1 or M2.
Proof of Th 1.12
19
20
Nondeterminism
To prove Theorem 1.13, we need
nondeterminism.
Nondeterminism is a generalization of
determinism. So, every deterministic
automaton is automatically a
nondeterministic automaton.
21
NFA N1
0,1
0,1
q1
q2
0,
q3
q4
23
...
...
accept
24
Example 1.14
NFA N2
0,1
q1
q2
0,
q3
0,1
q4
Let language A consist of all strings over {0,1} containing a 1 in the third
position from the end. N2 recognizes A.
25
A DFA equivalent to N2
0
q000
1
q100
q010
q110
1
0
0
1
q001
q101
1
q011
q111
26
Example 1.15
NFA N3
0
0
0
0
27
A DFA equivalent to N3
0, 1
q-1
1
q0
1
0
1
0
q3
q4
q5
28
q2
a,b
q3
30
1. Q {q1 , q2 , q3 , q4 },
q1
2. {0,1}
q3
q4
q2
0,
q3
q4
{q1} {q1 , q2 }
{q3 }
{q3 }
{q4 }
{q4 } {q4 }
q1
3. is given as q2
0,1
32
Theorem 1.19
Every nondeterministic finite automaton
has an equivalent deterministic finite
automaton.
Def. The two machines are equivalent is they
recognize the same language.
33
3. q0 {q0 }, and
4. F {R Q | R F }.
Proof of Th 1.19
34
Incorporate arrows
E ( R ) {q | q can be reached from R by traveling along zero or
more arrows.}
We modify as follows.
35
Corollary 1.20
A language is regular if and only if some
nondeterministic finite automaton
recognizes it.
36
a,b
Task 02
Parallel World
1. Write a program that simulates N4.
2. GUI
Three buttons for input 0, 1, and epsion.
State chart that reflect the branching of the
world.
38
39
{1}
{2}
{1,2}
a,b
{3}
{1,3}
{2,3}
a
a
b
{1,2,3}
40
N2
41
1 (q, a ) for q Q1
(q, a ) for q Q
2
2
{q1 , q2 }
for q q0 and a
for q q0 and a .
42
N1
43
1 ( q, a )
( q, a )
1
for q Q1 and q F1
for q F1 and a
44
45
1. Q {q0 } Q1
2. The start state q0 is the new start state.
3. F {q0 } F1
1 ( q, a )
( q, a )
1
4. (q, a ) 1 (q, a ) {q1}
{q }
1
for
for
for
for
q Q1
q F1
q F1
q q0
and q F1
and a
and a
and a
for q q0 and a .
46