Created
March 12, 2013 14:49
-
-
Save jbranchaud/5143509 to your computer and use it in GitHub Desktop.
Exercise 6 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
/* | |
* Now that we have an abs function, change the postcondition of method | |
* Abs to make use of abs. After confirming the method still verifies, | |
* change the body of Abs to also use abs. (After doing this, you will | |
* realize there is not much point in having a method that does exactly | |
* the same thing as a function method.) | |
*/ | |
function method abs(x: int): int | |
{ | |
if x < 0 then -x else x | |
} | |
method Abs(x: int) returns (y: int) | |
ensures y == abs(x); | |
{ | |
return abs(x); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment