0

Suppose that G is a context-free grammar. How can I show that “Is L(G) regular?” is undecidable. Also, prove that L is always context-free but is regular if and only if L(G) = Σ∗.

This is what I have so far

Let N be some language that is known to be context-free but not regular (for example, {a^nb^n | n ≥ 0}). Consider the language L = N#Σ∗ ∪ Σ∗#L(G), where # is some symbol that is not in L(G) or N.

Where to? I just know my prof is going to put this on my exam :s.

1 Answers1

2

This proof-snippet is what you are probably looking for.

We follow your definition. $N$ is a fixed non-regular context-free language over $\Sigma$, $\#$ is a new symbol. For a given grammar $G$ let $L = N\#\Sigma^* \cup \Sigma^* \# L(G)$. Assume $L(G) = \Sigma^*$, then $L = \Sigma^*\#\Sigma^*$ which is a regular language. On the other hand, if $w\notin L(G)$, then $L\cap \Sigma^*\#w = N\#w $, which is not regular (as regular languages are closed under quotient, and $N$ is not regular). Thus also $L$ itself is not regular (as regular languages are closed under intersection).

Conclusion: $L$ is context-free, and $L$ is regular iff $L(G) = \Sigma^*$.

Hendrik Jan
  • 31,459
  • 1
  • 54
  • 109