4
$\begingroup$

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?

$\endgroup$
6
  • 2
    $\begingroup$ This is essentially an exact duplicate of mathoverflow.net/questions/51657/… which has an answer. $\endgroup$ Feb 21, 2012 at 22:27
  • 1
    $\begingroup$ 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. $\endgroup$ Feb 21, 2012 at 22:50
  • 1
    $\begingroup$ Ok no longer a duplicate. $\endgroup$ Feb 21, 2012 at 22:53
  • 1
    $\begingroup$ 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. $\endgroup$
    – Kaveh
    Feb 22, 2012 at 1:55
  • 1
    $\begingroup$ @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. $\endgroup$ Feb 22, 2012 at 21:57

2 Answers 2

6
$\begingroup$

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

$\endgroup$
3
$\begingroup$

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.

$\endgroup$
3
  • 2
    $\begingroup$ 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. $\endgroup$ Feb 22, 2012 at 16:55
  • $\begingroup$ 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. $\endgroup$ Feb 22, 2012 at 17:53
  • $\begingroup$ Oh, he accepted that answer -- I guess you are right. $\endgroup$ Feb 22, 2012 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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