Skip to content

Commit 49ae248

Browse files
committed
Add regression tests
1 parent c2619cf commit 49ae248

File tree

6 files changed

+106
-0
lines changed

6 files changed

+106
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <assert.h>
2+
void main()
3+
{
4+
int N = 64, a[64];
5+
for(int i = 0; i < N; ++i)
6+
// clang-format off
7+
__CPROVER_loop_invariant((0 <= i) && (i <= N) && __CPROVER_forall {
8+
int k;
9+
(0 <= k && k < N) ==> 1 == 1
10+
})
11+
// clang-format on
12+
{
13+
a[i] = 1;
14+
}
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CORE
2+
main.c
3+
--enforce-all-contracts
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
Verification:
10+
This test case checks the handling of a forall expression within
11+
a loop invariant.
12+
This test case does not check correctness of the for loop.
13+
Instead, it is a trivial quantified expression to ensure that
14+
quantifiers can be handled in loop invariants.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <assert.h>
2+
void main()
3+
{
4+
int N = 64, a[64];
5+
for(int i = 0; i < N; ++i)
6+
// clang-format off
7+
__CPROVER_loop_invariant((0 <= i) && (i <= N) && __CPROVER_forall {
8+
int k;
9+
(0 <= k && k < i) ==> a[k] == 1
10+
})
11+
// clang-format on
12+
{
13+
a[i] = 1;
14+
}
15+
// clang-format off
16+
assert(__CPROVER_forall {
17+
int k;
18+
(0 <= k && k < N) ==> a[k] == 1
19+
});
20+
// clang-format on
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
KNOWNBUG
2+
main.c
3+
--enforce-all-contracts
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
Verification:
10+
This test case checks the handling of a forall expression within
11+
a loop invariant.
12+
In this test, the quantified variable has a symbolic upper limit.
13+
14+
Known Bug:
15+
Currently, cbmc (using the SAT back-end) does not support quantified
16+
expressions where the quantified variable has a symbolic range.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <assert.h>
2+
void main()
3+
{
4+
int N, a[64];
5+
__CPROVER_assume(0 <= N && N < 64);
6+
for(int i = 0; i < N; ++i)
7+
// clang-format off
8+
__CPROVER_loop_invariant((0 <= i) && (i <= N) && __CPROVER_forall {
9+
int k;
10+
(0 <= k && k < i) ==> a[k] == 1
11+
})
12+
// clang-format on
13+
{
14+
a[i] = 1;
15+
}
16+
// clang-format off
17+
assert(__CPROVER_forall {
18+
int k;
19+
(0 <= k && k < N) ==> a[k] == 1
20+
});
21+
// clang-format on
22+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
KNOWNBUG
2+
main.c
3+
--enforce-all-contracts
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
Verification:
10+
This test case checks the handling of a forall expression within
11+
a loop invariant.
12+
In this test, the quantified variable has a symbolic upper limit.
13+
Additionally, the number of loop iterations is also defined by a
14+
symbolic value.
15+
16+
Known Bug:
17+
Currently, cbmc (using the SAT back-end) does not support quantified
18+
expressions where the quantified variable has a symbolic range.

0 commit comments

Comments
 (0)