SlideShare a Scribd company logo
1 of 32
Download to read offline
PUMPING LEMMA
There are two Pumping Lemmas, which are defined for
1. Regular Languages, and
2. Context – Free Languages
APPLICATIONS OF PUMPING LEMMA
Pumping Lemma is to be applied to show that certain
languages are not regular.
It should never be used to show a language is regular.
 If L is regular, it satisfies Pumping Lemma.
 If L does not satisfy Pumping Lemma, it is non-
regular.
FORMAL STATEMENT
Pumping Lemma for Regular Languages
For any regular language L, there exists an integer n, such that for all w ∈
L with
|w| ≥ n, there exists (x, y, z ∈ Σ∗), such that w = xyz, and
(1) |xy| ≤ n
(2) |y| ≥ 1
(3) for all i ≥ 0: xyiz ∈ L
In simple terms, this means that if a string y is ‘pumped’, i.e., if y is
inserted any number of times, the resultant string still remains in L.
FORMAL STATEMENT
Pumping Lemma for Context-free Languages (CFL)
Pumping Lemma for CFL states that for any Context Free Language L, it is
possible to find two substrings that can be ‘pumped’ any number of times
and still be in the same language. For any language L, we break its strings
into five parts and pump second and fourth substring.
Pumping Lemma, here also, is used as a tool to prove that a language is not
CFL. Because, if any one string does not satisfy its conditions, then the
language is not CFL.
| w| n
The Pumping Lemma:
For infinite context-free language L
there exists an integer n such that
for any string
we can write
with lengths and |vy |1
w L,
w =uvxyz
| vxy | n
for all i  0
and it must be:
uvi xyiz  L,
TAKE AN INFINITE CONTEXT-FREE
LANGUAGE
Example: S → AB
A →aBb
B → Sb
B → b
Generates an infinite number
of different strings
S → AB
A →
ABB B
→ SB B
→B
A derivation:
S  AB  aBbB abbB
 abbSb  abbABb  abbaBbBb 
 abbabbBb  abbabbbb
In a derivation of a long string,
variables are repeated
S
A B
bBa
b
bS
A B
bBa
b
b
Derivation tree string abbabbbb
S
A B
bBa
b
bS
A B
bBa
b
b
repeated
Derivation tree string abbabbbb
B
bS
A B
bBa b
B  Sb  ABb 
 aBbBb  aBbbb
B b
b
*
BaBbbb
B
bS
A B
bBa b
Repeated Part
*
BaBbbb
B
bS
A B
ba bB
bS
A B
bBa b
* *
BaBbbbaaBbbbbbb
Another possible
*
BaBbbb
derivation from B
B
bS
A B
ba bB
bS
A B
bBa b
22
* *
B (a)B(bbb)(a) B(bbb)
*
BaBbbb
22
*
S  abb(a) b(bbb)
abb(a)2b(bbb)2 L(G)
*
B aBbbb B b
*
SabbBb
S
A B
bBa
b
*
BaBbbb
B  b
*
SabbBb
S abbBb  abbbb
*
b
= abb(a)0b(bbb)0
00
*
S  abb(a) b(bbb)
abb(a)0b(bbb)0 L(G)
*
B aBbbb B b
*
SabbBb
33 3 3
*
S  abb(a) B(bbb)  abb(a) b(bbb)
S
A B
B ba
b
bS
A B
ba bB
bS
A B
B ba b
bS
A B
bBa b
b
*
BaBbbb
B  b
*
S  abbBb
33
*
S  abb(a) b(bbb)
abb(a)3b(bbb)3 L(G)
*
B aBbbb B b
*
SabbBb
ii
*
S abb(a) b(bbb)
abb(a)ib(bbb)i L(G)
*
B aBbbb B b
*
SabbBb
In General:
i 0
S
A
x
u
Last repeated variable
z
v y
w =uvxyz
u,v, x, y, z :
repeated A
Strings of terminals
DERIVATION TREE OF
STRING W
S
A
A
x
u z
v y

SuAz

AvAy

Ax
Possible
derivations:
 
S uAz AvAy

Ax
We know:
This string is also generated:
 *
S uAzuxz
uv0xy0z
This string is also generated:
 * *
S uAzuvAyzuvxyz
The original w =uv1xy1z
 
S uAz AvAy

