Context Free Grammar Related Question Question: Eliminate ? productions, unit pr
ID: 3704122 • Letter: C
Question
Context Free Grammar Related Question
Question:
Eliminate ? productions, unit productions, useless symbols and then rewrite the resulting grammar in the Chomsky Normal Form (in that order) for the following two input grammars:
S -> 0E0 | 1FF | ?
E -> G
F -> S | E
G -> S | ?
_____________________________________________________________________________________________________________________
I am having trouble answering this question, mainly because I find that the Grammer just loops through itself no matter the derivation. When you remove null productions for start state S, you go through removing the null productions in G, and then E, and then F, and then S again, or when you are removing useless Unit Productions, I don't know when to stop. What I've got so far is after reducing the unit productions, before we begin converting to Chomsky Normal Form, I get:
S' -> 0E0 | 1FF | 00 | 1F | 1
S -> 0E0 | 1FF | 00 | 1F | 1
F -> 0E0 | 1FF | 00 | 1F | 1
E-> 0E0 | 1FF | 00 | 1F | 1
I don't have time to show my work, I just followed the standard rules of reduction for Null and Unit productions before converting to Chomsky Normal Form, this just doesn't look correct. I'd appreciate any help I can get. Thanks in advance!
Explanation / Answer
Algorithm to Convert into Chomsky Normal Form ?
Step 1 ? If the start symbol S occurs on some right side, create a new start symbol S’ and a new production S’? S.
Step 2 ? Remove Null productions. (Using the Null production removal algorithm discussed earlier)
Step 3 ? Remove unit productions. (Using the Unit production removal algorithm discussed earlier)
Step 4 ? Replace each production A ? B1…Bn where n > 2 with A ? B1C where C ? B2 …Bn. Repeat this step for all productions having two or more symbols in the right side.
Step 5 ? If the right side of any production is in the form A ? aB where a is a terminal and A, B are non-terminal, then the production is replaced by A ? XB and X ? a. Repeat this step for every production which is in the form A ? aB.
Please use above rules
Answer :
S0 -> CA | EB | CC | EF | 1 |
S -> CA | EB | CC | EF | 1
E -> CA | EB | CC | EF | 1
F -> CA | EB | CC | EF | 1
G -> CA | EB | CC | EF | 1
A -> EC
B -> FF
C -> 0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.