![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Explain Pumping lemma for context free language
Pumping lemma for context free language (CFL) is used to prove that a language is not a Context free language
Assume L is context free language
Then there is a pumping length n such that any string w εL of length>=n can be written as follows −
|w|>=n
We can break w into 5 strings, w=uvxyz, such as the ones given below
- |vxy| >=n
- |vy| # ε
- For all k>=0, the string uvkxyyz∈L
The steps to prove that the language is not a context free by using pumping lemma are explained below −
- Assume that L is context free.
- The pumping length is n.
- All strings longer than n can be pumped |w|>=n.
- Now find a string 'w' in L such that |w|>=n.
- Divide w into uvxyz
- Show that uvkxykz ∉L for some k
- Then, consider the ways that w can be divided into uvxyz.
- Show that none of these can satisfy all the 3 pumping conditions at same time.
- w cannot be pumped (contradiction).
Example
Find out whether L={xnynzn|n>=1} is context free or not
Solution
- Let L be context free.
- L must satisfy pumping length, say n.
- Now we can take a string such that s=xnynzn
- We divide s into 5 strings uvxyz.
Let n=4 so, s=x4y4z4
Case 1:
v and y each contain only one type of symbol.
{we are considering only v and y because v and y has power uv2xy2z}
X xx x yyyyz z zz
=uvkxykz when k=2
=uv2xy2z
=xxxxxxyyyyzzzzz
=x6y4z5
(Number of x # number of y #number of z)
Therefore,The resultant string is not satisfying the condition
x6y4z5 ∉ L
If one case fails then no need to check another condition.
Case 2:
Either v or y has more than one kind of symbols
Xx xx yy y y zzzz
=uvkxykz (k=2)
=uv2xy2z
=xxxxyyxxyyyyyzzzz
=x4y2x2y5z2
This string is not following the pattern of our string xnynzn