


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Solutions for converting given grammars to chomsky normal form and greibach normal form. It includes step-by-step explanations and justifications for each transformation. The document also discusses the elimination of left-recursion and the importance of eliminating recursion on a given non-terminal.
Typology: Assignments
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Convert the grammar to Chomsky Normal Form (please use rules U → a and V → b). answer: Besides some simpler transformations, we must remove unallowed λ-productions and chain rules. The general technique I taught in class is
to remove a given production P , add redundant productions until P itself becomes redundant. Then remove P.
First deal with the mixed (terminals and variables) terms using U → a and V → b:
To make B → λ redundant, add S → A and B → S:
To make S → A redundant, add S → AS + SV + a. Reasoning: when the rule S → A is used in a derivation, the variable A must at some point later be substituted for AS or SV or a.
Now we could remove B → S in the same way we removed S → A. Instead, and to show you that there is more than one way to do this, consider the step in a derivation where a new variable B is produced. This can only happen when the production S → AB is used.^1 The only place where B → S can later play a role is in changing this B into an S. So adding the rule A → AS makes B → S redundant. But this rule is already there, so we can simply remove the rule B → S:
Eliminating recursion on S is simple. The final grammar is
(^1) Why can we ignore the production B → BS here?
Greibach Normal Form requires expressions on the right-hand side of productions to begin with non-terminals. Simple substitution can be used to obtain
The text does not allow S in the right-hand side of productions in Greibach Normal Form. However, it was noted in class that there appears to be no good reason for this requirement. So the above is good enough.