Theorem 7.17

Download Report

Transcript Theorem 7.17

Pumping Lemma for CFLs
Theorem 7.17: Let G be a CFG in CNF and w
a string in L(G). Suppose we have a parse
tree for w. If the length of the longest path
of the parse tree is n, then |w| ≤ 2n-1
Proof: induction on n.
Theorem 7.18: (Pumping Lemma for Contextfree Languages)
Let L be a CFL. Then there exists a constant
n such that if z is any string in L such that |z|
 n, then we can write z = uvwxy, satisfying
the following conditions:
1) |vwx|  n
2) vx  
3) for all i  0, uviwxiy is in L.
Applications of pumping lemma:
{anbncn | n > 0}
{anbmcndm | m,n >0}
{ww | w is in {0, 1}*}
Closure Properties of CFLs
Definition (substitution):
Let  be a class of languages and let L  *
be in . Suppose that for each a in , La is a
language in .  is closed under substitution
if for all choices of L,
L' = {x1x2 …xn | a1a2 …an is in L
x1 is in La1
x2 is in La2
…
xn is in La }
n
is in .
Theorem 7.23: The class of context-free languages is
closed under substitution
Proof: Let G = (V, T, P, S) be such that
L(G) = L and Ga = (Va, Ta, Pa, Sa) be such that
La = L(Ga). Let L1 be the language resulting
from the substitution of La’s for a’s in L.
Construct G1 = (V1, T1, P1, S) where
V1 is the union of V and all Va’s
T1 is the union of T and all Ta’s
P1 is the union of all Pa’s and the productions of P
with Sa substituted for a
Then, L1 = L(G1)
Corollary (Theorem 7.24): The context-free
languages are
closed under:
1)
2)
3)
4)
Union
Concatenation
*, +
Homomorphism
Theorem 7.25: If L is a CFL, then LR is also a
CFL
Theorem: The class of context-free languages is not
closed under intersection.
Theorem 7.27: The class of context-free languages
are closed under intersection with regular
languages
Theorem 7.29: The following are true about CFLs L,
L1, and L2, and a regular language R.
1. L-R is a CFL
2. Complement of L is not necessarily a CFL
3. L1 – L2 is not necessarily a CFL
Theorem: If L is a CFL and h is a
homomorphism, then h-1(L) is a CFL.
Examples:
L = {ambnambn | m, n ≥ 1} is not a CFL
L = {ww | w in {a, b}* } is not a CFL
L = {begin integer w; w := 1; end | w is a string
in {a, b}+ } is not a CFL
Definition: A language which is defined by a
DPDA is called a deterministic context-free
language.
(The class of grammars called LR(k) grammars
generate deterministic CFLs. Every
deterministic CFL has a LR(1) grammar)
Lemma: If L is a deterministic CFL, then
h-1(L) is a deterministic CFL
Theorem: The class of deterministic CFL’s is
closed under complement and are not closed
under union, intersection, homomorphism,
concatenation, or (* or +) .
The deterministic CFL’s is a proper subset of the
class of CFL’s.