Converting A Grammar To Chomsky Normal Form
- Introduce
- Introduce a new start variable, and a new rule where is the previous start variable.
- Eliminate all rules
- rules are rules of the form where and where is the CFG's variable alphabet.
- Remove every rule with on its right hand side (RHS). For each rule with in its RHS, add a set of new rules consisting of the different possible combinations of replaced or not replaced with . If a rule has as a singleton on its RHS, add a new rule unless has already been removed through this process. For example, examine the following grammar :
- has one rule. When the is removed, we get the following:
- Notice that we have to account for all possibilities of and so we actually end up adding 3 rules.
- Eliminate all unit rules
- After all the rules have been removed, you can begin removing unit rules, or rules whose RHS contains one variable and no terminals (which is inconsistent with CNF).
- To remove
- add rule unless this is a unit rule which has already been removed.
- After all the rules have been removed, you can begin removing unit rules, or rules whose RHS contains one variable and no terminals (which is inconsistent with CNF).
- Clean up remaining rules that are not in Chomsky normal form.
- Replace with where are new variables.
- If, replace in above rules with some new variable and add rule .
Read more about this topic: Chomsky Normal Form
Famous quotes containing the words converting a, converting, grammar, chomsky, normal and/or form:
“Sigh no more, ladies, sigh no more,
Men were deceivers ever,
One foot in sea and one on shore,
To one thing constant never:
Then sigh not so, but let them go,
And be you blithe and bonny,
Converting all your sounds of woe
Into Hey nonny, nonny.”
—William Shakespeare (15641616)
“A way of certifying experience, taking photographs is also a way of refusing itby limiting experience to a search for the photogenic, by converting experience into an image, a souvenir. Travel becomes a strategy for accumulating photographs.”
—Susan Sontag (b. 1933)
“Grammar is the logic of speech, even as logic is the grammar of reason.”
—Richard Chenevix Trench (18071886)
“Suppose that humans happen to be so constructed that they desire the opportunity for freely undertaken productive work. Suppose that they want to be free from the meddling of technocrats and commissars, bankers and tycoons, mad bombers who engage in psychological tests of will with peasants defending their homes, behavioral scientists who cant tell a pigeon from a poet, or anyone else who tries to wish freedom and dignity out of existence or beat them into oblivion.”
—Noam Chomsky (b. 1928)
“Cant is always rather nauseating; but before we condemn political hypocrisy, let us remember that it is the tribute paid by men of leather to men of God, and that the acting of the part of someone better than oneself may actually commit one to a course of behaviour perceptibly less evil than what would be normal and natural in an avowed cynic.”
—Aldous Huxley (18941963)
“Be sure that it is not you that is mortal, but only your body. For that man whom your outward form reveals is not yourself; the spirit is the true self, not that physical figure which can be pointed out by your finger.”
—Marcus Tullius Cicero (10643 B.C.)