问题
How can I prove the following language is not context-free? Any help will be appreciated. Thank you. L = {0^n| n is a prime}
回答1:
The proof is by contradiction. Assume the language is context-free. Then, by the pumping lemma for context-free languages, any string in L can be written as uvxyz where |vxy| < p, |vy| > 0 and for all natural numbers k, u(v^k)x(y^k)z is in the language as well. Choose 0^m where m is any prime > p. Then we must be able to write 0^m as uvxyz so that |vy| > 0. Let |vy| = r. Then 0^(m-r+kr) must be prime for any natural number k. However, choosing k=m+1 gives m-r+(m+1)r = m - r + mr + r = m(1 + r) which cannot be prime, a contradiction. Therefore, our assumption that the language is context-free is disproven.
来源:https://stackoverflow.com/questions/52954769/prove-that-the-languages-are-not-context-free