Skip to content

Instantly share code, notes, and snippets.

@jbranchaud
Created March 12, 2013 15:01
Show Gist options
  • Save jbranchaud/5143620 to your computer and use it in GitHub Desktop.
Save jbranchaud/5143620 to your computer and use it in GitHub Desktop.
Exercise 7 from Microsoft's Dafny on Rise4Fun.com
/*
* Change the loop invariant to 0 <= i <= n+2. Does the loop still verify?
* Does the assertion i == n after the loop still verify?
* It no longer verifies because the invariant is no longer sufficient for
* proving the assertion.
*/
method m(n: nat)
{
var i: int := 0;
while (i < n)
invariant 0 <= i <= n+2;
{
i := i + 1;
}
assert i == n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment