Skip to content

Simplification towards singleton intervals requires single variable #7954

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
Oct 12, 2023
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/simplify_singleton_interval_7953/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <assert.h>
extern void __VERIFIER_assume(int cond);
extern int __VERIFIER_nondet_int(void);
int main()
{
int z = __VERIFIER_nondet_int();
int k = __VERIFIER_nondet_int();
__VERIFIER_assume(1 < z);
__VERIFIER_assume(1 <= z && k <= 1);
assert(0);
}
10 changes: 10 additions & 0 deletions regression/cbmc/simplify_singleton_interval_7953/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE new-smt-backend
main.c

^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
--
Simplification must not spuriously turn the second assumption into an equality.
4 changes: 4 additions & 0 deletions src/util/simplify_expr_boolean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ simplify_exprt::resultt<> simplify_exprt::simplify_boolean(const exprt &expr)
{
mp_integer lower;
mp_integer higher;
exprt non_const_value;
};
boundst bounds;

Expand All @@ -177,6 +178,7 @@ simplify_exprt::resultt<> simplify_exprt::simplify_boolean(const exprt &expr)
auto int_opt =
numeric_cast<mp_integer>(to_constant_expr(ge_expr->rhs())))
{
bounds.non_const_value = ge_expr->lhs();
bounds.lower = *int_opt;
return true;
}
Expand All @@ -199,6 +201,8 @@ simplify_exprt::resultt<> simplify_exprt::simplify_boolean(const exprt &expr)
// (e.g. i >= j)
if(!ge_expr->rhs().is_constant())
return false;
if(ge_expr->lhs() != bounds.non_const_value)
return false;
if(
auto int_opt =
numeric_cast<mp_integer>(to_constant_expr(ge_expr->rhs())))
Expand Down