1

How can we prove that:

$$ L = \{ w_1\#w_2 \mid w_1 \in w_2;\; |w_2| > |w_1|;\; w_1 , w_2 \in \{0, 1\}^*\} $$

is not context-free?

The language defines $w_1$ as a sub-string of $w_2$, and they are separated by a $\#$. This is easy with the CFG pumping-lemma for a slightly different language with $|w_2| \ge |w_1|$ by using the special case of $|w_2| = |w_1|$ (i.e. $w_1 = w_2$).

But here, $w_1$ is a proper sub-string of $w_2$ so I can't do the same. I fail to push the string out since we can always pump, for example the first symbol of $w_2$.

Raphael
  • 72,336
  • 29
  • 179
  • 389
perreal
  • 121
  • 5

1 Answers1

1

For large enough $p$, consider the word $w = 0^{p+1}1^{p+1}\#0^{p+1}1^{p+2} \in L$. Mark the part $1^{p+1}\#0^{p+1}$. According to Ogden's lemma, we can write $w = uxyzv$ such that $xyz$ contains at least $1$ and at most $p$ marked symbols, and $ux^iyz^iv \in L$ for all $i \geq 0$. The pumped part $xyz$ cannot lie all to the right of $\#$ since then pumping it down would result in a word not in the language (here we crucially use the fact that only the $0^{p+1}$ part to the right of $\#$ is marked). It also cannot lie all to the left of $\#$ since then pumping it up would result in a word not in the language. It follows that the part of $xyz$ to the right of $\#$ is of the form $0^k$, and the part of $xyz$ to the left of $\#$ is of the form $1^\ell$ (otherwise, there would be more than $p$ marked symbols). However, pumping up, the resulting word is not in the language. This contradiction shows that $L$ is not context-free.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
  • Can we not use the same logic to prove $0^n1^n$ is not CFG by marking 0's? Sorry if this sounds dumb. – perreal Apr 25 '14 at 16:19
  • Hopefully not. Try it out to see what goes wrong. Check out the statement of Ogden's lemma first. – Yuval Filmus Apr 25 '14 at 17:34
  • I think what goes wrong with $0^n1^n$ is, we have to show for all possible markings to show non-cfl. I also think since you are just showing a single possible marking in the proof it is not complete. So perhaps this language obeys the lemma's. – perreal Apr 27 '14 at 07:27
  • @perreal Ogden's lemma states that there exists $p$ such that for every word in $L$ and every possible marking with at least $p$ marks, there is a way to break the word in a certain way and pump it in a certain way. We get to chose the marks. Otherwise Ogden's lemma doesn't give us anything beyond the usual pumping lemma. – Yuval Filmus Apr 27 '14 at 16:21