标签:eps nbsp ilo a* strong 正规文法 rar bsp aaa
1.分别写出描述以下语言的正规文法和正规式:
L1={abna|n≥0}。
L2={ambn|n≥1,m ≥1}
L2={(ab)n|n≥1}
答:
(1)
正规文法:S → aA
A → Ba
B → bB | ε
正规式:ab*a
(2)
正规文法:S → AB
A → a | aA
B → b | Bb
正规式:aa*bb*
(3)
正规文法:S → abA
A → ε | abA
正规式:(ab)(ab)*
2.将以下正规文法转换到正规式
Z→0A
A→0A|0B
B→1A|ε
(1)Z = 0A
A = 0A+0B
B = 1A+ε
A = 0A+0(1A+ε)=0A+01A+0=(0+01)A+0=(0 | 01)A | 0 = (0 | 01)*0
S = 0(0 | 01)*0
Z→U0|V1
U→Z1|1
V→Z0|0
(2)Z = U0+V1
U = Z1+1
V = Z0+0
Z = (Z1+1)0+(Z0+0)1 = Z10+10+Z01+01 = (10+01)Z+(10+01) = (10+01)* (10 | 01)
S→aA
A→bA|aB|b
B→aA
(3)S = aA
A = bA+aB+b
B = aA
A = bA+aaA+b = (b+aa)A+b = (b | aa)*b
S = a(b | aa)*b
I→i|Ii|Id
(4) I = i + Ii +Id = i + I (i+d) = i (i+d)*
标签:eps nbsp ilo a* strong 正规文法 rar bsp aaa
原文地址:https://www.cnblogs.com/chenjd/p/11676330.html