Skip to content

Fully rewrite nested forall during symbolic execution #3924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions regression/cbmc/Quantifiers-simplify/rewrite_forall.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
int main()
{
// clang-format off
__CPROVER_assert(
__CPROVER_forall {
int i;
// clang-format would rewrite the "==>" as "== >"
i >= 0 ==> __CPROVER_forall
{
int j;
j<0 ==> j < i
}
},
"rewrite");
// clang-format on

return 0;
}
8 changes: 8 additions & 0 deletions regression/cbmc/Quantifiers-simplify/rewrite_forall.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
rewrite_forall.c

^VERIFICATION SUCCESSFUL$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
14 changes: 13 additions & 1 deletion src/goto-symex/symex_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Author: Daniel Kroening, [email protected]
#include <memory>

#include <util/exception_utils.h>
#include <util/expr_util.h>
#include <util/make_unique.h>
#include <util/mathematical_expr.h>
#include <util/replace_symbol.h>
Expand Down Expand Up @@ -86,7 +87,12 @@ void goto_symext::vcc(
exprt expr=vcc_expr;

// we are willing to re-write some quantified expressions
rewrite_quantifiers(expr, state);
if(has_subexpr(expr, ID_exists) || has_subexpr(expr, ID_forall))
{
// have negation pushed inwards as far as possible
do_simplify(expr);
rewrite_quantifiers(expr, state);
}

// now rename, enables propagation
state.rename(expr, ns);
Expand Down Expand Up @@ -143,8 +149,14 @@ void goto_symext::rewrite_quantifiers(exprt &expr, statet &state)
to_symbol_expr(to_ssa_expr(quant_expr.symbol()).get_original_expr());
symex_decl(state, tmp0);
exprt tmp = quant_expr.where();
rewrite_quantifiers(tmp, state);
quant_expr.swap(tmp);
}
else if(expr.id() == ID_or || expr.id() == ID_and)
{
for(auto &op : expr.operands())
rewrite_quantifiers(op, state);
}
}

void goto_symext::initialize_entry_point(
Expand Down