source: CIVL/examples/loop_invariants/max.cvl@ 9becdb9

1.23 2.0 main test-branch
Last change on this file since 9becdb9 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: 407 bytes
Line 
1#include <assert.h>
2
3#pragma PARSE_ACSL
4
5$input int N;
6$assume(N > 0);
7$input double a[N];
8
9int main() {
10 int i = 0;
11 double max = a[0];
12
13 /*@ loop invariant 1 <= i && i <= N;
14 @ loop invariant \forall int t; 0 <= t && t < i ==> a[t] <= max;
15 @ loop assigns i, max;
16 @*/
17 for (i = 1; i < N; i++)
18 if (a[i] > max)
19 max = a[i];
20
21 assert($forall (int i : 0 .. N-1) a[i] <= max);
22}
Note: See TracBrowser for help on using the repository browser.