Created
March 12, 2013 15:01
-
-
Save jbranchaud/5143620 to your computer and use it in GitHub Desktop.
Exercise 7 from Microsoft's Dafny on Rise4Fun.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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