More Efficient Left-to-Right Pattern Matching in Non-sequential Equational Programs

  • Nadia Nedjah
  • Luiza de Macedo Mourelle
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 2676)


Pattern matching is a fundamental feature in many applications such as functional programming, logic programming, theorem proving, term rewriting and rule-based expert systems. Usually, patterns are pre-processed into a deterministic finite automaton. Using such an automaton allows one to determine the matched pattern(s) by a single scan of the input term. The matching automaton is typically based on left-to-right traversal of patterns. In this paper, we propose a method to build such an automaton. Then, we propose an incremental method to build a deterministic concise automaton for non-necessarily sequential rewriting systems. With ambiguous patterns a subject term may be an instance of more than one pattern. To select the pattern to use, a priority rule is usually engaged. The pre-processing of the patterns adds new patterns, which are instances of the original ones. When the original patterns are ambiguous, some of the instances supplied may be irrelevant for the matching process. They may cause an unnecessary increase in the space requirements of the automaton and may also reduce the time efficiency of the matching process. Here, we devise a new pre-processing operation that recognises and avoids such irrelevant instances. Hence improves space and time requirements for the matching automaton.


Pattern Match Function Symbol Successor State Priority Rule Subject Term 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Augustsson A., A Compiler for lazy ML, Proc. Conference on Lisp and Functional Programming, ACM, pp. 218–227, 1984Google Scholar
  2. 2.
    Christian J., Flatterms, Discrimination nets and fast term rewriting, Journal of Automated Reasoning, vol. 10, pp. 95–113, 1993CrossRefMathSciNetGoogle Scholar
  3. 3.
    Cooper, D. and Wogrin, N. Rule-based programming with OPS5, Morgan Kaufmann, San Francisco, 1988Google Scholar
  4. 4.
    Dershowitz, N., Jouannaud, J.P., Rewrite systems, Handbook of Theoretical Computer Science, vol. 2, chap. 6, Elsevier Science, 1990Google Scholar
  5. 5.
    Field, A.J., Harrison, P.G., Functional programming, International Computer Science Series, 1988Google Scholar
  6. 6.
    Goguen, J.A., Winkler, T., Introducing OBJ3, Technical report SRI-CSL-88-9, Computer Science Laboratory, SRI International, 1998Google Scholar
  7. 7.
    Graf, A., Left-to-right tree pattern matching, Proc. Conference on Rewriting Techniques and Applications, Lecture Notes in Computer Science, Springer-Verlag, vol. 488, pp. 323–334, 1991Google Scholar
  8. 8.
    Hoffman, C.M., O’Donnell, M.J., Pattern matching in trees, Journal of ACM, vol. 29, no. 1, pp. 68–95, 1982CrossRefGoogle Scholar
  9. 9.
    Hudak, P., al., Report on the programming language Haskell: a Non-Strict, Purely Functional Language, Sigplan Notices, Section S, May 1992Google Scholar
  10. 10.
    Laville, A., Comparison of priority rules in pattern matching and term rewriting, Journal of Symbolic Computation, no. 11, pp. 321–347, 1991zbMATHMathSciNetCrossRefGoogle Scholar
  11. 11.
    Nedjah, N., Walter, C.D., Eldridge, S.E., Optimal left-to-right pattern matching automata, Proc. Conference on Algebraic and Logic Programming, Southampton, UK, Lecture Notes in Computer Science, M. Hanus, J. Heering and K. Meinke (Eds.), Springer-Verlag, vol. 1298, pp. 273–285, 1997CrossRefGoogle Scholar
  12. 12.
    Nedjah, N., Postponing redex contractions in equational programs, Proc. Symposium on Functional and Logic Programming, Kyoto, Japan, M. Sato and Y. Toyama (Eds.), World Scientific, pp. 40–60, 1998Google Scholar
  13. 13.
    Nedjah, N., Walter, C.D., Eldridge, S.E., Efficient automata-driven pattern matching for equational programs, Software-Practice and Experience, vol. 29, no 9, pp. 793–813, John Wiley, 1999CrossRefGoogle Scholar
  14. 14.
    Nedjah, N., Mourelle, L.M., Dynamic deterministic pattern matching, Proc. Computing: the Australasian Theory Symposium, Canberra, Australia, Elsevier Science, D.A. Wolfram (Ed.), vol. 31, 2000Google Scholar
  15. 15.
    Nedjah, N., Mourelle, L.M., Improving time, space and termination in term rewriting-based programming, Proc. International Conference on Industrial & Engineering Applications of Artificial Intelligence & Expert Systems, Budapest, Hungary, Lecture Notes in Computer Science, L. Monostori, J. Váncsa and A. M. Ali (Eds.), Springer-Verlag, vol. 2070, pp. 880–890, June 2001Google Scholar
  16. 16.
    O’Donnell, M.J, Equational logic as programming language, MIT Press, 1985Google Scholar
  17. 17.
    Sekar, R.C., Ramesh, R. and Ramakrishnan, I.V., Adaptive pattern matching, SIAM Journal, vol. 24, no. 5, pp. 1207–1234, 1995zbMATHCrossRefMathSciNetGoogle Scholar
  18. 18.
    Turner, D.A., Miranda: a Non strict functional language with polymorphic Types, Proc. Conference on Lisp and Functional Languages, ACM, pp. 1–16, 1985Google Scholar
  19. 19.
    Wadler, P., Efficient compilation of pattern matching, In “The Implementation of Functional Programming Languages”, In S. L. Peyton-Jones, Prentice-Hall International, pp. 78–103, 1987Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2003

Authors and Affiliations

  • Nadia Nedjah
    • 1
  • Luiza de Macedo Mourelle
    • 1
  1. 1.Department of Systems Engineering and Computation, Faculty of EngineeringState University of Rio de JaneiroMaracanã, Rio de Janeiro, RJBrazil

Personalised recommendations