MathOverflow is a question and answer site for professional mathematicians. 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

Let $L \subseteq A^\star$ be a formal language over $A$ generated by a context-free grammar, and $L' = A^\star - L$ be the relative complement in $A^\star$.

If $L$ and $L'$ are both context-free, are they necessarily deterministic context-free?

share|cite|improve this question
This is essentially an exact duplicate of… which has an answer. – Benjamin Steinberg Feb 21 '12 at 22:27
Perhaps you missed my last edit - I removed that part of the question. To clarify, my original question contained the above, as well as a "dual" question concerning the closure of the set of context-free languages w.r.t. finitary Boolean operations. In this question, I'm not looking for the closure of the class of context-free languages with respect to complements, but merely to know if the proper sub-class of CF languages which have CF complements is in fact the class DCF of deterministic CF languages. – Nick Loughlin Feb 21 '12 at 22:50
Ok no longer a duplicate. – Benjamin Steinberg Feb 21 '12 at 22:53
In other words, you are asking if $CFL \cap coCFL \subseteq DCFL$ or not. Interesting question. Couldn't find the answer in Hopcroft and Ullman. – Kaveh Feb 22 '12 at 1:55
@Nick, I rewrote the question to match your comment above as djlewis2 makes a good point. Please re-edit if this was not your intent. – Benjamin Steinberg Feb 22 '12 at 21:57
up vote 5 down vote accepted

It seems that the answer to your question is no. See here.

share|cite|improve this answer

Your question is a bit unclear, and when we clarify it, it becomes true.

If by "deterministic context-free grammar" you mean, as usual, an LR(k) grammar for some k, then Knuth proved in his seminal paper ("On the translation of languages from left to right", 1965) that the languages defined are the same as those defined by deterministic PDAs. These are the DFCLs, and the DFCLs are closed under complement. So both your L and L' are DFCLs and hence CFLs, and your last premise is redundant.

Your question really comes down to: are the DFCL's closed under complement -- and they are.

share|cite|improve this answer
You are right, but it seems from the discussion that the OP didn’t actually intend to demand $L$ to be DCFL a priori, it may be a typo. – Emil Jeřábek Feb 22 '12 at 16:55
Ah, perhaps. But if so, that's quite a bit more than a typo. He'd simply say "If L is a CFL and L' its complement is also a CFL..." Also, if the question is as you say, then it ~is~ a duplicate of the referenced question, and the answer is "no". Perhaps Nick needs to chime in here. – David Lewis Feb 22 '12 at 17:53
Oh, he accepted that answer -- I guess you are right. – David Lewis Feb 22 '12 at 17:54

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.