encyclopegia.org

Chomsky normal form

In formal language theory, a context-free grammar, G, is said to be in Chomsky normal form (first described by Noam Chomsky) if all of its production rules are of the form: : A → BC, or : A → a, or : S → ε, where A, B, and C are nonterminal symbols, the letter a is a terminal symbol (a symbol that represents a constant value), S is the start symbol, and ε denotes the empty string.[src] Also, neither B nor C may be the start symbol, and the third production rule can only appear if ε is in L(G), the language produced by the context-free grammar G.[src] Every grammar in Chomsky normal form is context-free, and conversely, every context-free grammar can be transformed into an equivalent one which is in Chomsky normal form and has a size no larger than the square of the original grammar's size.[src]

In formal language theory, a context-free grammar, G, is said to be in Chomsky normal form (first described by Noam Chomsky) if all of its production rules are of the form: A → BC,   or A → a,   or S → ε, where A, B, and C are nonterminal symbols, the letter a is a terminal symbol (a symbol that represents a constant value), S is the start symbol, and ε denotes the empty string.[src] Also, neither B nor C may be the start symbol, and the third production rule can only appear if ε is in L(G), the language produced by the context-free grammar G.[src] Every grammar in Chomsky normal form is context-free, and conversely, every context-free grammar can be transformed into an equivalent one which is in Chomsky normal form and has a size no larger than the square of the original grammar's size.[src] ==Converting a grammar to Chomsky normal form== To convert a grammar to Chomsky normal form, a sequence of simple transformations is applied in a certain order; this is described in most textbooks on automata theory.[src] The presentation here follows Hopcroft, Ullman (1979), but is adapted to use the transformation names from Lange, Leiß (2009).[src] Each of the following transformations establishes one of the properties required for Chomsky normal form.[src] ===START: Eliminate the start symbol from right-hand sides=== Introduce a new start symbol S 0 , and a new rule S 0 → S, where S is the previous start symbol.[src] This does not change the grammar's produced language, and S 0 will not occur on any rule's right-hand side.[src] ===TERM: Eliminate rules with nonsolitary terminals=== To eliminate each rule A → X 1 ...[src] a ...[src] X n with a terminal symbol a being not the only symbol on the right-hand side, introduce, for every such terminal, a new nonterminal symbol N a , and a new rule N a → a.[src] Change every rule A → X 1 ...[src] a ...[src] X n to A → X 1 ...[src] N a ...[src] X n .[src] If several terminal symbols occur on the right-hand side, simultaneously replace each of them by its associated nonterminal symbol.[src] This does not change the grammar's produced language.[src] ===BIN: Eliminate right-hand sides with more than 2 nonterminals=== Replace each rule A → X 1 X 2 ...[src] X n with more than 2 nonterminals X 1 ,...,X n by rules A → X 1 A 1 , A 1 → X 2 A 2 , ...[src] , A n-2 → X n-1 X n , where A i are new nonterminal symbols.[src] Again, this does not change the grammar's produced language.[src] ===DEL: Eliminate ε-rules=== An ε-rule is a rule of the form A → ε, where A is not S 0 , the grammar's start symbol.[src] To eliminate all rules of this form, first determine the set of all nonterminals that derive ε.[src] Hopcroft and Ullman (1979) call such nonterminals nullable, and compute them as follows: If a rule A → ε exists, then A is nullable.[src] If a rule A → X 1 ...[src] X n exists, and every single X i is nullable, then A is nullable, too.[src] Obtain an intermediate grammar by replacing each rule A → X 1 ...[src] X n by all versions with some nullable X i omitted.[src] By deleting in this grammar each ε-rule, unless its left-hand side is the start symbol, the transformed grammar is obtained.[src] For example, in the following grammar, with start symbol S 0 , S 0 → AbB | C B → AA | AC C → b | c A → a | ε the nonterminal A, and hence also B, is nullable, while neither C nor S 0 is.[src] Hence the following intermediate grammar is obtained: S 0 → b | b | b | b   |   C B → | | | ε   |   C | C C → b | c A → a | ε In this grammar, all ε-rules have been "inlined at the call site".[src] In the next step, they can hence be deleted, yielding the grammar: S 0 → 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.[src] {ab,aba,abaa,abab,abac,abb,abc,b,ba,baa,bab,bac,bb,bc,c}, but has no ε-rules.[src] ===UNIT: Eliminate unit rules=== A unit rule is a rule of the form A → B, where A, B are nonterminal symbols.[src] To remove it, for each rule B → X 1 ...[src] X n , where X 1 ...[src] X n is a string of nonterminals and terminals, add rule A → X 1 ...[src] X n unless this is a unit rule which has already been (or is being) removed.[src] The skipping of nonterminal symbol B in the resulting grammar is possible due to B being a member of the unit closure of nonterminal symbol A.[src] ===Order of transformations=== When choosing the order in which the above transformations are to be applied, it has to be considered that some transformations may destroy the result achieved by other ones.[src] For example, START will re-introduce a unit rule if it is applied after UNIT.[src] The table shows which orderings are admitted.[src] Moreover, the worst-case bloat in grammar size depends on the transformation order.[src] Using |G| to denote the size of the original grammar G, the size blow-up in the worst case may range from |G| 2 to 2 2 |G| , depending on the transformation algorithm used.[src] The blow-up in grammar size depends on the order between DEL and BIN.[src] It may be exponential when DEL is done first, but is linear otherwise.[src] UNIT can incur a quadratic blow-up in the size of the grammar.[src] The orderings START,TERM,BIN,DEL,UNIT and START,BIN,DEL,UNIT,TERM lead to the least (i.e.[src] quadratic) blow-up.[src] ==Example== of the arithmetic expression "a^2+4*b" wrt.[src] the example grammar (top) and its Chomsky normal form (bottom) The following grammar, with start symbol Expr, describes a simplified version of the set of all syntactical valid arithmetic expressions in programming languages like C or Algol60.[src] Both number and variable are considered terminal symbols here for simplicity, since in a compiler front end their internal structure is usually not considered by the parser.[src] The terminal symbol "^" denoted exponentiation in Algol60.[src] In step "START" of the above conversion algorithm, just a rule S 0 →Expr is added to the grammar.[src] After step "TERM", the grammar looks like this: After step "BIN", the following grammar is obtained: Since there are no ε-rules, step "DEL" does not change the grammar.[src] After step "UNIT", the following grammar is obtained, which is in Chomsky normal form: The N a introduced in step "TERM" are PowOp, Open, and Close.[src] The A i introduced in step "BIN" are AddOp_Term, MulOp_Factor, PowOp_Primary, and Expr_Close.[src] ==Alternative definition== \langle A \rangle ::= \, \langle B \rangle \mid \langle C \rangle or \langle A \rangle ::= \, \langle B \rangle \langle C \rangle or \langle A \rangle ::=\, a , where \langle A \rangle , \langle B \rangle and \langle C \rangle are nonterminal symbols, and a is a terminal symbol, because Robert W.[src] Floyd found any BNF syntax can be converted to the above one in 1961.[src] But he withdrew this term, "since doubtless many people have independently used this simple fact in their own work, and the point is only incidental to the main considerations of Floyd's note." While Floyd's note cites Chomsky's original 1959 article, Knuth's letter does not.[src] ==Notes== ==Further reading== Cole, Richard.[src] Converting CFGs to CNF (Chomsky Normal Form), October 17, 2007.[src] (pdf) — uses the order TERM, BIN, START, DEL, UNIT.[src] (Pages 237–240 of section 6.6: simplified forms and normal forms.) (Pages 98–101 of section 2.1: context-free grammars.[src] Page 156.) (pages 171-183 of section 7.1: Chomsky Normal Form) Sipser, Michael.[src] Introduction to the Theory of Computation, 2nd edition.[src]

70 sentences · 70 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Chomsky normal form." encyclopegia.org, 2026, https://encyclopegia.org/wiki/chomsky-normal-form. Accessed 29 November 2026.

Chicago

"Chomsky normal form." encyclopegia.org. Accessed November 29, 2026. https://encyclopegia.org/wiki/chomsky-normal-form.

APA

encyclopegia.org. (2026). Chomsky normal form. Retrieved November 29, 2026, from https://encyclopegia.org/wiki/chomsky-normal-form

Accessed November 29, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Form I-94

stub · references available

Ab-normal Beauty

stub · references available

quadratic form

stub · references available

curvature form

stub · references available

modular form

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1337949563 · 0.5 · snapshot enwiki-001337949563

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners
  • Index — every corpus, paper and record
  • Estate guide — what a public data estate is
  • Founder — Lois-Kleinner Alpasan
  • Records — DOIs and external deposits
  • Documents — one-pagers, PDFs and QR codes
  • Brand kit — logos and share images
  • Papers — plain-language briefs with citations
  • Browser — search engine, PWA and bookmarklet
  • Anticloud — the operator and its projects

As seen in Business Insider · 336 outlets · evidence DOIs · plain-language papers

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.