Skip to content

Commit 4f17111

Browse files
committed
make smt2_conv extensible
This adds a mechanism to extend the SMT2 conversion with a functor for a given expression id.
1 parent 1d94b74 commit 4f17111

File tree

82 files changed

+1273
-357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1273
-357
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
int main()
2+
{
3+
unsigned char array[10];
4+
__CPROVER_assert(__CPROVER_r_ok(array, 10), "property 1");
5+
unsigned char *array_ptr = array;
6+
__CPROVER_assert(__CPROVER_r_ok(array_ptr, 10), "property 2");
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
array_r_ok1.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$
7+
^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$
8+
--

regression/cprover/basic/assume1.desc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ assume1.c
99
^\(\d+\) ∀ ς : state \. \(S20\(ς\) ∧ ς\(❝main::1::x❞\) ≥ 10\) ⇒ S21\(ς\)$
1010
^\(\d+\) ∀ ς : state \. S21\(ς\) ⇒ \(ς\(❝main::1::x❞\) ≥ 5\)$
1111
^\(\d+\) ∀ ς : state \. S22\(ς\) ⇒ \(ς\(❝main::1::x❞\) ≥ 15\)$
12-
^\(\d+\) ∀ ς : state \. S24\(ς\) ⇒ S25\(ς\[❝return'❞:=nondet::S25-0\]\)$
1312
^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$
1413
^\[main\.assertion\.2\] line \d+ property 2: REFUTED$
1514
--

regression/cprover/basic/nondet1.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ nondet1.c
33
--text --solve --inline
44
^EXIT=10$
55
^SIGNAL=0$
6-
^\(\d+\) ∀ ς : state \. S21\(ς\) ⇒ S22\(ς\[❝main::1::x❞:=nondet::S22-0\]\)$
6+
^\(\d+\) ∀ ς : state, nondet::S22-0 : signedbv\[32\] \. S21\(ς\) ⇒ S22\(ς\[❝main::1::x❞:=nondet::S22-0\]\)$
77
^\(\d+\) ∀ ς : state \. S22\(ς\) ⇒ \(ς\(❝main::1::x❞\) = 20\)$
88
^\(\d+\) S23 = S22$
9-
^\(\d+\) ∀ ς : state \. S23\(ς\) ⇒ S24\(ς\[❝main::1::y❞:=nondet::S24-0\]\)$
9+
^\(\d+\) ∀ ς : state, nondet::S24-0 : signedbv\[32\] \. S23\(ς\) ⇒ S24\(ς\[❝main::1::y❞:=nondet::S24-0\]\)$
1010
^\(\d+\) ∀ ς : state \. S24\(ς\) ⇒ \(ς\(❝main::1::x❞\) = ς\(❝main::1::y❞\)\)$
1111
^\(\d+\) S25 = S24$
1212
^\(\d+\) ∀ ς : state \. S25\(ς\) ⇒ S26\(ς\[❝return'❞:=0\]\)$

regression/cprover/contracts/check_assigns1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
check_assigns1.c
3-
--no-inline
3+
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[my_function1\.assigns\.1\] line \d+ assigns clause: SUCCESS$
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
check_assigns2.c
3-
--no-inline
3+
44
^EXIT=0$
55
^SIGNAL=0$
66
--

regression/cprover/contracts/check_postcondition1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
check_postcondition1.c
3-
--no-inline
3+
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[my_function1\.postcondition\.1\] line \d+ postcondition: SUCCESS$

regression/cprover/contracts/check_postcondition2.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
check_postcondition2.c
3-
--no-inline
3+
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[my_function1\.postcondition\.1\] line \d+ postcondition: SUCCESS$

regression/cprover/contracts/check_postcondition3.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
KNOWNBUG
22
check_postcondition3.c
3-
--no-inline
3+
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[my_function1\.postcondition\.1\] line \d+ postcondition: SUCCESS$

regression/cprover/contracts/check_precondition1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
check_precondition1.c
3-
--no-inline
3+
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[main\.precondition\.1\] line \d+ precondition my_function: REFUTED$

regression/cprover/contracts/check_precondition2.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
check_precondition2.c
3-
--no-inline
3+
44
^EXIT=0$
55
^SIGNAL=0$
66
^\[caller\.precondition\.1\] line \d+ precondition callee: SUCCESS$

regression/cprover/contracts/check_return_value1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
check_return_value1.c
3-
--no-inline
3+
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[my_function1\.postcondition\.1\] line \d+ postcondition: SUCCESS$

regression/cprover/contracts/recursive_function1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
recursive_function1.c
3-
--no-inline
3+
44
^EXIT=0$
55
^SIGNAL=0$
66
^\[recursive_function\.precondition\.1] line \d+ precondition recursive_function: SUCCESS$

regression/cprover/contracts/use_assigns1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
use_assigns1.c
3-
--no-inline
3+
44
^EXIT=0$
55
^SIGNAL=0$
66
^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$

regression/cprover/contracts/use_assigns2.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
use_assigns2.c
3-
--no-inline
3+
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[main\.assertion\.1\] line \d+ property 1: REFUTED$

regression/cprover/contracts/use_postcondition1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
use_postcondition1.c
3-
--no-inline
3+
44
^EXIT=0$
55
^SIGNAL=0$
66
^\[callee\.assigns\.1\] line \d+ assigns clause: SUCCESS$

regression/cprover/contracts/use_precondition1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
use_precondition1.c
3-
--no-inline
3+
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[my_function\.assertion\.1\] line \d+ property 1: SUCCESS$

regression/cprover/cstrings/cstring_preserved2.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
cstring_preserved2.c
3-
--no-inline
3+
44
^EXIT=0$
55
^SIGNAL=0$
66
^\[cstring_preserved\.assertion\.1\] line \d+ p is still a cstring: SUCCESS$

regression/cprover/function_calls/call_no_body1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ call_no_body1.c
44
^EXIT=0$
55
^SIGNAL=0$
66
^\*\*\*\* WARNING: no body for function function_without_body$
7-
^\(\d+\) ∀ ς : state \. S28\.1\(ς\) ⇒ S28\.2\(ς\[❝main::\$tmp::return_value_function_without_body❞:=nondet::S28\.2-0\]\)$
7+
^\(\d+\) ∀ ς : state, nondet::S28\.2-0 : signedbv\[32\] \. S28\.1\(ς\) ⇒ S28\.2\(ς\[❝main::\$tmp::return_value_function_without_body❞:=nondet::S28\.2-0\]\)$
88
^\(\d+\) ∀ ς : state \. S28\.2\(ς\) ⇒ S28\.3\(ς\[❝main::1::x❞:=ς\(❝main::\$tmp::return_value_function_without_body❞\)\]\)$
99
--

regression/cprover/function_calls/call_no_body2.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ call_no_body2.c
33
--text
44
^EXIT=0$
55
^SIGNAL=0$
6-
^\(\d+\) ∀ ς : state \. S28\.1\(ς\) ⇒ S28\.2\(ς\[❝main::\$tmp::return_value_function_without_body❞\.❝x❞:=nondet::S28\.2-0\]\)$
6+
^\(\d+\) ∀ ς : state, nondet::S28\.2-0 : signedbv\[32\] \. S28\.1\(ς\) ⇒ S28\.2\(ς\[❝main::\$tmp::return_value_function_without_body❞\.❝x❞:=nondet::S28\.2-0\]\)$
77
--

regression/cprover/function_calls/va_args1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
va_args1.c
33

44
^EXIT=0$
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdarg.h>
2+
3+
void f(int first, ...)
4+
{
5+
va_list ap;
6+
va_start(ap, first);
7+
8+
int second;
9+
second = va_arg(ap, int);
10+
11+
__CPROVER_assert(first == 1, "property 1");
12+
__CPROVER_assert(second == 2, "property 2");
13+
}
14+
15+
int main()
16+
{
17+
f(1, 2);
18+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
va_args2.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\[f\.assertion\.1\] line \d+ property 1: SUCCESS$
7+
^\[f\.assertion\.2\] line \d+ property 2: SUCCESS$
8+
--
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <stdarg.h>
2+
3+
void f(int first, ...)
4+
{
5+
va_list ap;
6+
va_start(ap, first);
7+
8+
int second;
9+
second = va_arg(ap, int);
10+
11+
int third;
12+
third = va_arg(ap, int);
13+
14+
__CPROVER_assert(first == 1, "property 1");
15+
__CPROVER_assert(second == 2, "property 2");
16+
__CPROVER_assert(third == 3, "property 3");
17+
}
18+
19+
int main()
20+
{
21+
f(1, 2, 3);
22+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
va_args3.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\[f\.assertion\.1\] line \d+ property 1: SUCCESS$
7+
^\[f\.assertion\.2\] line \d+ property 2: SUCCESS$
8+
^\[f\.assertion\.3\] line \d+ property 3: SUCCESS$
9+
--

regression/cprover/loops/assigns1.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
int main()
2+
{
3+
int *p;
4+
__CPROVER_assume(__CPROVER_r_ok(p));
5+
6+
for(int i=0; i<10; i++)
7+
{
8+
// does not assign p
9+
}
10+
11+
__CPROVER_assert(__CPROVER_r_ok(p), "property 1"); // passes
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
KNOWNBUG
2+
assigns1.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$
7+
--
8+
--
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
int nondet_int();
2+
3+
int main()
4+
{
5+
int N = nondet_int();
6+
int x = 0;
7+
while(x < N)
8+
x++;
9+
10+
__CPROVER_assert(x == N, "property 1"); // fails
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
while_loop2.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[main\.assertion\.1\] line \d+ property 1: REFUTED$
7+
--

regression/cprover/pointers/const2.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
const2.c
33

44
^EXIT=0$
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
int some_int = 123;
2+
void *ptr_array[10] = { &some_int };
3+
4+
int main()
5+
{
6+
__CPROVER_assert(ptr_array[0] == &some_int, "property 1");
7+
8+
void **array_pointer = ptr_array;
9+
10+
__CPROVER_assert(array_pointer[0] == &some_int, "property 2");
11+
__CPROVER_assert(*((int *)(array_pointer[0])) == 123, "property 3");
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
pointer_array1.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$
7+
^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$
8+
^\[main\.assertion\.3\] line \d+ property 3: SUCCESS$
9+
--

regression/cprover/pointers/pointer_to_local1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
pointer_to_local1.c
3-
--no-inline
3+
44
^EXIT=0$
55
^SIGNAL=0$
66
^\[foo\.assertion\.1\] line \d+ property 1: SUCCESS$
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#include <stdlib.h>
22

3+
int *p;
4+
void **p_ptr;
5+
36
int main()
47
{
5-
int *p;
68
p = malloc(1);
7-
void **q = &p;
8-
void *new_mem = malloc(1);
9-
free(*q);
9+
p_ptr = &p;
10+
__CPROVER_assert(__CPROVER_LIVE_OBJECT(*p_ptr), "property 1");
11+
return 0;
1012
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
KNOWNBUG
1+
CORE
22
pointer_to_pointer1.c
3-
--safety
3+
44
^EXIT=0$
55
^SIGNAL=0$
6+
^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$
67
--
7-
^\[main\.pointer\.1\] line \d+ pointer q safe: SUCCESS$
8-
^\[main\.free\.1\] line \d+ free argument must be valid dynamic object: SUCCESS$
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
int main()
2+
{
3+
int x, *p;
4+
p = &x;
5+
__CPROVER_assert(*p == x, "property 1"); // should pass
6+
return 0;
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
pointers0.c
3+
--text --solve --inline
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\(\d+\) ∀ ς : state \. S21\(ς\) ⇒ S22\(ς\[❝main::1::p❞:=❝main::1::x❞\]\)$
7+
^\(\d+\) ∀ ς : state \. S22\(ς\) ⇒ \(ς\(ς\(❝main::1::p❞\)\) = ς\(❝main::1::x❞\)\)$
8+
^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$
9+
--

regression/cprover/pointers/struct_pointer6.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ struct buf {
55
int main()
66
{
77
struct buf *b;
8+
__CPROVER_assume(__CPROVER_r_ok(b));
89
__CPROVER_assume(b->len == 456);
910

1011
__CPROVER_size_t x, *size_t_ptr = &x;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
int main()
2+
{
3+
void *p, *q;
4+
// functional consistency of dynamic_object
5+
__CPROVER_assume(p == q);
6+
7+
__CPROVER_assert(
8+
__CPROVER_DYNAMIC_OBJECT(p) == __CPROVER_DYNAMIC_OBJECT(q), "property 1");
9+
10+
__CPROVER_assert(
11+
__CPROVER_DYNAMIC_OBJECT(p) == __CPROVER_DYNAMIC_OBJECT(q + 1), "property 2");
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
dynamic_object1.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\[main\.assertion\.1\] line \d+ property 1: SUCCESS$
7+
^\[main\.assertion\.2\] line \d+ property 2: SUCCESS$
8+
--

0 commit comments

Comments
 (0)