// check for b < log2(n)
unsigned size = utils::getSize(node);
unsigned log2_size = std::ceil(log2((double)size));
- Node a_size = utils::mkConst(BitVector(size, size));
+ Node a_size = utils::mkConst(size, size);
Node b_ult_a_size_node =
Rewriter::rewrite(utils::mkNode(kind::BITVECTOR_ULT, node[1], a_size));
// ensure that the inequality is bit-blasted
// check for b < log2(n)
unsigned size = utils::getSize(node);
unsigned log2_size = std::ceil(log2((double)size));
- Node a_size = utils::mkConst(BitVector(size, size));
+ Node a_size = utils::mkConst(size, size);
Node b_ult_a_size_node =
Rewriter::rewrite(utils::mkNode(kind::BITVECTOR_ULT, node[1], a_size));
// ensure that the inequality is bit-blasted
// check for b < n
unsigned size = utils::getSize(node);
unsigned log2_size = std::ceil(log2((double)size));
- Node a_size = utils::mkConst(BitVector(size, size));
+ Node a_size = utils::mkConst(size, size);
Node b_ult_a_size_node =
Rewriter::rewrite(utils::mkNode(kind::BITVECTOR_ULT, node[1], a_size));
// ensure that the inequality is bit-blasted
BvToBoolPreprocessor::BvToBoolPreprocessor()
: d_liftCache()
, d_boolCache()
- , d_one(utils::mkConst(BitVector(1, 1u)))
- , d_zero(utils::mkConst(BitVector(1, 0u)))
+ , d_one(utils::mkOne(1))
+ , d_zero(utils::mkZero(1))
, d_statistics()
{}
/* Normalize (no negative numbers, hence no subtraction)
* e.g., x = 4 - 2y --> x = 4 + 9y (modulo 11) */
Integer m = iprime - lhs[prow][i];
- Node bv =
- nm->mkConst<BitVector>(BitVector(utils::getSize(vvars[i]), m));
+ Node bv = utils::mkConst(utils::getSize(vvars[i]), m);
Node mult = nm->mkNode(kind::BITVECTOR_MULT, vvars[i], bv);
stack.push_back(mult);
}
if (rhs[prow] != 0)
{
tmp = nm->mkNode(kind::BITVECTOR_PLUS,
- nm->mkConst<BitVector>(BitVector(
- utils::getSize(vvars[pcol]), rhs[prow])),
+ utils::mkConst(
+ utils::getSize(vvars[pcol]), rhs[prow]),
tmp);
}
Assert(!is_bv_const(tmp));
bit_value == prop::SAT_VALUE_TRUE ? Integer(1) : Integer(0);
value = value * 2 + bit_int;
}
- return utils::mkConst(BitVector(bits.size(), value));
+ return utils::mkConst(bits.size(), value);
}
bool EagerBitblaster::collectModelInfo(TheoryModel* m, bool fullModel)
Integer bit_int = bit_value == prop::SAT_VALUE_TRUE ? Integer(1) : Integer(0);
value = value * 2 + bit_int;
}
- return utils::mkConst(BitVector(bits.size(), value));
+ return utils::mkConst(bits.size(), value);
}
bool TLazyBitblaster::collectModelInfo(TheoryModel* m, bool fullModel)
}
TNode num = node[0], den = node[1];
- Node den_eq_0 = nm->mkNode(kind::EQUAL, den, nm->mkConst(BitVector(width, Integer(0))));
+ Node den_eq_0 = nm->mkNode(kind::EQUAL, den, utils::mkZero(width));
Node divTotalNumDen = nm->mkNode(node.getKind() == kind::BITVECTOR_UDIV ? kind::BITVECTOR_UDIV_TOTAL :
kind::BITVECTOR_UREM_TOTAL, num, den);
TNode result = fact[1];
TNode divisor = urem[1];
Node result_ult_div = mkNode(kind::BITVECTOR_ULT, result, divisor);
- Node divisor_eq_0 = mkNode(kind::EQUAL,
- divisor,
- mkConst(BitVector(getSize(divisor), 0u)));
- Node split = utils::mkNode(kind::OR, divisor_eq_0, mkNode(kind::NOT, fact), result_ult_div);
+ Node divisor_eq_0 = mkNode(
+ kind::EQUAL, divisor, mkZero(getSize(divisor)));
+ Node split = utils::mkNode(
+ kind::OR, divisor_eq_0, mkNode(kind::NOT, fact), result_ult_div);
lemma(split);
}
if (fact[1].getKind() == kind::BITVECTOR_UREM_TOTAL) {
TNode result = fact[0];
TNode divisor = urem[1];
Node result_ult_div = mkNode(kind::BITVECTOR_ULT, result, divisor);
- Node divisor_eq_0 = mkNode(kind::EQUAL,
- divisor,
- mkConst(BitVector(getSize(divisor), 0u)));
- Node split = utils::mkNode(kind::OR, divisor_eq_0, mkNode(kind::NOT, fact), result_ult_div);
+ Node divisor_eq_0 = mkNode(
+ kind::EQUAL, divisor, mkZero(getSize(divisor)));
+ Node split = utils::mkNode(
+ kind::OR, divisor_eq_0, mkNode(kind::NOT, fact), result_ult_div);
lemma(split);
}
}
const unsigned size = utils::getSize(n[0]);
NodeManager* const nm = NodeManager::currentNM();
const Node z = nm->mkConst(Rational(0));
- const Node bvone = nm->mkConst(BitVector(1u, 1u));
+ const Node bvone = utils::mkOne(1);
NodeBuilder<> result(kind::PLUS);
Integer i = 1;
for(unsigned bit = 0; bit < size; ++bit, i *= 2) {
//taken from rewrite code
const unsigned size = n.getOperator().getConst<IntToBitVector>().size;
NodeManager* const nm = NodeManager::currentNM();
- const Node bvzero = nm->mkConst(BitVector(1u, 0u));
- const Node bvone = nm->mkConst(BitVector(1u, 1u));
+ const Node bvzero = utils::mkZero(1);
+ const Node bvone = utils::mkOne(1);
std::vector<Node> v;
Integer i = 2;
while(v.size() < size) {
std::vector<Node> children;
if (constant == BitVector(size, (unsigned)0)) {
- return utils::mkConst(BitVector(size, (unsigned)0));
+ return utils::mkZero(size);
}
if (constant != utils::mkBitVectorOnes(size)) {
for (; it != subterms.end(); ++it) {
if (it->second.pos > 0 && it->second.neg > 0) {
// if we have a and ~a
- return utils::mkConst(BitVector(size, (unsigned)0));
+ return utils::mkZero(size);
} else {
// idempotence
if (it->second.neg > 0) {
}
if (children.size() == 0) {
- return utils::mkConst(BitVector(size, (unsigned)0));
+ return utils::mkZero(size);
}
return utils::mkSortedNode(kind::BITVECTOR_OR, children);
}
Debug("bv-rewrite") << "RewriteRule<SltEliminate>(" << node << ")" << std::endl;
unsigned size = utils::getSize(node[0]);
- Node pow_two = utils::mkConst(BitVector(size, Integer(1).multiplyByPow2(size - 1)));
+ Integer val = Integer(1).multiplyByPow2(size - 1);
+ Node pow_two = utils::mkConst(size, val);
Node a = utils::mkNode(kind::BITVECTOR_PLUS, node[0], pow_two);
Node b = utils::mkNode(kind::BITVECTOR_PLUS, node[1], pow_two);
const unsigned size = utils::getSize(node[0]);
NodeManager* const nm = NodeManager::currentNM();
const Node z = nm->mkConst(Rational(0));
- const Node bvone = nm->mkConst(BitVector(1u, 1u));
+ const Node bvone = utils::mkOne(1);
NodeBuilder<> result(kind::PLUS);
Integer i = 1;
const unsigned size = node.getOperator().getConst<IntToBitVector>().size;
NodeManager* const nm = NodeManager::currentNM();
- const Node bvzero = nm->mkConst(BitVector(1u, 0u));
- const Node bvone = nm->mkConst(BitVector(1u, 1u));
+ const Node bvzero = utils::mkZero(1);
+ const Node bvone = utils::mkOne(1);
std::vector<Node> v;
Integer i = 2;
if (amount >= Integer(size)) {
// if we are shifting more than the length of the bitvector return 0
- return utils::mkConst(BitVector(size, Integer(0)));
+ return utils::mkZero(size);
}
// make sure we do not lose information casting
uint32_t uint32_amount = amount.toUnsignedInt();
Node left = utils::mkExtract(a, size - 1 - uint32_amount, 0);
- Node right = utils::mkConst(BitVector(uint32_amount, Integer(0)));
+ Node right = utils::mkZero(uint32_amount);
return utils::mkConcat(left, right);
}
if (amount >= Integer(size)) {
// if we are shifting more than the length of the bitvector return 0
- return utils::mkConst(BitVector(size, Integer(0)));
+ return utils::mkZero(size);
}
// make sure we do not lose information casting
uint32_t uint32_amount = amount.toUnsignedInt();
Node right = utils::mkExtract(a, size - 1, uint32_amount);
- Node left = utils::mkConst(BitVector(uint32_amount, Integer(0)));
+ Node left = utils::mkZero(uint32_amount);
return utils::mkConcat(left, right);
}
Node RewriteRule<XorDuplicate>::apply(TNode node) {
Unreachable();
Debug("bv-rewrite") << "RewriteRule<XorDuplicate>(" << node << ")" << std::endl;
- return utils::mkConst(BitVector(utils::getSize(node), Integer(0)));
+ return utils::mkZero(utils::getSize(node));
}
/**
Node RewriteRule<BitwiseNotAnd>::apply(TNode node) {
Unreachable();
Debug("bv-rewrite") << "RewriteRule<BitwiseNegAnd>(" << node << ")" << std::endl;
- return utils::mkConst(BitVector(utils::getSize(node), Integer(0)));
+ return utils::mkZero(utils::getSize(node));
}
/**
Unreachable();
Debug("bv-rewrite") << "RewriteRule<BitwiseNotOr>(" << node << ")" << std::endl;
uint32_t size = utils::getSize(node);
- Integer ones = Integer(1).multiplyByPow2(size) - 1;
- return utils::mkConst(BitVector(size, ones));
+ return utils::mkOnes(size);
}
/**
template<> inline
bool RewriteRule<ZeroUlt>::applies(TNode node) {
return (node.getKind() == kind::BITVECTOR_ULT &&
- node[0] == utils::mkConst(BitVector(utils::getSize(node[0]), Integer(0))));
+ node[0] == utils::mkZero(utils::getSize(node[0])));
}
template<> inline
template<> inline
bool RewriteRule<UltZero>::applies(TNode node) {
return (node.getKind() == kind::BITVECTOR_ULT &&
- node[1] == utils::mkConst(BitVector(utils::getSize(node[0]), Integer(0))));
+ node[1] == utils::mkZero(utils::getSize(node[0])));
}
template<> inline
template<> inline
bool RewriteRule<UltOne>::applies(TNode node) {
return (node.getKind() == kind::BITVECTOR_ULT &&
- node[1] == utils::mkConst(BitVector(utils::getSize(node[0]), Integer(1))));
+ node[1] == utils::mkOne(utils::getSize(node[0])));
}
template<> inline
Node RewriteRule<UltOne>::apply(TNode node) {
Debug("bv-rewrite") << "RewriteRule<UltOne>(" << node << ")" << std::endl;
- return utils::mkNode(kind::EQUAL, node[0], utils::mkConst(BitVector(utils::getSize(node[0]), 0u)));
+ return utils::mkNode(
+ kind::EQUAL, node[0], utils::mkZero(utils::getSize(node[0])));
}
/**
template<> inline
bool RewriteRule<SltZero>::applies(TNode node) {
return (node.getKind() == kind::BITVECTOR_SLT &&
- node[1] == utils::mkConst(BitVector(utils::getSize(node[0]), Integer(0))));
+ node[1] == utils::mkZero(utils::getSize(node[0])));
}
template<> inline
Debug("bv-rewrite") << "RewriteRule<UltZero>(" << node << ")" << std::endl;
unsigned size = utils::getSize(node[0]);
Node most_significant_bit = utils::mkExtract(node[0], size - 1, size - 1);
- Node one = utils::mkConst(BitVector(1, 1u));
-
- return utils::mkNode(kind::EQUAL, most_significant_bit, one);
+ return utils::mkNode(kind::EQUAL, most_significant_bit, utils::mkOne(1));
}
template<> inline
bool RewriteRule<UleZero>::applies(TNode node) {
return (node.getKind() == kind::BITVECTOR_ULE &&
- node[1] == utils::mkConst(BitVector(utils::getSize(node[0]), Integer(0))));
+ node[1] == utils::mkZero(utils::getSize(node[0])));
}
template<> inline
template<> inline
bool RewriteRule<ZeroUle>::applies(TNode node) {
return (node.getKind() == kind::BITVECTOR_ULE &&
- node[0] == utils::mkConst(BitVector(utils::getSize(node[0]), Integer(0))));
+ node[0] == utils::mkZero(utils::getSize(node[0])));
}
template<> inline
return false;
}
uint32_t size = utils::getSize(node[0]);
- Integer ones = Integer(1).multiplyByPow2(size) -1;
- return (node.getKind() == kind::BITVECTOR_ULE &&
- node[1] == utils::mkConst(BitVector(size, ones)));
+ return (node.getKind() == kind::BITVECTOR_ULE
+ && node[1] == utils::mkOnes(size));
}
template<> inline
return NodeManager::currentNM()->mkConst<BitVector>(val);
}
+inline Node mkConst(unsigned size, Integer& value)
+{
+ return NodeManager::currentNM()->mkConst<BitVector>(BitVector(size, value));
+}
+
inline Node mkConst(const BitVector& value) {
return NodeManager::currentNM()->mkConst<BitVector>(value);
}
#include "expr/kind.h"
#include "expr/type_node.h"
#include "theory/type_enumerator.h"
+#include "theory/bv/theory_bv_utils.h"
#include "util/bitvector.h"
#include "util/integer.h"
if(d_bits != d_bits.modByPow2(d_size)) {
throw NoMoreValuesException(getType());
}
- return NodeManager::currentNM()->mkConst(BitVector(d_size, d_bits));
+ return utils::mkConst(d_size, d_bits);
}
BitVectorEnumerator& operator++() throw() {