Processing math: 100%

6.Closure Properties§

L={anbn|n>0}, LL={anbnambm|n>0,m>0}

Theorem: CFL’s are closed under union, concatenation, and star-closure.

Given: 2 CFGs G1=(V1,T1,S1,P1) and G2=(V2,T2,S2,P2)

Union

Construct G3 such that L(G3)=L(G1)L(G2).
G3=(V3,T3,S3,P3)
V3=V1V2{S3},T3=T1T2, and P3=P1P2{S3S1|S2}.

Concatenation

Construct G3 such that L(G3)=L(G1)L(G2).
G3=(V3,T3,S3,P3)
V3=V1V2{S3},T3=T1T2, and P3=P1P2{S3S1S2}.

Star-Closure

Construct G3 such that L(G3)=L(G1)
G3=(V3,T3,S3,P3)
V3=V1{S3},T3=T1, and P3=P1P2{S3S1S3|λ}.

Intersection

Theorem: CFL’s are NOT closed under intersection
Let L1={anbncm|n,m>0} and L2={anbmcm|n,m>0}
L1 and L2 are CFLs
Then L1L2={anbncn|n>0} is not CFL.

Complementation

Theorem: CFL’s are NOT closed under complementation.
Set identity:
L1L2=¯¯L1¯L2

Thus, CFLs are not closed under complementation.

Example for theorem below:

L1={anbmanm>0,n>0}
L2={wwΣ and w has an even number of b’s}, Σ={a,b},
L1L2={anbmbman} is a CFL.

Regular Intersection (1)

CFL’s are closed under regular intersection. If L1 is CFL and L2 is regular, then L1L2 is CFL.

Proof: (sketch)
This proof is similar to the construction proof in which we showed regular languages are closed under intersection.
We can take a NPDA for L1 and a DFA for L2 and construct a NPDA for L1L2.

Some Decision Problems for CFGs

For a given CFG G, is L(G) empty?
A: Remove useless productions. Then, is S useless?
For a given CFG G, is L(G) infinite?
A: Is there a repeating variable?
For two given CFGs G1 and G2, does L(G1)=L(G2)?
A: There is no general algorithm that can always deterimine if two CFG generate the same language!

A Richer Grammar

Here is a grammar for L={anbncnn1}.
SabcaAbc
AbbA
AcBbcc
bBBb
aBaaaaA

Consider how to derive a3b3c3

This is called a Context Sensitive Grammar