Closure of CFL


Closure properties of CFL.

Recall definition of "closure":

   A set, S, is closed under a unary operation, 'O',
   if given x in S, the result of O(x) is also in S.

E.g., the integers is closed under unary minus:

   x in Z then so is -x

The set of positive integers is not closed under '-'.


   A set, S, is closed under a binary operation, 'O',
   if given x, y in S, the result of x O y is also in S.


[Give examples which are closed.]

[Give examples which are not closed.]

Finally, generically:

   A set, S, is closed under an operation, 'O', if the
   result of applying 'O' to members of the set yields
   a member of the set.


Theorem: Context Free Languages are closed under: union concatenation Kleene star Note - the text constructs an "effective proof" which is worth knowing: i) Union: add productions S -> S1 | S2 ii) Concat.: add production S -> S1 S2 iii) K.S.: add productions S -> S1 S | lambda
Theorem: The set of CFL is not closed under intersection or complementation. Note - the text constructs a proof "by counter example" which is worth noting: i i j i) intersection: L = {a b c | i, j >= 0} 1 j i i L = {a b c | i, j >= 0} 2 G : S -> BC 1 B -> aBb | lambda C -> cC | lambda G : S -> AB 2 A -> aA | lambda B -> bBc | lambda [good examples to ask: what is the language L(G)?] since the intersection of L and L is 1 2 i i i L = {a b c | i >= 0} and this has been shown to not be CF, it must be that CFL are not closed under intersection.
ii) Complementation: The text's proof is a good use of DeMorgan's Laws and "proof by contradiction": Assume that the set of CFL is closed under complementation. Let L1 and L2 be any two CFL. _______ _ _ By hypothesis, L = L U L = L Intersect L 1 2 1 2 is context-free. Thus the intersection of any two CFL's is a CFL, which contradicts part i.