...

/

Infinite CFLs and Another Pumping Theorem

Infinite CFLs and Another Pumping Theorem

Explore infinite context-free languages and build up to the pumping theorem from infinite CFLs.

We'll cover the following...

Intuitive reasoning behind the pumping theorem for CFLs

Now that we know how to determine if a context-free grammar generates an infinite language, let’s look a little closer at such languages. Suppose AA is a recursive variable in some CFG. Beginning with the start variable until the time AA first appears in a working derivation, symbols will have accumulated around AA. Look at the CFG below and the following derivation:

We’ll denote the aaaa prefix by uu and the last aa by zz so we have AuAzA\Rightarrow ^* uAz so far. Now we continue substituting until AA is repeated:

We have picked up v=bv=b and y=aby=ab around AA, giving us:

We can make the same choices we made previously between the occurrences of AA to arrive at AA again, giving us:

In general, with any recursive variable, we can derive this:

Eventually, we must terminate. We denote our terminating choices with AxA\Rightarrow ^* x, finally arriving at SuvnxynzS\Rightarrow ^* uv^nxy^nz. In this instance, we can use the rule AλA\Rightarrow \lambda and n=2n=2 ending with the string uv2xy2z=aabbababauv^2xy^2z= aabbababa, where x=λx=\lambda. We could also go right to the terminal rules, avoiding generating vv and yy in the first place, by letting n=0n=0, which is the derivation:

Since BB ...