Construct Phrase Structure Gammar G

50 Views Asked by At

I have the following question, construct the phrase structure grammar G such that the language $L(G)$ is equal to language $L=\{x^n y^m | n \geq 2, m =2k, k\in \mathbb{ N}\}$

From my basic understanding , $n\geq 2 $mean the $x$ appear probably at the second production.

my initial ans

1) $V_0 -----> V_0$ $y^2 $

2) $V_0 -----> V_1$

3) $V_1 -----> V_1 $$ x$

4) $V_1 -----> V_2$

5) $V_2 -----> x$

But it seem like it will appear one more x in the end. If i dont have the fifth production, i have no idea how to terminate the loop. Based on my lecturer hint, the this language will have many $y^2$ or none. How to even have a production that can allow none of the $y^2 $appear?

Thanks in advanced.