source: CIVL/examples/loop_invariants/arrayZeroes1d.cvl@ a2c8eb4

1.23 2.0 main test-branch
Last change on this file since a2c8eb4 was 9a23317, checked in by Ziqing Luo <ziqing@…>, 9 years ago

merged the loop invariants branch into trunk. It is in a rush, needs more effort to clean the code.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@4196 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 453 bytes
Line 
1#include<assert.h>
2
3#pragma PARSE_ACSL
4
5$input int N;
6$assume(N > 0);
7
8void arrayZeroes(int *a, int n) {
9 int i;
10
11 /*@ loop invariant 0 <= i && i <=n;
12 @ loop invariant \forall int j; 0<=j && j<i ==>
13 @ a[j] == 0;
14 @ loop assigns i, a[0 .. n-1];
15 @*/
16 for (i = 0; i < n; i++)
17 a[i] = 0;
18}
19
20int main() {
21 int a[N];
22
23 $havoc(&a);
24 arrayZeroes(a, N);
25 $assert($forall (int i : 0 .. N-1) a[i] == 0);
26}
Note: See TracBrowser for help on using the repository browser.