This paper solves the problem of transforming the initial context-free grammar (CF-grammar) without excess characters into equivalent CF-grammar with less complexity. To solve this problem, the following relation on the set of a CF-grammar non-terminals is introduced: E = {(X, Y) : (X = Y) V (X → α ⇔ Y → β ∧ |α∣ = ∣β∣ ∧ ∀i (α(i) = = β(i) ∨(α(i), β(i)) ∈ E))} where X, Y are non-terminals, α, β are chains of terminal and non-terminals, possibly blank, α(i) is the i-th character in chain α, β(i) is the i-th character in chain β. It is proved that the relation E has the equivalence property and splits the set of non-terminals into equivalence classes. An algorithm is proposed for splitting a set of non-terminals into equivalence classes based on the method of sequential decomposition of the set of non-terminals into subsets so that non-equivalent non-terminals fall into different subsets. New CF-grammar is built on a set of nonterminals N , which elements are representatives of equivalence classes. From the set of rules of the initial CF-grammar, the rules with the left parts belonging to the set N are chosen. If there is a non-terminal in the left side of any selected rule that does not belong to the set N , then it is replaced by its equivalent non-terminal from the set N. After such transformations in the CF-grammar, sets of identical rules may appear. From each set of identical rules, we leave only one rule. The result is a CF-grammar containing less rules and non-terminals than the initial CF-grammar. The paper provides an example of the implementation of the described transformations.
Download file
Counter downloads: 125
- Title Minimization of context-free grammars
- Headline Minimization of context-free grammars
- Publesher
Tomsk State University
- Issue Prikladnaya Diskretnaya Matematika - Applied Discrete Mathematics 45
- Date:
- DOI 10.17223/20710410/45/10
Keywords
формальный язык, формальная грамматика, отношение эквивалентности, минимизация, formal language, formal grammar, equivalence relation, minimizationAuthors
References
Aho A. V. and Ullman J. D. The Theory of Parsing, Translation and Compiling. NJ, USA: Prentice-Hall Inc., 1972. V. 1. 560 p
Aho A. V., Lam M. S., Sethi R., and Ullman J. D. Compilers: Principles, Techniques, and Tools. Addison-Wesley, 2007, 1009 p
Конюхова О. В., Кравцова Э. А. Программная реализация алгоритмов упрощения контекстно-свободных грамматик на языках программирования Haskell и Prolog // Информационные системы и технологии. 2017. №4. С. 77-86
Hopcroft J. E. An nlog n algorithm for minimizing states in a finite automaton // Theory of Machines and Computations. N.Y.: Academic Press, 1971. P. 189-196
Hopcroft J. E., Motwani R., and Ullman J. D. Introduction to Automata Theory, Languages, and Computation. Pearson, 2013, 496 p
Мартыненко Б. К. Ещё один метод минимизации конечных автоматов // Компьютерные инструменты в образовании. 2017. № 1. С. 5-14
Polyakov V. M. and Ryazanov Yu. D. Reducing the number of states in pushdown recognizers by means of equivalence relation // Intern. J. Pharmacy & Technology. 2016. V. 8. No. 4. P. 22578-22587
Рязанов Ю. Д. Сокращение количества магазинных символов в распознавателях с магазинной памятью и одним состоянием // Вестник БГТУ им. В. Г. Шухова. 2017. № 6. С. 152-157
Мартыненко Б. К. Синтаксически управляемая обработка данных. СПб.: Изд-во С.-Петербург. ун-та, 2004. 316 c
Федорченко Л. Н. Минимизация трансляционной КСР-грамматики и состояний синтаксического анализатора КСР-языка // Вестник Бурятского государственного университета. Математика, информатика. 2013. № 2. С. 39-49
Стасенко А. П. Автоматная модель визуального описания синтаксического разбора // Вычислительные технологии. 2008. Т. 13. № 5. С. 70-87

Minimization of context-free grammars | Prikladnaya Diskretnaya Matematika - Applied Discrete Mathematics. 2019. № 45. DOI: 10.17223/20710410/45/10
Download full-text version
Counter downloads: 385