Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the language {0^n 1^n 0^k | k != n} context free?

I believe this language isn't context free, because there is no chance that a PDA could compare 2 blocks of 0's and 1's of the same length and also remember it's length for later use.

Unfortunately, I have no idea how to prove it.

I tried using the pumping lemma to no avail...

I've also tried to assume by contradiction that the language is context free and use the fact that the intersection of a context free language with a regular language is also context free (by finding some mysterious regular language L), and surprisingly (or not) - all my efforts were in vain...

Any help would be appreciated

like image 545
Robert777 Avatar asked Oct 06 '22 13:10

Robert777


1 Answers

Is the language { 0n1n0k | k != n} context free?

No, the language L = { 0n1n0k | k!=n } is not a context free language. Also, Class of Regular Languages is subset of class Context free languages.

You Idea using PDA is correct and obvious way to show that language is not context free. And we can't draw PDA for language 0n1n0k because after matching prefix 0n to 1n stack become empty, then we don't have stored information to check weather suffix 0K are equal to n or not.

HINT: For formal proofs

  • First

L = {0n1n0k | k!=n } now complement of L is L'.

L' = {{0n1n0n} that is well known context sensitive language (can be proof).

And the complement of a context-sensitive language is itself context-sensitive.

  • Second

For Pumping Lemma:

L = {0n1n0k | k!=n } is Union of L1 and L2, Where
L1 = {0n1n0k | k > n } and L2 = {0n1n0k | k < n },

L = L1 U L2

L1 and L2 both are non-context-free Language. and union of two non-context free languages are non-context-free.( that can easily proof by grammar)


Also, The union, concatenation of two context-sensitive languages is context-sensitive.

like image 157
Grijesh Chauhan Avatar answered Oct 10 '22 04:10

Grijesh Chauhan