CS Atlas GATE 2027
TOC course
0 / 91 complete

TOC/Phase 3 · CFG, PDA & Context-Free Languages

Chapter review L3.4 · Item 63 of 91

Properties of CFLs

Read at your own pace. Try the questions before opening the answers.

On this page

Chapter recap

CFLs are closed under ∪, concatenation, star, reversal, homomorphisms and ∩ regular, but not ∩ or complement (aⁿbⁿcᵐ ∩ aᵐbⁿcⁿ = aⁿbⁿcⁿ). DCFLs are closed under complement and ∩ regular but not ∪, ∩, concatenation, star, reversal. Emptiness, finiteness and membership (CYK, O(n³)) have algorithms; equivalence, universality and ambiguity do not. CFL pumping: |vwx| ≤ p, |vx| ≥ 1, pump v and x together. Classification ladder: bounded → regular, one deterministic comparison → DCFL, guessed → CFL, two comparisons → not CFL.

Merged rule card

From 3.4.1 Closure properties of CFLs and DCFLs

  • CFL closed: ∪, concat, *, reversal, h, h⁻¹, substitution, ∩R, −R. Not: ∩, complement, difference.
  • DCFL closed: complement, ∩R, ∪R, −R, h⁻¹. Not: ∪, ∩, concat, *, reversal, h.
  • Counterexample: aⁿbⁿcᵐ ∩ aᵐbⁿcⁿ = aⁿbⁿcⁿ. Non-CFL proof: L ∩ R non-CFL ⇒ L non-CFL.

From 3.4.2 Algorithms for CFLs: emptiness, finiteness, membership (CYK)

  • Emptiness: is S generating? Finiteness: cycle in the cleaned variable graph. Membership: CYK O(n³|G|), CNF required.
  • No algorithm for general CFGs: equivalence, universality, ambiguity, regularity, emptiness of intersection.

From 3.4.3 Pumping lemma for CFLs

  • L CFL ⇒ ∃p ∀z ∈ L, |z| ≥ p: z = uvwxy, |vwx| ≤ p, |vx| ≥ 1, uvⁱwxⁱy ∈ L ∀i ≥ 0. p = 2ᵏ (CNF, k variables).
  • Non-CFL: aⁿbⁿcⁿ, ww, aⁿbᵐcⁿdᵐ, #a=#b=#c, a^{n²}, a^{prime}, aⁱbʲcᵏ (i<j<k).
  • Unary CFL ⇒ regular. Complement of ww is a CFL.

From 3.4.4 Drill: regular, DCFL, CFL or not CFL?

  • Ladder: bounded → regular; one comparison, no guess → DCFL; one comparison with a guess → CFL; two comparisons / crossing / copy / squares → not CFL.
  • “or” of comparisons → CFL not DCFL; “and” → not CFL.
  • Always check finiteness and collapses (unions that become a*b*).

Practice questions

  1. MSQ

    L₁ is a CFL, L₂ is a DCFL, R is regular. Which are always CFLs?

    1. L₁ ∪ R
    2. L̅₂ ∪ L₁
    3. L₁ ∩ L₂
    4. L₁*
  2. MCQ

    Which has no algorithm for arbitrary CFGs?

    1. membership
    2. emptiness
    3. finiteness
    4. universality (L = Σ*)
  3. NAT

    CYK cells for a string of length 10?

    Write your answer before opening the key.

  4. MCQ

    Which is the CFL pumping split?

    1. xyz, |xy| ≤ p
    2. uvwxy, |vwx| ≤ p, |vx| ≥ 1
    3. uvwxy, |uv| ≤ p
    4. xyz, |y| ≤ p
  5. MSQ

    Which are not CFLs?

    1. { aⁿbⁿcⁿ }
    2. { a^{p} : p prime }
    3. { ww }
    4. { wwᴿ }
  6. MCQ

    { aⁿbⁿ } ∪ { aⁿb²ⁿ } is:

    1. regular
    2. DCFL
    3. CFL but not DCFL
    4. not CFL
  7. MCQ

    DCFLs are closed under which?

    1. union
    2. reversal
    3. complement
    4. Kleene star
  8. MSQ

    Which are DCFLs?

    1. { aⁿbᵐcⁿ }
    2. balanced parentheses
    3. { wwᴿ }
    4. { aⁿbⁿcᵐdᵐ }

Answer key

Reveal answers when you’re ready
  1. ABD — L̅₂ is a DCFL (so a CFL), union keeps CFL.
    • C: Intersection of CFLs can fail.
  2. D — Universality of CFGs has no algorithm.
    • A: CYK.
    • B: Generating test.
    • C: Cycle test.
  3. 55 — 10·11/2.
  4. B — Two pumps in a short window.
    • A: Regular lemma.
    • C: Wrong window.
    • D: Wrong.
  5. ABC — Standard.
    • D: CFL.
  6. C — Union of two different ratios; a DPDA cannot decide which to check.
    • A: Unbounded.
    • B: Needs a guess.
    • D: It is a union of two CFLs.
  7. C — Only complement among these.
    • A: No.
    • B: No.
    • D: No.
  8. ABD — Deterministic designs exist.
    • C: Needs a guess.

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.