Greibach normal form: Difference between revisions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
No edit summary
 
imported>Chimneychobga
m Added short description
 
Line 1: Line 1:
{{Short description|Form for context-free grammars}}
In [[formal language]] theory, a [[context-free grammar]] is in '''Greibach normal form''' ('''GNF''') if the right-hand sides of all [[production (computer science)|production]] rules start with a [[terminal symbol]], optionally followed by some non-terminals. A non-strict form allows one exception to this format restriction for allowing the [[empty word]] (epsilon, ε) to be a member of the described language. The normal form was established by [[Sheila Greibach]] and it bears her name.
In [[formal language]] theory, a [[context-free grammar]] is in '''Greibach normal form''' ('''GNF''') if the right-hand sides of all [[production (computer science)|production]] rules start with a [[terminal symbol]], optionally followed by some non-terminals. A non-strict form allows one exception to this format restriction for allowing the [[empty word]] (epsilon, ε) to be a member of the described language. The normal form was established by [[Sheila Greibach]] and it bears her name.



Latest revision as of 19:42, 27 October 2025

Template:Short description In formal language theory, a context-free grammar is in Greibach normal form (GNF) if the right-hand sides of all production rules start with a terminal symbol, optionally followed by some non-terminals. A non-strict form allows one exception to this format restriction for allowing the empty word (epsilon, ε) to be a member of the described language. The normal form was established by Sheila Greibach and it bears her name.

More precisely, a context-free grammar is in Greibach normal form, if all production rules are of the form:

AaA1A2An

where A is a nonterminal symbol, a is a terminal symbol, and A1A2An is a (possibly empty) sequence of nonterminal symbols.

Observe that the grammar does not have left recursions.

Every context-free grammar can be transformed into an equivalent grammar in Greibach normal form.[1] Various constructions exist. Some do not permit the second form of rule and cannot transform context-free grammars that can generate the empty word. For one such construction the size of the constructed grammar is O(Template:Var4) in the general case and O(Template:Var3) if no derivation of the original grammar consists of a single nonterminal symbol, where Template:Var is the size of the original grammar.[2] This conversion can be used to prove that every context-free language can be accepted by a real-time (non-deterministic) pushdown automaton, i.e., the automaton reads a letter from its input every step.

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

See also

References

  1. Script error: No such module "Citation/CS1".
  2. Script error: No such module "Citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".