Skip to content

Commit 894745d

Browse files
committed
Add equal expressions in quantified symbol detection for loop contracts
1 parent c320360 commit 894745d

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

regression/contracts-dfcc/quantifiers-loop-01/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
#include <assert.h>
2+
#include <stdbool.h>
23

34
#define N 16
45

56
void main()
67
{
78
int a[N];
89
a[10] = 0;
10+
bool flag = true;
911

1012
for(int i = 0; i < N; ++i)
1113
// clang-format off
1214
__CPROVER_assigns(i, __CPROVER_object_whole(a))
1315
__CPROVER_loop_invariant(
1416
(0 <= i) && (i <= N) &&
15-
__CPROVER_forall {
17+
flag == __CPROVER_forall {
1618
int k;
1719
// constant bounds for explicit unrolling with SAT backend
1820
(0 <= k && k <= N) ==> (

regression/contracts/quantifiers-loop-01/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
#include <assert.h>
2+
#include <stdbool.h>
23

34
#define N 16
45

56
void main()
67
{
78
int a[N];
89
a[10] = 0;
10+
bool flag = true;
911

1012
for(int i = 0; i < N; ++i)
1113
// clang-format off
1214
__CPROVER_assigns(i, __CPROVER_object_whole(a))
1315
__CPROVER_loop_invariant(
1416
(0 <= i) && (i <= N) &&
15-
__CPROVER_forall {
17+
flag == __CPROVER_forall {
1618
int k;
1719
// constant bounds for explicit unrolling with SAT backend
1820
(0 <= k && k <= N) ==> (

src/goto-instrument/contracts/utils.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,9 @@ void add_quantified_variable(
376376
auto &unary_expression = to_unary_expr(expression);
377377
add_quantified_variable(symbol_table, unary_expression.op(), mode);
378378
}
379-
if(expression.id() == ID_notequal || expression.id() == ID_implies)
379+
if(
380+
expression.id() == ID_notequal || expression.id() == ID_equal ||
381+
expression.id() == ID_implies)
380382
{
381383
// For binary connectives, recursively check for
382384
// nested quantified formulae in the left and right terms

src/goto-symex/renaming_level.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Author: Romain Brenguier, [email protected]
1717
#include <util/symbol.h>
1818

1919
#include "goto_symex_state.h"
20+
#include <iostream>
2021

2122
renamedt<ssa_exprt, L0>
2223
symex_level0(ssa_exprt ssa_expr, const namespacet &ns, std::size_t thread_nr)

0 commit comments

Comments
 (0)