Abstract
A prefix-free language is a prime if it cannot be decomposed into a concatenation of two prefix-free languages. We show that we can check in polynomial time if a language generated by a simple context-free grammar is a prime. Our algorithm computes a canonical representation of a simple language, converting its arbitrary simple grammar into Prime Normal Form (PNF); a simple grammar is in PNF if all its nonterminals define primes. We also improve the complexity of testing the equivalence of simple grammars. The best previously known algorithm for this problem worked in O(n 13) time. We improve it to O(n 7 log2 n) and O(n 5 polylog v) deterministic time, and O(n 4 polylog n) randomized time, where n is the total size of the grammars involved, and v is the length of a shortest string derivable from a nonterminal, maximized over all nonterminals. Our improvement is based on a version of Caucal’s algorithm from [1].
The research of the first three authors was supported by NSERC and the research of the fourth author was supported by the grants KBN 4T11C04425 and ITR-CCR-0313219.
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Caucal, D.: A fast algorithm to decide on simple grammars equivalence. In: Djidjev, H.N. (ed.) Optimal Algorithms. LNCS, vol. 401, pp. 66–85. Springer, Heidelberg (1989)
Courcelle, B.: Une forme canonique pour les grammaires simples deterministes. RAIRO informatique, 19–36 (1974)
Korenjak, A.J., Hopcroft, J.E.: Simple deterministic languages. In: Proc. IEEE 7th Annual Symposium on Switching and Automata Theory. IEEE Symposium on Foundations of Computer Science, pp. 36–46 (1966)
Harrison, M.: Introduction to formal language theory. Addison-Wesley, Reading (1978)
Hirshfeld, Y., Jerrum, M., Moller, F.: A polynomial algorithm for deciding bisimilarity of normed context-free processes. Theoretical Computer Science 158, 143–159 (1996)
Plandowski, W.: Testing equivalence of morphisms on context-free languages. In: van Leeuwen, J. (ed.) ESA 1994. LNCS, vol. 855, pp. 460–470. Springer, Heidelberg (1994)
Karpinski, M., Rytter, W., Shinohara, A.: Pattern-matching for strings with short descriptions. In: Galil, Z., Ukkonen, E. (eds.) CPM 1995. LNCS, vol. 937, pp. 205–214. Springer, Heidelberg (1995)
Miyazaki, M., Shinohara, A., Takeda, M.: An improved pattern matching for strings in terms of straight-line programs. Journal of Discrete Algorithms 1, 187–204 (2000)
Debski, W., Fraczak, W.: Concatenation state machines and simple functions. In: Domaratzki, M., Okhotin, A., Salomaa, K., Yu, S. (eds.) CIAA 2004. LNCS, vol. 3317, pp. 113–124. Springer, Heidelberg (2005)
Czyzowicz, J., Fraczak, W., Pelc, A., Rytter, W.: Prime decompositions of regular prefix codes. In: Champarnaud, J.-M., Maurel, D. (eds.) CIAA 2002. LNCS, vol. 2608, pp. 85–94. Springer, Heidelberg (2003)
Fraczak, W., Podolak, A.: A characterization of s-languages. Information Processing Letters 89, 65–70 (2004)
Georgiadis, L., Tarjan, R.E.: Finding dominators revisited: extended abstract. In: Proceedings of the Fifteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2004, pp. 869–878. SIAM, Philadelphia (2004)
Courcelle, B.: An axiomatic approach to the Korenjak-Hopcroft algorithms. Mathematical Systems Theory 16, 191–231 (1983)
Rytter, W.: Application of Lempel–Ziv factorization to the approximation of grammar-based compression. Theoretical Computer Science 302, 211–222 (2003)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2006 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Bastien, C., Czyzowicz, J., Fraczak, W., Rytter, W. (2006). Prime Normal Form and Equivalence of Simple Grammars. In: Farré, J., Litovsky, I., Schmitz, S. (eds) Implementation and Application of Automata. CIAA 2005. Lecture Notes in Computer Science, vol 3845. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11605157_7
Download citation
DOI: https://doi.org/10.1007/11605157_7
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-31023-5
Online ISBN: 978-3-540-33097-4
eBook Packages: Computer ScienceComputer Science (R0)