Abstract
We propose a calculus for the analysis of list lengths in functional programs. In contrast to common type-based approaches, it is based on the syntactical structure of the program. To our knowledge, no other approach provides such a detailed analysis of nested lists.
The analysis of lists is preceded by a program transformation which makes sizes explicit as program values and eliminates the chain of cons operations. This permits alternative implementations of lists, e.g., by functions or arrays. The technique is being implemented in an experimental parallelizing compiler for the functional language \( \mathcal{H}\mathcal{D}\mathcal{C} \).
We believe that analysis and parallelization work best if higher-order functions are used to compose the program from functional building blocks, so-called skeletons, instead of using unrestrained recursion. Skeletons, e.g., data-parallel combinators come with a theory of sizes and parallelization.
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
Jeffrey M. Bell, Françoise Bellegarde, and James Hook. Type-driven defunctionalization. SIGPLAN Notices, 32(8):25–37, 1997.
Gianni Bellè and Eugenio Moggi. Typed intermediate languages for shape-analysis. In Typed Lambda Calculi and Applications (TLCA’97), Lecture Notes in Computer Science 1210, pages 11–29. Springer-Verlag, 1997.
Richard S. Bird. Algebraic identities for program calculation. The Computer Journal, 32(2):122–126, 1989.
Siddharta Chatterjee, Guy E. Blelloch, and Allan L. Fisher. Size and access inference for data-parallel programs. Technical Report CMU-CS-91-118, Dept. Computer Science, Carnegie-Mellon Univ., 1991.
Wei-Ngan Chin and Siau-Cheng Khoo. Tupling functions with multiple recursion parameters. In Patrick Cousot, Moreno Falaschi, Gilberto File, and Antoine Rauzy, editors, Static Analysis Third Int. Workshop (WAS’93), Lecture Notes in Computer Science 724, pages 124–140. Springer-Verlag, 1993.
Wei-Ngan Chin and Siau-Cheng Khoo. Calculating sized types. In Proceedings of the 2000 ACM SIGPLAN Workshop on Evaluation and Semantics-Based Program Manipulation (PEPM-00), pages 62–72, N.Y., 2000. ACM Press.
Koen Claessen and Mary Sheeran. A tutorial on Lava: A hardware description and verification system. Technical report, Dept. of Computing Science, Chalmers University of Technology, August 2000.
Patrick Cousot and Radhia Cousot. Abstract interpretation: A unified lattice model for static analysis of programs by construction of approximation of fixed points. In Proc. 4th ACM Symp. Principles of Programming Languages (POPL’77), pages 238–252. ACM Press, 1977.
John Darlington, Anthony Field, Peter Harrison, Paul Kelly, David Sharp, Qian Wu, and Ronald L. While. Parallel programming using skeleton functions. In Arndt Bode, Mike Reeve, and Gottfried Wolf, editors, PARLE’93: Parallel Architectures and Languages Europe, Lecture Notes in Computer Science 694, pages 146–160. Springer-Verlag, 1993.
Nancy A. Day, Jeffrey R. Lewis, and Byrin Cook. Symbolic simulation of microprocessor models using type classes in Haskell. Technical Report CSE-99-005, Pacific Software Research Center, Oregon Graduate Institute, 1999.
Roberto Di Cosmo. Isomorphisms of Types: from λ-calculus to information retrieval and language design. Progress in Theoretical Computer Science. Birkhäuser, 1995.
Pascal Fradet and Julien Mallet. Compilation of a specialized functional language for massively parallel computers. Technical Report 3894, Institut National der Recherche en Informatique et en Automatique (INRIA), 2000.
Sergei Gorlatch. Extracting and implementing list homomorphisms in parallel program development. Science of Computer Programming, 33(1):1–27, 1999.
Ronald L. Graham, Donald E. Knuth, and Oren Patashnik. Concrete Mathematics. Addison-Wesley Publishing Company, 1994.
Per Hammarlund and Björn Lisper. On the relation between functional and data parallel programming languages. In Proc. Sixth Conf. on Functional Programming Languages and Computer Architecture (FPCA’93), pages 210–222. ACM Press, 1993.
haskell.org, 2000. http://www.haskell.org.
Christoph A. Herrmann and Christian Lengauer. Size inference of nested lists in functional programs. In Kevin Hammond, Tony Davie, and Chris Clack, editors, Proc. 10th Int. Workshop on the Implementation of Functional Languages (IFL’98), pages 346–364. Dept. Computer Science, Univ. College London, 1998.
Christoph A. Herrmann, Christian Lengauer, Robert Günz, Jan Laitenberger, and Christian Schaller. A compiler for HDC. Technical Report MIP-9907, Fakultät für Mathematik und Informatik, Univ. Passau, May 1999.
Christoph A. Herrmann. The Skeleton-Based Parallelization of Divide-and-Conquer Recursions. PhD thesis, Fakultät für Mathematik und Informatik, Univ. Passau. Logos-Verlag, Berlin, 2000.
Christoph A. Herrmann and Christian Lengauer. HDC: A higher-order language for divide-and-conquer. Parallel Processing Letters, 10(2-3):239–250, 2000.
Martin Hofmann. A type system for bounded space and functional in-place update-extended abstract. In Gerd Smolka, editor, Programming Languages and Systems (ESOP 2000), Lecture Notes in Computer Science 1782, pages 165–179. Springer-Verlag, 2000.
John Hughes, Lars Pareto, and Amr Sabry. Proving the correctness of reactive systems using sized types. In Proc. 23rd Ann. ACM Symp. on Principles of Programming Languages (POPL’96), pages 410–423. ACM Press, 1996.
C. Barry Jay and Milan Sekanina. Shape checking of array programs. In J. Harland, editor, Proc. Australasian Theory Seminar on Computing, volume 19 of Australian Computer Science Communications, pages 113–121, 1997.
Björn Lisper and Jean-François Collard. Extent analysis of data fields. In Baudouin Le Charlier, editor, Static Analysis (SAS’94), Lecture Notes in Computer Science 864, pages 208–222. Springer-Verlag, 1994.
Hans-Wolfgang Loidl and Kevin Hammond. A sized time system for a parallel functional language. In Proc. 1996 Glasgow Workshop on Functional Programming, 1996. Electronic publication: http://www.dcs.gla.ac.uk/fp/workshops/fpw96/Proceedings96.html.
Jayadev Misra. Powerlist: A structure for parallel recursion. ACM Trans. on Programming Languages and Systems, 16(6):1737–1767, November 1994.
Flemming Nielson and Hanne Riis Nielson. Two-level functional languages. Number 34 in Cambridge Tracts in Theoretical Computer Science. Cambridge University Press, 1992.
John T. O’Donnell. Bidirectional fold and scan. In Functional Programming: Glasgow 1993, Workshops in Computing, pages 193–200. Springer-Verlag, 1994.
John T. O’Donnell. From transistors to computer architecture: Teaching functional circuit specification in Hydra. In Pieter H. Hartel and Rinus Plasmeijer, editors, Functional Programming Languages in Education, Lecture Notes in Computer Science 1022, pages 195–214. Springer-Verlag, 1995.
James Riely and Jan Prins. Flattening is an improvement. In Jens Palsberg, editor, Static Analysis (SAS’2000), Lecture Notes in Computer Science 1824, pages 360–376. Springer-Verlag, 2000.
Philip Wadler. Views: A way for pattern matching to cohabit with data abstraction. In Proc. 14th ACM Symp. Principles of Programming Languages (POPL’87), pages 307–313. ACM Press, 1987.
Hongwei Xi and Frank Pfenning. Dependent types in practical programming. In Proc. 26th ACM Symp. Principles of Programming Languages (POPL’99), pages 214–227. ACM Press, 1999.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2001 Springer-Verlag Berlin Heidelbrg
About this paper
Cite this paper
Herrmann, C.A., Lengauer, C. (2001). A Transformational Approach which Combines Size Inference and Program Optimization. In: Taha, W. (eds) Semantics, Applications, and Implementation of Program Generation. SAIG 2001. Lecture Notes in Computer Science, vol 2196. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-44806-3_12
Download citation
DOI: https://doi.org/10.1007/3-540-44806-3_12
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-42558-8
Online ISBN: 978-3-540-44806-8
eBook Packages: Springer Book Archive