Greibach normal form
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:
where is a nonterminal symbol, is a terminal symbol, and 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(n4) in the general case and O(n3) if no derivation of the original grammar consists of a single nonterminal symbol, where n 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 n, any top-down parser will halt at depth n.
Variants of Greibach normal form
It is even possible to convert a grammar into Greibach normal form in a way such that in every production, at most two nonterminal symbols occur on the right-hand side; this is referred to as quadratic Greibach normal form.
A context-free grammar is in double Greibach normal form, if all production rules take one of the two forms:
where is a nonterminal symbol, are terminal symbols (not necessarily distinct), and is a (possibly empty) sequence of nonterminal symbols. Similarly as above, a grammar is in quadratic double Greibach normal form, if at most two nonterminal symbols occur in the right-hand side of each production. A classic result by Hotz (1978) states that every context-free grammar that does not generate the empty word can be effectively converted into an equivalent grammar in quadratic double Greibach normal form.
See also
References
- ^ Greibach, Sheila (January 1965). "A New Normal-Form Theorem for Context-Free Phrase Structure Grammars". Journal of the ACM. 12 (1): 42–52. doi:10.1145/321250.321254. S2CID 12991430.
- ^ Blum, Norbert; Koch, Robert (1999). "Greibach Normal Form Transformation Revisited". Information and Computation. 150 (1): 112–118. CiteSeerX 10.1.1.47.460. doi:10.1006/inco.1998.2772. S2CID 10302796.
- Alexander Meduna (6 December 2012). Automata and Languages: Theory and Applications. Springer Science & Business Media. ISBN 978-1-4471-0501-5.
- György E. Révész (17 March 2015). Introduction to Formal Languages. Courier Corporation. ISBN 978-0-486-16937-8.
- Autebert, J. M., Berstel, J., & Boasson, L. (1997). Context-free languages and pushdown automata. In Handbook of Formal Languages: Volume 1 Word, Language, Grammar (pp. 111-174). Berlin, Heidelberg: Springer Berlin Heidelberg.
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.