无需过多理论和证明(您可以在 Wikipedia 中查看此内容),将上下文无关语法转换为乔姆斯基范式时必须做一些事情,通常必须执行四个范式转换。首先,您需要确定所有可以直接或间接产生空字符串(lambda/epsilon)的变量(无 Lambda 形式)。其次,您需要删除单元制作 - (Unit-Free form)。第三,您需要找到所有有效/有用的变量(有用性)。四、你需要找到所有的可达符号(Reachable)。在每一步,你可能有也可能没有新的语法。所以对于你的问题,这就是我想出的......
上下文无关语法
G(Variables = { A B S }
Start = S
Alphabet = { a b lamda}
Production Rules = {
S -> | AB | aB |
A -> | aab | lamda |
B -> | bbA | } )
删除 lambda/epsilon
ERRASABLE(G) = { A }
G(Variables = { A S B }
Start = S
Alphabet = { a b }
Production Rules = {
S -> | AB | aB | B |
B -> | bbA | bb | } )
删除单位产品
UNIT(A) { A }
UNIT(B) { B }
UNIT(S) { B S }
G (Variables = { A B S }
Start = S
Alphabet = { a b }
Production Rules = {
S -> | AB | aB | bb | bbA |
A -> | aab |
B -> | bbA | bb | })
确定实时符号
LIVE(G) = { b A B S a }
G(Variables = { A B S }
Start = S
Alphabet = { a b }
Production Rules = {
S -> | AB | aB | bb | bbA |
A -> | aab |
B -> | bbA | bb | })
删除无法访问
REACHABLE (G) = { b A B S a }
G(Variables = { A B S }
Start = S
Alphabet = { a b }
Production Rules = {
S -> | AB | aB | bb | bbA |
A -> | aab |
B -> | bbA | bb | })
用实心非终结符替换所有混合字符串
G( Variables = { A S B R I }
Start = S
Alphabet = { a b }
Production Rules = {
S -> | AB | RB | II | IIA |
A -> | RRI |
B -> | IIA | II |
R -> | a |
I -> | b | })
乔姆斯基范式
G( Variables = { V A B S R L I Z }
Start = S
Alphabet = { a b }
Production Rules = {
S -> | AB | RB | II | IV |
A -> | RL |
B -> | IZ | II |
R -> | a |
I -> | b |
L -> | RI |
Z -> | IA |
V -> | IA | })