Closure of Context-Free Languages Under Language Difference ()
Context-Free Languages: Closure Properties (CFL theory)
Let and be Context-Free Languages (CFLs). Consider the set difference
The question asks whether must be context-free in general. The key facts are:
- CFLs are closed under Intersection with a Regular Language and under Union.
- CFLs are closed under Complement only via special conditions, but not in general.
- Since difference can be written as whether is context-free hinges on what happens to for CFLs and how CFLs behave under intersection with it.
In general, context-free languages are not closed under difference. Therefore the correct choice is (iii) never.
This “never” means: there exist CFLs such that is not a CFL, so the statement “ is always context-free” fails.
Closure chain that forces the answer
Define Language difference:
Now use these closure notions:
- CFL closure under intersection: CFLs are not closed under intersection with arbitrary CFLs.
- CFL closure under complement: CFLs are not closed under complement in general.
Together, this implies that there is no guarantee that is a CFL even when both and are CFLs—hence the answer is (iii) never.
How to reason about $L_1-L_2$ from closure properties
- 1Step 1
Use .
- 2Step 2
If is not guaranteed to be CFL, then the intersection with is also not guaranteed to be CFL.
- 3Step 3
Because closure fails in the general case, there must exist CFLs where is not CFL.
- 4Step 4
Therefore the statement is false for all CFL pairs; the correct option is (iii) never.
Pro Tip
When you see , immediately rewrite it as . Then check whether CFLs are closed under complement and intersection in the form you need.
Common confusion
CFLs are closed under several operations (e.g., union). But missing closure under complement/intersection is exactly what breaks difference.
Closure-property logic roadmap
Start with difference
1Consider ."
Convert to intersection + complement
2Use ."
Check closure assumptions
3CFLs are not closed under complement (in general)."
Conclude non-closure
4So is not guaranteed to be CFL → choose (iii) never."
Answer selection
Correct choice for: If and are CFLs, is CFL?
Quick FAQs
CFL difference closure checkpoints
Knowledge Check
If and are context-free languages, is: