Skip to content

Commit f82fea4

Browse files
authored
Merge pull request #6145 from padhi-aws-forks/quantifiers-tests-fix
Cleanup regression tests for quantified contracts
2 parents 6e7d38d + ea71d66 commit f82fea4

File tree

60 files changed

+636
-419
lines changed

Some content is hidden

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

60 files changed

+636
-419
lines changed

regression/contracts/quantifiers-exists-both-01/main.c

Lines changed: 0 additions & 18 deletions
This file was deleted.

regression/contracts/quantifiers-exists-both-01/test.desc

Lines changed: 0 additions & 13 deletions
This file was deleted.

regression/contracts/quantifiers-exists-both-02/main.c

Lines changed: 0 additions & 18 deletions
This file was deleted.

regression/contracts/quantifiers-exists-both-02/test.desc

Lines changed: 0 additions & 19 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
// clang-format off
22
int f1(int *arr)
3-
__CPROVER_assigns(*arr)
3+
__CPROVER_requires(__CPROVER_exists {
4+
int i;
5+
(0 <= i && i < 8) && arr[i] == 0
6+
})
47
__CPROVER_ensures(__CPROVER_exists {
58
int i;
6-
(0 <= i && i < 10) ==> arr[i] == i
9+
(0 <= i && i < 8) && arr[i] == 0
710
})
811
// clang-format on
912
{
10-
for(int i = 0; i < 10; i++)
11-
{
12-
arr[i] = i;
13-
}
14-
1513
return 0;
1614
}
1715

1816
int main()
1917
{
20-
int arr[10];
18+
int arr[8];
2119
f1(arr);
2220
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CORE
2+
main.c
3+
--enforce-all-contracts
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\[1\] assertion: SUCCESS$
7+
^VERIFICATION SUCCESSFUL$
8+
--
9+
^warning: ignoring
10+
--
11+
The purpose of this test is to ensure that we can safely use __CPROVER_exists within both
12+
positive and negative contexts (ENSURES and REQUIRES clauses).
13+
14+
With the SAT backend existential quantifiers in a positive context,
15+
e.g., the ENSURES clause being enforced in this case,
16+
are supported only if the quantifier is bound to a constant range.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <stdlib.h>
2+
3+
#define MAX_LEN 8
4+
5+
// clang-format off
6+
int f1(int *arr, int len)
7+
__CPROVER_requires(
8+
len > 0 ==> __CPROVER_exists {
9+
int i;
10+
// constant bounds for explicit unrolling with SAT backend
11+
(0 <= i && i < MAX_LEN) && (
12+
// actual symbolic bound for `i`
13+
i < len && arr[i] == 0
14+
)
15+
}
16+
)
17+
__CPROVER_ensures(
18+
len > 0 ==> __CPROVER_exists {
19+
int i;
20+
// constant bounds for explicit unrolling with SAT backend
21+
(0 <= i && i < MAX_LEN) && (
22+
// actual symbolic bound for `i`
23+
i < len && arr[i] == 0
24+
)
25+
}
26+
)
27+
// clang-format on
28+
{
29+
return 0;
30+
}
31+
32+
int main()
33+
{
34+
int len;
35+
__CPROVER_assume(0 <= len && len <= MAX_LEN);
36+
37+
int *arr = malloc(len);
38+
if(len > 0)
39+
arr[0] = 0;
40+
41+
f1(arr, len);
42+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CORE
2+
main.c
3+
--replace-all-calls-with-contracts
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\[1\] assertion: SUCCESS$
7+
^VERIFICATION SUCCESSFUL$
8+
--
9+
^warning: ignoring
10+
--
11+
The purpose of this test is to ensure that we can safely use __CPROVER_exists within both
12+
positive and negative contexts (ENSURES and REQUIRES clauses).
13+
14+
With the SAT backend existential quantifiers in a positive context,
15+
e.g., the REQUIRES clause being replaced in this case,
16+
are supported only if the quantifier is bound to a constant range.

regression/contracts/quantifiers-exists-ensures-01/test.desc

Lines changed: 0 additions & 12 deletions
This file was deleted.

regression/contracts/quantifiers-exists-ensures-02/main.c

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)