1.将DFA最小化:教材P65 第9题
1 |
{1,2,3,4,5} |
{6,7} |
{1,2}b->{2} {3,4}b->{6,7} {5}b |
{6,7}b->{6} | |
2 | {1,2}{3,4}{5} | {6,7} |
令{1,2}为A,{3,4}为B,{5}为C,{6,7}为D
正规式:b*a((da)*|c*)bb*
2.构造以下文法相应的最小的DFA
S→ 0A|1B
A→ 1S|1
B→0S|0
(1)正规文法转为正规式
S=0A+1B
=0(1S+1)+1(0S+0)
=01S+01+10S+10
=S(01+10)|(01+10)
=S(01|10)|(01|10)
=(01|10)*(01|10)
(2)正规式转为自动机NFA
(3)非确定的自动机NFA确定化为DFA
0 | 1 | ||
a | A | C | D |
b | C | BE | |
c | D | BE | |
d | BE | CF | DG |
e | CF | BEHJ | |
f | DG | BEHJ | |
g | BEHJ | CF | DG |
(4)最小化DFA
{a,b,c,d,e,f} | {g} | |
{a}1->{c} {b}1->{d} {c,f}1 {d}1->{f} {e}1->{g} |
{g}1->{f} |
|
{a}{b}{c,f}{d}{e} |
{g} |
3.自上而下语法分析,回溯产生的原因是什么?
文法的产生式出现了问题
4.P100 练习4,反复提取公共左因子。
S->C$
C->bA|aB
A->aX|bAA
B->bX|aBB
X->C|ε