Using Dafny, an Automatic Program Verifier

  • Luke Herbert
  • K. Rustan M. Leino
  • Jose Quaresma
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7682)


These lecture notes present Dafny, an automated program verification system that is based on the concept of dynamic frames and is capable of producing .NET executables. These notes overview the basic design, Dafny’s history, and summarizes the environment configuration. The key language constructs, and various system limits, are illustrated through the development of a simple Dafny program. Further examples, linked to online demonstrations, illustrate Dafny’s approach to loop invariants, termination, data abstraction, and heap-related specifications.


Loop Iteration Fibonacci Sequence Automatic Program Dynamic Frame Loop Invariant 
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.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Barnett, M., Chang, B.-Y.E., DeLine, R., Jacobs, B., Leino, K.R.M.: Boogie: A Modular Reusable Verifier for Object-Oriented Programs. In: de Boer, F.S., Bonsangue, M.M., Graf, S., de Roever, W.-P. (eds.) FMCO 2005. LNCS, vol. 4111, pp. 364–387. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  2. 2.
    Barnett, M., et al.: Specification and verification: The Spec# experience. Communications of the ACM 54(6), 81–91 (2011) ISSN: 0001-0782, doi:10.1145/1953122.1953145Google Scholar
  3. 3.
    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)CrossRefGoogle Scholar
  4. 4.
    Hoare, C.A.R.: An axiomatic basis for computer programming. Communications of the ACM 12(10), 576–580 (1969) ISSN: 0001-0782, doi:10.1145/363235.363259Google Scholar
  5. 5.
    Kassios, I.T.: Dynamic Frames: Support for Framing, Dependencies and Sharing Without Restrictions. In: Misra, J., Nipkow, T., Sekerinski, E. (eds.) FM 2006. LNCS, vol. 4085, pp. 268–283. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  6. 6.
    Kassios, I.T.: The dynamic frames theory. Formal Aspects of Computing 23, 267–288 (2011) ISSN: 0934-5043, doi:10.1007/s00165-010-0152-5Google Scholar
  7. 7.
    Klebanov, V., Müller, P., Shankar, N., Leavens, G.T., Wüstholz, V., Alkassar, E., Arthan, R., Bronish, D., Chapman, R., Cohen, E., Hillebrand, M., Jacobs, B., Leino, K.R.M., Monahan, R., Piessens, F., Polikarpova, N., Ridge, T., Smans, J., Tobies, S., Tuerk, T., Ulbrich, M., Weiß, B.: The 1st Verified Software Competition: Experience Report. In: Butler, M., Schulte, W. (eds.) FM 2011. LNCS, vol. 6664, pp. 154–168. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  8. 8.
    Koenig, J.: Dafny Guide. Microsoft Research (2011), (visited on January 30, 2012)
  9. 9.
    Koenig, J., Leino, K.R.M.: Getting started with Dafny: A Guide. Summer School Marktoberdorf 2011 Lecture Notes. IOS Press (to appear, 2012)Google Scholar
  10. 10.
    Leino, K.R.M.: Specification and verification of object-oriented software. In: Broy, M., Sitou, W., Hoare, T. (eds.) Engineering Methods and Tools for Software Safety and Security. NATO Science for Peace and Security Series D: Information and Communication Security. Summer School Marktoberdorf 2008 Lecture Notes, vol. 22, pp. 231–266. IOS Press (2009)Google Scholar
  11. 11.
    Leino, K.R.M.: Dafny: An Automatic Program Verifier for Functional Correctness. In: Clarke, E.M., Voronkov, A. (eds.) LPAR-16. LNCS (LNAI), vol. 6355, pp. 348–370. Springer, Heidelberg (2010)Google Scholar
  12. 12.
    Leino, K.R.M., Monahan, R.: Dafny Meets the Verification Benchmarks Challenge. In: Leavens, G.T., O’Hearn, P., Rajamani, S.K. (eds.) VSTTE 2010. LNCS, vol. 6217, pp. 112–126. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  13. 13.
    Meyer, B.: Object-oriented Software Construction. Series in Computer Science. Prentice-Hall International (1988)Google Scholar
  14. 14.
    de Moura, L., Bjørner, N.: Z3: An Efficient SMT Solver. In: Ramakrishnan, C.R., Rehof, J. (eds.) TACAS 2008. LNCS, vol. 4963, pp. 337–340. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  15. 15.
    Weiß, B.: Deductive verification of object-oriented software: dynamic frames, dynamic logic and predicate abstraction. PhD thesis, Karlsruhe Institute of Technology (2011)Google Scholar
  16. 16.
    Wiles, A.: Modular elliptic curves and Fermat’s last theorem. The Annals of Mathematics 141(3), 443–551 (1995) ISSN: 0003486X, doi:10.2307/2118559Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Luke Herbert
    • 1
  • K. Rustan M. Leino
    • 2
  • Jose Quaresma
    • 1
  1. 1.Technical University of DenmarkDenmark
  2. 2.Microsoft ResearchUSA

Personalised recommendations