A Type System for Bounded Space and Functional In-Place Update

We show how linear typing can be used to obtain functional programs which modify heap-allocated data structures in place. We present this both as a "design pattern" for writing C-code in a functional style and as a compilation process from linearly typed first-order functional programs into malloc()-free C code. The main technical result is the correctness of this compilation. The crucial innovation over previous linear typing schemes consists of the introduction of a resource type ⋄ which controls the number of constructor symbols such as cons in recursive definitions and ensures linear space while restricting expressive power surprisingly little. While the space efficiency brought about by the new typing scheme and the compilation into C can also be realised by with state-of-the-art optimising compilers for functional languages such as OCAML [15], the present method provides guaranteed bounds on heap space which will be of use for applications such as languages for embedded systems or 'proof carrying code' [18].

[1]  E. R I K B A R En D S E N,et al.  Uniqueness Typing for Functional Languages with Graph Rewriting Semantics , 1996 .

[2]  Peter W. O'Hearn,et al.  Syntactic Control of Interference Revisited , 1999, Theor. Comput. Sci..

[3]  Alan Mycroft,et al.  Abstract interpretation and optimising transformations for applicative programs , 1982 .

[4]  Henry G. Baker A “linear logic” Quicksort , 1994, SIGP.

[5]  Ira Pohl,et al.  A book on C , 1984 .

[6]  Lars Birkedal,et al.  A region inference algorithm , 1998, TOPL.

[7]  Yves Lafont,et al.  The Linear Abstract Machine , 1988, Theor. Comput. Sci..

[8]  Carl A. Gunter,et al.  Reference counting as a computational interpretation of linear logic , 1996, Journal of Functional Programming.

[9]  Philip Wadler,et al.  Operational Interpretations of Linear Logic , 1999, Theor. Comput. Sci..

[10]  John Hughes,et al.  Recursion and dynamic data-structures in bounded space: towards embedded ML programming , 1999, ICFP '99.

[11]  Martin Hofmann,et al.  Linear types and non-size-increasing polynomial time computation , 1999, Proceedings. 14th Symposium on Logic in Computer Science (Cat. No. PR00158).

[12]  Andre Scedrov,et al.  Bounded Linear Logic: A Modular Approach to Polynomial-Time Computability , 1992, Theor. Comput. Sci..

[13]  George C. Necula,et al.  Proof-carrying code , 1997, POPL '97.

[14]  Paul Hudak,et al.  Rolling your own mutable ADT—a connection between linear types and monads , 1997, POPL '97.

[15]  Stephen A. Cook,et al.  Linear Time Simulation of Deterministic Two-Way Pushdown Automata , 1971, IFIP Congress.

[16]  Karl Crary,et al.  Resource bound certification , 2000, POPL '00.

[17]  Samson Abramsky,et al.  Computational Interpretations of Linear Logic , 1993, Theor. Comput. Sci..

[18]  P. Lincoln,et al.  Operational aspects of linear lambda calculus , 1992, [1992] Proceedings of the Seventh Annual IEEE Symposium on Logic in Computer Science.

[19]  Mads Tofte,et al.  Region-based Memory Management , 1997, Inf. Comput..

[20]  Chris Okasaki,et al.  Purely functional data structures , 1998 .

[21]  John C. Reynolds,et al.  Syntactic control of interference , 1978, POPL.

[22]  Andre Scedrov,et al.  Bounded Linear Logic , 1991 .

[23]  Ñ Blockinðº,et al.  A Statically Allocated Parallel Functional Language , 2000 .

[24]  Henry G. Baker,et al.  Lively linear Lisp: “look ma, no garbage!” , 1992, SIGP.