Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Chomsky normal form
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===DEL: Eliminate Ξ΅-rules=== An Ξ΅-rule is a rule of the form :''A'' β Ξ΅, where ''A'' is not ''S''<sub>0</sub>, the grammar's start symbol. To eliminate all rules of this form, first determine the set of all nonterminals that derive Ξ΅. Hopcroft and Ullman (1979) call such nonterminals ''nullable'', and compute them as follows: * If a rule ''A'' β Ξ΅ exists, then ''A'' is nullable. * If a rule ''A'' β ''X''<sub>1</sub> ... ''X''<sub>''n''</sub> exists, and every single ''X''<sub>''i''</sub> is nullable, then ''A'' is nullable, too. Obtain an intermediate grammar by replacing each rule :''A'' β ''X''<sub>1</sub> ... ''X''<sub>''n''</sub> by all versions with some nullable ''X''<sub>''i''</sub> omitted. By deleting in this grammar each Ξ΅-rule, unless its left-hand side is the start symbol, the transformed grammar is obtained.<ref name="Hopcroft.Ullman.1979"/>{{rp|90}} For example, in the following grammar, with start symbol ''S''<sub>0</sub>, : ''S''<sub>0</sub> β ''AbB'' | ''C'' : ''B'' β ''AA'' | ''AC'' : ''C'' β ''b'' | ''c'' : ''A'' β ''a'' | Ξ΅ the nonterminal ''A'', and hence also ''B'', is nullable, while neither ''C'' nor ''S''<sub>0</sub> is. Hence the following intermediate grammar is obtained:<ref group=note>indicating a kept and omitted nonterminal ''N'' by ''{{color|#006000|N}}'' and ''{{color|#ffc0c0|<s>N</s>}}'', respectively</ref> : ''S''<sub>0</sub> β ''{{color|#006000|A}}b{{color|#006000|B}}'' | ''{{color|#006000|A}}b{{color|#ffc0c0|<s>B</s>}}'' | ''{{color|#ffc0c0|<s>A</s>}}b{{color|#006000|B}}'' | ''{{color|#ffc0c0|<s>A</s>}}b{{color|#ffc0c0|<s>B</s>}}'' | ''C'' : ''B'' β ''{{color|#006000|AA}}'' | ''{{color|#ffc0c0|<s>A</s>}}{{color|#006000|A}}'' | ''{{color|#006000|A}}{{color|#ffc0c0|<s>A</s>}}'' | ''{{color|#ffc0c0|<s>A</s>}}Ξ΅{{color|#ffc0c0|<s>A</s>}}'' | ''{{color|#006000|A}}C'' | ''{{color|#ffc0c0|<s>A</s>}}C'' : ''C'' β ''b'' | ''c'' : ''A'' β ''a'' | Ξ΅ In this grammar, all Ξ΅-rules have been "[[inlining|inlined]] at the call site".<ref group=note>If the grammar had a rule ''S''<sub>0</sub> β Ξ΅, it could not be "inlined", since it had no "call sites". Therefore it could not be deleted in the next step.</ref> In the next step, they can hence be deleted, yielding the grammar: : ''S''<sub>0</sub> β ''AbB'' | ''Ab'' | ''bB'' | ''b'' | ''C'' : ''B'' β ''AA'' | ''A'' | ''AC'' | ''C'' : ''C'' β ''b'' | ''c'' : ''A'' β ''a'' This grammar produces the same language as the original example grammar, viz. {''ab'',''aba'',''abaa'',''abab'',''abac'',''abb'',''abc'',''b'',''ba'',''baa'',''bab'',''bac'',''bb'',''bc'',''c''}, but has no Ξ΅-rules.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)