Closure properties of CFL
Context-free languages are closed under β
- Union
- Concatenation
- Kleene Star operation
Union
Let L1 and L2 be two context free languages. Then L1 βͺ L2 is also context free.
Example
Let L1 = { anbn , n > 0}. Corresponding grammar G1 will have P: S1 β aAb|ab
Let L2 = { cmdm , m β₯ 0}. Corresponding grammar G2 will have P: S2 β cBb| Ξ΅
Union of L1 and L2, L = L1 βͺ L2 = { anbn } βͺ { cmdm }
The corresponding grammar G will have the additional production S β S1 | S2
Concatenation
If L1 and L2 are context free languages, then L1L2 is also context free.
Example
Union of the languages L1 and L2, L = L1L2 = { anbncmdm }
The corresponding grammar G will have the additional production S β S1 S2
Kleene Star
If L is a context free language, then L* is also context free.
Example
Let L = { anbn , n β₯ 0}. Corresponding grammar G will have P: S β aAb| Ξ΅
Kleene Star L1 = { anbn }*
The corresponding grammar G1 will have additional productions S1 β SS1 | Ξ΅
Context-free languages are not closed under β
Intersection β If L1 and L2 are context free languages, then L1 β© L2 is not necessarily context free.
Intersection with Regular Language β If L1 is a regular language and L2 is a context free language, then L1 β© L2 is a context free language.
Complement β If L1 is a context free language, then L1β may not be context free.
Labels: Automata, TAFL Unit-4
Discussion & Queries (<$I18NNumComments$>):
<$CommentPager$>
- <$I18NAtCommentTimeWithPermalink$>, <$I18NCommentAuthorSaid$>
<$CommentPager$>
<$BlogCommentBody$>
<$BlogCommentDeleteIcon$>