source: CIVL/examples/loop_invariants/loop_assigns_given/twoSec.cvl

main
Last change on this file 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: 660 bytes
Line 
1#pragma CIVL ACSL
2
3$input int N, M;
4$assume(0 <= M && M < N);
5$input int a[N];
6
7int main() {
8 int b[N];
9 int old = b[M];
10 /*@ loop invariant 0 <= i <= N;
11 @ loop invariant \forall int i1; 0 <= i1 < i ==>
12 @ ((i1 < M ==> b[i1] == 0) && (i1 > M ==> b[i1] == a[i1]));
13 @ loop assigns i, b[0 .. M-1], b[M+1 .. N-1];
14 @*/
15 for (int i = 0; i < N; i++) {
16 if (i < M) b[i] = 0;
17 else if (i > M) b[i] = a[i];
18 }
19 //$assert($forall (int i : 0 .. N-1) (i < M ? b[i] == 0 : (i > M ? b[i] == a[i] : $true)));
20 $assert($forall (int i : 0 .. N-1) (i < M => b[i] == 0) && (i > M => b[i] == a[i]));
21 $assert(b[M] == old);
22}
Note: See TracBrowser for help on using the repository browser.