Вы находитесь на странице: 1из 46

Pumping lemma for CFL,

DVA337 HT17 – LECTURE 12 countable and uncountable sets


and two uncomputability results
RECAP, PUMPING REGULAR LANGUAGES
y

For w ∈ L, |w| ≥ |Q|


 we can write w = xyz
 and have that xyiz ∈ L, for i ≥ 0

such that
 |y| ≥ 1
 |xz| < |w|
 |xy| ≤ |w|
...... q ......

Pumping lemma shows fundamental x z


structure of regular languages imposed
by structure of DFA

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

To prove that a language is not regular, proceed by a proof by contradiction


 Assume regular – the pumping lemma should hold for the language
 Find string in the language L that is longer than m such that
 all decompositions subject to the restrictions of the pumping lemma have at least
 one ‘pump’ that is not in the language, i.e, xyiz ∉ L
 This contradicts the assumption that the language is regular.
LIMITATIONS OF THE PUMPING LEMMA
Not that the pumping lemma for regular langauges can only be used to prove that a
language is not regular.
 it can never prove that a language is regular – why?
¬Pump(L) =
∀m ∃w . w ∈ L ∧ |w| ≥ m ∧

EXERCISE L
∀x,y,z . w = xyz ∧ |xy| ≤ m ∧ |y| ≥ 1 → ∃i . xyiz ∉

Prove that L = { w : w ∈ {0,1}*, |w|0 = |w|1 } is not regular


EXERCISE
Create NPDA that recognizes L = { w : w ∈ {0,1}*, |w|0 = |w|1 }
NORMAL FORMS
NORMAL FORM
A normal form of something is a more restricted version that
 is simpler than the general form
 has the same expressivity as the general form

What other normal forms have we seen in the course so far?


CHOMSKY NORMAL FORM
A context-free grammar is on Chomsky normal form if all productions are on the form
 A → BC or
 A → a, where
 A, B, C ∈ V and a ∈ T

It is a normal form since


 ∀G ∈ CNF ∃G’ ∈ CFG . L(G) = L(G’) (by definition) and
 ∀G ∈ CFG ∃G’ ∈ CNF . L(G) = L(G’) (see book 6.2)

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

S ⇒ AB ⇒ aBbB ⇒ abbB ⇒ abbSb ⇒ abbABb ⇒ abbaBbBb ⇒ abbabbBb


⇒ abbabbbb

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

WE CAN PUMP SUBTREES S 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

Then uvixyiz ∈ L(G) for all i ≥ 0 v y


A

x
JUSTIFICATION
Let G be a CNF grammar
 with n non-terminals
 pick w, |w| ≥ 2n

A derivation tree of w must have a path


of length n + 1 or more
 the full tree with maximum path length n can
only yield strings of length 2n-1

Consider a longest path for derivation


tree of w
 at least one non-terminal must be repeated
among the lowest n+1 variables
PUMP LEMMA FOR CONTEXT-FREE LANGUAGES
S
For an infinite context-free language L
there exists integer m such that
for any string w ∈ L that satisfies |w| ≥ m
u z
we can write w = uvxyz with A
|vxy| ≤ m and |vy| ≥ 1 such that
uvixyiz ∈ L, for all i ≥ 0 v y
A

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

Pumping lemma for context-free languages


Pump-CFL(L) = ∃m ∀w . w ∈ L ∧ |w| ≥ m →
∃u,v,x,y,z . w = uvxyz ∧ |vxy| ≤ m ∧ |vy| ≥ 1 ∧ ∀i . uvixyiz ∈ L
APPLICATIONS OF THE PUMPING
LEMMA
COMPARE
Pumping lemma for context-free languages
Pump-CFL(L) = ∃m ∀w . w ∈ L ∧ |w| ≥ m →
∃u,v,x,y,z . w = uvxyz ∧ |vxy| ≤ m ∧ |vy| ≥ 1 ∧ ∀i . uvixyiz ∈ L

Use of pumping lemma for context-free languages


 to prove that a language is not context free,
 find a string w subject to the restrictions and
 show that none of the decompositions can be pumped
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.
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

A partial function is defined only for some input elements


PROPERTIES OF FUNCTIONS
Injective, one-to-one

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∈ℕ

if n is a natural number, then n + 1 is a natural number,


 ∀n ∈ ℕ . n + 1 ∈ ℕ

ℕ is by necessity an infinite set, can be ‘created’ by an infinite process


NATURAL NUMBERS
A fixed point of a function f : A → A is an element a ∈ A such that
 f(a) = a

We formalized this process, imagine a function on sets defined by


 F(X) = { 0 } ∪ { n + 1 : n ∈ X }

We have that F(ℕ) = ℕ


 ℕ is a fixed point of F

ℕ can be computed by (infinite) iteration


CARDINALITY
The cardinality |A| of a finite set A is the number of elements.
The cardinality of |ℕ| = ℵ0

If there exists a (total) injective function f : A → ℕ


 what can we say about the cardinality of A?
COUNTABLE SET
A set A is countable if it does not have more elements than the natural numbers
 i.e., there exists an injective function f : A → ℕ (called an enumeration procedure)

Is the set of integers, ℤ = { ... -2, -1, 0, 1, 2 ... }, countable?


QUESTION
Is the set of (positive) rational numbers, ℝ+ = { a/b : a,b ∈ ℕ } countable?
QUESTION
What about the set rational numbers, ℝ = { a/b : a,b ∈ ℤ }?
EXERCISE
Show that {a,b}+ is countable.

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

Observation: an infinite string over ℕ can be seen as a function f : ℕ → ℕ


 why?
OUR FIRST UNCOMPUTABILITY RESULT
Not all functions are computable.
POWERSET
Theorem: The power set of natural numbers, P(ℕ) is uncountable.
Proof: By contradiction. Argument similar to Cantor’s diagonalization proof.

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

Consider the set of all languages over Σ


 infinite and uncountable

A grammar is a string in the language of all grammars


 only countably many grammars

Not all languages can be described!


HOW MANY?
How many languages can be described?
How many functions can be computed?
SUMMARY
Pumping lemma for RL – repetition
Pumping lemma for CFL
Functions in set theory
Countable and uncountable sets

Uncomputability result for


 mathematical functions
 languages

Вам также может понравиться