- 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

Here CFL refers to Context Free Language. Now, let us understand closure under concatenation.

**Closure under Concatenations**

If L1 and L2 are CFLs, then L1L2 is a CFL.

Follow the steps given below −

L1 CFL implies that L1 has CFG1 that generates it.

Assume that the nonterminals in CFG1 are S, A, B, C, . . ..

Change the nonterminal in CFG1 to S1, A1, B1, C1, . . ..

Don’t change the terminals in the CFG1.

L2 CFL implies that L2 has CFG2 that generates it.

Assume that the nonterminals in CFG2 are S, A, B, C, . . ..

Change the nonterminal in CFG2 to S2, A2, B2, C2, . . ..

Don’t change the terminals in the CFG2.

Now CFG1 and CFG2 have non intersecting sets of nonterminals.

Then we create a CFG for L1L2 as follows −

Include all the nonterminal S1, A1, B1, C1, . . . and S2, A2, B2, C2, . . ..

Include all the productions of CFG1 and CFG2.

Create a new nonterminal S and a production

S → S1S2

**Example**

CFG1 for L1 S → SS | TaTb |FFF | ∧ T → SaS | bFb | abba F → SSS | baab CFG2 for L2 S → aS | aTba | FbF | ∧ T → aSa | abab F → FabaF | bb

To construct CFG for L1L2, follow the steps given below −

Transform CFG1

S1 → S1S1 | T1aT1b | F1F1F1 | ∧ T1 → S1aS1 | bF1b | abba F1 → S1S1S1 | baab

Transform CFG2

S2 → aS2 | aT2ba | F2bF2 | ∧ T2 → aS2a | abab F2 → F2abaF2 | bb

Construct CFG for L1L2 −

S → S1S2 S1 → S1S1 | T1aT1b | F1F1F1 | ∧ T1 → S1aS1 | bF1b | abba F1 → S1S1S1 | baab S2 → aS2 | aT2ba | F2bF2 | ∧ T2 → aS2a | abab F2 → F2abaF2 | bb

- Related Questions & Answers
- Explain the context free language closure under union operation?
- What are the closure properties for context free language?
- Explain Pumping lemma for context free language
- Explain about pumping lemma for context free language?
- Explain the Closure Under Kleene Star of CFL in TOC?
- How to generate the language for context free grammar?
- Explain the simplification of context free grammar in TOC
- What is context free grammar? Explain with examples
- Explain about CYK Algorithm for Context Free Grammar
- Explain removing unit productions in context free grammar
- Give the examples of a context free language that are not regular?
- Generate a Context-free grammar for the language L = {anbm| m≠n}?
- What is Context-Free Grammar?
- Convert the given Context free grammar to CNF
- Explain the concatenation process in DFA

Advertisements