Skip to content

Bugfix in bdd::as_expr #4279

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 2 commits into from
Feb 25, 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
7 changes: 5 additions & 2 deletions src/solvers/prop/bdd_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ exprt bdd_exprt::as_expr(const bdd_nodet &r, bool complement) const
if(r.else_branch().is_complement() != complement)
{
return and_exprt(
n_expr, as_expr(r.then_branch(), complement != r.is_complement()));
n_expr,
as_expr(
r.then_branch(), complement != r.then_branch().is_complement()));
}
return or_exprt(
not_exprt(n_expr),
as_expr(r.then_branch(), complement != r.is_complement()));
as_expr(
r.then_branch(), complement != r.then_branch().is_complement()));
}
}
else if(r.then_branch().is_constant())
Expand Down
21 changes: 21 additions & 0 deletions unit/solvers/prop/bdd_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,25 @@ SCENARIO("bdd_expr", "[core][solver][prop][bdd_expr]")
REQUIRE(bdd.as_expr() == bdd2.as_expr());
}
}

GIVEN("A bdd for (a&!b)")
{
const symbol_exprt a("a", bool_typet());
const symbol_exprt b("b", bool_typet());

bdd_exprt bdd{ns};
bdd.from_expr(and_exprt(a, not_exprt(b)));

WHEN("It is converted to an exprt")
{
const exprt result = bdd.as_expr();
THEN("It is equal to the expression (a & !b) or (!b & a)")
{
REQUIRE(result.id() == ID_and);
REQUIRE(result.operands().size() == 2);
REQUIRE((result.op0() == a || result.op1() == a));
REQUIRE((result.op0() == not_exprt(b) || result.op1() == not_exprt(b)));
}
}
}
}