2
$\begingroup$

i am asking myself the following question:

Assuming: A and B are context-free languages, then A - B (difference) must also be context-free language, right? but I do not know how to prove it.

$\endgroup$

2 Answers 2

7
$\begingroup$

The complement of a context-free language $L$ is not necessarily context-free, but it is the difference between two context-free languages ($\Sigma^* - L$). (Here $\Sigma$ is the alphabet of $L$.)

See, for example, Is the complement of { ww | ... } context-free? for an example of a context-free language whose complement is not context-free.

$\endgroup$
2
$\begingroup$

It might be context sensitive as well...

example:-

let

L1= ${\{a^n b^n c^m | n>0, m>0\}}$

and

L2=${\{a^m b^n c^n | m>0, n>0\}}$

Here L1 and L2 are context free but L1-L2 will be

L1-L2 = ${\{a^n b^n c^m | n>0, m>0 \space \& \space n \neq m\}}$

which is NOT context free.

$\endgroup$

Your Answer

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

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