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:
1.3 KB
|
| Rev | Line | |
|---|
| [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;
|
|---|
| [3ff27cf] | 21 | $assume(0< N && N <= 2);
|
|---|
| 22 | $assume(0< M && M <= 2);
|
|---|
| 23 | $assume(0< L && L <= 2);
|
|---|
| 24 | $assume(0 <= x && x < N);
|
|---|
| 25 | $assume(0 <= y && y < M);
|
|---|
| 26 | $assume(0 <= z && z < L);
|
|---|
| [f3282f0] | 27 | $input int a[N][M][L];
|
|---|
| [3ff27cf] | 28 | $assume(offset + x*M*L + y*L + z < M*N*L &&
|
|---|
| 29 | offset + x*M*L + y*L + z >= 0);
|
|---|
| [d010d61] | 30 |
|
|---|
| 31 | void main(){
|
|---|
| [734b2d8] | 32 | $elaborate(M);
|
|---|
| 33 | $elaborate(N);
|
|---|
| 34 | $elaborate(L);
|
|---|
| 35 | $elaborate(x);
|
|---|
| 36 | $elaborate(y);
|
|---|
| 37 | $elaborate(z);
|
|---|
| 38 | $elaborate(offset);
|
|---|
| [d010d61] | 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;
|
|---|
| [d980649] | 48 | $assert(*(&a[x][y][z] + offset) == a[X][Y][Z]);
|
|---|
| [d010d61] | 49 |
|
|---|
| 50 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.