![Page 1: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/1.jpg)
INF2080Non-Context-Free Langugaes
Daniel Lupp
Universitetet i Oslo
15th February 2018
Department ofInformatics
University ofOslo
INF2080 Lecture :: 15th February 1 / 32
![Page 2: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/2.jpg)
Repetition
Definition (Context-Free Grammar)
A context-free grammar is a 4-tuple (V ,Σ,R, S) where1 V is a finite set of variables2 Σ is a finite set disjoint from V of terminals3 R is a finite set of rules, each consisting of a variable and of a string of variables and
terminals4 and S is the start variable
A language generated by a context-free grammar is a context-free language
INF2080 Lecture :: 15th February 2 / 32
![Page 3: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/3.jpg)
Repetition
Definition (Context-Free Grammar)
A context-free grammar is a 4-tuple (V ,Σ,R, S) where1 V is a finite set of variables2 Σ is a finite set disjoint from V of terminals3 R is a finite set of rules, each consisting of a variable and of a string of variables and
terminals4 and S is the start variable
A language generated by a context-free grammar is a context-free language
INF2080 Lecture :: 15th February 2 / 32
![Page 4: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/4.jpg)
Context-Free Grammar
S → aSa | bSb | cSc | a | b | c | ε
Palindromes over {a, b, c}
S → 01S10 | ε
{(01)n(10)n | n ≥ 0}
S → 1 | 1B1 | 0 | 0B0B → 1B | 0B | ε
All {0, 1} words beginningand ending with the same
digit
INF2080 Lecture :: 15th February 3 / 32
![Page 5: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/5.jpg)
Context-Free Grammar
S → aSa | bSb | cSc | a | b | c | ε
Palindromes over {a, b, c}
S → 01S10 | ε
{(01)n(10)n | n ≥ 0}
S → 1 | 1B1 | 0 | 0B0B → 1B | 0B | ε
All {0, 1} words beginningand ending with the same
digit
INF2080 Lecture :: 15th February 3 / 32
![Page 6: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/6.jpg)
Context-Free Grammar
S → aSa | bSb | cSc | a | b | c | ε
Palindromes over {a, b, c}
S → 01S10 | ε
{(01)n(10)n | n ≥ 0}
S → 1 | 1B1 | 0 | 0B0B → 1B | 0B | ε
All {0, 1} words beginningand ending with the same
digit
INF2080 Lecture :: 15th February 3 / 32
![Page 7: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/7.jpg)
Context-Free Grammar
S → aSa | bSb | cSc | a | b | c | ε
Palindromes over {a, b, c}
S → 01S10 | ε
{(01)n(10)n | n ≥ 0}
S → 1 | 1B1 | 0 | 0B0B → 1B | 0B | ε
All {0, 1} words beginningand ending with the same
digit
INF2080 Lecture :: 15th February 3 / 32
![Page 8: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/8.jpg)
Context-Free Grammar
S → aSa | bSb | cSc | a | b | c | ε
Palindromes over {a, b, c}
S → 01S10 | ε
{(01)n(10)n | n ≥ 0}
S → 1 | 1B1 | 0 | 0B0B → 1B | 0B | ε
All {0, 1} words beginningand ending with the same
digit
INF2080 Lecture :: 15th February 3 / 32
![Page 9: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/9.jpg)
Context-Free Grammar
S → aSa | bSb | cSc | a | b | c | ε
Palindromes over {a, b, c}
S → 01S10 | ε
{(01)n(10)n | n ≥ 0}
S → 1 | 1B1 | 0 | 0B0B → 1B | 0B | ε
All {0, 1} words beginningand ending with the same
digit
INF2080 Lecture :: 15th February 3 / 32
![Page 10: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/10.jpg)
Chomsky Normal Form
Every context-free grammar can be rewritten into Chomsky normal form:
Definition (Chomsky Normal Form)
A grammar in Chomsky normal form consists only of rules of the following form:
S → ε
A→ BC
A→ d ,
where S is the start variable, A,B,C are variables with B,C distinct from S , and d is aterminal.
INF2080 Lecture :: 15th February 4 / 32
![Page 11: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/11.jpg)
PDA
A pushdown automaton (PDA) is, informally, a NFA with an additional stack to storeinformation.
Definition (PDA)
A PDA is a tuple (Q,Σ, Γ, δ, q0,F ) where Q,Σ, Γ,F are finite states and1 Q is a set of states,2 Σ is the input alphabet,3 Γ is the stack alphabet,4 δ : Q × Σε × Γε → P(Q × Γε) is the transition function5 q0 ∈ Q is the start state, and6 F ⊆ Q is the set of accepting states.
INF2080 Lecture :: 15th February 5 / 32
![Page 12: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/12.jpg)
PDA
A pushdown automaton (PDA) is, informally, a NFA with an additional stack to storeinformation.
Definition (PDA)
A PDA is a tuple (Q,Σ, Γ, δ, q0,F ) where Q,Σ, Γ,F are finite states and1 Q is a set of states,2 Σ is the input alphabet,3 Γ is the stack alphabet,4 δ : Q × Σε × Γε → P(Q × Γε) is the transition function5 q0 ∈ Q is the start state, and6 F ⊆ Q is the set of accepting states.
INF2080 Lecture :: 15th February 5 / 32
![Page 13: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/13.jpg)
PDA
Examples:
start1
q1start q2
q3q4
ε, ε→ $
0, ε→ 0
1, 0→ ε
1, 0→ ε
ε, $→ ε
INF2080 Lecture :: 15th February 6 / 32
![Page 14: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/14.jpg)
PDA
Examples:
start1
q1start q2
q3q4
ε, ε→ $
0, ε→ 0
1, 0→ ε
1, 0→ ε
ε, $→ ε
INF2080 Lecture :: 15th February 6 / 32
![Page 15: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/15.jpg)
PDA
Examples:
start1
q1start q2
q3q4
ε, ε→ $
0, ε→ 0
1, 0→ ε
1, 0→ ε
ε, $→ ε
INF2080 Lecture :: 15th February 6 / 32
![Page 16: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/16.jpg)
PDAs and CFLs
Last lecture we saw that PDAs and CFLs are closely related:
TheoremA language is context-free if and only if a PDA recognizes it.
Proof was quite involved, check last lecture/book for details (a very good exercise!)So PDAs and CFLs have a similar relationship as NFAs and regular languagesWhat about DPDAs (deterministic PDAs)? Are they the same as PDAs? → Nope! Have,in fact, different expressive power. See book (not exam-relevant).
INF2080 Lecture :: 15th February 7 / 32
![Page 17: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/17.jpg)
PDAs and CFLs
Last lecture we saw that PDAs and CFLs are closely related:
TheoremA language is context-free if and only if a PDA recognizes it.
Proof was quite involved, check last lecture/book for details (a very good exercise!)
So PDAs and CFLs have a similar relationship as NFAs and regular languagesWhat about DPDAs (deterministic PDAs)? Are they the same as PDAs? → Nope! Have,in fact, different expressive power. See book (not exam-relevant).
INF2080 Lecture :: 15th February 7 / 32
![Page 18: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/18.jpg)
PDAs and CFLs
Last lecture we saw that PDAs and CFLs are closely related:
TheoremA language is context-free if and only if a PDA recognizes it.
Proof was quite involved, check last lecture/book for details (a very good exercise!)So PDAs and CFLs have a similar relationship as NFAs and regular languages
What about DPDAs (deterministic PDAs)? Are they the same as PDAs? → Nope! Have,in fact, different expressive power. See book (not exam-relevant).
INF2080 Lecture :: 15th February 7 / 32
![Page 19: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/19.jpg)
PDAs and CFLs
Last lecture we saw that PDAs and CFLs are closely related:
TheoremA language is context-free if and only if a PDA recognizes it.
Proof was quite involved, check last lecture/book for details (a very good exercise!)So PDAs and CFLs have a similar relationship as NFAs and regular languagesWhat about DPDAs (deterministic PDAs)? Are they the same as PDAs?
→ Nope! Have,in fact, different expressive power. See book (not exam-relevant).
INF2080 Lecture :: 15th February 7 / 32
![Page 20: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/20.jpg)
PDAs and CFLs
Last lecture we saw that PDAs and CFLs are closely related:
TheoremA language is context-free if and only if a PDA recognizes it.
Proof was quite involved, check last lecture/book for details (a very good exercise!)So PDAs and CFLs have a similar relationship as NFAs and regular languagesWhat about DPDAs (deterministic PDAs)? Are they the same as PDAs? → Nope! Have,in fact, different expressive power. See book (not exam-relevant).
INF2080 Lecture :: 15th February 7 / 32
![Page 21: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/21.jpg)
Non-Context-Free Languages
Today, we deal with non-context-free languages, i.e., we are interested in seeing whether alanguage is non-context free.
Recall our discussion on nonregular languages, in particular the pumping lemma:
Lemma (Pumping Lemma for Regular Languages)
If A is a regular language, then there is a number p, called the pumping length, where if s is aword in A of length ≥ p then s can be divided into three parts, s = xyz , such that
1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.
INF2080 Lecture :: 15th February 8 / 32
![Page 22: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/22.jpg)
Non-Context-Free Languages
Today, we deal with non-context-free languages, i.e., we are interested in seeing whether alanguage is non-context free.Recall our discussion on nonregular languages, in particular the pumping lemma:
Lemma (Pumping Lemma for Regular Languages)
If A is a regular language, then there is a number p, called the pumping length, where if s is aword in A of length ≥ p then s can be divided into three parts, s = xyz , such that
1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.
INF2080 Lecture :: 15th February 8 / 32
![Page 23: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/23.jpg)
Non-Context-Free Languages
Today, we deal with non-context-free languages, i.e., we are interested in seeing whether alanguage is non-context free.Recall our discussion on nonregular languages, in particular the pumping lemma:
Lemma (Pumping Lemma for Regular Languages)
If A is a regular language, then there is a number p, called the pumping length, where if s is aword in A of length ≥ p then s can be divided into three parts, s = xyz , such that
1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.
INF2080 Lecture :: 15th February 8 / 32
![Page 24: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/24.jpg)
Pumping Lemma for Regular Languages
Lemma (Pumping Lemma for Regular Languages)
If A is a regular language, then there is a number p, called the pumping length, where if s is aword in A of length ≥ p then s can be divided into three parts, s = xyz , such that
1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.
Recall that each component x , y , z corresponed to one part in an accepting path in theDFA.y corresponded to a cycle in the DFAx corresponded to a path from the initial node to the start of the cycle.z corresponded to a path from the end of the cycle to an accepting state.Condition (3) in the lemma was a useful tool when proving the nonregularity of a language.
INF2080 Lecture :: 15th February 9 / 32
![Page 25: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/25.jpg)
Pumping Lemma for Regular Languages
Lemma (Pumping Lemma for Regular Languages)
If A is a regular language, then there is a number p, called the pumping length, where if s is aword in A of length ≥ p then s can be divided into three parts, s = xyz , such that
1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.
Recall that each component x , y , z corresponed to one part in an accepting path in theDFA.
y corresponded to a cycle in the DFAx corresponded to a path from the initial node to the start of the cycle.z corresponded to a path from the end of the cycle to an accepting state.Condition (3) in the lemma was a useful tool when proving the nonregularity of a language.
INF2080 Lecture :: 15th February 9 / 32
![Page 26: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/26.jpg)
Pumping Lemma for Regular Languages
Lemma (Pumping Lemma for Regular Languages)
If A is a regular language, then there is a number p, called the pumping length, where if s is aword in A of length ≥ p then s can be divided into three parts, s = xyz , such that
1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.
Recall that each component x , y , z corresponed to one part in an accepting path in theDFA.y corresponded to a cycle in the DFA
x corresponded to a path from the initial node to the start of the cycle.z corresponded to a path from the end of the cycle to an accepting state.Condition (3) in the lemma was a useful tool when proving the nonregularity of a language.
INF2080 Lecture :: 15th February 9 / 32
![Page 27: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/27.jpg)
Pumping Lemma for Regular Languages
Lemma (Pumping Lemma for Regular Languages)
If A is a regular language, then there is a number p, called the pumping length, where if s is aword in A of length ≥ p then s can be divided into three parts, s = xyz , such that
1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.
Recall that each component x , y , z corresponed to one part in an accepting path in theDFA.y corresponded to a cycle in the DFAx corresponded to a path from the initial node to the start of the cycle.
z corresponded to a path from the end of the cycle to an accepting state.Condition (3) in the lemma was a useful tool when proving the nonregularity of a language.
INF2080 Lecture :: 15th February 9 / 32
![Page 28: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/28.jpg)
Pumping Lemma for Regular Languages
Lemma (Pumping Lemma for Regular Languages)
If A is a regular language, then there is a number p, called the pumping length, where if s is aword in A of length ≥ p then s can be divided into three parts, s = xyz , such that
1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.
Recall that each component x , y , z corresponed to one part in an accepting path in theDFA.y corresponded to a cycle in the DFAx corresponded to a path from the initial node to the start of the cycle.z corresponded to a path from the end of the cycle to an accepting state.
Condition (3) in the lemma was a useful tool when proving the nonregularity of a language.
INF2080 Lecture :: 15th February 9 / 32
![Page 29: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/29.jpg)
Pumping Lemma for Regular Languages
Lemma (Pumping Lemma for Regular Languages)
If A is a regular language, then there is a number p, called the pumping length, where if s is aword in A of length ≥ p then s can be divided into three parts, s = xyz , such that
1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.
Recall that each component x , y , z corresponed to one part in an accepting path in theDFA.y corresponded to a cycle in the DFAx corresponded to a path from the initial node to the start of the cycle.z corresponded to a path from the end of the cycle to an accepting state.Condition (3) in the lemma was a useful tool when proving the nonregularity of a language.
INF2080 Lecture :: 15th February 9 / 32
![Page 30: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/30.jpg)
Pumping Lemma for CFLs
Lemma (Pumping Lemma for CFLs)
For every context-free language A there exists a number p (called the pumping length) where,if s is a word in A of length ≥ p, then s can be divided into five parts, s = uvxyz , satisfying thefollowing conditions:
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
→ Things are a bit more involved this time!
INF2080 Lecture :: 15th February 10 / 32
![Page 31: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/31.jpg)
Pumping Lemma for CFLs
Lemma (Pumping Lemma for CFLs)
For every context-free language A there exists a number p (called the pumping length) where,if s is a word in A of length ≥ p, then s can be divided into five parts, s = uvxyz , satisfying thefollowing conditions:
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
→ Things are a bit more involved this time!
INF2080 Lecture :: 15th February 10 / 32
![Page 32: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/32.jpg)
Pumping Lemma for CFLs
Lemma (Pumping Lemma for CFLs)
For CFL A there exists a pumping length p where, if s ∈ A of length ≥ p, then s can bedivided into five parts, s = uvxyz , such that:
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof idea: Let G be the CFG generating A and τ a parse tree of s. If s is sufficientlylarge, we can argue that, along a path, a variable must occur twice.
INF2080 Lecture :: 15th February 11 / 32
![Page 33: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/33.jpg)
Pumping Lemma - Proof
Parse tree for s:
T
R
R
u v x y z
INF2080 Lecture :: 15th February 12 / 32
![Page 34: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/34.jpg)
Pumping Lemma - Proof
Parse tree for s:
T
R
R
u v x y z
INF2080 Lecture :: 15th February 12 / 32
![Page 35: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/35.jpg)
Pumping Lemma - Proof
T
R
u x z
→ uv0xy0z = uxz
INF2080 Lecture :: 15th February 13 / 32
![Page 36: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/36.jpg)
Pumping Lemma - Proof
T
R
u x z
→ uv0xy0z = uxz
INF2080 Lecture :: 15th February 13 / 32
![Page 37: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/37.jpg)
Pumping Lemma - Proof
T
R
R
u v x y z
INF2080 Lecture :: 15th February 14 / 32
![Page 38: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/38.jpg)
Pumping Lemma - Proof
T
R
R
Ru v
v x
y
y
z
→ uv2xy2z , and so on
INF2080 Lecture :: 15th February 15 / 32
![Page 39: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/39.jpg)
Pumping Lemma - Proof
T
R
R
Ru v
v x
y
y
z
→ uv2xy2z , and so on
INF2080 Lecture :: 15th February 15 / 32
![Page 40: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/40.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:Let G be the CFG generating A and b be the maximal number of symbols on the rightside of any rule in G .We can assume b ≥ 2, since any CFG is equivalent to a CFG in Chomsky normal form.Thus, in a parse tree, any node can have maximally b children.⇒ If a parse tree has height h, then it has at most bh leaves.
INF2080 Lecture :: 15th February 16 / 32
![Page 41: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/41.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:Let G be the CFG generating A and b be the maximal number of symbols on the rightside of any rule in G .
We can assume b ≥ 2, since any CFG is equivalent to a CFG in Chomsky normal form.Thus, in a parse tree, any node can have maximally b children.⇒ If a parse tree has height h, then it has at most bh leaves.
INF2080 Lecture :: 15th February 16 / 32
![Page 42: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/42.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:Let G be the CFG generating A and b be the maximal number of symbols on the rightside of any rule in G .We can assume b ≥ 2, since any CFG is equivalent to a CFG in Chomsky normal form.
Thus, in a parse tree, any node can have maximally b children.⇒ If a parse tree has height h, then it has at most bh leaves.
INF2080 Lecture :: 15th February 16 / 32
![Page 43: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/43.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:Let G be the CFG generating A and b be the maximal number of symbols on the rightside of any rule in G .We can assume b ≥ 2, since any CFG is equivalent to a CFG in Chomsky normal form.Thus, in a parse tree, any node can have maximally b children.
⇒ If a parse tree has height h, then it has at most bh leaves.
INF2080 Lecture :: 15th February 16 / 32
![Page 44: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/44.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:Let G be the CFG generating A and b be the maximal number of symbols on the rightside of any rule in G .We can assume b ≥ 2, since any CFG is equivalent to a CFG in Chomsky normal form.Thus, in a parse tree, any node can have maximally b children.⇒ If a parse tree has height h, then it has at most bh leaves.
INF2080 Lecture :: 15th February 16 / 32
![Page 45: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/45.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:If a parse tree has height h, then it has at most bh leaves.
Hence if a string has length bh + 1, then the parse tree must have height at least h + 1.Let |V | be the number of variables in the grammar G and set the pumping lengthp = b|V |+1.If |s| ≥ p, then its parse tree must have height at least |V |+ 1.
INF2080 Lecture :: 15th February 17 / 32
![Page 46: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/46.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:If a parse tree has height h, then it has at most bh leaves.Hence if a string has length bh + 1, then the parse tree must have height at least h + 1.
Let |V | be the number of variables in the grammar G and set the pumping lengthp = b|V |+1.If |s| ≥ p, then its parse tree must have height at least |V |+ 1.
INF2080 Lecture :: 15th February 17 / 32
![Page 47: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/47.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:If a parse tree has height h, then it has at most bh leaves.Hence if a string has length bh + 1, then the parse tree must have height at least h + 1.Let |V | be the number of variables in the grammar G and set the pumping lengthp = b|V |+1.
If |s| ≥ p, then its parse tree must have height at least |V |+ 1.
INF2080 Lecture :: 15th February 17 / 32
![Page 48: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/48.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:If a parse tree has height h, then it has at most bh leaves.Hence if a string has length bh + 1, then the parse tree must have height at least h + 1.Let |V | be the number of variables in the grammar G and set the pumping lengthp = b|V |+1.If |s| ≥ p, then its parse tree must have height at least |V |+ 1.
INF2080 Lecture :: 15th February 17 / 32
![Page 49: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/49.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:If |s| ≥ p, then its parse tree must have height at least|V |+ 1.
Let τ be the parse tree with the smallest number of nodes
It has height at least |V |+ 1, so the longest path from T toa leaf has length ≥ |V |+ 1, i.e., it contains ≥ |V |+ 2 nodes.The path must have at least |V |+ 1 variables. But G onlyhas |V | variables, hence one must occur twice!
T
R
R
INF2080 Lecture :: 15th February 18 / 32
![Page 50: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/50.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:If |s| ≥ p, then its parse tree must have height at least|V |+ 1.Let τ be the parse tree with the smallest number of nodes
It has height at least |V |+ 1, so the longest path from T toa leaf has length ≥ |V |+ 1, i.e., it contains ≥ |V |+ 2 nodes.The path must have at least |V |+ 1 variables. But G onlyhas |V | variables, hence one must occur twice!
T
R
R
INF2080 Lecture :: 15th February 18 / 32
![Page 51: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/51.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:If |s| ≥ p, then its parse tree must have height at least|V |+ 1.Let τ be the parse tree with the smallest number of nodes
It has height at least |V |+ 1, so the longest path from T toa leaf has length ≥ |V |+ 1, i.e., it contains ≥ |V |+ 2 nodes.The path must have at least |V |+ 1 variables. But G onlyhas |V | variables, hence one must occur twice!
T
R
R
INF2080 Lecture :: 15th February 18 / 32
![Page 52: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/52.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:If |s| ≥ p, then its parse tree must have height at least|V |+ 1.Let τ be the parse tree with the smallest number of nodesIt has height at least |V |+ 1, so the longest path from T toa leaf has length ≥ |V |+ 1, i.e., it contains ≥ |V |+ 2 nodes.
The path must have at least |V |+ 1 variables. But G onlyhas |V | variables, hence one must occur twice!
T
R
R
INF2080 Lecture :: 15th February 18 / 32
![Page 53: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/53.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:If |s| ≥ p, then its parse tree must have height at least|V |+ 1.Let τ be the parse tree with the smallest number of nodesIt has height at least |V |+ 1, so the longest path from T toa leaf has length ≥ |V |+ 1, i.e., it contains ≥ |V |+ 2 nodes.The path must have at least |V |+ 1 variables. But G onlyhas |V | variables, hence one must occur twice!
T
R
R
INF2080 Lecture :: 15th February 18 / 32
![Page 54: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/54.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:If |s| ≥ p, then its parse tree must have height at least|V |+ 1.Let τ be the parse tree with the smallest number of nodesIt has height at least |V |+ 1, so the longest path from T toa leaf has length ≥ |V |+ 1, i.e., it contains ≥ |V |+ 2 nodes.The path must have at least |V |+ 1 variables. But G onlyhas |V | variables, hence one must occur twice!
T
R
R
INF2080 Lecture :: 15th February 18 / 32
![Page 55: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/55.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:But the path could be much longer than |V |+ 1, so wechoose R to be a repeating variable from the lowest |V |+ 1variables.
We get the situation we looked at before and subdivides = uvxyz .
T
R
R
u v x y z
INF2080 Lecture :: 15th February 19 / 32
![Page 56: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/56.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:But the path could be much longer than |V |+ 1, so wechoose R to be a repeating variable from the lowest |V |+ 1variables.We get the situation we looked at before and subdivides = uvxyz .
T
R
R
u v x y z
INF2080 Lecture :: 15th February 19 / 32
![Page 57: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/57.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:But the path could be much longer than |V |+ 1, so wechoose R to be a repeating variable from the lowest |V |+ 1variables.We get the situation we looked at before and subdivides = uvxyz .
T
R
R
u v x y z
INF2080 Lecture :: 15th February 19 / 32
![Page 58: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/58.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:The first occurence of R generates vxy , while the secondgenerates x (remember, only using rules from G),
Thus we can replace one subtree with the other and get validparse trees for uxz and uv ixy iz , i > 1.This proves condition 1.
T
R
R
u v x y z
INF2080 Lecture :: 15th February 20 / 32
![Page 59: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/59.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:The first occurence of R generates vxy , while the secondgenerates x (remember, only using rules from G),Thus we can replace one subtree with the other and get validparse trees for uxz and uv ixy iz , i > 1.
This proves condition 1.
T
R
R
u v x y z
INF2080 Lecture :: 15th February 20 / 32
![Page 60: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/60.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:The first occurence of R generates vxy , while the secondgenerates x (remember, only using rules from G),Thus we can replace one subtree with the other and get validparse trees for uxz and uv ixy iz , i > 1.
This proves condition 1.
T
R
u x z
INF2080 Lecture :: 15th February 20 / 32
![Page 61: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/61.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:The first occurence of R generates vxy , while the secondgenerates x (remember, only using rules from G),Thus we can replace one subtree with the other and get validparse trees for uxz and uv ixy iz , i > 1.
This proves condition 1.
T
R
R
Ru v
v x
y
y
z
INF2080 Lecture :: 15th February 20 / 32
![Page 62: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/62.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:The first occurence of R generates vxy , while the secondgenerates x (remember, only using rules from G),Thus we can replace one subtree with the other and get validparse trees for uxz and uv ixy iz , i > 1.This proves condition 1.
T
R
R
Ru v
v x
y
y
z
INF2080 Lecture :: 15th February 20 / 32
![Page 63: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/63.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:
For condition 2, assume, to the contrary, that v = y = ε.
Then replacing the first R (generating vxy) with the secondR (generating x) gives us a smaller parse tree for s.
Contradiction! We assumed the parse tree was the smallest
T
R
R
u v x y z
INF2080 Lecture :: 15th February 21 / 32
![Page 64: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/64.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:
For condition 2, assume, to the contrary, that v = y = ε.Then replacing the first R (generating vxy) with the secondR (generating x) gives us a smaller parse tree for s.
Contradiction! We assumed the parse tree was the smallest
T
R
R
u v x y z
INF2080 Lecture :: 15th February 21 / 32
![Page 65: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/65.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:For condition 2, assume, to the contrary, that v = y = ε.Then replacing the first R (generating vxy) with the secondR (generating x) gives us a smaller parse tree for s.
Contradiction! We assumed the parse tree was the smallest
T
R
u x z
INF2080 Lecture :: 15th February 21 / 32
![Page 66: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/66.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:For condition 2, assume, to the contrary, that v = y = ε.Then replacing the first R (generating vxy) with the secondR (generating x) gives us a smaller parse tree for s.Contradiction! We assumed the parse tree was the smallest
T
R
u x z
INF2080 Lecture :: 15th February 21 / 32
![Page 67: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/67.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:Condition 3: We chose the Rs such that they lie in thelowest |V |+ 1 variables on the path.
Hence the subtree generated by the first R (which generatesvxy) has height at most |V |+ 1.Thus that subtree has at most b|V |+1 leaves.
⇒ |vxy | ≤ b|V |+1 = p
T
R
R
u v x y z
INF2080 Lecture :: 15th February 22 / 32
![Page 68: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/68.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:Condition 3: We chose the Rs such that they lie in thelowest |V |+ 1 variables on the path.Hence the subtree generated by the first R (which generatesvxy) has height at most |V |+ 1.
Thus that subtree has at most b|V |+1 leaves.
⇒ |vxy | ≤ b|V |+1 = p
T
R
R
u v x y z
INF2080 Lecture :: 15th February 22 / 32
![Page 69: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/69.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:Condition 3: We chose the Rs such that they lie in thelowest |V |+ 1 variables on the path.Hence the subtree generated by the first R (which generatesvxy) has height at most |V |+ 1.Thus that subtree has at most b|V |+1 leaves.
⇒ |vxy | ≤ b|V |+1 = p
T
R
R
u v x y z
INF2080 Lecture :: 15th February 22 / 32
![Page 70: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/70.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:Condition 3: We chose the Rs such that they lie in thelowest |V |+ 1 variables on the path.Hence the subtree generated by the first R (which generatesvxy) has height at most |V |+ 1.Thus that subtree has at most b|V |+1 leaves.⇒ |vxy | ≤ b|V |+1 = p
T
R
R
u v x y z
INF2080 Lecture :: 15th February 22 / 32
![Page 71: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/71.jpg)
Pumping Lemma - Proof
Lemma (Pumping Lemma for CFLs)
CFL A, s ∈ A with |s| ≥ p, then s = uvxyz , such that:1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Proof:Condition 3: We chose the Rs such that they lie in thelowest |V |+ 1 variables on the path.Hence the subtree generated by the first R (which generatesvxy) has height at most |V |+ 1.Thus that subtree has at most b|V |+1 leaves.⇒ |vxy | ≤ b|V |+1 = p
T
R
R
u v x y z
INF2080 Lecture :: 15th February 22 / 32
![Page 72: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/72.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A1 = {anbncn | n ≥ 0}.Assume A1 is context-free.
Then let p be its pumping length and s = apbpcp.|s| = 3p ≥ p and s ∈ A1 X
Now we consider how we can subdivide s into uvxyz .Condition 2: v or y must be nonempty.
INF2080 Lecture :: 15th February 23 / 32
![Page 73: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/73.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A1 = {anbncn | n ≥ 0}.Assume A1 is context-free. Then let p be its pumping length and s = apbpcp.|s| = 3p ≥ p and s ∈ A1
X
Now we consider how we can subdivide s into uvxyz .Condition 2: v or y must be nonempty.
INF2080 Lecture :: 15th February 23 / 32
![Page 74: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/74.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A1 = {anbncn | n ≥ 0}.Assume A1 is context-free. Then let p be its pumping length and s = apbpcp.|s| = 3p ≥ p and s ∈ A1 X
Now we consider how we can subdivide s into uvxyz .Condition 2: v or y must be nonempty.
INF2080 Lecture :: 15th February 23 / 32
![Page 75: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/75.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A1 = {anbncn | n ≥ 0}.Assume A1 is context-free. Then let p be its pumping length and s = apbpcp.|s| = 3p ≥ p and s ∈ A1 X
Now we consider how we can subdivide s into uvxyz .Condition 2: v or y must be nonempty.
INF2080 Lecture :: 15th February 23 / 32
![Page 76: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/76.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A1 = {anbncn | n ≥ 0}.Case 1: Either v or y contains more than one type of symbol.
Then uv2xy2z does not have the symbols in the correct order. Contradiction!
INF2080 Lecture :: 15th February 24 / 32
![Page 77: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/77.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A1 = {anbncn | n ≥ 0}.Case 1: Either v or y contains more than one type of symbol.Then uv2xy2z does not have the symbols in the correct order.
Contradiction!
INF2080 Lecture :: 15th February 24 / 32
![Page 78: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/78.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A1 = {anbncn | n ≥ 0}.Case 1: Either v or y contains more than one type of symbol.Then uv2xy2z does not have the symbols in the correct order. Contradiction!
INF2080 Lecture :: 15th February 24 / 32
![Page 79: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/79.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A1 = {anbncn | n ≥ 0}.Case 2: Both v and y contains only one type of symbol.
Then v and y cannot contain both a’s and b’s or both b’s and c ’s.But then uv2xy2z cannot have an equal number of a’s, b’s, and c ’s. Contradiction!s cannot be pumped.A3 is, in fact, context-sensitive (more on that in a later lecture)
INF2080 Lecture :: 15th February 25 / 32
![Page 80: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/80.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A1 = {anbncn | n ≥ 0}.Case 2: Both v and y contains only one type of symbol.Then v and y cannot contain both a’s and b’s or both b’s and c ’s.
But then uv2xy2z cannot have an equal number of a’s, b’s, and c ’s. Contradiction!s cannot be pumped.A3 is, in fact, context-sensitive (more on that in a later lecture)
INF2080 Lecture :: 15th February 25 / 32
![Page 81: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/81.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A1 = {anbncn | n ≥ 0}.Case 2: Both v and y contains only one type of symbol.Then v and y cannot contain both a’s and b’s or both b’s and c ’s.But then uv2xy2z cannot have an equal number of a’s, b’s, and c ’s.
Contradiction!s cannot be pumped.A3 is, in fact, context-sensitive (more on that in a later lecture)
INF2080 Lecture :: 15th February 25 / 32
![Page 82: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/82.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A1 = {anbncn | n ≥ 0}.Case 2: Both v and y contains only one type of symbol.Then v and y cannot contain both a’s and b’s or both b’s and c ’s.But then uv2xy2z cannot have an equal number of a’s, b’s, and c ’s. Contradiction!s cannot be pumped.
A3 is, in fact, context-sensitive (more on that in a later lecture)
INF2080 Lecture :: 15th February 25 / 32
![Page 83: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/83.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A1 = {anbncn | n ≥ 0}.Case 2: Both v and y contains only one type of symbol.Then v and y cannot contain both a’s and b’s or both b’s and c ’s.But then uv2xy2z cannot have an equal number of a’s, b’s, and c ’s. Contradiction!s cannot be pumped.A3 is, in fact, context-sensitive (more on that in a later lecture)
INF2080 Lecture :: 15th February 25 / 32
![Page 84: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/84.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A2 = {aibjck | 0 ≤ i ≤ j ≤ k}.Same as before, assume A2 is context-free and let s = apbpcp. Again, s = uvxyz .
Case 1: Same argument as before. If either v or y contains more than one type of symbol,then uv2xy2z will not have the right order of symbols. Contradiction!
INF2080 Lecture :: 15th February 26 / 32
![Page 85: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/85.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A2 = {aibjck | 0 ≤ i ≤ j ≤ k}.Same as before, assume A2 is context-free and let s = apbpcp. Again, s = uvxyz .Case 1: Same argument as before. If either v or y contains more than one type of symbol,then uv2xy2z will not have the right order of symbols.
Contradiction!
INF2080 Lecture :: 15th February 26 / 32
![Page 86: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/86.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A2 = {aibjck | 0 ≤ i ≤ j ≤ k}.Same as before, assume A2 is context-free and let s = apbpcp. Again, s = uvxyz .Case 1: Same argument as before. If either v or y contains more than one type of symbol,then uv2xy2z will not have the right order of symbols. Contradiction!
INF2080 Lecture :: 15th February 26 / 32
![Page 87: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/87.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A2 = {aibjck | 0 ≤ i ≤ j ≤ k}, s = apbpcp.Case 2: If both v and y contain only one type of symbol, then we cannot use the samereasoning as in the last example (the number of a’s, b’s, and c ’s are different now!)
However, since each contains only one type of symbol, one symbol a, b, or c does notoccur in v or y .
INF2080 Lecture :: 15th February 27 / 32
![Page 88: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/88.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A2 = {aibjck | 0 ≤ i ≤ j ≤ k}, s = apbpcp.Case 2: If both v and y contain only one type of symbol, then we cannot use the samereasoning as in the last example (the number of a’s, b’s, and c ’s are different now!)However, since each contains only one type of symbol, one symbol a, b, or c does notoccur in v or y .
INF2080 Lecture :: 15th February 27 / 32
![Page 89: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/89.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A2 = {aibjck | 0 ≤ i ≤ j ≤ k}, s = apbpcp.Case 2a: a does not appear.
Then consider the string uxz . This has the same amount (p)of a’s as s, but fewer b’s and c ’s. Contradiction!Case 2b: b does not appear. Then either a’s or c ’s must occur in v or y (both cannot beempty). If a’s appear, then uv2xy2z has more a’s than b’s. If c ’s appear, then uxz hasmore b’s than c ’s, contradiction!Case 2c: c does not appear. Then the string uv2xy2z contains more a’s or b’s than c ’s,contradiction!
INF2080 Lecture :: 15th February 28 / 32
![Page 90: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/90.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A2 = {aibjck | 0 ≤ i ≤ j ≤ k}, s = apbpcp.Case 2a: a does not appear. Then consider the string uxz . This has the same amount (p)of a’s as s, but fewer b’s and c ’s.
Contradiction!Case 2b: b does not appear. Then either a’s or c ’s must occur in v or y (both cannot beempty). If a’s appear, then uv2xy2z has more a’s than b’s. If c ’s appear, then uxz hasmore b’s than c ’s, contradiction!Case 2c: c does not appear. Then the string uv2xy2z contains more a’s or b’s than c ’s,contradiction!
INF2080 Lecture :: 15th February 28 / 32
![Page 91: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/91.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A2 = {aibjck | 0 ≤ i ≤ j ≤ k}, s = apbpcp.Case 2a: a does not appear. Then consider the string uxz . This has the same amount (p)of a’s as s, but fewer b’s and c ’s. Contradiction!Case 2b: b does not appear.
Then either a’s or c ’s must occur in v or y (both cannot beempty). If a’s appear, then uv2xy2z has more a’s than b’s. If c ’s appear, then uxz hasmore b’s than c ’s, contradiction!Case 2c: c does not appear. Then the string uv2xy2z contains more a’s or b’s than c ’s,contradiction!
INF2080 Lecture :: 15th February 28 / 32
![Page 92: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/92.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A2 = {aibjck | 0 ≤ i ≤ j ≤ k}, s = apbpcp.Case 2a: a does not appear. Then consider the string uxz . This has the same amount (p)of a’s as s, but fewer b’s and c ’s. Contradiction!Case 2b: b does not appear. Then either a’s or c ’s must occur in v or y (both cannot beempty).
If a’s appear, then uv2xy2z has more a’s than b’s. If c ’s appear, then uxz hasmore b’s than c ’s, contradiction!Case 2c: c does not appear. Then the string uv2xy2z contains more a’s or b’s than c ’s,contradiction!
INF2080 Lecture :: 15th February 28 / 32
![Page 93: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/93.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A2 = {aibjck | 0 ≤ i ≤ j ≤ k}, s = apbpcp.Case 2a: a does not appear. Then consider the string uxz . This has the same amount (p)of a’s as s, but fewer b’s and c ’s. Contradiction!Case 2b: b does not appear. Then either a’s or c ’s must occur in v or y (both cannot beempty). If a’s appear, then uv2xy2z has more a’s than b’s.
If c ’s appear, then uxz hasmore b’s than c ’s, contradiction!Case 2c: c does not appear. Then the string uv2xy2z contains more a’s or b’s than c ’s,contradiction!
INF2080 Lecture :: 15th February 28 / 32
![Page 94: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/94.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A2 = {aibjck | 0 ≤ i ≤ j ≤ k}, s = apbpcp.Case 2a: a does not appear. Then consider the string uxz . This has the same amount (p)of a’s as s, but fewer b’s and c ’s. Contradiction!Case 2b: b does not appear. Then either a’s or c ’s must occur in v or y (both cannot beempty). If a’s appear, then uv2xy2z has more a’s than b’s. If c ’s appear, then uxz hasmore b’s than c ’s, contradiction!Case 2c: c does not appear.
Then the string uv2xy2z contains more a’s or b’s than c ’s,contradiction!
INF2080 Lecture :: 15th February 28 / 32
![Page 95: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/95.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A2 = {aibjck | 0 ≤ i ≤ j ≤ k}, s = apbpcp.Case 2a: a does not appear. Then consider the string uxz . This has the same amount (p)of a’s as s, but fewer b’s and c ’s. Contradiction!Case 2b: b does not appear. Then either a’s or c ’s must occur in v or y (both cannot beempty). If a’s appear, then uv2xy2z has more a’s than b’s. If c ’s appear, then uxz hasmore b’s than c ’s, contradiction!Case 2c: c does not appear. Then the string uv2xy2z contains more a’s or b’s than c ’s,contradiction!
INF2080 Lecture :: 15th February 28 / 32
![Page 96: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/96.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Assume A3 is CF, and choose s = 0p10p1.
set u = 0p−1, v = 0, x = 1, y = 0, and z = 0p−11. Then s = uvxyz .But this can be pumped! uv ixy iz is still a word in A3.We need to be more careful with our choice of s.
INF2080 Lecture :: 15th February 29 / 32
![Page 97: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/97.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Assume A3 is CF, and choose s = 0p10p1.set u = 0p−1, v = 0, x = 1, y = 0, and z = 0p−11. Then s = uvxyz .
But this can be pumped! uv ixy iz is still a word in A3.We need to be more careful with our choice of s.
INF2080 Lecture :: 15th February 29 / 32
![Page 98: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/98.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Assume A3 is CF, and choose s = 0p10p1.set u = 0p−1, v = 0, x = 1, y = 0, and z = 0p−11. Then s = uvxyz .But this can be pumped! uv ixy iz is still a word in A3.
We need to be more careful with our choice of s.
INF2080 Lecture :: 15th February 29 / 32
![Page 99: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/99.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Assume A3 is CF, and choose s = 0p10p1.set u = 0p−1, v = 0, x = 1, y = 0, and z = 0p−11. Then s = uvxyz .But this can be pumped! uv ixy iz is still a word in A3.We need to be more careful with our choice of s.
INF2080 Lecture :: 15th February 29 / 32
![Page 100: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/100.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Let s = 0p1p0p1p. We will make use of condition 3, so |vxy | ≤ p.
Two options: vxy is contained in the first or second half of s, or covers the middle.If vxy is contained in the first half, then pumping up to uv2xy2z “pushes” a 1 to the firstposition of the second half. But this is not a word in A3.Example: 000111 000111, where v and y are green. pumping up to uv2xy2z yields0000111 1000111
INF2080 Lecture :: 15th February 30 / 32
![Page 101: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/101.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Let s = 0p1p0p1p. We will make use of condition 3, so |vxy | ≤ p.Two options: vxy is contained in the first or second half of s, or covers the middle.
If vxy is contained in the first half, then pumping up to uv2xy2z “pushes” a 1 to the firstposition of the second half. But this is not a word in A3.Example: 000111 000111, where v and y are green. pumping up to uv2xy2z yields0000111 1000111
INF2080 Lecture :: 15th February 30 / 32
![Page 102: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/102.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Let s = 0p1p0p1p. We will make use of condition 3, so |vxy | ≤ p.Two options: vxy is contained in the first or second half of s, or covers the middle.If vxy is contained in the first half, then pumping up to uv2xy2z “pushes” a 1 to the firstposition of the second half.
But this is not a word in A3.Example: 000111 000111, where v and y are green. pumping up to uv2xy2z yields0000111 1000111
INF2080 Lecture :: 15th February 30 / 32
![Page 103: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/103.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Let s = 0p1p0p1p. We will make use of condition 3, so |vxy | ≤ p.Two options: vxy is contained in the first or second half of s, or covers the middle.If vxy is contained in the first half, then pumping up to uv2xy2z “pushes” a 1 to the firstposition of the second half. But this is not a word in A3.
Example: 000111 000111, where v and y are green. pumping up to uv2xy2z yields0000111 1000111
INF2080 Lecture :: 15th February 30 / 32
![Page 104: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/104.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Let s = 0p1p0p1p. We will make use of condition 3, so |vxy | ≤ p.Two options: vxy is contained in the first or second half of s, or covers the middle.If vxy is contained in the first half, then pumping up to uv2xy2z “pushes” a 1 to the firstposition of the second half. But this is not a word in A3.Example: 000111 000111, where v and y are green. pumping up to uv2xy2z yields0000111 1000111
INF2080 Lecture :: 15th February 30 / 32
![Page 105: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/105.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Let s = 0p1p0p1p. We will make use of condition 3, so |vxy | ≤ p.Two options: vxy is contained in the first or second half of s, or covers the middle.If vxy is contained in the second half, then pumping up to uv2xy2z “pushes” a 0 to thelast position of the first half. Contradiction.
Example: 000111 000111, where v and y are green. pumping up to uv2xy2z yields0001110 0000111
INF2080 Lecture :: 15th February 31 / 32
![Page 106: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/106.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Let s = 0p1p0p1p. We will make use of condition 3, so |vxy | ≤ p.Two options: vxy is contained in the first or second half of s, or covers the middle.If vxy is contained in the second half, then pumping up to uv2xy2z “pushes” a 0 to thelast position of the first half. Contradiction.Example: 000111 000111, where v and y are green. pumping up to uv2xy2z yields0001110 0000111
INF2080 Lecture :: 15th February 31 / 32
![Page 107: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/107.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Now assume vxy covers the middle.
Then pumping s down to uxz yields something of theform 0p1i0j1p. Since v and y are not both empty, i and j cannot both equal p. ⇒ not aword in A3
Hence s cannot be pumped. ⇒ A3 is not context-free
INF2080 Lecture :: 15th February 32 / 32
![Page 108: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/108.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Now assume vxy covers the middle. Then pumping s down to uxz yields something of theform 0p1i0j1p.
Since v and y are not both empty, i and j cannot both equal p. ⇒ not aword in A3
Hence s cannot be pumped. ⇒ A3 is not context-free
INF2080 Lecture :: 15th February 32 / 32
![Page 109: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/109.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Now assume vxy covers the middle. Then pumping s down to uxz yields something of theform 0p1i0j1p. Since v and y are not both empty, i and j cannot both equal p.
⇒ not aword in A3
Hence s cannot be pumped. ⇒ A3 is not context-free
INF2080 Lecture :: 15th February 32 / 32
![Page 110: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/110.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Now assume vxy covers the middle. Then pumping s down to uxz yields something of theform 0p1i0j1p. Since v and y are not both empty, i and j cannot both equal p. ⇒ not aword in A3
Hence s cannot be pumped. ⇒ A3 is not context-free
INF2080 Lecture :: 15th February 32 / 32
![Page 111: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/111.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Now assume vxy covers the middle. Then pumping s down to uxz yields something of theform 0p1i0j1p. Since v and y are not both empty, i and j cannot both equal p. ⇒ not aword in A3
Hence s cannot be pumped.
⇒ A3 is not context-free
INF2080 Lecture :: 15th February 32 / 32
![Page 112: INF2080 - uio.no€¦ · INF2080 Non-Context-FreeLangugaes DanielLupp Universitetet i Oslo 15thFebruary2018 Department of Informatics University of Oslo INF2080 Lecture :: 15th February](https://reader034.vdocuments.pub/reader034/viewer/2022042803/5f447628f5004161dc2286a6/html5/thumbnails/112.jpg)
Pumping Lemma - Examples
Lemma (Pumping Lemma for CFLs)
1 uv ixy iz ∈ A for all i ≥ 0,2 |vy | > 0,3 |vxy | ≤ p.
Language: A3 = {ωω |ω ∈ {0, 1}∗}.Now assume vxy covers the middle. Then pumping s down to uxz yields something of theform 0p1i0j1p. Since v and y are not both empty, i and j cannot both equal p. ⇒ not aword in A3
Hence s cannot be pumped. ⇒ A3 is not context-free
INF2080 Lecture :: 15th February 32 / 32