summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndres Notzli <andres.noetzli@gmail.com>2016-12-08 14:21:28 -0800
committerAndres Notzli <andres.noetzli@gmail.com>2016-12-08 20:12:53 -0800
commit762c8a3cf028fa7c12c2ee32d8643bd73ff2f07c (patch)
treea3535a4fdf9bdaf2564f8efe5bff02deeb5c4ced /test
parentbe7662bdcd3881d349bfba4c959a0c2be4159ce9 (diff)
Fix (inactive) `MultSlice` rewrite
The `MultSlice` rewrite was previously accepting multiplications of three and more variables even though it was designed for multiplications of two variables only. Fortunately, the rewrite was not actively used in the bitvector solver. This commit strengthens the condition in `applies()` and adds a unit test that checks that x * y * z and x * y do not get rewritten to the same term.
Diffstat (limited to 'test')
-rw-r--r--test/unit/theory/theory_engine_white.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/unit/theory/theory_engine_white.h b/test/unit/theory/theory_engine_white.h
index 978440576..9775dca1b 100644
--- a/test/unit/theory/theory_engine_white.h
+++ b/test/unit/theory/theory_engine_white.h
@@ -33,6 +33,7 @@
#include "smt/smt_engine.h"
#include "smt/smt_engine_scope.h"
#include "theory/bv/theory_bv_rewrite_rules_normalization.h"
+#include "theory/bv/theory_bv_rewrite_rules_simplification.h"
#include "theory/rewriter.h"
#include "theory/theory.h"
#include "theory/theory_engine.h"
@@ -442,6 +443,21 @@ public:
Node expected =
d_nm->mkNode(BITVECTOR_SUB, d_nm->mkNode(BITVECTOR_MULT, x, z),
d_nm->mkNode(BITVECTOR_MULT, y, z));
- TS_ASSERT(result == expected);
+ TS_ASSERT_EQUALS(result, expected);
+
+ // Try to apply MultSlice to a multiplication of two and three different
+ // variables, expect different results (x * y and x * y * z should not get
+ // rewritten to the same term).
+ expr = d_nm->mkNode(BITVECTOR_MULT, x, y, z);
+ result = expr;
+ Node expr2 = d_nm->mkNode(BITVECTOR_MULT, x, y);
+ Node result2 = expr;
+ if (RewriteRule<MultSlice>::applies(expr)) {
+ result = RewriteRule<MultSlice>::apply(expr);
+ }
+ if (RewriteRule<MultSlice>::applies(expr2)) {
+ result2 = RewriteRule<MultSlice>::apply(expr2);
+ }
+ TS_ASSERT_DIFFERS(result, result2);
}
};
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback