6
$\begingroup$

Is the following problem decidable in general:

Given a regular language $R$ and context-free $C$, is every string in $R$ also in $C$? That is, is $L(R)\subseteq L(C)$? What about $L(C)\subseteq L(R)$?

I know that this is decidable if $R$ and $C$ are both regular and undecidable if they are both context free.

$\endgroup$
10
$\begingroup$

It is a well-known undecidable problem whether a context-free grammar generates all possible strings over the alphabet. Therefore your problem must also be undecidable, because it is easy to write down a regular grammar for all strings.

$\endgroup$
12
$\begingroup$

This is a correct answer for $R \subseteq C$ for regular $R$ and context-free $C$. The question also mentions the reverse inclusion $C \subseteq R$.

Somewhat surprisingly, that is decidable. We have $C \subseteq R$ iff $C \cap R^c = \emptyset$. Here $R^c$ is the complement of $R$ is regular, and thus the intersection $C \cap R^c$ is context-free. Emptiness of context-free languages is decidable.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.