HiveBrain v1.2.0
Get Started
← Back to all entries
patternModerate

If $L$ is CFL and $\overline{L}$ is CFL, then is L regular?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
cfloverlineregularthenand

Problem

I've seen in previous exams that professors marked the theory as correct:


If $L$ is CFL and $\overline{L}$ is CFL, then L is regular.

I just don't see how this would work. How would we prove such a thing? I also can't come up with contradicting languages.

Solution

As Shaull noted in the comments, $\{a^n b^n\}$ works. The language is trivially context-free but not regular, so I'll show the complement is context-free. A word which is not of the form $a^n b^n$ is either $a^n b^m$ where $n\neq m$, or not of the form $a^n b^m$ at all. So

$(a+b)^{\ast}-{a^n b^n}=\{a^i b^j: i \neq j\} \cup ((a+b)^{\ast}-a^{\ast} b^{\ast})$

which is a sum of context-free language $\{a^i b^j: i \neq j\}$ and the complement of $a^{\ast} b^{\ast}$ which is a regular language.

Another way to see it is that $\{a^n b^n\}$ is a deterministic context-free language, which is a class closed under complement. In other words any nonregular DCFL is a counterexample to the question.

I'll leave the following question to the reader:


Suppose $L$ and $\overline L$ are CFLs, is $L$ a DCFL?

Context

StackExchange Computer Science Q#19834, answer score: 10

Revisions (0)

No revisions yet.