Summary
A large, automatically detectable class of non-linear functions is defined and their evaluation graphs are characterised. These results are then used to develop space-efficient implementation ofmemo-functions. We generate a variant of memo-functions which can be used to linearise the time cost of calls of a non-linear function to itself whilst executing in bounded space. These memo-functions dynamically garbage collect (or reuse) memo-table entries when it is known that such entries will not be useful again. For each non-linear function a function called the “table-manager” function is synthesised by a static analysis of the definition of the non-linear function. The table-managers delete (or reuse) entries that are guaranteed to be obsolete as a result of any insertion into the memo-tables. In this way they ensure that the size of the tables is minimised. Furthermore, the sizes of the tables for these memo-functions are guaranteed not to exceed a compile-time constant found by the same static analysis which synthesises the table-managers. The applicability of the method also includes many problems which have been previously solved by applyingdynamic programming techniques. An implementation of these memo-functions for the functional language HOPE is also outlined.
Similar content being viewed by others
References
[AbHa87] Abramsky, S., Hankin, C.L.: Abstract interpretation of declarative languages. Chichester: Ellis Horwood 1987
[AhHoUl174] Aho, A.V., Hopcroft, J.E., Ullman, J.D.: The design and analysis of computer algorithms. Reading, Mass.: Addison-Wesley 1974
[Ba78] Backus, J.W.: Can programming be liberated from the von Neumann Style? A functional style and its algebra of programs. CACM21(8), 613–641 (1978)
[Ba81] Backus, J.W.: The algebra of functional programs: function level reasoning, linear equations and extended definitions. (Lect. Notes Comput. Sci., vol. 107, pp. 1–43) Berlin Heidelberg New York: Springer 1981
[BaFiKh86] Bailey, R., Field, A.J., Khoshnevisan, H.: Efficient implementation of functional programs. Research Report, Department of Computing, Imperial College, London 1986
[Be 75] Bellman, R.E.: Dynamic programming. Princeton, NJ: Princeton University Press 1975
[Bi77] Bird, R.S.: Improving programs by the introduction of recursion. Commun. ACM20(11), 856–863 (1977)
[Bi80] Bird, R.S.: Tabulation techniques for recursive programs. ACM Comput. Surveys12(4), 403–417 (1980)
[Bi86] Bird, R.S.: Transformational programming and the paragraph problem. Sci. Comput. Program.6, 159–189 (1986)
[BuDa77] Burstall, R.M., Darlington, J.: A transformation system for developing recursive programs. JACM24, No. 1 (1977)
[BuMcSa80] Burstall, R.M., McQueen, D.B., Sannella, D.T.: HOPE: An experimental applicative language. Proceedings 1st International LISP conference, Stanford, pp. 136–143 (1980)
[Co79] Cohen, N.H.: Characterisation and elimination of redundancy in recursive programs. 6th Annual ACM Symposium on Principles of Programming Languages. Antonio, Texas, pp. 143–157 (1979)
[Co80] Cohen, N.H.: Source-to-Source improvement of recursive programs. Ph.D. thesis, Division of Applied Sciences, Harvard Univ, Cambridge, Mass. (1980)
[Co83] Cohen, N.H.: Eliminating redundant recursive calls. ACM Trans. Program. Languages Systems5, 265–299 (1983)
[Da79] Darlington, J., A synthesis of several sorting algorithms. Acta Inf.11, 1 (1979)
[DaBu76] Darlington, J., Burstall, R.M.: A system which automatically improves programs. Acta Inf.6, 1 (1976)
[GiKi84] Givler, J.S., Kieburtz, R.G.: Schema recognition for program transformation. ACM Symposium on LISP and Functional Programming, pp. 74–85 (1984)
[Ha88] Harrison, P.G.: Linearisation: An optimisation for non-linear functional programs. Sci. Comput. Program.10, 281–318 (1988)
[Hi76] Hilden, J.: Elimination of recursive calls using a small table of “randomly” selected function values. BIT16(1), 60–73 (1976)
[Hu85] Hughes, J.: Lazy memo-functions. In: Jouannand, J.P. (ed.) Functional programming languages and computer architectures. (Lect. Notes Comput. Sci., vol. 201) Berlin Heidelberg New York: Springer 1985
[Kh87] Khoshnevisan, H.: Automatic transformation systems based on function-level reasoning. Ph.D. thesis, Department of Computing, Imperial College, University of London (1987)
[KeS181] Keller, R.M., Sleep, M.R.: APPLICATIVE CACHING: Programmer control of object sharing and lifetime in distributed implementations of applicative languages. ACM Conference on functional languages and computer architecture, Portsmouth, pp. 131–140 (1981)
[Mc63] McCarthy, J.: Predicate calculus with undefined as a truth value. Stanford Artificial Intelligence Memo 1, Computer Science Dept., Stanford Univ., Stanford, Calif. (1963)
[Mc] McCarthy, J.: On efficient ways of evaluating certain recursive functions. Project MAC A.I. Memo 32, M.I.T., Cambridge, Mass. (undated)
[PaHe70] Paterson, M.S., Hewitt, C.E.: Comparative schematology. Record of project MAC Conference on concurrent systems and parallel computation, Woods Hole, Mass., pp. 119–127 (June 1970)
[PaPe76] Partsch, H., Pepper, P.: A family of rules for recursion removal related to the towers of Hanoi problem. Inf. Process. Lett.5(6), 174–177 (1976)
[ReNiDe77] Reingold, E.M., Nievergelt, J., Deo, N.: Combinatorial algorithms: Theory and practice. Englewood Cliffs, N.J., Prentice-Hall 1977
[Se83] Sedgewick, R.: Algorithms. Reading, MA: Addison-Wesley 1983
[SpLe78] Spitzen, J.M., Levitt, K.N.: An example of hierarchical design and proof. Commun. ACM21(12), 1064–1075 (1978)
[Vo66] Voroboyov, N.N.: The Fibonacci numbers. Boston, Mass.: D.C. Heath 1966
[We71] Wells, M.B.: Elements of combinatorial computing. London New York: Pergamon Press 1971
[Wi82] Williams, J.H.: On the development of the algebra of functional programs. ACM Trans. Program. Languages Systems4(4), 733–757 (1982)
Author information
Authors and Affiliations
Rights and permissions
About this article
Cite this article
Khoshnevisan, H. Efficient memo-table management strategies. Acta Informatica 28, 43–81 (1990). https://doi.org/10.1007/BF02983374
Received:
Issue Date:
DOI: https://doi.org/10.1007/BF02983374