

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Explain Union and Intersection of Regular languages with CFL
We know that the languages accepted by finite automata (FA) are called regular languages and the languages accepted by push down automata (PDA) are called context free languages (CFG).
Closure of CFLs under Union
CFL is the short form for Context Free Language. Here the CFL is as follows −
G = (V, Σ, R, S) such that L(G) = L(G1) ∪ L(G2)
Thus,
V = V1 ∪ V2 ∪ {S} (the three sets are disjoint)
Σ = Σ1 ∪ Σ2
R = R1 ∪ R2 ∪ {S → S1|S2}
Union of Regular language with CFG
If all regular languages are context-free then union of both results is also a context-free language.
Example
Let’s L1 = {0*1*} is a regular language and
L2 = {0^n1^n |n>=0} be a context free
And let L=L1 ∪ L2 be the union of both these languages. In the problem, it is given L = {0*1*} is a regular language.
We know that every regular language is context-free. So, obviously we can say the union of two always results in context-free language. Because the union of two context-free languages is a context-free language.
Hence proved.
Intersection of Regular language with CFG
We know that all regular languages are subset of CFG .
It is easy to understand the union operation and we also proved that union of regular language with context free language generates a context free language.
Now coming to intersection,
The intersection of a regular and a context-free language always result in a context-free language.
Example
L1 = {0*1*} is a regular language and
L2 = {0^n1^n |n>=0} is a CFL
The intersection of two languages is as follows −
L= L1 ∩ L2
It results in the following −
L={0^n1^n | n>=0} which is context-free .
So, finally it is concluded that the intersection of regular language and context free language generates a context free language.
- Related Questions & Answers
- Prove that CFL is closed under union and star but not under intersection?
- Find Union and Intersection of two unsorted arrays in C++
- C++ program to find union and intersection of two unsorted arrays
- What are the closure properties of Regular languages?
- Explain the Closure Under Kleene Star of CFL in TOC?
- Explain the Star Height of Regular Expression and Regular Language
- Character class: union - Java regular expressions
- Character class: intersection - Java regular expressions
- Explain Union process in DFA
- Explain and show the use of UNION in MySQL using Python?
- Construct the Regular expression for the given languages.
- Difference between LED and CFL Bulbs
- Explain JavaScript Regular Expression modifiers with examples
- What is the difference between DB2 JOIN and UNION? Explain with the help of an example
- Explain the concept of Regular expression.