can the union of regular languages be non-Context-Free

63 Views Asked by At

I came across the following statement which is supposedly true:

There exists an infinite set of regular languages, such that their union is not a CFL

it is explained this way: we'll define $L_k = \{ 0^k1^k0^k \}$

$\bigcup_{i=1}^{\infty} $ $ L_i = \left\{ 0^k1^k0^k \mid k \geq 1 \right\} $

so that each language in the union only contains one string and therefore - regular, but their union is equivalent to: $0^n1^n0^n$ which is not CF.

on the other hand regular languages are closed under union, which means it'd be easy to prove inductively that the above union = regular language, since it consists only of regular languages.

and all regular languages are CF.

isn't that a contradiction?

2

There are 2 best solutions below

1
On BEST ANSWER

No it’s not a contradiction, by induction you can only prove a finite union of regular languages is regular, it tells you nothing about whether or not an infinite union is always regular.

0
On

Actually, every language $L$ on a finite alphabet is a countable union of regular languages. Just observe that all finite languages are regular and that $$ L = \bigcup_{u \in L}\ \{u\} $$ Now, you can choose for $L$ not only a non-context-free language, but a non-context-sensitive or a non-recursively enumerable one if you wish.