ABSTRACT
Contracts (dynamically checked programmer assertions) are a widely accepted mechanism for specifying, checking and documenting properties of software components. Most, if not all, contract systems expect programmers to use the native programming language to express their program invariants. While this is most effective for many simple invariants, expressing properties of data structures and aliasing patterns can be extremely complicated. If written in the native language in an unstructured way, such contracts are bound to be unclear and ineffective as documentation. In this paper, we show how to use linear logic as a language of contracts for an imperative programming language. The high-level nature of our linear logical contracts makes specifying memory shape and aliasing properties of complex recursive data structures easy. Moreover, since we give our logic a clear, compositional semantics, the contracts serve as effective, executable documentation for programmer expectations. In order to evaluate the truth of our linear logical contracts at run time, we use a modified version of LolliMon, a linear logic programming language.
- A. Ahmed and D. Walker. The logical approach to stack typing. In ACM SIGPLAN Workshop on Types in Language Design and Implementation, New Orleans, Jan. 2003.]] Google ScholarDigital Library
- A. W. Appel and D. A. McAllester. An indexed model of recursive types for foundational proof-carrying code. Programming Languages and Systems, 23(5):657--683, 2001.]] Google ScholarDigital Library
- L. Birkedal, N. Torp-Smith, and J. Reynolds. Local reasoning about a copying garbage collector. In ACM Symposium on Principles of Programming Languages, pages 220--231, Venice, Italy, Jan. 2004.]] Google ScholarDigital Library
- R. B. Findler and M. Felleisen. Contracts for higher-order functions. In ICFP '02: Proceedings of the seventh ACM SIGPLAN international conference on Functional programming, pages 48--59, New York, NY, USA, 2002. ACM Press.]] Google ScholarDigital Library
- R. Hastings and B. Joyce. Fast detection of memory leaks and access errors. In Proceedings of the Winter '92 USENIX conference, pages 125--136. USENIX Association, 1992.]]Google Scholar
- M. Hauswirth and T. M. Chilimbi. Low-overhead memory leak detection using adaptive statistical profiling. In ASPLOS, pages 156--164, 2004.]] Google ScholarDigital Library
- J. S. Hodas and D. Miller. Logic programming in a fragment of intuitionistic linear logic. In Papers presented at the IEEE symposium on Logic in computer science, pages 327--365, Orlando, FL, USA, 1994. Academic Press, Inc.]] Google ScholarDigital Library
- R. C. Holt and J. R. Cordy. The Turing programming language. Commun. ACM, 31(12):1410--1423, 1988.]] Google ScholarDigital Library
- S. Ishtiaq and P. O'Hearn. BI as an assertion language for mutable data structures. In Twenty-Eighth ACM Symposium on Principles of Programming Languages, pages 14--26, London, UK, Jan. 2001.]] Google ScholarDigital Library
- L. Jia, F. Spalding, D. Walker, and N. Glew. Certifying compilation for a language with stack allocation. In Proceedings of the Twentieth Annual IEEE Symp. on Logic in Computer Science, LICS 2005, 2005.]] Google ScholarDigital Library
- L. Jia and D. Walker. ILC: A foundation for automated reasoning about pointer programs. In European Symposium on Programming Languages, Apr. 2006.]] Google ScholarDigital Library
- P. López, F. Pfenning, J. Polakow, and K. Watkins. Monadic concurrent linear logic programming. In PPDP '05, pages 35--46, New York, NY, USA, 2005. ACM Press.]] Google ScholarDigital Library
- P. López and J. Polakow. Implementing efficient resource management for linear logic programming. In Logic for Programming Artificial Intelligence and Reasoning (LPAR), pages 528--543, 2004.]]Google Scholar
- D. C. Luckham. Programming with Specifications: An Introduction to Anna, a Language for Specifying ADA Programs. Springer-Verlag New York, Inc., Secaucus, NJ, USA, 1990.]] Google ScholarDigital Library
- B. Meyer. Eiffel: programming for reusability and extendibility. SIGPLAN Not., 22(2):85--94, 1987.]] Google ScholarDigital Library
- B. Meyer. Eiffel: the language. Prentice-Hall, Inc., Upper Saddle River, NJ, USA, 1992.]] Google ScholarDigital Library
- G. Morrisett, A. Ahmed, and M. Fluet. L3: A linear language with locations. In Seventh International Conference on Typed Lambda Calculi and Applications, Apr. 2005.]] Google ScholarDigital Library
- P. O'Hearn and D. Pym. The logic of bunched implications. Bulletin of Symbolic Logic, 5(2):215--244, 1999.]]Google ScholarCross Ref
- P. O'Hearn, J. Reynolds, and H. Yang. Local reasoning about programs that alter data structures. In Computer Science Logic, number 2142 in LNCS, pages 1--19, Paris, 2001.]] Google ScholarDigital Library
- D. L. Parnas. A technique for software module specification with examples. Commun. ACM, 15(5):330--336, 1972.]] Google ScholarDigital Library
- Programming with assertions. http://java.sun.com/j2se/1.4.2/docs /guide/lang/assert.html.]]Google Scholar
- J. C. Reynolds. Separation logic: A logic for shared mutable data structures. In Proceedings of the 17th Annual IEEE Symposium on Logic in Computer Science, pages 55--74. 2002.]] Google ScholarDigital Library
Index Terms
- Expressing heap-shape contracts in linear logic
Recommendations
The decidability of the intensional fragment of classical linear logic
Intensional classical linear logic (MELL) is proved decidable.Intensional interlinear logic (RLL) is proved decidable.We adapt Kripke's method used to prove decidability for some relevance logics.The semi-relevant RLL emerges as a logic superior to MELL ...
Linear and temporal logic programming language
ACS'06: Proceedings of the 6th WSEAS international conference on Applied computer scienceRecent logic calculi open new possibilities for logic programming. Apparently the most important of them is a linear logic which makes possible to solve problems by resources treatment. The linear logic has already been used for several proposals of ...
Monadic concurrent linear logic programming
PPDP '05: Proceedings of the 7th ACM SIGPLAN international conference on Principles and practice of declarative programmingLolli is a logic programming language based on the asynchronous propositions of intuitionistic linear logic. It uses a backward chaining, backtracking operational semantics. In this paper we extend Lolli with the remaining connectives of intuitionistic ...
Comments