in Theory of Computation
563 views
0 votes
0 votes
is union of regular language and context free language always regular?
in Theory of Computation
by
563 views

3 Comments

take a regular language over input alphabet set {a, b} as L1= $\{ab\} $

take a CFL over input alphabet {a, b} as L2 = $\{a^nb^n | n >0\}$ where n is a positive integer.
Now, union of both will be $\{a^nb^n | n >0\}$which is CFL but not regular.
4
4
Thanks brother.. :)
1
1
No, Union of regular language and CFL is not regular.
0
0

1 Answer

1 vote
1 vote
Suppose there are two CFL's L1 and L2. $\because$ they are CFL's they have equivalent CFG's. They have a start symbol as well, say S1 and S2. Now create a new production S->S1|S2. As you can see now you have a grammar for the language $L1\cup L2$ of two languages. Therefore you have a CFL for it as well. You also know that every regular language is also context free. Therefore union of regular and context free languages is closed under union.

Related questions

0 votes
0 votes
0 answers
3