After 2 failed attempts, that were disproved by @Hendrik Jan (thank you), here is another one, that is not more successful. @Vor found an example of a deterministic CF language where
the same construction would apply, if correct. This allowed identifying an error in the anchoring of the y string in the application of the lemma. The lemma itself does not seem at fault. This is clearly too simplistic a construction. See more details in the comments.
The language L={uxvy∣u,v,x,y∈{0,1}∗{ϵ} , ∣u∣=∣v∣ , u≠v , ∣x∣=∣y∣ , x≠y } is not Context-Free.
It is helpful to keep in mind the characterization L={uv:|u|=|v|,d(u,v)≥2} where d is the Hamming distance,
proposed by @sdcvvc. What one needs to think about are 2 selected positions in each half string such that the corresponding symbols differ.
Then you consider a string 10i10j such that i<j and i+j is even. It is clearly in the language L, by cutting u and x anywhere between the two 1's. We want to pump that string on the first part between the 1's, so that it will become 10j10j which is not supposed to be in the language.
We first try to use Ogden's lemma, which is like the pumping lemma, but applies to p or more distinguished symbols that are marked on the string, p being the pumping length for marked symbols (but the lemma can pump more because it can pump also unmarked symbols). The pumping marked-length p depends only on the language. This attempt will fail, but the failure will be a hint.
We can then choose i=p and we mark symbols on the first sequence of i 0's.
We know that none of the two 1's will be in the pump, because it can pump out once (exponent 0) instead of pumping in. And pumping out the 1's would get us out of the language.
However, we could be pumping on both sides of the second 1 as fast or even faster on the right side, so that the second 1 would never get across the middle of the string. Also Ogden's lemma does not fix an upper limit to the size of what is being pumped, so that it is not possible to organize the pumping to get the rightmost 1 exactly across the middle of the string.
We use a modified version of the lemma, here called Nash's Lemma, which can handle these difficulties.
We first need a definition (it probably has another name in the literature, but I do not know which - help is welcome). A string u is said to be an erasure of a string v iff it is obtained from v by erasing symbols in v. We will note u≺v.
Lp>0q>0wpLpwww=uxyzv with string u, x, y, z, v, such that
- xz has at least one marked position,
- xyzp
- x^y^z^
- x^≺xy^≺yz^≺z
- 1≤∣x^z^∣≤q, 1≤∣y^∣≤q, and
- uxjx^iy^z^izjv is in L for every i≥0 and for every j≥0.
Proof: Similar to the proof of Ogden's lemma, but the subtrees corresponding to the strings y and xz are pruned so that they do not contain any path with twice the same non-terminal (except for the roots of these two subtrees). This necessarily limits the size of the generated strings x^z^ and y^ by a constant q.
The strings xj and zj, for j≥0, corresponding to an unpruned version of the tree, are used mainly with j=1 to simplify the accounting when the lemma is applied.
We modify the above proof attempt by marking the p leftmost symbols
0, but they are followed by 2q symbols 0 to make sure that we pump
in the left part of the string, between the two 1's. That make a total of i=p+2q 0's between the 1's (actually i=p+q would be sufficient, since the rightmost 1 cannot be in z^, which would allow to simply remove it).
What is left is to have chosen j so that we can pump exactly the right number of 0's so that the two sequences are equal. But so far, the only constraint on j is to be greater than i. And we also know that the number of 0's that are pumped at each pumping is between 1 and q. So let h be product of the first q integers. We choose j=i+h.
Hence, since the pumping increment d - whatever it is - is in [1,q], it divides h. Let k be the quotient. If we pump exactly k times, we get a string 10j10j which is not in the language. Hence L is not context-free.
.
I think that I shall never see
A string lovely as a tree.
For if it does not have a parse,
The string is naught but a farce