Академический Документы
Профессиональный Документы
Культура Документы
such that
|y| ≥ 1
|xz| < |w|
|xy| ≤ |w|
...... q ......
2
PUMPING LEMMA FOR REGULAR LANGUAGES
Pumping lemma for regular languages
Pump-REL(L) = ∃m ∀w . w ∈ L ∧ |w| ≥ m →
∃x,y,z . w = xyz ∧ |xy| ≤ m ∧ |y| ≥ 1 ∧ ∀i . xyiz ∈ L
EXERCISE L
∀x,y,z . w = xyz ∧ |xy| ≤ m ∧ |y| ≥ 1 → ∃i . xyiz ∉
9
THE PUMPING LEMMA for context-free languages
PUMPING LEMMA FOR CONTEXT-FREE LANGUAGES
Consider derivations in CFG
S → AB
A → aBb
B → Sb | b
11
DERIVATION TREE
S
For abbabbbb in
A B
S → AB
A → aBb
a B b S b
B → Sb | b
A B
b
a B b b
b
12
B
A B
B aBbbb a B b b
S b
A B
a B b b
B aBbbb aaBbbbbbb
13
WE CAN PUMP SUBTREES
We have that
B⇒b
B ⇒* aBbbb
S ⇒* abbaBbbb
Therefore
S ⇒* abbaBbbb ⇒ abbabbbb = abba(a)0b(bbb)0bbb
⇒* abba(aBbbb)bbb ⇒ abba(a)1b(bbb)1bbb
⇒* abba(a(aBbbb)bbb)bbb ⇒ abba(a)2b(bbb)2bbb
...
⇒* abba(a)ib(bbb)ibbb
OTHER PUMPS?
For
S → AB
A → aBb
B → Sb | b
We have that
B⇒b
B ⇒* abbBb
B ⇒* aBbbb
S ⇒* abbaBbbb
S ⇒* aBbb
IN GENERAL
S
If we have a derivation loop
A ⇒* vAy
A ⇒* x u z
That can be reached from the start symbol A
S ⇒* uAz
x
JUSTIFICATION
Let G be a CNF grammar
with n non-terminals
pick w, |w| ≥ 2n
x
COMPARE
Pumping lemma for regular languages
Pump-REL(L) = ∃m ∀w . w ∈ L ∧ |w| ≥ m →
∃x,y,z . w = xyz ∧ |xy| ≤ m ∧ |y| ≥ 1 ∧ ∀i . xyiz ∈ L
EXAMPLE
Theorem: L = { anbncn : n ≥ 0 } is not context free.
Pump-CFL(L) = ∃m ∀w . w ∈ L ∧ |w| ≥ m →
∃u,v,x,y,z . w = uvxyz ∧ |vxy| ≤ m ∧ |vy| ≥ 1 ∧ ∀i . uvixyiz ∈ L
EXAMPLE
Theorem: L = { anbncn : n ≥ 0 } is not context free.
Case 2: aaa...aaabbb...bbbccc...ccc
Case 3: aaa...aaabbb...bbbccc...ccc
Pump-CFL(L) = ∃m ∀w . w ∈ L ∧ |w| ≥ m →
∃u,v,x,y,z . w = uvxyz ∧ |vxy| ≤ m ∧ |vy| ≥ 1 ∧ ∀i . uvixyiz ∈ L
EXAMPLE
Theorem: L = { anbncn : n ≥ 0 } is not context free.
Case 4: aaa...aaabbb...bbbccc...ccc
Case 5: aaa...aaabbb...bbbccc...ccc
EXERCISE
Show that L = { ww : w ∈ {a,b}* } is not context free.
OBSERVATION
We cannot use the pumping lemmas to prove that a language is regular (or context
free)
The pumping lemmas identify a certain structure that all regular (or context free)
languages have.
It does not state that only the regular (or context free) languages have this structure!
FUNCTIONS
FUNCTION
How can we define what a function is?
PROPERTIES OF FUNCTIONS
A total function is defined for all input elements
Surjective, onto
Bijective
injective and surjective
EXERCISE
Draw a picture of a function that
is injective but not surjective
is surjective but not injective
QUESTION
If there is an injective (total) function f : A → B
what can be said about the sizes of A and B?
What about
a bijective function f : A → B
two injective functions f : A → B, and g : B → A
NATURAL NUMBERS
0 is a natural number,
0∈ℕ
What about
language generated by regular grammar?
language generated by context-free grammar?
SET OF INFINITE STRINGS
Theorem: the set of all infinite strings over {0,1} is uncountable.
Proof.
SET OF INFINITE STRINGS
Corollary: the set of all infinite strings over ℕ is uncountable
Not surprising
the set of all functions is P(ℕ⨯ℕ)
OUR SECOND UNCOMPUTABILITY RESULT
Consider the set of all strings over some alphabet Σ
infinite and countable