简体   繁体   中英

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.

But could L* be a context-free language?

Yes, this is possible. As an example, consider the alphabet Σ = {1} and let L be the language { 1 p | p is a prime number }. 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*, because ε ∈ N* for any language N.
  • 1 2 ∈ L* because 2 is prime.
  • 1 3 ∈ L* because 3 is prime.
  • 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.

This language is indeed context-free, and you can prove that by writing a grammar for it.

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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