Skip to main content

State Based Encapsulation for Modular Reasoning about Behavior-Preserving Refactorings

  • Chapter
Aliasing in Object-Oriented Programming. Types, Analysis and Verification

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 7850))

Abstract

A properly encapsulated data representation can be revised for refactoring or other purposes without affecting the correctness of client programs and extensions of a class. But encapsulation is difficult to achieve in object-oriented programs owing to heap based structures and reentrant callbacks. This chapter shows that it is achieved by a discipline using assertions and auxiliary fields to manage invariants and transferrable ownership. The main result is representation independence: a rule for modular proof of equivalence of class implementations.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Dietl, W., Müller, P.: Object Ownership in Program Verification. In: Clarke, D., Noble, J., Wrigstad, T. (eds.) Aliasing in Object-Oriented Programming. LNCS, vol. 7850, pp. 289–318. Springer, Heidelberg (2013)

    Google Scholar 

  2. Parkinson, M., Bierman, G.: Separation Logic for Object-Oriented Programming. In: Clarke, D., Noble, J., Wrigstad, T. (eds.) Aliasing in Object-Oriented Programming. LNCS, vol. 7850, pp. 366–406. Springer, Heidelberg (2013)

    Google Scholar 

  3. Smans, J., Jacobs, B., Piessens, F.: VeriFast for Java: A Tutorial. In: Clarke, D., Noble, J., Wrigstad, T. (eds.) Aliasing in Object-Oriented Programming. LNCS, vol. 7850, pp. 407–442. Springer, Heidelberg (2013)

    Google Scholar 

  4. Jacobs, B., Poll, E.: Java Program Verification at Nijmegen: Developments and Perspective. In: Futatsugi, K., Mizoguchi, F., Yonezaki, N. (eds.) ISSS 2003. LNCS, vol. 3233, pp. 134–153. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  5. Hoare, C.A.R.: Proofs of correctness of data representations. Acta Informatica 1, 271–281 (1972)

    Article  MATH  Google Scholar 

  6. Mitchell, J.C.: Representation independence and data abstraction. In: ACM Symp. on Princ. of Program. Lang., pp. 263–276 (1986)

    Google Scholar 

  7. de Roever, W.P., Engelhardt, K.: Data Refinement: Model-Oriented Proof Methods and their Comparison. Cambridge University Press (1998)

    Google Scholar 

  8. Banerjee, A., Naumann, D.A.: Ownership confinement ensures representation independence for object-oriented programs. J. ACM 52(6), 894–960 (2005)

    MathSciNet  Google Scholar 

  9. Müller, P., Poetzsch-Heffter, A., Leavens, G.T.: Modular invariants for layered object structures. Sci. Comput. Program. 62(3), 253–286 (2006)

    Article  MATH  Google Scholar 

  10. Barnett, M., DeLine, R., Fähndrich, M., Leino, K.R.M., Schulte, W.: Verification of object-oriented programs with invariants. Journal of Object Technology 3(6), 27–56 (2004)

    Article  Google Scholar 

  11. Leino, K.R.M., Müller, P.: Object Invariants in Dynamic Contexts. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 491–515. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  12. Detlefs, D.L., Leino, K.R.M., Nelson, G.: Wrestling with rep exposure. Research 156, DEC Systems Research Center (1998)

    Google Scholar 

  13. O’Hearn, P.W., Yang, H., Reynolds, J.C.: Separation and information hiding. ACM Trans. Program. Lang. Syst. 31(3) (2009)

    Google Scholar 

  14. Banerjee, A., Naumann, D.A.: Ownership transfer and abstraction. Technical Report TR 2004-1, Computing and Information Sciences, Kansas State University (2003)

    Google Scholar 

  15. Barnett, M., Leino, K.R.M., Schulte, W.: The Spec# Programming System: An Overview. In: Barthe, G., Burdy, L., Huisman, M., Lanet, J.-L., Muntean, T. (eds.) CASSIS 2004. LNCS, vol. 3362, pp. 49–69. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  16. Cohen, E., Moskal, M., Schulte, W., Tobies, S.: Local Verification of Global Invariants in Concurrent Programs. In: Touili, T., Cook, B., Jackson, P. (eds.) CAV 2010. LNCS, vol. 6174, pp. 480–494. Springer, Heidelberg (2010)

    Chapter  Google Scholar 

  17. Banerjee, A., Naumann, D.A.: State Based Ownership, Reentrance, and Encapsulation. In: Black, A. (ed.) ECOOP 2005. LNCS, vol. 3586, pp. 387–411. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  18. Guttag, J.V., Horning, J.J. (eds.): Larch: Languages and Tools for Formal Specification. Texts and Monographs in Computer Science. Springer-Verlag (1993); With Garland, S.J., Jones, K.D., Modet, A., Wing, J.M.

    Google Scholar 

  19. Meyer, B.: Object-oriented Software Construction, 2nd edn. Prentice Hall, New York (1997)

    MATH  Google Scholar 

  20. Naumann, D.A., Barnett, M.: Towards imperative modules: Reasoning about invariants and sharing of mutable state. Theoretical Computer Science 365, 143–168 (2006)

    Article  MathSciNet  MATH  Google Scholar 

  21. Ahmed, A., Dreyer, D., Rossberg, A.: State-dependent representation independence. In: ACM Symp. on Princ. of Program. Lang., pp. 340–353 (2009)

    Google Scholar 

  22. Thamsborg, J., Birkedal, L., Yang, H.: Two for the price of one: lifting separation logic assertions. Logical Methods in Computer Science 8(3) (2012)

    Google Scholar 

  23. Igarashi, A., Pierce, B., Wadler, P.: Featherweight Java: A minimal core calculus for Java and GJ. ACM Transactions on Programming Languages and Systems 23(3), 396–459 (2001)

    Article  Google Scholar 

  24. Naumann, D.A.: Verifying a Secure Information Flow Analyzer. In: Hurd, J., Melham, T. (eds.) TPHOLs 2005. LNCS, vol. 3603, pp. 211–226. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  25. Apt, K.R., de Boer, F.S., Olderog, E.R.: Verification of Sequential and Concurrent Programs, 3rd edn. Springer (2009)

    Google Scholar 

  26. Borba, P., Sampaio, A., Cornélio, M.: A Refinement Algebra for Object-oriented Programming. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743, pp. 457–482. Springer, Heidelberg (2003)

    Chapter  Google Scholar 

  27. Cavalcanti, A., Naumann, D.A.: Forward Simulation for Data Refinement of Classes. In: Eriksson, L.-H., Lindsay, P.A. (eds.) FME 2002. LNCS, vol. 2391, pp. 471–490. Springer, Heidelberg (2002)

    Chapter  Google Scholar 

  28. Naumann, D.A., Sampaio, A., Silva, L.: Refactoring and representation independence for class hierachies. Theoretical Computer Science 433, 60–97 (2012)

    Article  MathSciNet  MATH  Google Scholar 

  29. Filipovic, I., O’Hearn, P.W., Torp-Smith, N., Yang, H.: Blaming the client: on data refinement in the presence of pointers. Formal Asp. Comput. 22(5), 547–583 (2010)

    Article  MATH  Google Scholar 

  30. Reynolds, J.C.: Types, abstraction, and parametric polymorphism. In: Mason, R. (ed.) Information Processing 1983, pp. 513–523. North-Holland (1984)

    Google Scholar 

  31. Pitts, A.M.: Typed operational reasoning. In: Pierce, B.C. (ed.) Advanced Topics in Types and Programming Languages, pp. 245–289. The MIT Press (2005)

    Google Scholar 

  32. Ahmed, A.: Step-Indexed Syntactic Logical Relations for Recursive and Quantified Types. In: Sestoft, P. (ed.) ESOP 2006. LNCS, vol. 3924, pp. 69–83. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  33. Crary, K., Harper, R.: Syntactic logical relations for polymorphic and recursive types. Electr. Notes Theor. Comput. Sci. 172, 259–299 (2007)

    Article  MathSciNet  Google Scholar 

  34. Melliès, P.A., Vouillon, J.: Recursive polymorphic types and parametricity in an operational framework. In: IEEE Symp. on Logic in Computer Science, pp. 82–91 (2005)

    Google Scholar 

  35. Sumii, E., Pierce, B.C.: A bisimulation for type abstraction and recursion. J. ACM 54(5) (2007)

    Google Scholar 

  36. Koutavas, V., Wand, M.: Small bisimulations for reasoning about higher-order imperative programs. In: ACM Symp. on Princ. of Program. Lang., pp. 141–152 (2006)

    Google Scholar 

  37. Birkedal, L., Yang, H.: Relational parametricity and separation logic. Logical Methods in Computer Science 4(2) (2008)

    Google Scholar 

  38. Dreyer, D., Neis, G., Rossberg, A., Birkedal, L.: A relational modal logic for higher-order stateful adts. In: ACM Symp. on Princ. of Program. Lang., pp. 185–198 (2010)

    Google Scholar 

  39. Koutavas, V., Wand, M.: Reasoning about class behavior. In: Informal Proceedings of FOOL/WOOD (2007)

    Google Scholar 

  40. Banerjee, A., Naumann, D.A.: State based encapsulation and generics. Technical Report CS Report 2004-11, Stevens Institute of Technology (2004)

    Google Scholar 

  41. Clarke, D.G., Potter, J.M., Noble, J.: Ownership types for flexible alias protection. In: OOPSLA 1998 Conference Proceedings. SIGPLAN, vol. 33(10), pp. 48–64 (October 1998)

    Google Scholar 

  42. Boyapati, C., Lee, R., Rinard, M.C.: Ownership types for safe programming: preventing data races and deadlocks. In: ACM Conference on Object-Oriented Programming Languages, Systems, and Applications, pp. 211–230 (2002)

    Google Scholar 

  43. Clarke, D., Drossopoulou, S.: Ownership, encapsulation and the disjointness of type and effect. In: ACM Conference on Object-Oriented Programming Languages, Systems, and Applications, pp. 292–310 (November 2002)

    Google Scholar 

  44. Boyapati, C., Liskov, B., Shrira, L.: Ownership types for object encapsulation. In: ACM Symp. on Princ. of Program. Lang., pp. 213–223 (2003) (invited paper)

    Google Scholar 

  45. Boyland, J., Noble, J., Retert, W.: Capabilities for Sharing: A Generalisation of Uniqueness and Read-Only. In: Lindskov Knudsen, J. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 2–7. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  46. Smith, F., Walker, D., Morrisett, G.: Alias Types. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, pp. 366–381. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  47. Müller, P., Rudich, A.: Ownership transfer in universe types. In: ACM Conference on Object-Oriented Programming Languages, Systems, and Applications, pp. 461–478 (2007)

    Google Scholar 

  48. Drossopoulou, S., Francalanza, A., Müller, P., Summers, A.J.: A Unified Framework for Verification Techniques for Object Invariants. In: Vitek, J. (ed.) ECOOP 2008. LNCS, vol. 5142, pp. 412–437. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  49. Barnett, M., Naumann, D.A.: Friends Need a Bit More: Maintaining Invariants Over Shared State. In: Kozen, D. (ed.) MPC 2004. LNCS, vol. 3125, pp. 54–84. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  50. Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley (1995)

    Google Scholar 

  51. Cameron, N.R., Drossopoulou, S., Noble, J., Smith, M.J.: Multiple ownership. In: ACM Conference on Object-Oriented Programming Languages, Systems, and Applications, pp. 441–460 (2007)

    Google Scholar 

  52. Cohen, E., Dahlweid, M., Hillebrand, M., Leinenbach, D., Moskal, M., Santen, T., Schulte, W., Tobies, S.: VCC: A Practical System for Verifying Concurrent C. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds.) TPHOLs 2009. LNCS, vol. 5674, pp. 23–42. Springer, Heidelberg (2009)

    Chapter  Google Scholar 

  53. O’Hearn, P.W., Reynolds, J., Yang, H.: Local Reasoning about Programs that Alter Data Structures. In: Fribourg, L. (ed.) CSL 2001. LNCS, vol. 2142, pp. 1–19. Springer, Heidelberg (2001)

    Google Scholar 

  54. Kassios, I.T.: The dynamic frames theory. Formal Aspects of Computing 23(3), 267–288 (2011)

    Article  MathSciNet  MATH  Google Scholar 

  55. Banerjee, A., Naumann, D.A., Rosenberg, S.: Local reasoning for global invariants, part I: Region logic. Extended version of [64] (2011), http://www.cs.stevens.edu/~naumann/pub/locResGloInvI.pdf

  56. Banerjee, A., Naumann, D.A.: Local reasoning for global invariants, part II: Dynamic boundaries. Extended version of [65] (2011), http://www.cs.stevens.edu/~naumann/pub/locResGloInvII.pdf

  57. Verl: VErifier for Region Logic Software distribution, http://www.cs.stevens.edu/~naumann/pub/VERL/

  58. Dafny: http://boogie.codeplex.com/

  59. Leino, K.R.M.: Dafny: An Automatic Program Verifier for Functional Correctness. In: Clarke, E.M., Voronkov, A. (eds.) LPAR-16 2010. LNCS (LNAI), vol. 6355, pp. 348–370. Springer, Heidelberg (2010)

    Chapter  Google Scholar 

  60. Parkinson, M.J., Bierman, G.M.: Separation logic and abstraction. In: ACM Symp. on Princ. of Program. Lang., pp. 247–258 (2005)

    Google Scholar 

  61. Distefano, D., Parkinson, M.J.: jStar: Towards practical verification for Java. In: ACM Conference on Object-Oriented Programming Languages, Systems, and Applications, pp. 213–226 (2008)

    Google Scholar 

  62. Parkinson, M.J.: Class invariants: the end of the road? In: International Workshop on Aliasing, Confinement and Ownership in Object-oriented Programming (2007)

    Google Scholar 

  63. Vitek, J., Bokowski, B.: Confined types in Java. Software Practice and Experience 31(6), 507–532 (2001)

    Article  MATH  Google Scholar 

  64. Banerjee, A., Naumann, D.A., Rosenberg, S.: Regional Logic for Local Reasoning about Global Invariants. In: Vitek, J. (ed.) ECOOP 2008. LNCS, vol. 5142, pp. 387–411. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  65. Naumann, D.A., Banerjee, A.: Dynamic Boundaries: Information Hiding by Second Order Framing with First Order Assertions. In: Gordon, A.D. (ed.) ESOP 2010. LNCS, vol. 6012, pp. 2–22. Springer, Heidelberg (2010)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2013 Springer-Verlag Berlin Heidelberg

About this chapter

Cite this chapter

Banerjee, A., Naumann, D.A. (2013). State Based Encapsulation for Modular Reasoning about Behavior-Preserving Refactorings. In: Clarke, D., Noble, J., Wrigstad, T. (eds) Aliasing in Object-Oriented Programming. Types, Analysis and Verification. Lecture Notes in Computer Science, vol 7850. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-36946-9_12

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-36946-9_12

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-36945-2

  • Online ISBN: 978-3-642-36946-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics