[英]Chomsky languages: how to recognize them?
I have a problem with the recognition of languages. 我对语言的识别有疑问。 Given a certain language, for example a n cb 2n , n > 0 , how do I determine quickly what type belongs according Chomsky?
给定某种语言,例如n cb 2n ,n> 0 ,如何根据乔姆斯基快速确定属于哪种类型?
My idea was to determine the grammar that generates it and then up to the language but it is a long process. 我的想法是确定生成语法的语法,然后确定语言的语法,但这是一个漫长的过程。 I think there's another way to recognize it by eye, without writing grammars or automata.
我认为,还有另一种无需编写语法或自动机就能通过肉眼识别它的方法。 can someone help me?
有人能帮我吗?
Unfortunately, associating an arbitrary language with a level of the Chomsky hierarchy is, in the general case, undecidable. 不幸的是,在一般情况下,将任意语言与Chomsky层次结构级别相关联是不确定的。 (See Rice's Theorem .)
(请参阅赖斯定理 。)
Of course, it is easy to categorize a given grammar, since the Chomsky hierarchy is defined by a simple syntactic analysis of the grammar itself. 当然,对给定的语法进行分类很容易,因为乔姆斯基层次结构是通过对语法本身的简单句法分析来定义的。 However, languages do not have unique grammars;
但是,语言没有唯一的语法。 the existence of (for example) a Type 2 (context-free) grammar for a language does not mean that there is not a Type 3 (regular) grammar for the same language.
语言的类型2(无上下文)语法的存在(例如)并不意味着同一语言没有类型3(常规)语法。
So there are no shortcuts. 因此没有捷径。
However, there is a lot to be said for experience. 但是,经验可以说很多。 The language
{ a n cb 2n | n > 0 }
语言
{ a n cb 2n | n > 0 }
{ a n cb 2n | n > 0 }
is context-free (and not regular), as are all languages of similar forms. { a n cb 2n | n > 0 }
是上下文无关的(并且不是常规的),所有相似形式的语言也是如此。 That it is context free is demonstrated by the grammar 语法证明了上下文无关
L → c
L → a L b b
and the fact that it is not regular can be proven using the pumping lemma for regular languages . 使用不规则语言的抽水引理可以证明它不规则 。 (The linked Wikipedia article contains, as an example of the use of the lemma, a proof for a similar language which should be easy to adapt.)
(链接的Wikipedia文章以引理的使用为例,提供了一种类似语言的证明,应该易于适应。)
On the other hand, a language which requires three equal counts ( { a n c n b n | n > 0 }
) is not context-free (but is context-sensitive). 另一方面,要求三个相等计数(
{ a n c n b n | n > 0 }
)的语言不是上下文无关的(而是上下文相关的)。 (That's not the same as { a n c n+m b m | n > 0 }
, which is context-free.) (这与
{ a n c n+m b m | n > 0 }
,后者是上下文无关的。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.