Ax
We know:
This string is also generated:
 * * *
S uAzuvAyzuvvAyyzuvvxyyz
uv2xy2z
 
S uAz AvAy

Ax
We know:
This string is also generated:
 * *
S uAz  uvAyzuvvAyyz
* *
uvvvAyyyzuvvvxyyyz
uv3xy3z
 
S uAz AvAy

Ax
We know:
We know:
  
S uAz AvAy A x
This string is also generated:
S  uAz  uvAyz  uvvAyyz 
 uvvvAyyyz …
 u v v v v A y yyyz 
 u v v v v x y yyyz
uvi xyiz
Therefore, any string of the form
uvixyiz
is generated by the grammar G
i 0
knowing that uvxyz  L(G)
we also know that uvixyiz L(G)
Therefore,
L(G) = L−{}
uvi xyiz L
S
A
A
u z
v y
x
| vxy |  mObservation:
Since A is the last repeated variable
S
A
u z
v y
A
x
Observation: | vy |  1
Since there are no unit or -productions
| w| n
The Pumping Lemma:
For infinite context-free language L
there exists an integer n such that
for any string
we can write
with lengths and |vy |1
w L,
w =uvxyz
| vxy | n
for all i  0
and it must be:
uvi xyiz  L,

More Related Content

What's hot

Theory of Automata
Theory of AutomataTheory of Automata
Theory of AutomataFarooq Mian
 
Chomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsChomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsRajendran
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examplesankitamakin
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of LanguageDipankar Boruah
 
Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automatahafizhamza0322
 
TOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity CheckTOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity CheckMohammad Imam Hossain
 
Simplification of cfg ppt
Simplification of cfg pptSimplification of cfg ppt
Simplification of cfg pptShiela Rani
 
Introduction to Computer theory (Automata Theory) 2nd Edition By Denial I.A. ...
Introduction to Computer theory (Automata Theory) 2nd Edition By Denial I.A. ...Introduction to Computer theory (Automata Theory) 2nd Edition By Denial I.A. ...
Introduction to Computer theory (Automata Theory) 2nd Edition By Denial I.A. ...Farwa Ansari
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4shah zeb
 
Theory of computing
Theory of computingTheory of computing
Theory of computingRanjan Kumar
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languagesparmeet834
 
Lecture 1,2
Lecture 1,2Lecture 1,2
Lecture 1,2shah zeb
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computationBipul Roy Bpl
 

What's hot (20)

TOC 7 | CFG in Chomsky Normal Form
TOC 7 | CFG in Chomsky Normal FormTOC 7 | CFG in Chomsky Normal Form
TOC 7 | CFG in Chomsky Normal Form
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of Automata
 
Chomsky & Greibach Normal Forms
Chomsky & Greibach Normal FormsChomsky & Greibach Normal Forms
Chomsky & Greibach Normal Forms
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
Pumping lemma
Pumping lemmaPumping lemma
Pumping lemma
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
 
Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automata
 
TOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity CheckTOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity Check
 
push down automata
push down automatapush down automata
push down automata
 
Chomsky Normal Form
Chomsky Normal FormChomsky Normal Form
Chomsky Normal Form
 
Simplification of cfg ppt
Simplification of cfg pptSimplification of cfg ppt
Simplification of cfg ppt
 
Introduction to Computer theory (Automata Theory) 2nd Edition By Denial I.A. ...
Introduction to Computer theory (Automata Theory) 2nd Edition By Denial I.A. ...Introduction to Computer theory (Automata Theory) 2nd Edition By Denial I.A. ...
Introduction to Computer theory (Automata Theory) 2nd Edition By Denial I.A. ...
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Chomsky Normal Form
Chomsky Normal FormChomsky Normal Form
Chomsky Normal Form
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
 
pushdown automata
pushdown automatapushdown automata
pushdown automata
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
Lecture 1,2
Lecture 1,2Lecture 1,2
Lecture 1,2
 
Flat unit 3
Flat unit 3Flat unit 3
Flat unit 3
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 

Similar to Pumping lemma for cfl

Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxRaviAr5
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfdawod yimer
 
Free Ebooks Download ! Edhole
Free Ebooks Download ! EdholeFree Ebooks Download ! Edhole
Free Ebooks Download ! EdholeEdhole.com
 
