Jump to content

Greibach normal form

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 169.231.46.33 (talk) at 10:09, 21 March 2008 (Corrected null string character). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer science, to say that a context-free grammar is in Greibach normal form (GNF) means that all production rules are of the form:

or

where A is a nonterminal symbol, α is a terminal symbol, X is a (possibly empty) sequence of nonterminal symbols not including the start symbol, S is the start symbol, and λ is the null string.

Observe that the grammar must be without left recursions.

Every context-free grammar can be transformed into an equivalent grammar in Greibach normal form. (Some definitions do not consider the second form of rule to be permitted, in which case a context-free grammar that can generate the null string cannot be so transformed.) This can be used to prove that every context-free language can be accepted by a non-deterministic pushdown automaton.

Given a grammar in GNF and a derivable string in the grammar with length n, any top-down parser will halt at depth n.

Greibach normal form is named after Sheila Greibach.

See also

References

  • John E. Hopcroft and Jeffrey D. Ullman, Introduction to Automata Theory, Languages and Computation, Addison-Wesley Publishing, Reading Massachusetts, 1979. ISBN 0-201-029880-X. (See chapter 4.)