简体   繁体   English

非上下文无关语言L在迭代下是否可以无上下文?

[英]Would it be possible for a non-context-free language L to be context-free under iteration?

Language L is not a context-free language. 语言L不是无上下文的语言。

But could L* be a context-free language? 但L *可以是一种无语境的语言吗?

Yes, this is possible. 是的,这是可能的。 As an example, consider the alphabet Σ = {1} and let L be the language { 1 p | 例如,考虑字母表Σ= {1}并且让L为语言{1 p | p is a prime number }. p是素数}。 You can prove that this language is not context-free by using the pumping lemma. 通过使用泵浦引理,您可以证明该语言不是无上下文的。

However, the language L* is the set of all strings except for 1. The reason for this is that 但是,语言L *是除1之外的所有字符串的集合。原因是这样

  • ε ∈ L*, because ε ∈ N* for any language N. ε∈L*,因为任何语言N的ε∈N*。
  • 1 2 ∈ L* because 2 is prime. 1 2∈L * 2,因为是素数。
  • 1 3 ∈ L* because 3 is prime. 1 3∈L *,因为3是素数。
  • 1 n ∈ L* for any n ≥ 2, because you can start with either 1 2 or 1 3 and concatenate an appropriate number of copies of 1 2 to it. 1层的n∈L *为任意的n≥2,因为你可以开始与任一1 2或1 3并连接到它的1 2个拷贝的适当数量。

This language is indeed context-free, and you can prove that by writing a grammar for it. 这种语言确实没有上下文,你可以通过为它编写语法来证明。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM