Skip to content

Commit e3157d9

Browse files
committed
Fix onehot0 flattening
This fixes the flattening of onehot0 expressions.
1 parent fb28475 commit e3157d9

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/solvers/flattening/boolbv_onehot.cpp

+5-10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ literalt boolbvt::convert_onehot(const unary_exprt &expr)
1515

1616
bvt op=convert_bv(expr.op());
1717

18+
// onehot0 is the same as onehot with the input bits flipped
19+
if(expr.id() == ID_onehot0)
20+
op = bv_utils.inverted(op);
21+
1822
literalt one_seen=const_literal(false);
1923
literalt more_than_one_seen=const_literal(false);
2024

@@ -25,14 +29,5 @@ literalt boolbvt::convert_onehot(const unary_exprt &expr)
2529
one_seen=prop.lor(*it, one_seen);
2630
}
2731

28-
if(expr.id()==ID_onehot)
29-
return prop.land(one_seen, !more_than_one_seen);
30-
else
31-
{
32-
INVARIANT(
33-
expr.id() == ID_onehot0,
34-
"should be a onehot0 expression as other onehot expression kind has been "
35-
"handled in other branch");
36-
return !more_than_one_seen;
37-
}
32+
return prop.land(one_seen, !more_than_one_seen);
3833
}

unit/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ SRC += analyses/ai/ai.cpp \
9696
pointer-analysis/value_set.cpp \
9797
solvers/bdd/miniBDD/miniBDD.cpp \
9898
solvers/flattening/boolbv.cpp \
99+
solvers/flattening/boolbv_onehot.cpp \
99100
solvers/flattening/boolbv_update_bit.cpp \
100101
solvers/floatbv/float_utils.cpp \
101102
solvers/prop/bdd_expr.cpp \

0 commit comments

Comments
 (0)