Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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|improve this question
add comment

2 Answers

up vote 4 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|improve this answer
Obvious, now that you say it. Thanks. –  Dave Clarke Oct 6 '11 at 20:00
add comment

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|improve this answer
add comment

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.