Optimal left-to-right pattern-matching automata
We propose a practical technique to compile pattern-matching for prioritised overlapping patterns in equational languages into a minimal, deterministic, left-to-right, matching automaton. First, we present a method for constructing a tree matching automaton for such patterns. This allows pattern-matching to be performed without any backtracking. Space requirements are reduced by using a directed acyclic graph (dag) automaton that shares all the isomorphic subautomata which are duplicated in the tree automaton. We design an efficient method to identify such subautomata and avoid duplicating their construction while generating the dag automaton. We conclude with some easily computed bounds on the size of the automata, thereby improving on previously known equivalent bounds for the tree automaton.
KeywordsTerm rewriting system pattern-matching tree automaton dag automaton
Unable to display preview. Download preview PDF.
- Aho, A.V., Sethi, R. and Ulmann, J.D., Compilers: Principles, Techniques and Tools, Addison-Wesley Publishing Company, 1986.Google Scholar
- Gräf, A., “Left-to-Right Pattern-Matching”, in Proc. Rewriting Techniques and Applications, Lecture Notes in Computer Science, Vol. 488, pp. 323–334, Springer Verlag, 1991.Google Scholar
- Hoffman, C.M. and O'Donnell, M.J., “Pattern-Matching in Trees”, Journal of the ACM, Vol 29, pp. 68–95, January 1982.Google Scholar
- Hoffman, C.M., O'Donnell, M.J. and Strandh, R. “Programming with Equations”, Software, Practice and Experience, Vol. 15, No. 12, pp. 1185–1204, December 1985.Google Scholar
- Johnson, S. C., Yacc — Yet Another Compiler Compiler, Computing Science Technical Report 32, AT&T Laboratories, Murray Hill, N. J., 1975.Google Scholar
- Kennaway, J. R., “The Specificity Rule for Lazy Pattern Matching in Ambiguous Term Rewriting Systems”, Proc. 3rd European Symposium on Programming, Lecture Notes in Computer Science, Vol. 432, pp. 256–270, Springer-Verlag,1990.Google Scholar
- Knuth, D.E., Morris, J. and Pratt, V., “Fast Pattern-Matching in Strings”, SIAM Journal on Computing, Vol. 6, No. 2, pp. 323–350, 1977.Google Scholar
- Nedjah, N., Pattern-Matching Automata for Efficient Evaluation in Equational Programming, Ph.D. Thesis, UMIST, Manchester, UK, 1997.Google Scholar
- Nedjah, N., Walter, C.D. and Eldridge, S.E., Efficient Automaton-Driven Pattern-Matching for Equational Programs, Technical Report, Computation Dept., UMIST, Manchester, UK, 1996.Google Scholar
- O'Donnell, M.J., Equational Logic as a Programming Language, The MIT Press, 1985.Google Scholar
- Sekar, R.C., Ramesh, R. and Ramakrishnan, I.V., “Adaptive Pattern Matching”, SIAM Journal on Computing, Vol. 24, No. 5, pp. 1207–1234, December 1995.Google Scholar