If L1 and L2 are context free languages and R a regular set, one of the…

1996

If L1 and L2 are context free languages and R a regular set, one of the languages below is not necessarily a context free language, which one?

  1. A.

    L1 . L2

  2. B.

    L1 ∩ L2

  3. C.

    L1 ∩ R

  4. D.

    L1 ∪ L2

Attempted by 7 students.

Show answer & explanation

Correct answer: B

Let's evaluate the algebraic closure properties for each operation listed in the options:

  • Concatenation (L1 . L2): CFLs are closed under concatenation. If you have two context-free languages, combining them sequentially always results in another context-free language.

  • Union (L1 U L2): CFLs are closed under union. If you combine all strings from two different context-free languages, the resulting language remains context-free.

  • Intersection with a Regular Language (L1 R): CFLs are closed under intersection with a regular language. This is a special property: if you pass a context-free language through a regular filter, the result is guaranteed to stay context-free.

  • Intersection of two CFLs (L1 L2): Context-Free Languages are NOT closed under intersection.

For example, consider these two context-free languages:

  • L1 = { (an)(bn)(cm) | n, m >= 0 } (Context-free because it only matches a's and b's)

  • L2 = { (am)(bn)(cn) | n, m >= 0 } (Context-free because it only matches b's and c's)

If we take their intersection (L1 n L2), all three symbols must have the exact same count:

  • L1 ∩ L2 = { (an)(bn)(cn) | n >= 0 }

This resulting language is a well-known Context-Sensitive Language and cannot be parsed by a standard Pushdown Automaton. Therefore, the intersection of two CFLs is not necessarily a context-free language.

Correct Answer: B

Explore the full course: Gate Guidance By Sanchit Sir