Mba ebooks ! Edhole
Mba ebooks ! EdholeMba ebooks ! Edhole
Mba ebooks ! EdholeEdhole.com
 
Hw2 2017-spring
Hw2 2017-springHw2 2017-spring
Hw2 2017-spring奕安 陳
 
RegularLanguageProperties [Autosaved].pptx
RegularLanguageProperties [Autosaved].pptxRegularLanguageProperties [Autosaved].pptx
RegularLanguageProperties [Autosaved].pptxRaviAr5
 
Conteext-free Grammer
Conteext-free GrammerConteext-free Grammer
Conteext-free GrammerHASHIR RAZA
 
Top school in ghaziabad
Top school in ghaziabadTop school in ghaziabad
Top school in ghaziabadEdhole.com
 
Context free langauges
Context free langaugesContext free langauges
Context free langaugessudhir sharma
 
Class7
 Class7 Class7
Class7issbp
 
9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptxmainakmail2585
 
09.LearningMaterial_Sample.pdf
09.LearningMaterial_Sample.pdf09.LearningMaterial_Sample.pdf
09.LearningMaterial_Sample.pdfssuser47f7f2
 
Presentation (5).pdf
Presentation (5).pdfPresentation (5).pdf
Presentation (5).pdfGaurav447273
 
10 Regular VS Non Regular Language.pptx
10 Regular VS Non Regular Language.pptx10 Regular VS Non Regular Language.pptx
10 Regular VS Non Regular Language.pptxMuhammadFaizanHameed1
 

Similar to Pumping lemma for cfl (20)

pumpexamples.pptx
pumpexamples.pptxpumpexamples.pptx
pumpexamples.pptx
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptx
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
 
Free Ebooks Download ! Edhole
Free Ebooks Download ! EdholeFree Ebooks Download ! Edhole
Free Ebooks Download ! Edhole
 
Mba ebooks ! Edhole
Mba ebooks ! EdholeMba ebooks ! Edhole
Mba ebooks ! Edhole
 
Hw2 2017-spring
Hw2 2017-springHw2 2017-spring
Hw2 2017-spring
 
RegularLanguageProperties [Autosaved].pptx
RegularLanguageProperties [Autosaved].pptxRegularLanguageProperties [Autosaved].pptx
RegularLanguageProperties [Autosaved].pptx
 
Conteext-free Grammer
Conteext-free GrammerConteext-free Grammer
Conteext-free Grammer
 
Top school in ghaziabad
Top school in ghaziabadTop school in ghaziabad
Top school in ghaziabad
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
Module 1 TOC.pptx
Module 1 TOC.pptxModule 1 TOC.pptx
Module 1 TOC.pptx
 
Context free langauges
Context free langaugesContext free langauges
Context free langauges
 
hop-chap4.ppt
hop-chap4.ppthop-chap4.ppt
hop-chap4.ppt
 
L_2_apl.pptx
L_2_apl.pptxL_2_apl.pptx
L_2_apl.pptx
 
Class7
 Class7 Class7
Class7
 
9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx
 
09.LearningMaterial_Sample.pdf
09.LearningMaterial_Sample.pdf09.LearningMaterial_Sample.pdf
09.LearningMaterial_Sample.pdf
 
Presentation (5).pdf
Presentation (5).pdfPresentation (5).pdf
Presentation (5).pdf
 
To lec 03
To lec 03To lec 03
To lec 03
 
10 Regular VS Non Regular Language.pptx
10 Regular VS Non Regular Language.pptx10 Regular VS Non Regular Language.pptx
10 Regular VS Non Regular Language.pptx
 

Recently uploaded

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 

Recently uploaded (20)

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 

