source: CIVL/examples/loop_invariants/loop_assigns_gen/arrayEquals2.cvl@ 367a390

main test-branch
Last change on this file since 367a390 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: 522 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
10int arrayEquals(double * a, double * b, int n) {
11 int i = 0;
12
13 /*@ loop invariant 0 <= i && i <= n;
14 @ loop invariant \forall int j; 0<=j && j<i ==> a[j] == b[j];
15 @*/
16 while (0<=i && i < n && a[i] == b[i])
17 i++;
18 return i;
19}
20
21int main() {
22 int ret = arrayEquals(a, b, N);
23
24 if (ret == N)
25 assert($forall (int i: 0 .. ret-1) a[i] == b[i]);
26 if (ret < N)
27 assert(a[ret] != b[ret]);
28}
Note: See TracBrowser for help on using the repository browser.