1. Free Ebooks Download
Mba Ebooks
By Edhole
Mba ebooks
Free ebooks download
http://ebooks.edhole.com
2. Chapter 6 Properties of Context-free
Languages
Lemma 1 (The pumping lemma for context-free languages).
Let L be any infinite CFL.
Then there exists a constant n, depending on L, such that if z
is in L and |z| ≥ n, then we can write z = uvwxy such that
6.1 Pumping Lemma for CFL's
|vx| ≥ 1,
|vwx| ≤ n, and
for all i ≥ 0, uvi
wxi
y is in L.
http://ebooks.edhole.com
3. Proof (sketch of the proof)
Let G be a Chomsky normal-form grammar
generating L - {ε}.
Since the size of the variables of a context-free grammar for L
is fixed and L is infinite. There exits a long sentence z in L
such that any parse tree for z must contain a long path of
variables. And there would be at least one variable that appear
twice in the path.
For Chomsky normal-form grammar, there are only two types
of the production rules: A→BC and A→a.
Hence for a parse tree of sentence z in L having no path of
length greater than i, then the length of z is no more than 2 i-1
.
We consider the length of a path as the length of the internal
nodes of the path, not including the leaf.
http://ebooks.edhole.com
4. a
S S
BA
ba
|Path|=k=1,
|word|=1 2≦ k-1
|path|=k=2
|word|=2 2≦ k-1
S
T1 T2
|word of T1| 2≦ i-1
|word of T2| 2≦ i-1
|path of T1| i≦
|path of T2| i≦
|word| 2≦ i
|path| i+1≦=>
http://ebooks.edhole.com
5. Suppose that G has k variables, and let n = 2k
.
If z is in L and |z| ≥ n, then any parse tree of z must have a path
of length > k.
Hence there must be at least one variables that appears at least
twice in the path of the parse tree.
Let the two vertices v1 and v2 in the parse tree be the vertices
labeled with the same variable A, and the vertex v1 is closer
to the root than vertex v2 . Also they are the vertices with the
same label closest to leaves of the tree.
http://ebooks.edhole.com
6. S
A
A
v w xu y
≦ k+1
≦ 2k
= n
Since A→BC, we have that |vx| 1.≧
A ⇒* vAx and A⇒*w, where |vwx| n.≦
http://ebooks.edhole.com
7. Now, we have that A ⇒* vAx and A⇒*w, where
|vwx| n.≦
A ⇒* vi
wxi
, for i=0, 1, 2, … .
Hence S ⇒* uvi
wxi
y in L, for i=0, 1, 2, … .
End of lemma 1.
http://ebooks.edhole.com
8. Example 1 L={0n
1n
0n
| n=0, 1, 2,…} is not context-free.
Pf Suppose that L is context-free. Let n be the constant
in the pumping lemma for CFL.
For a sentence z in L, |z| ≥ n. Write z = uvwxy, for all
u, v, w, x, and y with |vx| ≥ 1 and |vwx| ≤ n.
If the substring vwx contains only one kind of symbol, then
for i=0, uwx is not in L. Since the number of 1’s is not equal
to the number of consecutive 0’s.
If the substring vwx contains two kinds of symbols, then for
i=2, uv2
wx2
y is not in L. Since there are 0’s between two 1’s.
Contradiction.
http://ebooks.edhole.com
9. Example 2 L={0n
| n is a prime numer} is not context-free.
Pf Suppose that L is context-free. Let n be the constant
in the pumping lemma for CFL.
For a sentence z in L, |z| = p ≥ n, where p is a prime.
Write z = uvwxy, for all u, v, w, x, and y satisfying that
|vx| ≥ 1, and |vwx| ≤ n.
Let |vx|=k ≥ 1. Choose i = (p+1)k.
We have that |uvi
wxi
y| = (p – k) + i*k = (p – k) + (p + 1)k =
p(k + 1), a composite number. Hence uvi
wxi
y is not in L.
Contradiction.
http://ebooks.edhole.com
10. Example 3 L={am
br
cs
dt
| m = 0 or r = s = t} is not context-free.
Pumping lemma for CFL fails.
For z = br
cs
dt
= uvwxy. When v and x are of the same
type of symbol, say b, for i = 0, 1, 2, …, uvi
wxi
y are all
in L.
Ogden’s lemma for CFL works.
For z = am
br
cr
dr
= uvwxy. When v and x are of the same
type of symbol, say a, for i = 0, 1, 2, …, uvi
wxi
y are all
in L.
http://ebooks.edhole.com
11. Lemma 2 (Ogden’s lemma).
Let L be any infinite CFL.
Then there exists a constant n, depending on L, such that if z
is in L and |z| ≥ n, and we mark any n or more positions of z
“distinguished,” then we can write
z = uvwxy, such that:
v and x together have at least one distinguished position,
vwx has at most n distinguished positions, and
for all i ≥ 0, uvi
wxi
y is in L.
http://ebooks.edhole.com
12. Proof (sketch of the proof)
Let G be a Chomsky normal-form grammar
generating L - {ε}.
Suppose that G has k variables, and let n = 1+ 2k
.
Suppose that z is in L and |z| ≥ n. We can mark any n or more
positions of z “distinguished”.
Select a path in a parse tree of z so that each vertex of the path
is a branch point, i.e., both branches of the vertex have
distinguished descendants.
http://ebooks.edhole.com
13. The selection is as follows:
Step 1: path = {}, empty.
Step 2: path S; P := S; // path = <S>
Step 3: If P is leaf, done.
Step 4: If P has two children, say A and B.
If the sub-tree of B has less number of
distinguished descendant than the sub-tree of A,
then path A; P := A; // path = <S, …, A>
else path B; P := B; // path = <S, …, B>
goto step 3.
http://ebooks.edhole.com
14. Since there are at least n markers on the leaves, the selected
path must have at least k+1 branch points. Hence there are at
least one variable on the path appears twice or more.
The rest of the proof is similar to the proof of pumping lemma
for context-free languages.
End of lemma 2.
http://ebooks.edhole.com
15. Example 4 L = {br
cs
dt
| r≠s ≠ t ≠r} is not context-free.
Proof (by Ogden’s lemma)
Suppose that L is CF. Let n be the constant in the Ogden’s lemma.
Choose z = bn
cn+n!
dn+2n!
.
Let positions of the b’s be distinguished and z = uvwxy.
v and x together have at least one b .
vwx has at most n b’s.
If either v or x contains two different kinds of symbols, then
uv2
wx2
y is not in L.
http://ebooks.edhole.com
16. Assume that x is in c* and let |v| = s, i.e., v = bs
.
Then 1 s n. We have that s | n!.≦ ≦
Let t = n!/s. Choose i = 2t+1.
Then z’= uv2t+1
wx2t+1
y is in L. But v2t+1
= bs+2st
= bs+2n!
.
uwx has (n – s) b’s ⇒ z’ has (n – s) + s + 2n! = n+2n! b’s.
We have that z’ is not in L. Contradiction.
1. If x is in c* or d*, then v must be in b+
.
If each of v and x contains only one kind of symbol, then one
of v and x must be a substring of b+
.
Assume that x is in d* and let |v| = s, i.e., v = bs
.
Let t = n!/s. Choose i = t+1. Then z’= uvt+1
wxt+1
y is in L. But
vt+1
= bs+st
= bs+n!
. uwx has (n – s) b’s.
Then z’ has (n – s) + s + n! = n+n! b’s and z’ is not in L.
Contradiction.
http://ebooks.edhole.com
17. 2. If x is in b+
, then v must be in b+
. And w is in b*.
Let |vx| = s, i.e., vx = bs
.
Then 1 s n. We have that s | n!.≦ ≦
Let t = n!/s. Choose i = 2t+1. Then z’= uv2t+1
wx2t+1
y is in L.
But v2t+1
x2t+1
= bs+2st
= bs+2n!
.
The substring uwx has (n – s) b’s.
Then z’ has n+2n! b’s and hence is not in L.
Contradiction.
End of example 4.
http://ebooks.edhole.com
18. Example 5 L={am
br
cs
dt
| m = 0 or r = s = t} is not context-free.
Proof (by Ogden’s lemma)
Choose z = an
bn
cn
dn
.
Mark all positions of b’s “distinguished.
Write z = uvwxy, where vx contains at least one b, and vx
contains at most n b’s.
Choose i = 0. We have that z’ = uwy is in L.
But the number of b’s in z’ ≠ the number of c’s in z’.
Contradiction.
http://ebooks.edhole.com
19. Free Ebooks Download
Mba Ebooks
By Edhole
Mba ebooks
Free ebooks download
http://ebooks.edhole.com