Confusion related to the type 3 grammar

179 Views Asked by At

I have this confusion. Lets say I have language produced by type 3 grammar such that

L(G1) = <Vn1,Vt,P1,S1>

I need to find a type3 grammar G3 such that

L(G3) = [L(G1)]*

I can't use S3→S3S1 and S3→null rule in this new G3, because the production is not type 3 as well. So what should I do?

2

There are 2 best solutions below

3
On BEST ANSWER

You have to arrange things so that whenever $G_1$ would generate a word, $G_3$ will either generate that word, or generate that word and start over. The obvious way to do that is to add to each production $X\to a$ of $G_1$ the production $X\to aS_3$. In addition, you will have to change every instance of $S_1$ to $S_3$ and add the production $S_3\to\lambda$, if $S_1\to\lambda$ wasn’t in the original grammar.

7
On

If you have a language $L$ defined by grammar $$S \to a \\ S \to b$$ the language $L^*$ can be defined by $$S \to a \\ S \to b \\ S \to aS \\ S \to bS$$