CINV is a tool for abstract reachability analysis of programs manipulating dynamic (singly linked) lists. It implements a generic abstract domain HS for reasoning about dynamic lists with unbounded data which includes an abstraction on the shape of the heap and which is parametrized by some abstract domain on finite sequences of data (a data words abstract domain, DW-domain for short). The DW-domain is intended to abstract the sequences of data in the lists by capturing relevant aspects such as their sizes, the sums or the multisets of their elements, or some class of constraints on their data at different (linearly ordered or successive) positions.
CINV provides currently three classes of DW-domains:
We have applied CINV to a large class of programs manipulating lists. In particular, we have carried out the analysis of several sorting algorithms, of lists traversals with computation of complex arithmetical relations, etc.
For example, the following program sorts a list using an insertion sort algorithm which moves cells of the list instead of moving data.
| C code | Results of the analysis
|
|---|---|
#include "intlist.h"
/* acyclic(x) and l[x]==_l and data(x) */
intlist insertSortLst(intlist x) {
intlist xi, y, yi, z, r;
z = xi = yi = y = NULL;
r = z = x;
xi = x->next;
while (xi != NULL) {
yi = NULL;
y = r;
while (y != xi && y->data < xi->data) {
yi = y;
y = y->next;
}
if (yi == NULL) {
z->next = xi->next;
xi->next = r;
r = xi;
}
else {
z->next = xi->next;
yi->next = xi;
xi->next = y;
}
xi = NULL;
xi = z->next;
}
return r;
}
|
Using the UCONS domain with pattern forall y1,y2. y1 < y2, we obtain at the end of the main loop the ordering constraint on resulting list:
Using the LSUM domain, we obtain the preservation of data and length of the initial list at the end of the program as follows:
See the specific documentation of this example for details. |
Another example dealt by our tool is the intialisation of a list with the first elements of the Fibonacci sequence.
| C code | Results of the analysis
|
|---|---|
#include "intlist.h"
/* acyclic(x) and l[x]==_l and data(x) */
void initFibo(intlist x) {
int m1 = 1;
int m2 = 0;
intlist xi = x;
while (xi != NULL) {
xi->data = m1+m2;
m1 = m2;
m2 = xi->data;
xi = xi->next;
}
}
|
Using the LSUM domain, we obtain at the end of the program an invariant correspoding to a known identity of Fibonacci sequence:
Using the UCONS domain with pattern forall y1,y2. y1 < y2, we obtain at the end of the main loop the ordering constraint on resulting list:
See the specific documentation of this example for details. |
The programs dealt currently by CINV are available on the distributed package (see Download, directory samples/src).
A detailed presentation of results is given in the following documentation:
CINV is a free software under LGPL license. The current version of CINV is 0.2.2. Older versions:
For installing CINV you need:
Participants to the CINV project:
Last updated: Mon Oct 17 10:09:57 CEST 2011