This PR ensures we do not eagerly rewrite bv2nat and int2bv when using solve-bv-as-int. Instead they are rewritten during expandDefinitions (at the end of preprocessing).
It also updates regressions that relied on lazy extended function reductions in the lazy solver to use solve-bv-as-int, and adds a missing case (INT_TO_BITVECTOR) in the solve-int-as-bv preprocessing pass.
A followup PR will remove support for lazy extended function reductions for bv2nat / int2bv altogether.
returnNode = translated_children[0];
break;
}
+ case kind::INT_TO_BITVECTOR:
+ {
+ // ((_ int2bv n) t) ---> (mod t 2^n)
+ size_t sz = original.getOperator().getConst<IntToBitVector>().d_size;
+ returnNode = d_nm->mkNode(
+ kind::INTS_MODULUS_TOTAL, translated_children[0], pow2(sz));
+ }
+ break;
case kind::BITVECTOR_AND:
{
// We support three configurations:
}
}
- /* Only BVSolver::LAZY natively supports int2bv and nat2bv, for other solvers
- * we need to eagerly eliminate the operators. */
- if (options::bvSolver() == options::BVSolver::SIMPLE
- || options::bvSolver() == options::BVSolver::BITBLAST)
- {
- opts.bv.bvLazyReduceExtf = false;
- opts.bv.bvLazyRewriteExtf = false;
- }
-
/* Disable bit-level propagation by default for the BITBLAST solver. */
if (options::bvSolver() == options::BVSolver::BITBLAST)
{
if (options::solveBVAsInt() != options::SolveBVAsIntMode::OFF)
{
+ // do not rewrite bv2nat eagerly
+ opts.bv.bvLazyRewriteExtf = true;
if (options::boolToBitvector() != options::BoolToBVMode::OFF)
{
throw OptionException(
logic.lock();
}
}
+ else if (options::bvSolver() == options::BVSolver::SIMPLE
+ || options::bvSolver() == options::BVSolver::BITBLAST)
+ {
+ // Only BVSolver::LAZY natively supports int2bv and nat2bv, for other
+ // solvers we need to eagerly eliminate the operators. Note this is only
+ // applied if we are not eliminating BV (e.g. with solveBVAsInt).
+ opts.bv.bvLazyReduceExtf = false;
+ }
// set options about ackermannization
if (options::ackermann() && options::produceModels()
case kind::BITVECTOR_SDIV:
case kind::BITVECTOR_SREM:
case kind::BITVECTOR_SMOD: ret = eliminateBVSDiv(node); break;
-
+ case kind::BITVECTOR_TO_NAT:
+ if (!options::bvLazyReduceExtf())
+ {
+ ret = utils::eliminateBv2Nat(node);
+ }
+ break;
+ case kind::INT_TO_BITVECTOR:
+ if (!options::bvLazyReduceExtf())
+ {
+ ret = utils::eliminateInt2Bv(node);
+ }
+ break;
default: break;
}
if (!ret.isNull() && node != ret)
regress1/bags/union_disjoint.smt2
regress1/bags/union_max1.smt2
regress1/bags/union_max2.smt2
+ regress1/bv2int-isabelle.smt2
regress1/bv/bench_38.delta.smt2
regress1/bv/bug787.smt2
regress1/bv/bug_extract_mult_leading_bit.smt2
-; COMMAND-LINE: --bv-solver=lazy
+; COMMAND-LINE: --solve-bv-as-int=sum
; EXPECT: unsat
(set-logic ALL)
(set-info :status unsat)
-; COMMAND-LINE: --bv-solver=lazy
+; COMMAND-LINE: --solve-bv-as-int=sum
; EXPECT: unsat
(set-logic ALL)
(set-info :status unsat)
+; COMMAND-LINE: --solve-bv-as-int=sum
; EXPECT: unsat
(set-logic ALL)
(set-info :status unsat)
-; COMMAND-LINE: --bv-solver=lazy
+; COMMAND-LINE: --solve-bv-as-int=sum
; EXPECT: unsat
(set-logic QF_BVLIA)
(set-info :status unsat)
--- /dev/null
+; COMMAND-LINE: --solve-bv-as-int=sum --no-check-unsat-cores
+; EXPECT: unsat
+(set-logic ALL)
+(declare-fun s$ () (_ BitVec 32))
+(declare-fun x$ () (_ BitVec 32))
+(declare-fun i$ () (_ BitVec 32))
+(define-fun bound () Int (bv2nat ((_ int2bv 32) 2048)))
+(define-fun bseg ((x (_ BitVec 32)) (s (_ BitVec 32))) Bool (and (< (bv2nat x) bound) (<= (+ (bv2nat x) (bv2nat s)) bound)))
+
+;assumptions
+(assert (bseg x$ s$))
+(assert (<= (bv2nat i$) (bv2nat s$)))
+
+;conclusion
+(assert (not (= (bv2nat (bvadd x$ i$)) (+ (bv2nat x$) (bv2nat i$)))))
+(check-sat)
; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1
; COMMAND-LINE: --solve-bv-as-int=iand --iand-mode=value
; COMMAND-LINE: --solve-bv-as-int=iand --iand-mode=sum
-; COMMAND-LINE: --solve-bv-as-int=bv
+; COMMAND-LINE: --solve-bv-as-int=bv --no-check-unsat-cores
; EXPECT: unsat
(set-logic ALL)
(declare-fun A () (Array Int Int))