source: CIVL/examples/languageFeatures/pointerAdd2.cvl@ 5c27aa5

1.23 2.0 main test-branch
Last change on this file since 5c27aa5 was 5ddac35, checked in by Ziqing Luo <ziqing@…>, 12 years ago

changes variables names which are more reasonable

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

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[d010d61]1/*************************************************/
2/* FILE: pointerAdd2.cvl
3 AUTHOR: Ziqing Luo
4
5 This example tries to verify 3 d array in general
6 case with iterating all possible values for every
7 symbolic input variable. The reason of why we don't
8 just use symbolic execution is the prover may not be
9 able to prove the assertion in certainty. So we force
10 to iterate all possible values for every input variable.
11*/
12/*************************************************/
[e6b02c8]13#include <civlc.cvh>
[d010d61]14#include <stdio.h>
15
16$input int N;
17$input int M;
18$input int L;
19$input int x,y,z;
20$input int offset;
21$input int a[N][M][L];
22$assume 0< N && N <= 2;
23$assume 0< M && M <= 2;
24$assume 0< L && L <= 2;
25$assume 0 <= x && x < N;
26$assume 0 <= y && y < M;
27$assume 0 <= z && z < L;
28$assume offset + x*M*L + y*L + z < M*N*L &&
29 offset + x*M*L + y*L + z >= 0;
30
31void main(){
32 for(int i=0; i<M; i++);
33 for(int i=0; i<N; i++);
34 for(int i=0; i<L; i++);
35 for(int i=0; i<x; i++);
36 for(int i=0; i<y; i++);
37 for(int i=0; i<z; i++);
38 for(int i=0; i<offset; i++);
39
[5ddac35]40 int oldTotal = x * M * L + y * L + z;
41 int newTotal = oldTotal + offset;
[d010d61]42 int X,Y,Z; //new indexes
43
[5ddac35]44 X = newTotal / (M * L);
45 newTotal = newTotal - X * M * L;
46 Y = newTotal / (L);
47 Z = newTotal - Y * L;
[d010d61]48 $assert(*(&a[x][y][z] + offset) == a[X][Y][Z]);
49
50}
Note: See TracBrowser for help on using the repository browser.