Does the union of two (irregular) context-free languages ​​produce a regular language?

Given L1 and L2 (irregular) context-free languages ​​- is it possible that L1 U L2 is regular?

I know this is possible, but I just cannot find an example demonstrating this. I would like some help.

+4
source share
1 answer

Can a union of two CFLs be regular?

Considering and context languages (but not regular), if that is possible unification of the two it is a regular?L1L2L1 ∪ L2

Yes it is possible!

Suppose the first language is L 1 :

L 1: {anbm | n = m}

L 1 CFL, . L 1 - anbn. , CFL, .

L 2:

L 2: {anbm | n ≠ m}

L 2 CFL, . L 2 L 1.

L 1 L 2:

L: {anbm | n m}

L= L1 ∪ L2 L a*b*.

, - CFL. .

: - , CFL CFL ( CFL), -CFL, CSL.

:

CFL ?

L1 L2 Context Free ( ) , , L1 ∩ L2 ?

!

, L 1:

L 1: {anbm | n = m}

L 2:

L 2: {anbm | n <= 3 or n ≠ m}

L= L1 ∩ L2= {ab, aabb, aaabbb} , , .

+7

All Articles