I’m learning the difference between the lemmata in the question. Every reference I can find uses the example:
{(a^i)(b^j)(c^k)(d^l) : i = 0 or j = k = l}
to show the difference between the two. I can find an example using the regular lemma to “disprove” it.
Select w = uvxyz, s.t. |vy| > 0, |vxy| <= p.
Suppose w contains an equal number of b’s, c’s, d’s.
I selected:
u,v,x = ε
y = (the string of a's)
z = (the rest of the string w)
Pumping y will just add to the number of a’s, and if |b|=|c|=|d| at first, it still will now.
(Similar argument for if w has no a’s. Then just pump whatever you want.)
My question is, how does Ogden’s lemma change this strategy? What does “marking” do?
Thanks!
One important stumbling issue here is that “being able to pump” does not imply context free, rather “not being able to pump” shows it is not context free. Similarly, being grey does not imply you’re an elephant, but being an elephant does imply you’re grey…
That is to say, in order to demonstrate that a language is not context free we must show it fails(!) to satisfy one of these lemmata. (Even if it satisfies both we haven’t proved it is context free.)
Below is a sketch proof that
L = { a^i b^j c^k d^l where i = 0 or j = k = l}is not context free (although it satisfies The Pumping Lemma, it doesn’t satisfy Ogden’s Lemma):Pumping lemma for context free grammars:
In our example:
For any
sinL(with|s|>=p):scontainsas then choosev=a, x=epsilon, y=epsilon(and we have no contradiction to the language being context-free).scontains noas (w=b^j c^k d^land one ofj,korlis non-zero, since|s|>=1) then choosev=b(ifj>0,v=celifk>0, elsev=c),x=epsilon,y=epsilon(and we have no contradiction to the language being context-free).(So unfortunately: using the Pumping Lemma we are unable to prove anything about
L!Note: the above was essentially the argument you gave in the question.)
Ogden’s Lemma:
Note: this marking is the key part of Ogden’s Lemma, it says: “not only can every element be “pumped”, but it can be pumped using any
pmarked positions”.In our example:
Let
w = a b^p c^p d^pand mark the positions of thebs (of which there arep, sowsatisfies the requirements of Ogden’s Lemma), and letu,x,y,z,vbe a decomposition satisfying the conditions from Ogden’s lemma (z=uxyzv).xorzcontain multiple symbols, thenu x^2 y z^2 wis not inL, because there will be symbols in the wrong order (consider(bc)^2 = bcbc).xorzmust contain ab(by Lemma condition 1.)This leaves us with five cases to check (for
i,j>0):x=epsilon, z=b^ix=a, z=b^ix=b^i, z=c^jx=b^i, z=d^jx=b^i, z=epsilonin every case (by comparing the number of
bs,cs andds) we can see thatu x^2 v y^2 zis not inL(and we have a contradiction (!) to the language being context-free, that is, we’ve proved thatLis not context free)..
To summarise,
Lis not context-free, but this cannot be demonstrated using The Pumping Lemma (but can by Ogden’s Lemma) and thus we can say that: