Skip to content

Commit d4e627b

Browse files
authored
Merge pull request #3924 from tautschnig/rewrite-forall
Fully rewrite nested forall during symbolic execution
2 parents f8fb27d + 9351d80 commit d4e627b

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
int main()
2+
{
3+
// clang-format off
4+
__CPROVER_assert(
5+
__CPROVER_forall {
6+
int i;
7+
// clang-format would rewrite the "==>" as "== >"
8+
i >= 0 ==> __CPROVER_forall
9+
{
10+
int j;
11+
j<0 ==> j < i
12+
}
13+
},
14+
"rewrite");
15+
// clang-format on
16+
17+
return 0;
18+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
rewrite_forall.c
3+
4+
^VERIFICATION SUCCESSFUL$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring

src/goto-symex/symex_main.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Author: Daniel Kroening, [email protected]
1515
#include <memory>
1616

1717
#include <util/exception_utils.h>
18+
#include <util/expr_util.h>
1819
#include <util/make_unique.h>
1920
#include <util/mathematical_expr.h>
2021
#include <util/replace_symbol.h>
@@ -86,7 +87,12 @@ void goto_symext::vcc(
8687
exprt expr=vcc_expr;
8788

8889
// we are willing to re-write some quantified expressions
89-
rewrite_quantifiers(expr, state);
90+
if(has_subexpr(expr, ID_exists) || has_subexpr(expr, ID_forall))
91+
{
92+
// have negation pushed inwards as far as possible
93+
do_simplify(expr);
94+
rewrite_quantifiers(expr, state);
95+
}
9096

9197
// now rename, enables propagation
9298
state.rename(expr, ns);
@@ -143,8 +149,14 @@ void goto_symext::rewrite_quantifiers(exprt &expr, statet &state)
143149
to_symbol_expr(to_ssa_expr(quant_expr.symbol()).get_original_expr());
144150
symex_decl(state, tmp0);
145151
exprt tmp = quant_expr.where();
152+
rewrite_quantifiers(tmp, state);
146153
quant_expr.swap(tmp);
147154
}
155+
else if(expr.id() == ID_or || expr.id() == ID_and)
156+
{
157+
for(auto &op : expr.operands())
158+
rewrite_quantifiers(op, state);
159+
}
148160
}
149161

150162
void goto_symext::initialize_entry_point(

0 commit comments

Comments
 (0)