Skip to content

Commit

Permalink
Correct annotations in 008-sum_product.dfy (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesyspa authored Oct 8, 2024
1 parent a50f3ab commit 5a7e344
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 008-sum_product.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ lemma prod_prop(s: seq<int>)
}

method sum_product(numbers: seq<int>) returns (s : int, p : int)
// post-condition-start
ensures s == sum(numbers)
ensures p == prod(numbers)
// post-condition-end
{
// impl-start
assert numbers[..|numbers|] == numbers; // assert-line
s := 0;
p := 1;
for i := 0 to |numbers|
// invariants-start
invariant s == sum(numbers[..i])
invariant p == prod(numbers[..i])
// invariants-end
{
// assert-start
assert sum(numbers[..i + 1]) == sum(numbers[..i]) + numbers[i] by {
Expand Down

0 comments on commit 5a7e344

Please sign in to comment.