views:

30

answers:

0

I am trying to do an exercise where I translate a grammar into Chomsky normal form. I understand how to do this in normal circumstances but this time the grammar I am working with is right recursive. (Technically the grammar is the answer to the previous question, so I might just have the wrong gamma.)

I think I can do this by using a fixed sequence of rules in place of ε rules but I want to make sure I'm not heading in the wrong direction. It's easier to explain with an example:

For a grammar that produces n 'a's where n is greater than 0 and a multiple of three: (don't worry, this is entirely different to the grammar my actual exercise)

S-> Aaaa
A-> Aaaa
A-> ε

Would the correct Translation be:

S0-> S
S-> A'B
A'-> AA'
A-> A'B
B-> B'C
A'-> a
B'-> a
C-> a