A Generic Complete Dynamic Logic for Reasoning About Purity and Effects

  • Till Mossakowski
  • Lutz Schröder
  • Sergey Goncharov
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4961)


For a number of programming languages, among them Eiffel, C, Java and Ruby, Hoare-style logics and dynamic logics have been developed. In these logics, pre- and postconditions are typically formulated using potentially effectful programs. In order to ensure that these pre- and postconditions behave like logical formulae (that is, enjoy some kind of referential transparency), a notion of purity is needed. Here, we introduce a generic framework for reasoning about purity and effects. Effects are modeled abstractly and axiomatically, using Moggi’s idea of encapsulation of effects as monads. We introduce a dynamic logic (from which, as usual, a Hoare logic can be derived) whose logical formulae are pure programs in a strong sense. We formulate a set of proof rules for this logic, and prove it to be complete with respect to a categorical semantics. Using dynamic logic, we then develop a relaxed notion of purity which allows for observationally neutral effects such writing on newly allocated memory.


  1. 1.
    Beckert, B.: A dynamic logic for the formal verification of Java Card programs. In: Attali, I., Jensen, T. (eds.) JavaCard 2000. LNCS, vol. 2041, pp. 6–24. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  2. 2.
    Boehm, H.-J.: Side effects and aliasing can have simple axiomatic descriptions. ACM Trans. Program. Lang. Syst 7, 637–655 (1985)MATHCrossRefGoogle Scholar
  3. 3.
    Bonniot, D., Keller, B.: The Nice user’s manual (2003), http://nice.sourceforge.net
  4. 4.
    Bright, W.: The D programming language. Dr. Dobb’s Journal of Software Tools 27(2), 36–40 (2002)MathSciNetGoogle Scholar
  5. 5.
    Cok, D.R., Kiniry, J.R.: ESC/Java2: Uniting ESC/Java and JML. In: Barthe, G., Burdy, L., Huisman, M., Lanet, J.-L., Muntean, T. (eds.) CASSIS 2004. LNCS, vol. 3362, pp. 108–128. Springer, Heidelberg (2005)Google Scholar
  6. 6.
    Findler, R.B., Felleisen, M.: Contracts for higher-order functions. In: ICFP, pp. 48–59 (2002)Google Scholar
  7. 7.
    Goncharov, S., Schröder, L., Mossakowski, T.: Completeness of global evaluation logic. In: Královič, R., Urzyczyn, P. (eds.) MFCS 2006. LNCS, vol. 4162, pp. 447–458. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  8. 8.
    Hoare,: An axiomatic basis for computer programming. CACM 12 (1969)Google Scholar
  9. 9.
    Huisman, M.: Java program verification in higher order logic with PVS and Isabelle. PhD thesis, University of Nijmegen (2001)Google Scholar
  10. 10.
    Jacobs, B., Poll, E.: Coalgebras and Monads in the Semantics of Java. Theoret. Comput. Sci. 291, 329–349 (2003)MATHCrossRefMathSciNetGoogle Scholar
  11. 11.
    Mac Lane, S.: Categories for the Working Mathematician. Springer, Heidelberg (1997)Google Scholar
  12. 12.
    Meyer, B.: Eiffel: The Language. Prentice-Hall, Englewood Cliffs (1992)MATHGoogle Scholar
  13. 13.
    Moggi, E.: Notions of computation and monads. Inform. and Comput. 93, 55–92 (1991)MATHCrossRefMathSciNetGoogle Scholar
  14. 14.
    Moggi, E.: A semantics for evaluation logic. Fund. Inform. 22, 117–152 (1995)MATHMathSciNetGoogle Scholar
  15. 15.
    Naumann, D.A.: Observational purity and encapsulation. Theoret. Comput. Sci 376, 205–224 (2007)MATHCrossRefMathSciNetGoogle Scholar
  16. 16.
    Nipkow, T.: Hoare logics in Isabelle/HOL. In: Schwichtenberg, H., Steinbrüggen, R. (eds.) Proof and System-Reliability, pp. 341–367. Kluwer Academic Publishers, Dordrecht (2002)Google Scholar
  17. 17.
    Omohundro, S.M.: The Sather language. Technical report, International Computer Science Institute, Berkeley (1991)Google Scholar
  18. 18.
    Peyton-Jones, S. (ed.): Haskell 98 Language and Libraries — The Revised Report, Cambridge (2003), also: J. Funct. Programming 13 (2003)Google Scholar
  19. 19.
    Pitts, A.: Evaluation logic. In: Higher Order Workshop, Workshops in Computing, pp. 162–189. Springer, Heidelberg (1991)Google Scholar
  20. 20.
    Pratt, V.: Semantical considerations on Floyd-Hoare logic. In: Foundations of Conputer Science, FOCS 1976, pp. 109–121. IEEE, Los Alamitos (1976)Google Scholar
  21. 21.
    Schröder, L., Mossakowski, T.: Monad-independent Hoare logic in HasCASL. In: Pezzè, M. (ed.) FASE 2003. LNCS, vol. 2621, pp. 261–277. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  22. 22.
    Schröder, L., Mossakowski, T.: Generic Exception Handling and the Java Monad. In: Rattray, C., Maharaj, S., Shankland, C. (eds.) AMAST 2004. LNCS, vol. 3116, pp. 443–459. Springer, Heidelberg (2004)Google Scholar
  23. 23.
    Schröder, L., Mossakowski, T.: Monad-independent dynamic logic in HASCASL. J. Logic Comput. 14, 571–619 (2004)MATHCrossRefMathSciNetGoogle Scholar
  24. 24.
    Sonntag, B., Colnet, D.: Lisaac: the power of simplicity at work for operating system. In: Technology of Object-Oriented Languages and Systems, TOOLS Pacific 2002. CRPIT, vol. 10, pp. 45–52. ACS (2002)Google Scholar
  25. 25.
    Stenzel, K.: A formally verified calculus for full Java Card. In: Rattray, C., Maharaj, S., Shankland, C. (eds.) AMAST 2004. LNCS, vol. 3116, pp. 491–505. Springer, Heidelberg (2004)Google Scholar
  26. 26.
    van den Berg, J., Jacobs, B.: The LOOP compiler for Java and JML. In: Margaria, T., Yi, W. (eds.) TACAS 2001. LNCS, vol. 2031, pp. 299–312. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  27. 27.
    von Oheimb, D.: Hoare logic for Java in Isabelle/HOL. Concurrency and Computation: Practice and Experience 13, 1173–1214 (2001)MATHCrossRefGoogle Scholar
  28. 28.
    Walter, D.: Monadic dynamic logic: Application and implementation. Master’s thesis, University of Bremen (2005), http://www.cs.chalmers.se/~denniswa
  29. 29.
    Walter, D., Schröder, L., Mossakowski, T.: Parametrized exceptions. In: Fiadeiro, J.L., Harman, N.A., Roggenbach, M., Rutten, J. (eds.) CALCO 2005. LNCS, vol. 3629, pp. 424–438. Springer, Heidelberg (2005)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2008

Authors and Affiliations

  • Till Mossakowski
    • 1
    • 2
  • Lutz Schröder
    • 1
    • 2
  • Sergey Goncharov
    • 2
  1. 1.DFKI LaboratoryBremen
  2. 2.Department of Computer ScienceUniversity of Bremen 

Personalised recommendations