skip to main content
tutorial

Developing verified programs with Dafny

Published:02 December 2012Publication History
Skip Abstract Section

Abstract

Reasoning about programs is a fundamental skill that every software engineer needs. This tutorial provides participants an opportunity to get hands-on experience with Dafny, a tool that can help develop this skill.

Dafny is a programming language and state-of-the-art program verifier. The language is type-safe and sequential, and it includes common imperative features, dynamic object allocation, and inductive datatypes. It also includes specification constructs like pre- and postconditions, which let a programmer record the intended behavior of the program along with the executable code that is supposed to cause that behavior. Because the Dafny verifier runs continuously in the background, the consistency of a program and its specifications is always enforced.

In this tutorial, I give a taste of how to use Dafny in program development. This includes an overview of Dafny, basics of writing specifications, how to debug verification attempts, and how to formulate and prove lemmas. Dafny has been used to verify a number of challenging algorithms, including Schorr-Waite graph marking, Floyd's ``tortoise and hare'' cycle-detection algorithm, and snapshotable trees with iterators. Dafny is also being used in teaching, with over 100,000 program-verification attempts submitted to the online version of the tool. Dafny was a popular choice in the VSTTE 2012 program verification competition, where two of the Dafny teams were among the competition's 6 medalists. Its open-source implementation has also been used as a foundation for other verification tools. More information is found from the Dafny project page, http://research.microsoft.com/dafny and in the references below. Binary downloads and sources are available from http://dafny.codeplex.com. The tool can also be run on the web at http://rise4fun.com/dafny, where there is an online version of the tutorial.

References

  1. L. Herbert, K. R. M. Leino, and J. Quaresma. Using Dafny, an automatic program verifier. In B. Meyer and M. Nordio, editors, LASER 2012, volume 7682 of LNCS, pages 156--181. Springer, 2012.Google ScholarGoogle Scholar
  2. B. Jacobs, J. Smans, and F. Piessens. VeriFast: Imperative programs as proofs. In VS-Tools workshop at VSTTE 2010, Aug. 2010.Google ScholarGoogle Scholar
  3. J. Koenig and K. R. M. Leino. Getting started with Dafny: A guide. In T. Nipkow, O. Grumberg, and B. Hauptmann, editors, Software Safety and Security: Tools for Analysis and Verification, volume 33 of NATO Science for Peace and Security Series D: Information and Communication Security, pages 152--181. IOS Press, 2012. Summer School Marktoberdorf 2011 lecture notes.Google ScholarGoogle Scholar
  4. C. Le Goues, K. R. M. Leino, and M. Moskal. The Boogie Verification Debugger (tool paper). In G. Barthe, A. Pardo, and G. Schneider, editors, Software Engineering and Formal Methods - 9th International Conference, SEFM 2011, volume 7041 of LNCS, pages 407--414. Springer, Nov. 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. K. R. M. Leino. Specification and verification of object-oriented software. In M. Broy, W. Sitou, and T. Hoare, editors, Engineering Methods and Tools for Software Safety and Security, volume 22 of NATO Science for Peace and Security Series D: Information and Communication Security, pages 231--266. IOS Press, 2009. Summer School Marktoberdorf 2008 lecture notes.Google ScholarGoogle Scholar
  6. K. R. M. Leino. Dafny: An automatic program verifier for functional correctness. In E. M. Clarke and A. Voronkov, editors, LPAR-16, volume 6355 of LNCS, pages 348--370. Springer, Apr. 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. K. R. M. Leino. Automating induction with an SMT solver. In V. Kuncak and A. Rybalchenko, editors, Verification, Model Checking, and Abstract Interpretation - 13th International Conference, VMCAI 2012, volume 7148 of LNCS, pages 315--331. Springer, Jan. 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. K. R. M. Leino and M. Moskal. Usable auto-active verification. In T. Ball, L. Zuck, and N. Shankar, editors, UV10 (Usable Verification) workshop. http://fm.csl.sri.com/UV10/, Nov. 2010.Google ScholarGoogle Scholar
  9. B. Meyer. Object-oriented Software Construction. Series in Computer Science. Prentice-Hall International, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Developing verified programs with Dafny

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!