Advertisement

Local Reasoning about Programs that Alter Data Structures

  • Peter O’Hearn
  • John Reynolds
  • Hongseok Yang
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 2142)

Abstract

We describe an extension of Hoare’s logic for reasoning about programs that alter data structures. We consider a low-level storage model based on a heap with associated lookup, update, allocation and deallocation operations, and unrestricted address arithmetic. The assertion language is based on a possible worlds model of the logic of bunched implications, and includes spatial conjunction and implication connectives alongside those of classical logic. Heap operations are axiomatized using what we call the “small axioms”, each of which mentions only those cells accessed by a particular command. Through these and a number of examples we show that the formalism supports local reasoning: A specification and proof can concentrate on only those cells in memory that a program accesses.

This paper builds on earlier work by Burstall, Reynolds, Ishtiaq and O’Hearn on reasoning about data structures.

Keywords

Frame Problem Weak Precondition Memory Fault Hoare Logic Local Reasoning 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    A. Borgida, J. Mylopoulos, and R. Reiter. On the frame problem in procedure specifications. IEEE Transactions of Software Engineering, 21:809–838, 1995.CrossRefGoogle Scholar
  2. 2.
    R. Bornat. Proving pointer programs in Hoare logic. Mathematics of Program Construction, 2000.Google Scholar
  3. 3.
    R.M. Burstall. Some techniques for proving correctness of programs which alter data structures. Machine Intelligence, 7:23–50, 1972.zbMATHGoogle Scholar
  4. 4.
    C. Calcagno, S. Isthiaq, and P. W. O’Hearn. Semantic analysis of pointer aliasing, allocation and disposal in Hoare logic. Proceedings of the Second International ACM SIGPLAN Conference on Principles and Practice of Declarative Programming, 2000.Google Scholar
  5. 5.
    P. Cousot. Methods and logics for proving programs. In J. van Leeuwen, editor, Handbook of Theoretical Computer Science, volume B, pages 843–993. Elsevier, Amsterdam, and The MIT Press, Cambridge, Mass., 1990.Google Scholar
  6. 6.
    C. A. R. Hoare and J. He. A trace model for pointers and objects. In Rachid Guerraoui, editor, ECCOP’99-Object-Oriented Programming, 13th European Conference, pages 1–17, 1999. Lecture Notes in Computer Science, Vol. 1628, Springer.Google Scholar
  7. 7.
    S. Isthiaq and P.W. O’Hearn. BI as an assertion language for mutable data structures. In Conference Record of the Twenty-Eighth Annual ACM Symposium on Principles of Programming Languages, pages 39–46, London, January 2001.Google Scholar
  8. 8.
    K. R. M. Leino and G. Nelson. Data abstraction and information hiding. Technical Report Reearch Report 160, Compaq Systems Research Center, Palo Alto,CA, November 2000.Google Scholar
  9. 9.
    J. McCarthy and P. Hayes. Some philosophical problems from the standpoint of artificial intelligence. Machine Intelligence, 4:463–502, 1969.zbMATHGoogle Scholar
  10. 10.
    P. W. O’Hearn. Resource interpretations, bunched implications and the αλ-calculus. In Typed λ-calculus and Applications, J-Y Girard editor, L’Aquila, Italy, April 1999. Lecture Notes in Computer Science 1581.Google Scholar
  11. 11.
    P. W. O’Hearn and D. J. Pym. The logic of bunched implications. Bulletin of Symbolic Logic, 5(2):215–244, June 99.Google Scholar
  12. 12.
    P. W. O’Hearn and J. C. Reynolds. From Algol to polymorphic linear lambda-calculus. J. ACM, 47(1):267–223, January 2000.Google Scholar
  13. 13.
    P. W. O’Hearn and R. D. Tennent. Parametricity and local variables. J. ACM, 42(3):658–709, May 1995. Also in [14], vol 2, pages 109–164.Google Scholar
  14. 14.
    P. W. O’Hearn and R. D. Tennent, editors. Algol-like Languages. Two volumes, Birkhauser, Boston, 1997.Google Scholar
  15. 15.
    F. J. Oles. A Category-Theoretic Approach to the Semantics of Programming Languages. Ph.D. thesis, Syracuse University, Syracuse, N.Y., 1982.Google Scholar
  16. 16.
    F. J. Oles. Functor categories and store shapes. In O’Hearn and Tennent [14], pages 3–12. Vol. 2.Google Scholar
  17. 17.
    D. J. Pym. The Semantics and Proof Theory of the Logic of Bunched Implications. Monograph to appear, 2001.Google Scholar
  18. 18.
    J. C. Reynolds. Syntactic control of interference. In Conference Record of the Fifth Annual ACM Symposium on Principles of Programming Languages, pages 39–46, Tucson, Arizona, January 1978. ACM, New York. Also in [14], vol 1.Google Scholar
  19. 19.
    J. C. Reynolds. The essence of Algol. In J. W. de Bakker and J. C. van Vliet, editors, Algorithmic Languages, pages 345–372, Amsterdam, October 1981. North-Holland, Amsterdam. Also in [14], vol 1, pages 67–88.Google Scholar
  20. 20.
    J. C. Reynolds. Intuitionistic reasoning about shared mutable data structure. In Jim Davies, Bill Roscoe, and Jim Woodcock, editors, Millennial Perspectives in Computer Science, pages 303–321, Houndsmill, Hampshire, 2000. Palgrave.Google Scholar
  21. 21.
    J. C. Reynolds. Lectures on reasoning about shared mutable data structure. IFIP Working Group 2.3 School/Seminar on State-of-the-Art Program Design Using Logic. Tandil, Argentina, September 2000.Google Scholar
  22. 22.
    M. Shanahan. Solving the Frame Problem: A Mathematical Investigation of the Common Sense Law of Inertia. MIT Press, 1997.Google Scholar
  23. 23.
    H. Yang. An example of local reasoning in BI pointer logic: the Schorr-Waite graph marking algorithm. Manuscript, October 2000.Google Scholar
  24. 24.
    H. Yang. Local Reasoning for Stateful Programs. Ph.D. thesis, University of Illinois, Urbana-Champaign, Illinois, USA, 2001 (expected).Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2001

Authors and Affiliations

  • Peter O’Hearn
    • 1
  • John Reynolds
    • 2
  • Hongseok Yang
    • 3
  1. 1.Queen Mary, University of LondonUK
  2. 2.Carnegie Mellon UniversityUSA
  3. 3.University of Birmingham and University of Illinois at Urbana-ChampaignUSA

Personalised recommendations