Skip to content

Commit f3b7374

Browse files
authored
Merge pull request #1329 from diffblue/smv_bitimplies
SMV: lowering for `smv_bitimplies`
2 parents 68b2bb0 + 07bf21d commit f3b7374

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

regression/smv/word/bitwise1.desc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ bitwise1.smv
77
^\[.*\] \(0ud8_123 \| 0ud8_7\) = 0ud8_127: PROVED .*$
88
^\[.*\] \(0ud8_123 xor 0ud8_7\) = 0ud8_124: PROVED .*$
99
^\[.*\] \(0ud8_123 xnor 0ud8_7\) = 0ud8_131: PROVED .*$
10+
^\[.*\] \(0ud8_123 -> 0ud8_7\) = 0ud8_135: PROVED .*$
1011
^\[.*\] \(0ud8_123 <-> 0ud8_7\) = 0ud8_131: PROVED .*$
1112
^EXIT=0$
1213
^SIGNAL=0$

regression/smv/word/bitwise1.smv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ SPEC (uwconst(123, 8) xor uwconst(7, 8)) = uwconst(124, 8)
1717
SPEC (uwconst(123, 8) xnor uwconst(7, 8)) = uwconst(131, 8)
1818

1919
-- implication
20-
--SPEC (uwconst(123, 8) -> uwconst(7, 8)) = uwconst(135, 8)
20+
SPEC (uwconst(123, 8) -> uwconst(7, 8)) = uwconst(135, 8)
2121

2222
-- iff
2323
SPEC (uwconst(123, 8) <-> uwconst(7, 8)) = uwconst(131, 8)

src/smvlang/smv_expr.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,30 @@ inline smv_min_exprt &to_smv_min_expr(exprt &expr)
209209
return static_cast<smv_min_exprt &>(expr);
210210
}
211211

212+
// ->
213+
class smv_bitimplies_exprt : public binary_exprt
214+
{
215+
public:
216+
smv_bitimplies_exprt(exprt __lhs, exprt __rhs)
217+
: binary_exprt{std::move(__lhs), ID_smv_bitimplies, std::move(__rhs)}
218+
{
219+
}
220+
};
221+
222+
inline const smv_bitimplies_exprt &to_smv_bitimplies_expr(const exprt &expr)
223+
{
224+
PRECONDITION(expr.id() == ID_smv_bitimplies);
225+
smv_bitimplies_exprt::check(expr);
226+
return static_cast<const smv_bitimplies_exprt &>(expr);
227+
}
228+
229+
inline smv_bitimplies_exprt &to_smv_bitimplies_expr(exprt &expr)
230+
{
231+
PRECONDITION(expr.id() == ID_smv_bitimplies);
232+
smv_bitimplies_exprt::check(expr);
233+
return static_cast<smv_bitimplies_exprt &>(expr);
234+
}
235+
212236
class smv_unsigned_cast_exprt : public unary_exprt
213237
{
214238
public:

src/smvlang/smv_typecheck.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Author: Daniel Kroening, kroening@kroening.com
99
#include "smv_typecheck.h"
1010

1111
#include <util/arith_tools.h>
12+
#include <util/bitvector_expr.h>
1213
#include <util/bitvector_types.h>
1314
#include <util/expr_util.h>
1415
#include <util/mathematical_expr.h>
@@ -1480,6 +1481,12 @@ void smv_typecheckt::lower_node(exprt &expr) const
14801481
auto one = from_integer(1, expr.type());
14811482
expr = if_exprt{op, std::move(one), std::move(zero)};
14821483
}
1484+
else if(expr.id() == ID_smv_bitimplies)
1485+
{
1486+
// we'll lower a->b to !a|b
1487+
auto &implies = to_smv_bitimplies_expr(expr);
1488+
expr = bitor_exprt{bitnot_exprt{implies.op0()}, implies.op1()};
1489+
}
14831490

14841491
// lower the type
14851492
lower(expr.type());

0 commit comments

Comments
 (0)