[英]understanding basics of CFG
Have just started the chapter about CFL in Sipser's book and already fail to understand the basics. 刚刚开始撰写Sipser的书中有关CFL的章节,已经不了解其基础知识。
Let this be the grammar of some language: 让这成为某种语言的语法:
S -> A0A
A -> 00A | 11A | 10A | 01A | e
I am really confused about this A0A part. 我对这个A0A部分感到非常困惑。 Does it mean that the left hand side from 0 should be always the same as the right hands side.
这是否意味着从0开始的左侧应始终与右侧相同。 Does this mean 00011 or 000 are not in this language then?
这是否意味着00011或000不是这种语言的?
Any S
is any option you have for any A
, followed by a single literal 0
and then another option for A
. 任何
S
是您对任何A
都有的任何选项,其后是单个文字0
,然后是A
另一个选项。 Each A
is independent. 每个
A
是独立的。
The string 00011
is in the language because you can pick your two A
s (for example) such that the first one is 00A
and the second one is 11A
. 字符串
00011
是该语言的语言,因为您可以选择两个A
,例如,第一个为00A
,第二个为11A
。 If you pick recursively the empty string ( e
) for both of the "remaining" A
s, when you concatenate everything you'll end up with the string 00011
. 如果递归地为两个“剩余”
A
s选择空字符串( e
),则在将所有内容连接在一起时,最终将得到字符串00011
。
You can do a similar thing to obtain the string 000
. 您可以执行类似的操作来获取字符串
000
。
A transforms to either empty, or two binary digits then A. It means that A transforms to any sequence of even number of binary digits. A转换为空,或者转换为两个二进制数字,然后转换为A。这意味着A转换为任何偶数个二进制数字序列。
S transforms to A, then 0, then A. This means that S is transforms to even number of binary digits, then 0, then even number of binary digits. S转换为A,然后转换为0,然后转换为A。这意味着S转换为二进制数的偶数,然后转换为0,然后转换为偶数。 That is, S is any sequence of odd number of binary digits with 0 in the middle.
也就是说,S是中间为0的任何奇数个二进制数字序列。
Does it mean that the left hand side from 0 should be always the same as the right hands side.
这是否意味着从0开始的左侧应始终与右侧相同。
No, why? 没有为什么? Two different A's can transform to different sequences.
两个不同的A可以转换为不同的序列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.