File tree Expand file tree Collapse file tree 6 files changed +106
-0
lines changed Expand file tree Collapse file tree 6 files changed +106
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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.
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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.
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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.
You can’t perform that action at this time.
0 commit comments