Abstract
Equational programming [HO82b] involves replacing subterms in a term according to a set of equations or rewrite rules. Each time an equation is applied to the term, the subterm that matches the left hand side of the equation is replaced by the corresponding right hand side. In that process several nodes of the term tree are created. Some of these nodes may later turn out to be useless, and will be reclaimed.
This paper discusses important relationships between two equational programs. In particular we define the term mutual confluence and show that two equational programs with the mutual confluence property have the same output behavior with very general assumptions about the reduction strategy. As an application of our result, we discuss source-to-source transformations of an equational program E to an equational program F. Our transformations are used as a part of a compiler to improve execution time of E by avoiding the creation of too many nodes in the reduction process. We show that our transformations indeed give E and F the mutual confluence property, thus preserving the output behavior of E when transformed to F.
Preserving the output behavior is more general than preserving just normal forms, in that we allow for infinite computations where we output stable parts of the term, i.e., parts that can never change as a result of further reductions.
Chapter PDF
Similar content being viewed by others
7. Bibliography
Aho, A. V. and Corasick, M. J. ”Efficient String Matching: An Aid to Bibliographic Search”, Communications of the ACM 18:6 pp. 333–340 (1975).
Backus, J. ”Can Programming Be Liberated from the von Neumann Style? A Functional Style and its Algebra of Programs”, Communications of the ACM 21:8 pp. 613–641 (1978).
Friedman, D. and Wise, D. ”Cons should not evaluate its arguments”, 3rd International Colloquium on Automata, Languages and Programming., Edinburgh University Press pp. 257–284 (1976).
Gabriel, R. P. Performance and Evaluation of Lisp Systems, MIT Press, Cambridge, Mass. (1985).
Huet, G. and Lévy, J.-J. ”Computations in Non-ambiguous Linear Term Rewriting Systems”, INRIA Technical Report #359 (1979).
Henderson, P. and Morris, J. H. ”A Lazy Evaluator”, 3rd ACM Symposium on Principles of Programming Languages pp. 95–103 (1976).
Hoffmann, C., O'Donnell, M. ”Pattern Matching in Trees”, Journal of the ACM, pp. 68–95 (1982).
Hoffmann, C., O'Donnell, M. ”Programming with Equations”, ACM Transactions on Programming Languages and Systems pp. 83–112 (1982).
Hoffmann, C., O'Donnell, M. and Strandh, R., ”Programming with Equations”, Software, Practice and Experience, (December 1985).
Johnsson, T. ”Efficient Compilation of Lazy Evaluation”, Proceedings of the ACM SIGPLAN 1984 Symposium on Compiler Construction, Montreal (1984).
Knuth, D. E., Morris, J. and Pratt, V. ”Fast Pattern Matching in Strings” SIAM Journal on Computing 6:2: pp. 323–350 (1977).
O'Donnell, M. J. Computing in Systems Described by Equations, Lecture Notes in Computer Science v. 58, Springer-Verlag (1977).
O'Donnell, M. J. Equational Logic as a Programming Language, MIT Press, Cambridge, Mass. (1985).
Thatte, S. ”On the Correspondence Between Two Classes of Reduction Systems” Information Processing Letters 20, pp. 83–85, (1985).
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1987 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Strandh, R. (1987). Optimizing equational programs. In: Lescanne, P. (eds) Rewriting Techniques and Applications. RTA 1987. Lecture Notes in Computer Science, vol 256. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-17220-3_2
Download citation
DOI: https://doi.org/10.1007/3-540-17220-3_2
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-17220-8
Online ISBN: 978-3-540-47421-0
eBook Packages: Springer Book Archive