Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|cite|improve this question
up vote 8 down vote accepted

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.

share|cite|improve this answer
Obvious, now that you say it. Thanks. – Dave Clarke Oct 6 '11 at 20:00

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.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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