1.23
2.0
main
test-branch
|
Last change
on this file since a2c8eb4 was 1247db4, checked in by Ziqing Luo <ziqing@…>, 9 years ago |
|
fixed a typo in one loop invariants.
Here is log for the last commitment. It was accidently missing log:
Clean some of the codes committed in a rush for hitting VerifyThis comptition.
Fixed an incorrect contract for summation.cvl
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@4213 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
568 bytes
|
| Line | |
|---|
| 1 | #include<assert.h>
|
|---|
| 2 |
|
|---|
| 3 | #pragma PARSE_ACSL
|
|---|
| 4 |
|
|---|
| 5 | $input int N;
|
|---|
| 6 | $assume(N > 0);
|
|---|
| 7 | $input double a[N];
|
|---|
| 8 | $input double b[N];
|
|---|
| 9 |
|
|---|
| 10 | _Bool arrayEquals(double * a, double * b, int n) {
|
|---|
| 11 | int i;
|
|---|
| 12 |
|
|---|
| 13 | /*@ loop invariant 0 <= i && i <= n;
|
|---|
| 14 | @ loop invariant \forall int j; 0<=j && j<i ==> a[j] == b[j];
|
|---|
| 15 | @ loop assigns i;
|
|---|
| 16 | @*/
|
|---|
| 17 | for (i = 0; i < n; i++)
|
|---|
| 18 | if (a[i] != b[i])
|
|---|
| 19 | return $false;
|
|---|
| 20 | return $true;
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | int main() {
|
|---|
| 24 | _Bool ret = arrayEquals(a, b, N);
|
|---|
| 25 |
|
|---|
| 26 | if (ret)
|
|---|
| 27 | assert($forall (int i: 0 .. N-1) a[i] == b[i]);
|
|---|
| 28 | // if (ret < N)
|
|---|
| 29 | // assert(a[ret] != b[ret]);
|
|---|
| 30 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.