Formale Methoden der Softwareentwicklung
Instructions for installing the Dafny verifying compiler
Dafny is an imperative, object-oriented programming language with classes and inductive datatypes, and specification constructs for describing intended behavior. The Dafny verifier checks that programs live up to their specifications. To do this, it ultimately relies on the Z3 SMT solver.
Being “academic tools” they require some effort to get them installed, but that is just part of the fun (?!) of using them; so here we go…
-
The first thing is to get a working version of Z3. There are pre-compiled binaries available for Windows, OSX, FreeBSD, Ubuntu and Debian available here. Otherwise, we have to compile from sources:
$ git clone https://git01.codeplex.com/z3 # gets the sources $ cd z3 $ autoconf $ ./configure $ python scripts/mk_make.py $ cd build $ make $ ./z3 # we run it to verify it built ok...
-
Second, to run Dafny, non-Windows users need a working installation of the mono runtime. If running mono on a terminal issues an error, one needs to install the package. Linux users can get it using their package manager (e.g.
sudo apt-get install mono-completeon Ubuntu). OS X users can download the Mono.framework from here (select MRE, not SDK). -
Finally, we install the Dafny verifying-compiler:
-
Download Dafny.zip from here.
-
Unzip the downloaded file to, say,
~/tools/Dafny. -
Copy the binary of
z3to~/tools/Dafny, call itz3.exe(the.exeis crucial). For example, you can use a command such ascp ~/tools/z3/buld/z3 ~/tools/Dafny/z3.exe. NB. This may not be necessary in casez3was installed and is on the path. -
Finally, time to check if all this effort was worth it. Download this example Dafny file and try to verify it running
$ mono Dafny.exe mul.dfy
-