Skip to content
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
11 changes: 11 additions & 0 deletions regression/cbmc/Quantifiers-simplify/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
int main()
{
__CPROVER_assert(
!__CPROVER_forall {
int i;
i >= 0
},
"simplify");

return 0;
}
8 changes: 8 additions & 0 deletions regression/cbmc/Quantifiers-simplify/simplify_not_forall.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--program-only
ASSERT\(exists \{ signed int i!0#0; !\(i!0#0 >= 0\) \}\)$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
8 changes: 8 additions & 0 deletions regression/cbmc/Quantifiers-simplify/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
KNOWNBUG
main.c

^VERIFICATION SUCCESSFUL$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
18 changes: 18 additions & 0 deletions src/util/mathematical_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,24 @@ class forall_exprt : public quantifier_exprt
}
};

inline const forall_exprt &to_forall_expr(const exprt &expr)
{
PRECONDITION(expr.id() == ID_forall);
DATA_INVARIANT(
expr.operands().size() == 2,
"forall expressions have exactly two operands");
return static_cast<const forall_exprt &>(expr);
}

inline forall_exprt &to_forall_expr(exprt &expr)
{
PRECONDITION(expr.id() == ID_forall);
DATA_INVARIANT(
expr.operands().size() == 2,
"forall expressions have exactly two operands");
return static_cast<forall_exprt &>(expr);
}

/// \brief An exists expression
class exists_exprt : public quantifier_exprt
{
Expand Down
9 changes: 9 additions & 0 deletions src/util/simplify_expr_boolean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@ bool simplify_exprt::simplify_not(exprt &expr)
expr = rewritten_op;
return false;
}
else if(op.id() == ID_forall) // !(forall: a) <-> exists: not a
{
auto const &op_as_forall = to_forall_expr(op);
exists_exprt rewritten_op(
op_as_forall.symbol(), not_exprt(op_as_forall.where()));
simplify_node(rewritten_op.where());
expr = rewritten_op;
return false;
}

return true;
}