Closure and Decision Properties of CFL
Closure properties of CFLs
Closed under — you can always build a grammar/PDA from the given ones.
-
Union: If is a CFL.
Construction sketch: Given grammars with disjoint nonterminals, add a new start symbol and rule . (Or for PDAs, nondeterministically choose which PDA to simulate.) -
Concatenation: If are CFLs then is a CFL.
Construction sketch: New start (or make the PDA simulate the first then the second). -
Kleene star: If is CFL then is CFL.
Construction sketch: Grammar rule -
Reversal: If is CFL then is CFL.
Construction sketch: Reverse each right-hand side in the grammar (or run the PDA backwards with stack actions reversed). -
Homomorphism: If is a homomorphism and is CFL, then Sketch: Apply to terminals in productions (or have PDA output mapped symbols).
-
Inverse homomorphism: If is a homomorphism and is CFL, then is CFL.
Sketch: Build a PDA that, on input , simulates the PDA for on (or use grammar constructions). -
Intersection with regular languages: If is CFL and is regular, then is CFL.
Construction sketch: Product construction: simulate the PDA for and the DFA for in parallel (PDA keeps its stack and the DFA state in its control). -
(Substitution by regular languages): Replacing each terminal by a regular language yields a CFL. (This is a generalization of homomorphism and inverse homomorphism.)
Not closed under — there exist CFLs with an operation producing a non-CFL:
-
Intersection (general): CFLs are not closed under intersection.
Counterexample:Both and are CFLs, but
, which is not context-free. -
Complement: CFLs are not closed under complement.
Reason: If CFLs were closed under complement, then closure under union + De Morgan would imply closure under intersection — contradiction (see previous point). -
Difference: Not closed (difference can be expressed with complement + intersection).
Deterministic CFLs (DCFLs) — note the contrast: DCFLs (languages of deterministic PDAs) enjoy some different properties: DCFLs are closed under complement (a classic result) but not closed under union or general intersection. I’ll mention DCFLs further if you want.
Decision properties (which questions about CFLs are decidable?)
Below is a list of common decision problems, with status and why (short):
Decidable problems
-
Membership (word problem)
Problem: Given CFG and string , is ?
Status: Decidable.
How: Convert to Chomsky Normal Form (CNF) and use CYK dynamic programming: O() time classically. There are faster algorithms for special cases, but CYK is standard and effective for proofs. -
Emptiness of a CFG
Problem: Given CFG , is ?
Status: Decidable.
How: Compute generating variables (those that derive some terminal string) by fixed-point marking; then check if start symbol is generating. This runs in linear time in the grammar size. -
Finiteness
Problem: Given CFG , isStatus: Decidable.
How (sketch): Remove useless symbols first (non-generating/non-reachable). If the dependency graph (variables with edges when one can derive the other) contains a cycle reachable from and that cycle can produce at least one terminal, you can pump to obtain arbitrarily long strings → infinite. Otherwise finite. So check for reachable cycles in the generating subgraph: decidable (graph algorithms). -
Emptiness of where is regular
Problem: Given CFG and regular , is ?
Status: Decidable.
How: Build PDA for × DFA for (PDA for intersection) and check emptiness (emptiness for PDA/CFG is decidable). -
Membership for PDAs / equivalently CFGs (same as 1): decidable.
Undecidable problems
-
Universality
Problem: Given CFG over alphabet , is ?
Status: Undecidable. -
Equivalence
Problem: Given CFGs is ?
Status: Undecidable. -
Inclusion
Problem: Given CFGs , is ?
Status: Undecidable. (Equivalence reduces to mutual inclusion, so inclusion undecidable.) -
Emptiness of intersection of two CFLs
Problem: Given CFGs , is Status: Undecidable.
Consequence: This is consistent with non-closure under intersection and with undecidability results (standard reductions show undecidability). -
Ambiguity of a CFG
Problem: Given a CFG , is ambiguous? (i.e., does some string have ≥2 distinct parse trees?)
Status: Undecidable. -
Inherent ambiguity
Problem: Given a CFL , is inherently ambiguous? (i.e., every grammar for is ambiguous)
Status: Undecidable.
Quick reference table (summary)
Property / problem | CFLs: status | Notes / sketch |
---|---|---|
Union | Closed | |
Concatenation | Closed | |
Kleene star | Closed | |
Reversal | Closed | Reverse RHSs |
Homomorphism | Closed | Replace terminals |
Inverse homomorphism | Closed | PDA/transducer construction |
Intersection (general) | Not closed | Example → |
Complement | Not closed | If closed → intersection closed (contradiction) |
Intersection w/ regular | Closed | Product PDA+DFA |
Membership (G,w) | Decidable | CYK (O(n³)) |
Emptiness (G) | Decidable | Mark generating variables |
Finiteness (G) | Decidable | detect reachable cycles in generating graph |
Universality | Undecidable | reduction proofs |
Equivalence (G1,G2) | Undecidable | reduction proofs |
Inclusion (G1⊆G2) | Undecidable | reduction proofs |
Ambiguity (G) | Undecidable | classic result |
Comments
Post a Comment