Use Pumping Lemma to show that $L_7$ is not context-free

1.5k Views Asked by At

I was studying an old test and struggled to answer this question:

Let $L_7$ be the language $\{ w@y \mid y \text{ is a substring of } w\}$, where $w, y \in \{c,d\}^*$. Use the Pumping Lemma for context-free languages to show that $L_7$ is not context-free.

2

There are 2 best solutions below

1
On BEST ANSWER

Suppose $L7$ satisfies the Pumping Lemma and let $p$ satisfy the conditions of the Pumping Lemma as stated on Wikipedia. Let $$s = c^pd^p @ c^pd^p \in L7$$ Note that $|s| > p$. Let $u, v, w, x, y \in \{c, d, @\}^*$ satisfy the conditions of the theorem (again, as stated on Wikipedia). First, let's consider the $@$. It obviously cannot lie in $v$ or $x$, as precisely one $@$ is allowed. It cannot lie in $u$, since considering $n > 1$ will make $uv^nwx^ny$ into the form $a@b$ where $|a| < |b|$. For the same reason, this time considering $n = 0$, we cannot have $@$ be in $y$. So, the $@$ must lie in $w$.

Since $|vwx| \le p$, it follows that $v = d^m$ and $x = c^l$ for some natural numbers $m$ and $l$. Then, it follows that $$uv^2wx^2y = c^pd^{p+m}@c^{p+l}d^p \notin L7,$$ which is a contradiction.

1
On

I suggest to first intersect $L_7$ with the regular language $$ddd\cdot\{cc,cd,dc\}^+ddd@ddd\cdot\{cc,cd,dc\}^+ddd.$$ This takes away all strings where the substring is not the entire string (and some more). The result is $$\{ddd\cdot w\cdot ddd@ddd\cdot w\cdot ddd: w\in \{cc,cd,dc\}^+\}$$ which is very close to the copy language over three letters. Therefore you can apply the pumping lemma in the same way.

I have read "substring" as "factor," but this should even work if "substring" means "scattered substring."