@@ -91,6 +91,7 @@ br_status arith_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * c
91
91
case OP_SINH: SASSERT (num_args == 1 ); st = mk_sinh_core (args[0 ], result); break ;
92
92
case OP_COSH: SASSERT (num_args == 1 ); st = mk_cosh_core (args[0 ], result); break ;
93
93
case OP_TANH: SASSERT (num_args == 1 ); st = mk_tanh_core (args[0 ], result); break ;
94
+ case OP_ARITH_BAND: SASSERT (num_args == 2 ); st = mk_band_core (f->get_parameter (0 ).get_int (), args[0 ], args[1 ], result); break ;
94
95
default : st = BR_FAILED; break ;
95
96
}
96
97
CTRACE (" arith_rewriter" , st != BR_FAILED, tout << st << " : " << mk_pp (f, m);
@@ -1349,6 +1350,34 @@ app* arith_rewriter_core::mk_power(expr* x, rational const& r, sort* s) {
1349
1350
return y;
1350
1351
}
1351
1352
1353
+ br_status arith_rewriter::mk_band_core (unsigned sz, expr* arg1, expr* arg2, expr_ref& result) {
1354
+ numeral x, y, N;
1355
+ bool is_num_x = m_util.is_numeral (arg1, x);
1356
+ bool is_num_y = m_util.is_numeral (arg2, y);
1357
+ N = rational::power_of_two (sz);
1358
+ if (is_num_x)
1359
+ x = mod (x, N);
1360
+ if (is_num_y)
1361
+ y = mod (y, N);
1362
+ if (is_num_x && x.is_zero ()) {
1363
+ result = m_util.mk_int (0 );
1364
+ return BR_DONE;
1365
+ }
1366
+ if (is_num_y && y.is_zero ()) {
1367
+ result = m_util.mk_int (0 );
1368
+ return BR_DONE;
1369
+ }
1370
+ if (is_num_x && is_num_y) {
1371
+ rational r (0 );
1372
+ for (unsigned i = 0 ; i < sz; ++i)
1373
+ if (x.get_bit (i) && y.get_bit (i))
1374
+ r += rational::power_of_two (i);
1375
+ result = m_util.mk_int (r);
1376
+ return BR_DONE;
1377
+ }
1378
+ return BR_FAILED;
1379
+ }
1380
+
1352
1381
br_status arith_rewriter::mk_power_core (expr * arg1, expr * arg2, expr_ref & result) {
1353
1382
numeral x, y;
1354
1383
bool is_num_x = m_util.is_numeral (arg1, x);
0 commit comments