-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
118 changed files
with
1,537 additions
and
519 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
|
||
|
||
function truncate(x : real) : (i : real) | ||
// pre-conditions-start | ||
requires x >= 0.0 | ||
// pre-conditions-end | ||
// post-conditions-start | ||
ensures (0.0 <= x - i < 1.0) | ||
// post-conditions-end | ||
{ | ||
// impl-start | ||
x.Floor as real | ||
} | ||
// impl-end | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
|
||
method intersperse(numbers: seq<int>, delimeter: int) returns (res: seq<int>) | ||
ensures |numbers| != 0 ==> |numbers| * 2 - 1 == |res| | ||
ensures |numbers| == 0 ==> |res| == 0 | ||
ensures forall i : int :: i >= 0 && i < |res| && i % 2 == 0 ==> res[i] == numbers[i / 2] | ||
ensures forall i : int :: i >= 0 && i < |res| && i % 2 == 1 ==> res[i] == delimeter | ||
// post-conditions-start | ||
ensures |numbers| != 0 ==> |numbers| * 2 - 1 == |res| | ||
ensures |numbers| == 0 ==> |res| == 0 | ||
ensures forall i : int :: i >= 0 && i < |res| && i % 2 == 0 ==> res[i] == numbers[i / 2] | ||
ensures forall i : int :: i >= 0 && i < |res| && i % 2 == 1 ==> res[i] == delimeter | ||
// post-conditions-end | ||
{ | ||
res := []; | ||
if (|numbers| != 0) | ||
// impl-start | ||
res := []; | ||
if (|numbers| != 0) | ||
{ | ||
var i : int := 0; | ||
while (i + 1 < |numbers|) | ||
// invariants-start | ||
invariant 0 <= i && i < |numbers| | ||
invariant |res| == 2 * i | ||
invariant forall i1 : int :: i1 >= 0 && i1 < |res| && i1 % 2 == 0 ==> res[i1] == numbers[i1 / 2] | ||
invariant forall i1 : int :: i1 >= 0 && i1 < |res| && i1 % 2 == 1 ==> res[i1] == delimeter | ||
// invariants-end | ||
{ | ||
var i : int := 0; | ||
while (i + 1 < |numbers|) | ||
invariant 0 <= i && i < |numbers| | ||
invariant |res| == 2 * i | ||
invariant forall i1 : int :: i1 >= 0 && i1 < |res| && i1 % 2 == 0 ==> res[i1] == numbers[i1 / 2] | ||
invariant forall i1 : int :: i1 >= 0 && i1 < |res| && i1 % 2 == 1 ==> res[i1] == delimeter | ||
{ | ||
res := res + [numbers[i]]; | ||
res := res + [delimeter]; | ||
i := i + 1; | ||
} | ||
res := res + [numbers[i]]; | ||
res := res + [numbers[i]]; | ||
res := res + [delimeter]; | ||
i := i + 1; | ||
} | ||
res := res + [numbers[i]]; | ||
} | ||
// impl-end | ||
} |
This file contains 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
Oops, something went wrong.