edited by
1,189 views
1 votes
1 votes

Let $G = (V, \Sigma, R, S)$ be the following grammar. $V = \{S, T, U\}; \Sigma = \{0, \#\};$ and $R$ is the set of rules$:$

  •  $S\rightarrow TT\mid U$
  •  $T\rightarrow 0T\mid T0\mid \#$
  •  $U\rightarrow 0U00\mid \#$


Consider the language $B = L(G),$ where $G$ is the grammar which is given above$.$The pumping lemma for context-free languages$\text{, Theorem 2.34,}$ states the existence of a pumping length $p$ for $B.$ What is the minimum value of $p$ that works in the pumping lemma$?$ Justify your answer$.$

edited by

1 Answer

6 votes
6 votes

For my convinience, I am replacing $\#$ in the alphabet by $1.$

Given CFG :

$S\rightarrow TT (This\,\, will\,\,derive\,\,Exactly \,\,two\,\,1's\,\,i.e. 0^*10^*10^*)\mid U(This\,\,will\,\,derive\,\, 0^n10^{2n} \mid n \geq 0)$               

$T\rightarrow 0T\mid T0\mid 1$    $// Exactly\,\, one\,\, 1$ $i.e. \,\,0^*10^*$  

$U\rightarrow 0U00\mid 1$        $// 0^n10^{2n} \mid n \geq 0$

So, Our language is Union of Two languages. 

$L = A \cup B =  \{0^*10^*10^*\} \cup \{ 0^n10^{2n} \mid n \geq 0\} $

Pumping lemma for CFLs:

Let $L$ be a CFL. Then there exists some integer constant $P \geq 1$ (Called Pumping length or pumping-lemma constant)  such that if $w ∈ L$ with $|w| ≥ P,$ then we can write $w = uvxyz,$ subject to the following conditions:

1. $|vxy| ≤ P.$

2. $vy \neq \in .$

3. For all $i ≥ 0,$ we have $uv^ixy^iz ∈ L.$

i.e. Informally, For every sufficiently large string $w$ in $L,$ We must be able to split it such that it is possible to find at most two short, nearby substrings that we can “pump” $i$ times in tandem, for any non-negative integer $i,$ and the resulting string will still be in that language.  

So, In the Whole String $w$ with $|w| \geq P,$ "Anywhere in this string", "Within At Most $P$ symbols", We must find Two sub-strings(Possibly empty, Not Both Though) such that we can "Pump" both of these sub-strings $i \geq 0$ times in tandem i.e. Both repeated $i \geq 0$ times.

Now, Coming to Our Language, which is CFL (because It has been derived/generated from CFG), So, It must satisfy "Pumping lemma for CFLs". 

So, There must be some positive integer constant (pumping length) $\geq1$ exists for this language. Let it be $P.$

So, Now for every string $w \in L$ whose length is greater than or equal to $P,$ we must have some partition $uvxyz$ satisfying all the above conditions. 

Since here we are asked to find the Minimum Pumping Length(MPL). So, We can start from taking Pumping length as $1,2,3$ etc.. But with some experience, You can remove some possibilities. Like $MPL$ can not be 1 because the minimal string of this language is of length 1.

(MPL will always be strictly greater than the minimal string in the language. (Hint for Proof : Since $v,y$ can be repeated Zero or more times, When you repeat $v,y$ Zero times, the string length decreases by at least one symbol) )

You can also remove the possibility of $MPL$ being 2 by considering the String $11$ in the language. However you choose $v,y$ for this string, When you Pump it Twice i.e. $i = 2,$ It will definitely generate some string which is Not in the language.

So, Now we can check for Pumping length being $3.$ For Pumping length 3,  All the strings of the sub-language $A$ i.e. $\{0^*10^*10^*\}$ can be Pumped by choosing $u = \in,$ and $v = \in$ and $y$ being any Zero in the first three symbols (At least one zero will be there in the first three symbols because the language is Exactly Two 1's) and rest of the symbols in the string being $x,z$ accordingly. 

But By Taking $MPL$ as 3, We cannot pump the sub-language $B$ i.e. $\{ 0^n10^{2n} \mid n \geq 0\}$ because say you take the string $0100$, Now since $P = 3$, You want to find $"$at most $3"$ consecutive symbols in the String(anywhere in the String) such that you can find two short sub-strings in that part and Pump those sub-strings in tandem. But You can check that It will fail. So, Pumping length cannot be $3.$ 

So, Now check for Pumping length $4$ :

Now you don't need to check the strings of sub-language $A$ again because Pumping length 3 worked for $A$ so any pumping length $\geq 3$ will also work for $A.$

(If Minimum pumping length for a language is $x$ then any number $\geq x$ is also a Pumping length for the language.) 

So, We only need to check for strings of sub-language $B.$ Pumping length $4$ will work for $B$ by choosing $x = 1$ (There is exactly one 1 in every string of $B$..choose that 1 as $x$) and the 0 before that 1 as $v$ and Two 0's after that $1$ as $y$ and rest of the string as $u,z$ accordingly. So, Now you can pump $v,y$ $i$ times in tandem and the resulting string will still belong to the language $L.$

So, Answer is $4.$ i.e. $MPL$ will be $4$ for the given language.  

 (Refer My Answer Here for some Facts about Pumping lemma : https://gateoverflow.in/302833/gate2019-15?show=304424#a304424 


$\color{Red}{\text{Understand Complete Pumping Lemma of Regular Languages, Crystal Clear:}}$

Here is Complete Pumping Lemma Lecture: https://youtu.be/8cdPjuYbIrU 

This Pumping Lemma lecture contains EVERYTHING about Pumping Lemma of Regular Languages, i.e. Proof, Examples, Variations, GATE PYQs, Finding minimum pumping length etc. Watch this lecture for Complete, Correct & Clear Understanding.

edited by

Related questions

1 votes
1 votes
1 answer
1
0 votes
0 votes
1 answer
3
admin asked May 4, 2019
621 views
Let $G$ be a $CFG$ in Chomsky normal form that contains $b$ variables$.$ Show that if $G$ generates some string with a derivation having at least $2^{b}$ steps$, L(G)$ is...
0 votes
0 votes
2 answers
4