File tree 13 files changed +84
-9
lines changed
13 files changed +84
-9
lines changed Original file line number Diff line number Diff line change 1
- #include <assert.h>
1
+ // function_apply_01
2
2
3
- // Note that this is supposed to have an incorrect contract.
3
+ // Note that this test is supposed to have an incorrect contract.
4
4
// We verify that applying (without checking) the contract yields success,
5
5
// and that checking the contract yields failure.
6
+
7
+ #include <assert.h>
8
+
6
9
int foo ()
7
10
__CPROVER_ensures (__CPROVER_return_value == 0 )
8
11
{
Original file line number Diff line number Diff line change
1
+ // function_check_01
2
+
3
+ // This tests a simple example of a function with requires and
4
+ // ensures which should both be satisfied.
5
+
1
6
#include <assert.h>
2
7
3
8
int min (int a , int b )
Original file line number Diff line number Diff line change
1
+ // function_check_02
2
+
3
+ // This test checks the use of quantifiers in ensures clauses.
4
+ // A known bug causes the use of quantifiers in ensures to fail.
5
+
1
6
int initialize (int * arr )
2
7
__CPROVER_ensures (
3
8
__CPROVER_forall {int i ; (0 <= i && i < 10 ) == > arr [i ] == i }
Original file line number Diff line number Diff line change
1
+ // function_check_03
2
+
3
+ // This extends function_check_02's test of quantifiers in ensures
4
+ // and adds in a loop invariant which can be used to prove the ensures.
5
+ // This currently fails because side-effect checking in loop invariants is
6
+ // incorrect.
7
+
1
8
void initialize (int * arr , int len )
2
9
__CPROVER_ensures (
3
10
__CPROVER_forall {int i ; (0 <= i && i < len ) == > arr [i ] == i }
Original file line number Diff line number Diff line change
1
+ // function_check_04
2
+
3
+ // Note that this test is supposed to have an incorrect contract.
4
+ // We verify that checking this faulty contract (correctly) yields a failure.
5
+
1
6
#include <assert.h>
2
7
3
- // Note that this is supposed to have an incorrect contract.
4
- // We verify that applying (without checking) the contract yields success,
5
- // and that checking the contract yields failure.
6
8
int foo ()
7
9
__CPROVER_ensures (__CPROVER_return_value == 0 )
8
10
{
Original file line number Diff line number Diff line change
1
+ // function_check_05
2
+
3
+ // This test checks that when a function call is replaced by an invariant,
4
+ // it adequately havocs the locations modified by the function.
5
+ // This test currently fails because the analysis of what is modified by
6
+ // a function is flawed.
7
+
1
8
#include <assert.h>
2
9
3
10
int foo (int * x )
Original file line number Diff line number Diff line change
1
+ // function_check_mem_01
2
+
3
+ // This test checks the use of pointer-related predicates in assumptions and
4
+ // requires.
5
+ // This test currently fails because of the lack of support for assuming
6
+ // pointer predicates.
7
+
1
8
#include <stddef.h>
2
9
3
10
#define __CPROVER_VALID_MEM (ptr , size ) \
Original file line number Diff line number Diff line change
1
+ // invar_check_01
2
+
3
+ // This test checks that a basic loop invariant can be proven and used in
4
+ // combination with the negation of the loop guard to get a result.
5
+
1
6
#include <assert.h>
2
7
3
8
int main ()
Original file line number Diff line number Diff line change
1
+ // invar_check_02
2
+
3
+ // This test checks that loop invariants adequately handle continues.
4
+
1
5
#include <assert.h>
2
6
3
7
int main ()
Original file line number Diff line number Diff line change
1
+ // invar_check_03
2
+
3
+ // This test checks the use of loop invariants on a larger problem --- in this
4
+ // case, the partition portion of quicksort, applied to a fixed-length array.
5
+ // This serves as a stop-gap test until issues to do with quantifiers and
6
+ // side-effects in loop invariants are fixed.
7
+
1
8
#include <stdio.h>
2
9
#include <assert.h>
3
10
Original file line number Diff line number Diff line change
1
+ // invar_check_04
2
+
3
+ // This test checks the handling of break by loop invariants.
4
+ // This test is expected to fail along the code path where r is even before
5
+ // entering the loop.
6
+
1
7
#include <assert.h>
2
8
3
9
int main ()
Original file line number Diff line number Diff line change
1
+ // invar_loop_constant
2
+
3
+ // This test checks to see whether loop invariant checking discards sufficiently
4
+ // little information to be aware after the loop that s is necessarily 1.
5
+ // This test currently fails due to excessive havocking in checking loop
6
+ // invariants, but is not an obstacle to soundness of contract checking.
7
+
1
8
#include <assert.h>
2
9
3
10
int main () {
4
11
int r ;
5
- int s ;
6
- __CPROVER_assume (r > 0 );
12
+ int s = 1 ;
13
+ __CPROVER_assume (r >= 0 );
7
14
while (r > 0 )
8
15
__CPROVER_loop_invariant (r >= 0 )
9
16
{
Original file line number Diff line number Diff line change
1
+ // quicksort_contracts_01
2
+
3
+ // This test checks the correctness of a quicksort implementation using explicit
4
+ // ghost state.
5
+
6
+ // This test currently fails for a variety of reasons, including:
7
+ // (1) Lack of support for quantifiers in ensures statements.
8
+ // (2) Lack of support for reading from memory in loop invariants (under some
9
+ // circumstances)
10
+
1
11
#include <stdio.h>
2
12
#include <stdlib.h>
3
13
#include <string.h>
@@ -32,13 +42,13 @@ __CPROVER_ensures(
32
42
int pivot = arr [pivot_idx ];
33
43
34
44
while (h > l )
35
- /* __CPROVER_loop_invariant(
45
+ __CPROVER_loop_invariant (
36
46
0 <= l && l <= pivot_idx && pivot_idx <= h && h < len &&
37
47
arr [pivot_idx ] == pivot &&
38
48
__CPROVER_forall {int i ; (0 <= i && i < l ) == > arr [i ] <= pivot } &&
39
49
__CPROVER_forall {int i ; (h < i && i < len ) == > pivot <= arr [i ]} &&
40
50
1 == 1
41
- )*/
51
+ )
42
52
{
43
53
if (arr [h ] <= pivot && arr [l ] >= pivot ) {
44
54
swap (arr + h , arr + l );
You can’t perform that action at this time.
0 commit comments