Pumping lemma for cfl

  • 1.
  • 2. PUMPING LEMMA There are two Pumping Lemmas, which are defined for 1. Regular Languages, and 2. Context – Free Languages
  • 3. APPLICATIONS OF PUMPING LEMMA Pumping Lemma is to be applied to show that certain languages are not regular. It should never be used to show a language is regular.  If L is regular, it satisfies Pumping Lemma.  If L does not satisfy Pumping Lemma, it is non- regular.
  • 4. FORMAL STATEMENT Pumping Lemma for Regular Languages For any regular language L, there exists an integer n, such that for all w ∈ L with |w| ≥ n, there exists (x, y, z ∈ Σ∗), such that w = xyz, and (1) |xy| ≤ n (2) |y| ≥ 1 (3) for all i ≥ 0: xyiz ∈ L In simple terms, this means that if a string y is ‘pumped’, i.e., if y is inserted any number of times, the resultant string still remains in L.
  • 5. FORMAL STATEMENT Pumping Lemma for Context-free Languages (CFL) Pumping Lemma for CFL states that for any Context Free Language L, it is possible to find two substrings that can be ‘pumped’ any number of times and still be in the same language. For any language L, we break its strings into five parts and pump second and fourth substring. Pumping Lemma, here also, is used as a tool to prove that a language is not CFL. Because, if any one string does not satisfy its conditions, then the language is not CFL.
  • 6. | w| n The Pumping Lemma: For infinite context-free language L there exists an integer n such that for any string we can write with lengths and |vy |1 w L, w =uvxyz | vxy | n for all i  0 and it must be: uvi xyiz  L,
  • 7. TAKE AN INFINITE CONTEXT-FREE LANGUAGE Example: S → AB A →aBb B → Sb B → b Generates an infinite number of different strings
  • 8. S → AB A → ABB B → SB B →B A derivation: S  AB  aBbB abbB  abbSb  abbABb  abbaBbBb   abbabbBb  abbabbbb In a derivation of a long string, variables are repeated
  • 11. B bS A B bBa b B  Sb  ABb   aBbBb  aBbbb B b b * BaBbbb
  • 12. B bS A B bBa b Repeated Part * BaBbbb
  • 13. B bS A B ba bB bS A B bBa b * * BaBbbbaaBbbbbbb Another possible * BaBbbb derivation from B
  • 14. B bS A B ba bB bS A B bBa b 22 * * B (a)B(bbb)(a) B(bbb) * BaBbbb
  • 15. 22 * S  abb(a) b(bbb) abb(a)2b(bbb)2 L(G) * B aBbbb B b * SabbBb
  • 16. S A B bBa b * BaBbbb B  b * SabbBb S abbBb  abbbb * b = abb(a)0b(bbb)0
  • 17. 00 * S  abb(a) b(bbb) abb(a)0b(bbb)0 L(G) * B aBbbb B b * SabbBb
  • 18. 33 3 3 * S  abb(a) B(bbb)  abb(a) b(bbb) S A B B ba b bS A B ba bB bS A B B ba b bS A B bBa b b * BaBbbb B  b * S  abbBb
  • 19. 33 * S  abb(a) b(bbb) abb(a)3b(bbb)3 L(G) * B aBbbb B b * SabbBb
  • 20. ii * S abb(a) b(bbb) abb(a)ib(bbb)i L(G) * B aBbbb B b * SabbBb In General: i 0
  • 21. S A x u Last repeated variable z v y w =uvxyz u,v, x, y, z : repeated A Strings of terminals DERIVATION TREE OF STRING W
  • 23.   S uAz AvAy  Ax We know: This string is also generated:  * S uAzuxz uv0xy0z
  • 24. This string is also generated:  * * S uAzuvAyzuvxyz The original w =uv1xy1z   S uAz AvAy  Ax We know:
  • 25. This string is also generated:  * * * S uAzuvAyzuvvAyyzuvvxyyz uv2xy2z   S uAz AvAy  Ax We know:
  • 26. This string is also generated:  * * S uAz  uvAyzuvvAyyz * * uvvvAyyyzuvvvxyyyz uv3xy3z   S uAz AvAy  Ax We know:
  • 27. We know:    S uAz AvAy A x This string is also generated: S  uAz  uvAyz  uvvAyyz   uvvvAyyyz …  u v v v v A y yyyz   u v v v v x y yyyz uvi xyiz
  • 28. Therefore, any string of the form uvixyiz is generated by the grammar G i 0
  • 29. knowing that uvxyz  L(G) we also know that uvixyiz L(G) Therefore, L(G) = L−{} uvi xyiz L
  • 30. S A A u z v y x | vxy |  mObservation: Since A is the last repeated variable
  • 31. S A u z v y A x Observation: | vy |  1 Since there are no unit or -productions
  • 32. | w| n The Pumping Lemma: For infinite context-free language L there exists an integer n such that for any string we can write with lengths and |vy |1 w L, w =uvxyz | vxy | n for all i  0 and it must be: uvi xyiz  L,