Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
article

A type system for bounded space and functional in-place update

Published: 01 December 2000 Publication History
  • Get Citation Alerts
  • Abstract

    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 [16], the present method provides guaranteed bounds on heap space which will be of use for applications such as languages for embedded systems or automatic certification of resource bounds.We show that the functions expressible in the system are precisely those computable on a linearly space-bounded Turing machine with an unbounded stack. By a result of Cook this equals the complexity class 'exponential time'. A tail recursive fragment of the language captures the complexity class 'linear space'.We discuss various extensions, in particular an extension with FIFO queues admitting constant time catenation and enqueuing, and an extension of the type system to fully-fledged intuitionistic linear logic.

    References

    [1]
    {1} ABRAMSKY, SAMSON. 1993. Computational interpretations of linear logic. Theoretical Computer Science 111, 3-57.]]
    [2]
    {2} BAKER, HENRY. 1992. Lively Linear LISP--Look Ma, No Garbage. ACM Sigplan Notices 27, 8, 89-98.]]
    [3]
    {3} BAKER, HENRY. 1994. A Linear Logic Quicksort. ACM Sigplan Notices 29, 2, 13-18.]]
    [4]
    {4} BARENDSEN, E. AND SMETSERS, S. 1996. Uniqueness typing for functional languages with graph rewriting semantics. Mathematical Structures in Computer Science 6, 579-612.]]
    [5]
    {5} CASEIRO, VUOKKO-HELENA. 1997. Equations for Defining Poly-time Functions. PhD thesis, University of Oslo, Norway. Available by ftp from ftp. ifi.uio.no/pub/ vuokko/Oadm.ps.]]
    [6]
    {6} CHIRIMAR, J., GUNTER, C., AND RIECKE, J. 1995. Reference counting as a computational interpretation of linear logic. Journal of Functional Programming 6, 2.]]
    [7]
    {7} COOK, STEPHEN A. 1972. Linear-time simulation of deterministic two-way pushdown automata. Information Processing 71, 75-80.]]
    [8]
    {8} CRARY, K. AND WEIRICH, S. 2000. Resource bound certification. In Proc. 27th Symp. Principles of Prog. Lang. (POPL), 184-198.]]
    [9]
    {9} GIRARD, J.-Y., SCEDROV, A., AND SCOTT, P. 1992. Bounded linear logic. Theoretical Computer Science 97, 1, 1-66.]]
    [10]
    {10} HOFMANN, MARTIN. 1999. Linear types and non size-increasing polynomial time computation. In Logic in Computer Science (LICS). IEEE, Computer Society Press, 464-476.]]
    [11]
    {11} HOLMSTRÖM, SÖREN. 1988. A linear functional language. In Proceedings of the Workshop on Implemenation of Lazy Functional Languages. Chalmers University, Göteborg, Programming Methodology Group, Report 53.]]
    [12]
    {12} HUDAK, PAUL AND CHEN, CHIH-PING. 1997. Rolling your own mutable adt -- a connection between linear types and monads, In Proc. Symp. POPL'97. ACM Press, New York.]]
    [13]
    {13} HUGHES, J. AND PARETO, L. 1999. Recursion and dynamic data structures in bounded space: towards embedded ML programming. In Proc. International Conference on Functional Programming. ACM Press, New York, 70-81.]]
    [14]
    {14} KELLEY, A. AND POHL, I. 1995. A book on C, third edition. Benjamin/Cummings.]]
    [15]
    {15} LAFONT, YVES. 1988. The linear abstract machine. Theoretical Computer Science 59, 157-180.]]
    [16]
    {16} LEROY, XAVIER. 1999. The Objective Caml System, documentation and user's guide. Release 2.02. http://pauillac.inria.fr/ocaml/htmlman.]]
    [17]
    {17} LINCOLN, P. AND MITCHELL, J. 1992. Operational aspects of linear lambda calculus. In Proc. LICS 1992. IEEE, Computer Society Press.]]
    [18]
    {18} MYCROFT, ALAN. 1981. Abstract interpretation and optimising transformations for applicative programs. PhD thesis, University of Edinburgh, Scotland.]]
    [19]
    {19} MYCROFT, ALAN AND SHARP, RICHARD. 2000. A Statically Allocated Parallel Functional Language. In Automata, languages, and programming (Proc. ICALP 2000), Montanari, U. et al., Editors. Volume 1853 of Lecture Notes in Computer Science, Springer-Verlag.]]
    [20]
    {20} O'HEARN, P. W., TAKEYAMA, M., POWER, A. J., AND TENNENT, R. D. 1995. Syntactic control of interference revisited. In MFPS XI, conference on Mathematical Foundations of Program Semantics. Volume 1 of Electronic Notes in Theoretical Computer Science, Elsevier.]]
    [21]
    {21} OKASAKI, CHRIS. 1998. Purely Functional Data Structures. Cambridge University Press.]]
    [22]
    {22} REYNOLDS, J. C. 1978. Syntactic control of interference. In Proc. Fifth ACM Symp. on Princ. of Prog. Lang. (POPL).]]
    [23]
    {23} TOFTE, M. AND TALPIN, J.-P. 1997. Region, based memory management. Information and Computation 132, 2, 109-176.]]
    [24]
    {24} TOFTE, MADS AND BIRKEDAL, LARS. 1998. Region inference algorithm. ACM Transactions on Programming Languages and Systems 20, 5, 724-767.]]
    [25]
    {25} TURNER, D. AND WADLER, P. 1999. Operational interpretations of linear logic. Theoretical Computer Science 227, 1-2, 231-248.]]

    Cited By

    View all
    • (2023)A High-Level Separation Logic for Heap Space under Garbage CollectionProceedings of the ACM on Programming Languages10.1145/35712187:POPL(718-747)Online publication date: 11-Jan-2023
    • (2022)A separation logic for heap space under garbage collectionProceedings of the ACM on Programming Languages10.1145/34986726:POPL(1-28)Online publication date: 12-Jan-2022
    • (2019)Verifying the Correctness and Amortized Complexity of a Union-Find Implementation in Separation Logic with Time CreditsJournal of Automated Reasoning10.1007/s10817-017-9431-762:3(331-365)Online publication date: 1-Mar-2019
    • Show More Cited By

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Nordic Journal of Computing
    Nordic Journal of Computing  Volume 7, Issue 4
    Winter 2000
    144 pages

    Publisher

    Publishing Association Nordic Journal of Computing

    Finland

    Publication History

    Published: 01 December 2000

    Author Tags

    1. C
    2. compilers
    3. computational complexity
    4. functional programming
    5. garbage collection
    6. memory organization

    Qualifiers

    • Article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)0
    • Downloads (Last 6 weeks)0
    Reflects downloads up to 27 Jul 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2023)A High-Level Separation Logic for Heap Space under Garbage CollectionProceedings of the ACM on Programming Languages10.1145/35712187:POPL(718-747)Online publication date: 11-Jan-2023
    • (2022)A separation logic for heap space under garbage collectionProceedings of the ACM on Programming Languages10.1145/34986726:POPL(1-28)Online publication date: 12-Jan-2022
    • (2019)Verifying the Correctness and Amortized Complexity of a Union-Find Implementation in Separation Logic with Time CreditsJournal of Automated Reasoning10.1007/s10817-017-9431-762:3(331-365)Online publication date: 1-Mar-2019
    • (2015)Program equivalence in linear contextsTheoretical Computer Science10.1016/j.tcs.2015.03.006585:C(71-90)Online publication date: 20-Jun-2015
    • (2013)Ten years of amortized resource analysisProceedings of the 16th international conference on Foundations of Software Science and Computation Structures10.5555/2450348.2450350(xvii-xix)Online publication date: 16-Mar-2013
    • (2012)Higher-order functional reactive programming in bounded spaceProceedings of the 39th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages10.1145/2103656.2103665(45-58)Online publication date: 25-Jan-2012
    • (2012)Higher-order functional reactive programming in bounded spaceACM SIGPLAN Notices10.1145/2103621.210366547:1(45-58)Online publication date: 25-Jan-2012
    • (2011)The essence of monotonic stateProceedings of the 7th ACM SIGPLAN workshop on Types in language design and implementation10.1145/1929553.1929565(73-86)Online publication date: 25-Jan-2011
    • (2010)A modality for safe resource sharing and code reentrancyProceedings of the 7th International colloquium conference on Theoretical aspects of computing10.5555/1881833.1881866(382-396)Online publication date: 1-Sep-2010
    • (2010)Type inference in intuitionistic linear logicProceedings of the 12th international ACM SIGPLAN symposium on Principles and practice of declarative programming10.1145/1836089.1836118(219-230)Online publication date: 26-Jul-2010
    • Show More Cited By

    View Options

    View options

    Get Access

    Login options

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media