This PR changes --solve-bv-as-int from a numerical option (specifying the granularity) to an enum (specifying the approach). Currently we support only two modes: OFF and SUM. Future PRs will add more modes.
The numerical value of the granularity is now captured by the new option --bvand-integer-granularity.
Tests are updated accordingly.
[[option]]
name = "solveBVAsInt"
category = "undocumented"
- long = "solve-bv-as-int=N"
+ long = "solve-bv-as-int=MODE"
+ type = "SolveBVAsIntMode"
+ default = "OFF"
+ help = "mode for translating BVAnd to integer"
+ help_mode = "solve-bv-as-int modes."
+[[option.mode.OFF]]
+ name = "off"
+ help = "Do not translate bit-vectors to integers"
+[[option.mode.SUM]]
+ name = "sum"
+ help = "Generate a sum expression for each bvand instance, based on the value in --solbv-bv-as-int-granularity"
+
+[[option]]
+ name = "BVAndIntegerGranularity"
+ category = "undocumented"
+ long = "bvand-integer-granularity=N"
type = "uint32_t"
- default = "0"
+ default = "1"
read_only = true
- help = "attempt to solve BV formulas by translation to integer arithmetic (experimental)"
+ help = "granularity to use in --solve-bv-as-int mode and for iand operator (experimental)"
[[option]]
name = "iandMode"
n = makeBinary(n);
vector<Node> toVisit;
toVisit.push_back(n);
- uint64_t granularity = options::solveBVAsInt();
+ uint64_t granularity = options::BVAndIntegerGranularity();
while (!toVisit.empty())
{
{
d_passes["bv-to-bool"]->apply(&assertions);
}
- if (options::solveBVAsInt() > 0)
+ if (options::solveBVAsInt() != options::SolveBVAsIntMode::OFF)
{
d_passes["bv-to-int"]->apply(&assertions);
}
logic.lock();
}
- if (options::solveBVAsInt() > 0)
+ if (options::solveBVAsInt() != options::SolveBVAsIntMode::OFF)
{
// not compatible with incremental
if (options::incrementalSolving())
throw OptionException(
"solving bitvectors as integers is incompatible with --bool-to-bv.");
}
- if (options::solveBVAsInt() > 8)
+ if (options::BVAndIntegerGranularity() > 8)
{
/**
* The granularity sets the size of the ITE in each element
}
- if (options::solveBVAsInt() > 0)
+ if (options::solveBVAsInt() != options::SolveBVAsIntMode::OFF)
{
/**
* Operations on 1 bits are better handled as Boolean operations
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models --no-check-unsat-cores --no-check-proofs
-; COMMAND-LINE: --solve-bv-as-int=2 --no-check-models --no-check-unsat-cores --no-check-proofs
-; COMMAND-LINE: --solve-bv-as-int=3 --no-check-models --no-check-unsat-cores --no-check-proofs
-; COMMAND-LINE: --solve-bv-as-int=4 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=2 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=3 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=4 --no-check-models --no-check-unsat-cores --no-check-proofs
; EXPECT: unsat
(set-logic QF_BV)
(declare-fun x () (_ BitVec 4))
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models --no-check-unsat-cores
-; COMMAND-LINE: --solve-bv-as-int=5 --no-check-models --no-check-unsat-cores
-; COMMAND-LINE: --solve-bv-as-int=8 --no-check-models --no-check-unsat-cores
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models --no-check-unsat-cores
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=5 --no-check-models --no-check-unsat-cores
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=8 --no-check-models --no-check-unsat-cores
; EXPECT: sat
(set-logic QF_BV)
(declare-fun a () (_ BitVec 8))
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models --no-check-unsat-cores --no-check-proofs
-; COMMAND-LINE: --solve-bv-as-int=5 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=5 --no-check-models --no-check-unsat-cores --no-check-proofs
; EXPECT: unsat
(set-logic QF_BV)
(declare-fun s () (_ BitVec 4))
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models --no-check-unsat-cores
-; COMMAND-LINE: --solve-bv-as-int=4 --no-check-models --no-check-unsat-cores
-; COMMAND-LINE: --solve-bv-as-int=8 --no-check-models --no-check-unsat-cores
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models --no-check-unsat-cores
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=4 --no-check-models --no-check-unsat-cores
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=8 --no-check-models --no-check-unsat-cores
; EXPECT: sat
(set-logic QF_BV)
(declare-fun a () (_ BitVec 8))
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models --no-check-unsat-cores --no-check-proofs
; EXPECT: unsat
(set-logic QF_BV)
(declare-fun T4_180 () (_ BitVec 32))
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models
; EXPECT: sat
(set-logic QF_BV)
(declare-fun _substvar_183_ () (_ BitVec 32))
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models --no-check-unsat-cores --no-check-proofs
; EXPECT: unsat
(set-logic QF_BV)
(declare-fun T1_31078 () (_ BitVec 8))
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models --no-check-unsat-cores
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models --no-check-unsat-cores
; EXPECT: sat
(set-logic QF_UFBV)
(declare-fun a () (_ BitVec 4))
-;COMMAND-LINE: --solve-bv-as-int=1 --no-produce-models --no-produce-unsat-cores --no-check-proofs
+;COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-produce-models --no-produce-unsat-cores --no-check-proofs
;EXPECT: unsat
(set-logic QF_UFBV)
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models --no-check-unsat-cores
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models --no-check-unsat-cores
; EXPECT: sat
(set-logic QF_UFBV)
(declare-sort S 0)
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models --no-check-unsat-cores --no-check-proofs
-; COMMAND-LINE: --solve-bv-as-int=8 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=8 --no-check-models --no-check-unsat-cores --no-check-proofs
; EXPECT: unsat
(set-logic QF_BV)
(declare-fun a () (_ BitVec 8))
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models --no-check-unsat-cores --no-check-proofs
; EXPECT: unsat
(set-logic ALL)
(declare-fun A () (Array Int Int))
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models --no-check-unsat-cores --no-check-proofs
; EXPECT: sat
(set-logic ALL)
(declare-fun A () (Array Int Int))
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models --no-check-unsat-cores
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models --no-check-unsat-cores
; EXPECT: sat
(set-logic QF_BV)
(declare-fun s () (_ BitVec 64))
-; COMMAND-LINE: --solve-bv-as-int=1 --no-check-models --no-check-unsat-cores --no-check-proofs
-; COMMAND-LINE: --solve-bv-as-int=2 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-models --no-check-unsat-cores --no-check-proofs
+; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=2 --no-check-models --no-check-unsat-cores --no-check-proofs
; EXPECT: unsat
(set-logic QF_BV)
-(declare-fun a () (_ BitVec 8))
-(declare-fun b () (_ BitVec 8))
+(declare-fun a () (_ BitVec 4))
+(declare-fun b () (_ BitVec 4))
(assert (bvult (bvor a b) (bvand a b)))
(check-sat)