Example- Pumping Lemma For CFL

 

Using the Pumping Lemma to Show a Language is Not Context-Free


We will use the pumping lemma for context-free languages to prove that:

L={anbncnn1}L = \{ a^n b^n c^n \mid n \ge 1 \}

is not a context-free language.


Proof

Step 1: Assume LL is context-free

Suppose, for contradiction, that LL is a context-free language.

Then, by the pumping lemma, there exists a positive integer mm such that
any string ωL\omega \in L with ωm|\omega| \ge m can be written as:

ω=uvxyz\omega = u v x y z

satisfying:

  1. vxym|v x y| \le m

  2. vy1|v y| \ge 1

  3. uvixyizLu v^i x y^i z \in L for all i=0,1,2,


Step 2: Choose a specific string in LL

Let us take:

ω=ambmcm\omega = a^m b^m c^m

Clearly, ωL\omega \in L and ω=3mm|\omega| = 3m \ge m.


Step 3: Analyze the possible locations of vv and yy

Because vxym|v x y| \le m
the substring vxyv x y must lie within a span of length mm in ω\omega.
That means vxyv x y can only cover a limited portion of ω\omega —
it cannot stretch over all three regions (the block of a’s, b’s, and c’s).

Hence, vv and yy can appear in one of the following ways:

(a) Entirely within the block of a’s

(b) Entirely within the block of b’s

(c) Entirely within the block of c’s

(d) Across the boundary between a’s and b’s

(e) Across the boundary between b’s and c’s

We will show in each case that uvixyizLu v^i x y^i z \notin L for some ii.


Step 4: Consider all possible cases

Case (a): vyv y lies entirely within the a’s

Then vv and yy contain only a’s.

When we pump i=2i = 2, the number of a’s increases,
but the number of b’s and c’s remains the same.

Resulting string:

uv2xy2z=am+kbmcm(k>0)u v^2 x y^2 z = a^{m + k} b^m c^m \quad (k > 0)

This string is not in LL because the numbers of a’s, b’s, and c’s are no longer equal.


Case (b): vyv y lies entirely within the b’s

Then vv and yy contain only b’s.

Pumping increases or decreases the number of b’s without changing a’s or c’s:

uv2xy2z=ambm+kcmu v^2 x y^2 z = a^m b^{m+k} c^m

This is not in LL since the counts differ.


Case (c): vyv y lies entirely within the c’s

Similar to case (a):

uv2xy2z=ambmcm+ku v^2 x y^2 z = a^m b^m c^{m+k}

This is not in LL.


Case (d): vyv y spans the boundary between a’s and b’s

Then vv contains some a’s and yy contains some b’s.

When we pump i=2i = 2, we add extra a’s and b’s simultaneously,but not the same number necessarily, and no extra c’s.

Resulting string:

uv2xy2zu v^2 x y^2 z

contains unequal numbers of a’s, b’s, and c’s → not in LL.


Case (e): vyv y spans the boundary between b’s and c’s

Similarly, pumping changes the number of b’s and c’s differently, producing a string with unequal counts.

Thus again uv2xy2zLu v^2 x y^2 z \notin L


Step 5: Conclusion

In all possible cases, pumping changes the balance among a’s, b’s, and c’s.Therefore, there exists some ii (such as i=0 or i=2i = 2) for which:

uvixyizLu v^i x y^i z \notin L

This contradicts the third condition of the pumping lemma.

Hence, our assumption that LL is context-free must be false.

L={anbncnn1} is not a context-free language.\boxed{L = \{ a^n b^n c^n \mid n \ge 1 \} \text{ is not a context-free language.}}

🧠 Intuitive Summary 

  • Pumping lemma tells us every long enough CFL string can be “pumped” by repeating some substrings vv and yy.

  • For anbncna^n b^n c^n, the balance of a’s, b’s, and c’s is strict.

  • Pumping always destroys that balance.

  • Therefore, no context-free grammar (and hence no PDA) can generate this language.

Comments

Popular posts from this blog

Theory Of Computation PCCST302 KTU Semester 3 BTech 2024 Scheme

Non deterministic Finite Automata NFA

Formal Definition - Turing Machine