main
test-branch
|
Last change
on this file since bb03188 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:
676 bytes
|
| Rev | Line | |
|---|
| [01c5b2ce] | 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 | /*@ requires n > 0;
|
|---|
| 11 | @ requires \valid(a+(0..n)) && \valid(b+(0..n));
|
|---|
| 12 | @ assigns \nothing;
|
|---|
| 13 | @ ensures (\result == \true) ==> (\forall int i; 0 <= i && i < n ==> a[i] == b[i]);
|
|---|
| 14 | @*/
|
|---|
| 15 | _Bool arrayEquals(double * a, double * b, int n) {
|
|---|
| 16 | _Bool equal = $true;
|
|---|
| 17 |
|
|---|
| 18 | //@ focus F;
|
|---|
| 19 | for (int i = 0; i < n; i++)
|
|---|
| 20 | if (a[i] != b[i])
|
|---|
| 21 | equal = $false;
|
|---|
| 22 | //@ focus F;
|
|---|
| 23 | assert($forall (int i: 0 .. n-1) equal => a[i] == b[i]);
|
|---|
| 24 | return equal;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | int main() {
|
|---|
| 28 | _Bool ret = arrayEquals(a, b, N);
|
|---|
| 29 |
|
|---|
| 30 | if (ret) {
|
|---|
| 31 | assert($forall (int i: 0 .. N-1) a[i] == b[i]);
|
|---|
| 32 | }
|
|---|
| 33 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.