main
test-branch
|
Last change
on this file since a389857 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
567 bytes
|
| Line | |
|---|
| 1 | #include<assert.h>
|
|---|
| 2 |
|
|---|
| 3 | #pragma CIVL 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.