If L is a CFL, then L*is a CFL. Here CFL refers to Context Free Language.
Let CFG for L has nonterminal S, A, B, C, . . ..
Change the nonterminal from S to S1.
We create a new CFG for L* as follows −
Include all the nonterminal S1, A, B, C, . . . from the CFG for L.
Include all productions of the CFG for L.
Add new nonterminal S and new production
S → S1S | ∧
We can repeat last production
S → S1S → S1S1S → S1S1S1S → S1S1S1S1S → S1S1S1S1∧ → S1S1S1S1
Note that any word in L* can be generated by the new CFG.
We have to show that any word generated by the new CFG is in L*,
Also, make sure that there is no interaction between the different S1’s.
CFG for L is as follows −
S → PaQ | QQ | ∧ P → SaS | bQb | ab Q → SS | ba Convert CFG for L: S1 → PaQ | QQ | ∧ P → S1aS1 | bQb | ab Q → S1S1 | ba
New CFG for L* is given below −
S → S1S | ∧ S1 → PaQ | QQ | ∧ P → S1aS1 | bQb | ab Q → S1S1 | ba