1.设有 NFA M=( {0,1,2,3}, {a,b},f,0,{3} ),其中 f(0,a)={0,1} f(0,b)={0} f(1,b)={2} f(2,b)={3}
画出状态转换矩阵,状态转换图,并说明该NFA识别的是什么样的语言。
2.NFA 确定化为 DFA
1.解决多值映射:子集法
1). 上述练习1的NFA
2). P64页练习3
2.解决空弧:对初态和所有新状态求ε-闭包
1). 发给大家的图2
2).P50图3.6
子集法:
f(q,a)={q1,q2,…,qn},状态集的子集
将{q1,q2,…,qn}看做一个状态A,去记录NFA读入输入符号之后可能达到的所有状态的集合。
步骤:
1).根据NFA构造DFA状态转换矩阵
①确定DFA的字母表,初态(NFA的所有初态集)
②从初态出发,经字母表到达的状态集看成一个新状态
③将新状态添加到DFA状态集
④重复23步骤,直到没有新的DFA状态
2).画出DFA
3).看NFA和DFA识别的符号串是否一致。
----------------------------------------------------------------------------------------------------------------------------
解:
1.
a | b | |
0 | {0,1} | {0} |
1 | - | {2} |
2 | - | {3} |
3 | - |
- |
∴该识别语言为:(a | b)*abb
2.
1.1)
a | b | ||
A | {0} | {0,1} | {0} |
B | {0,1} | {0,1} | {0,2} |
C | {0,2} | {0,1} | {0,3} |
D | {0,3} | {0,1} | {0} |
其DFA图如下:
1.2)、
|
|
0 |
1 |
A |
{S} |
{V,Q} |
{Q,U} |
B |
{V,Q} |
{Z,V} |
{Q,U} |
C |
{Q,U} |
{V} |
{Q,U,Z} |
D |
{V} |
{Z} |
|
E |
{Z,V} |
{Z} |
{Z} |
F |
{Q,U,Z} |
{Z} |
{Q,Z} |
G |
{Z} |
{Z} |
{Z} |
H |
{Q,Z} |
{Z} |
{Q,Z} |
DFA图:
2.1)、
|
|
0 |
1 |
2 |
0 |
ε{A} = {ABC} |
ε{A} = {ABC} |
ε{B} = {BC} |
ε{C} = {C} |
1 |
{BC} |
|
ε{B} = {BC} |
ε{C} = {C} |
2 |
{C} |
|
|
ε{C} = {C} |
2.2)、
a | b | ||
Q | {0,1,2,4,7} | {1,2,3,4,6,7,8} | {1,2,4,5,6,7} |
W | {1,2,3,4,6,7,8} | {1,2,3,4,6,7,8} | {1,2,4,5,6,7,9} |
X | {1,2,4,5,6,7} | {1,2,3,4,6,7,8} | {1,2,4,5,6,7} |
Y | {1,2,4,5,6,7,9} | {1,2,3,4,6,7,8} | {1,2,4,5,6,7,10} |
Z | {1,2,4,5,6,7,10} | {1,2,3,4,6,7,8} | {1,2,4,5,6,7} |