Skip to content

Commit 1550bdb

Browse files
committed
Fully rewrite nested forall during symbolic execution
This permits (correctly) solving another simple regression test.
1 parent 133d830 commit 1550bdb

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/replace_symbol.h>
2021
#include <util/std_expr.h>
@@ -81,7 +82,12 @@ void goto_symext::vcc(
8182
exprt expr=vcc_expr;
8283

8384
// we are willing to re-write some quantified expressions
84-
rewrite_quantifiers(expr, state);
85+
if(has_subexpr(expr, ID_exists) || has_subexpr(expr, ID_forall))
86+
{
87+
// have negation pushed inwards as far as possible
88+
do_simplify(expr);
89+
rewrite_quantifiers(expr, state);
90+
}
8591

8692
// now rename, enables propagation
8793
state.rename(expr, ns);
@@ -138,8 +144,14 @@ void goto_symext::rewrite_quantifiers(exprt &expr, statet &state)
138144
to_symbol_expr(to_ssa_expr(quant_expr.symbol()).get_original_expr());
139145
symex_decl(state, tmp0);
140146
exprt tmp = quant_expr.where();
147+
rewrite_quantifiers(tmp, state);
141148
quant_expr.swap(tmp);
142149
}
150+
else if(expr.id() == ID_or || expr.id() == ID_and)
151+
{
152+
for(auto &op : expr.operands())
153+
rewrite_quantifiers(op, state);
154+
}
143155
}
144156

145157
void goto_symext::initialize_entry_point(

0 commit comments

Comments
 (0)