Git Product home page Git Product logo

dafny-training's Introduction

dafny-training

Some examples of Dafny code to support training sessions

Install Dafny/VSCode

You should install the Dafny VsCode plugin.

The installer may prompt you to agree to install Dafny 3.0.0, Z3 and change some permissions.

You may configure the plugin to verify on save only (set the Dafny plugin settings in VSCode) as otherwise live and continuous verification can alter performance.

Dafny CLI

In the session we may use the CLI (e.g. for compile/run). You can use the Dafny executubla bundled in the plugin located at $HOME/.vscode/extensions/correctnesslab.dafny-vscode-1.4.0/out/dafnyLanguageServer/Dafny.dll. To run the .dll on non-windows system, you'll have to install dotnet. You can then create an alias for dafny

alias dafny=`dotnet ../../.vscode/extensions/correctnesslab.dafny-vscode-1.4.0/out/dafnyLanguageServer/Dafny.dll`

Alternatively, you can install the Dafny 3.0.0 latest release for your system which provide a dafny executable (the VSCode plugin also runs Dafny 3.0.0). There is no conflict between the plugin version and another one that you install manually. The plugin configuration defaults to use the Dafny executables bundled with the plugin.

Make sure you add the path to the Dafny executable to your paths.

Checking your installation

Checking Plugin

  1. Clone/fork this repository.
  2. Open the file training1.dfy in session1
  3. The Problems tab should display a couple of information (decreases and another related to triggers). If this is the case you should be all set.

Checking CLI

In a terminal, the command dafny /help should output something like:

% dafny -version
Dafny 3.0.0.30203

You can cd to the sessions directory and try the following commands:

% dafny /dafnyVerify:1 /compile:0 /trace training1.dfy

On my computer this results in (path names may differ on your system):

Parsing training1.dfy
Coalescing blocks...
Inlining...

Running abstract interpretation...
  [0.060479 s]
[TRACE] Using prover: /Users/franck/local/dafny3.0.0/z3/bin/z3

Verifying Impl$$_module.__default.abs ...
  [0.465 s, 1 proof obligation]  verified

Verifying Impl$$_module.__default.max ...
  [0.068 s, 1 proof obligation]  verified

Verifying Impl$$_module.__default.ex1 ...
  [0.070 s, 3 proof obligations]  verified

Verifying Impl$$_module.__default.find ...
  [0.070 s, 6 proof obligations]  verified

Verifying CheckWellformed$$_module.__default.sorted ...
  [0.067 s, 2 proof obligations]  verified

Verifying Impl$$_module.__default.unique ...
  [0.064 s, 1 proof obligation]  verified

Verifying Impl$$_module.__default._default_Main ...
  [0.076 s, 6 proof obligations]  verified

Dafny program verifier finished with 7 verified, 0 errors

Note

On MacOSX, if you have manually installed the Dafny 3.0.0 release you may encounter some permission issues on MacOSX. In that case, you may have to allow several files to be executable (this is via the Security widget in the Preferences.)

Dafny Reference Manual

The current versions of the Dafny Reference Manual should be:

dafny-training's People

Contributors

franck44 avatar sandjohnson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.