Abstract
Functional programs are more amenable to rigorous mathematical analysis than imperative programs, but are typically less efficient in terms of execution space and time. The update of aggregate data structures, such as arrays, are a significant source of space/time inefficiencies in functional programming. Imperative programs can execute such updates in place, whereas the semantics of functional languages require aggregate data structures to be copied and updated. In many functional programs, the execution of aggregate updates by copying is redundant and could be safely implemented by means of destructive, inplace updates. We describe a method for analyzing higher-order, eager functional programs for safe destructive updates. This method has been implemented for the PVS specification language for the purpose of animating or testing specifications to check if they accurately reflect their intended function. We also give a careful proof of correctness for the safety of the destructive update optimization.
Funded by NSF Grants CCR-0082560 and CCR-9712383, DARPA/AFRL Contract F33615-00-C-3043, and NASA Contract NAS1-20334. The author is deeply grateful to the programme committee of the 11th International Workshop on Logic-based Program Synthesis and Transformation, LOPSTR 01, for the opportunity to present this work. The LOPSTR 01 programme chair, Professor Alberto Pettorossi, made several excellent suggestions, and Pavol Cerny (visiting SRI from ENS Paris) corrected numerous typographical errors in earlier drafts of this paper.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
A. Bloss and P. Hudak. Path semantics. In Proceedings of the Third Workshop on the Mathematical Foundations of Programming Language Semantics, number 298 in Lecture Notes in Computer Science, pages 476–489. Springer-Verlag, 1987.
Adrienne Bloss. Path analysis and the optimization of nonstrict functional languages. ACM Transactions on Programming Languages and Systems, 16(3):328–369, 1994.
M. Draghicescu and S. Purushothaman. A uniform treatment of order of evaluation and aggregate update. Theoretical Computer Science, 118(2):231–262, September 1993.
M. Felleisen. On the expressive power of programming languages. In European Symposium on Programming, number 432 in Lecture Notes in Computer Science, pages 35–75. Springer-Verlag, 1990.
K. Gopinath and John L. Hennessy. Copy elimination in functional languages. In 16th ACM Symposium on Principles of Programming Languages. Association for Computing Machinery, January 1989.
Deepak Goyal and Robert Paige. A new solution to the hidden copy problem. In Static Analysis Symposium, pages 327–348, 1998.
P. Hudak. A semantic model of reference counting and its abstraction. In S. Abramsky and C. Hankin, editors, Abstract Interpretation of Declarative Languages. Ellis Horwood Ltd., 1987. Preliminary version appeared in Proceedings of 1986 ACM Conference on LISP and Functional Programming, August 1986, pages 351–363.
Martin Odersky. How to make destructive updates less destructive. In Proc. 18th ACM Symposium on Principles of Programming Languages, pages 25–26, January 1991.
S. Owre, J. M. Rushby, and N. Shankar. PVS: A prototype verification system. In Deepak Kapur, editor, 11th International Conference on Automated Deduction (CADE), volume 607 of Lecture Notes in Artificial Intelligence, pages 748–752, Saratoga, NY, June 1992. Springer-Verlag.
Sam Owre and Natarajan Shankar. The formal semantics of PVS. Technical Report SRI-CSL-97-2, Computer Science Laboratory, SRI International, Menlo Park, CA, August 1997.
A. Pettorossi. Improving memory utilization in transforming recursive programs. InJ. Winkowski, editor, Proceedings of MFCS 1978, pages 416–425, Berlin, Germany, 1978. Springer-Verlag.
Alberto Pettorossi and Maurizio Proietti. Synthesis and transformation of logic programs using unfold/fold proofs. Journal of Logic Programming, 41(2–3):197–230, 1999.
A. V. S. Sastry, William Clinger, and Zena Ariola. Order-of-evaluation analysis for destructive updates in strict functional languages with flat aggregates. In Conference on Functional Programming Languages and Computer Architecture, pages 266–275, New York, 1993. ACM Press.
Jerald Schwarz. Using annotation to make recursion equations behave. IEEE Transactions on Software Engineering, 8(1):21–33, 1982.
John H. G. van Groningen. The implementation and efficiency of arrays in Clean 1.1. In Proc. 8th International Workshop on Implementation of Functional Languages, IFL’96, number 1268 in Lecture Notes in Computer Science, pages 105–124. Springer-Verlag, 1996.
P. Wadler. Linear types can change the world! In M. Broy and C. Jones, editors, Programming Concepts and Methods. North-Holland, Amsterdam, 1990.
P. Wadler. How to declare an imperative. ACM Computing Surveys, 29(3):240–263, September 1997.
Mitchell Wand and William D. Clinger. Set constraints for destructive array update optimization. In Proc. IEEE Conf. on Computer Languages’ 98, pages 184–193. IEEE, April 1998.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2002 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Shankar, N. (2002). Static Analysis for Safe Destructive Updates in a Functional Language. In: Pettorossi, A. (eds) Logic Based Program Synthesis and Transformation. LOPSTR 2001. Lecture Notes in Computer Science, vol 2372. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-45607-4_1
Download citation
DOI: https://doi.org/10.1007/3-540-45607-4_1
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-43915-8
Online ISBN: 978-3-540-45607-0
eBook Packages: Springer Book Archive