namespace arith {
-typedef uint64_t ArithVar;
+typedef uint32_t ArithVar;
//static const ArithVar ARITHVAR_SENTINEL = std::numeric_limits<ArithVar>::max();
#define ARITHVAR_SENTINEL std::numeric_limits<ArithVar>::max()
struct ArithVarAttrID{};
-typedef expr::Attribute<ArithVarAttrID,ArithVar> ArithVarAttr;
+typedef expr::Attribute<ArithVarAttrID,uint64_t> ArithVarAttr;
+
+inline bool hasArithVar(TNode x){
+ return x.hasAttribute(ArithVarAttr());
+}
inline ArithVar asArithVar(TNode x){
- Assert(x.hasAttribute(ArithVarAttr()));
+ Assert(hasArithVar(x));
+ Assert(x.getAttribute(ArithVarAttr()) <= ARITHVAR_SENTINEL);
return x.getAttribute(ArithVarAttr());
}
+inline void setArithVar(TNode x, ArithVar a){
+ Assert(!hasArithVar(x));
+ return x.setAttribute(ArithVarAttr(), (uint64_t)a);
+}
+
inline Node mkRationalNode(const Rational& q){
return NodeManager::currentNM()->mkConst<Rational>(q);
}
ArithVar TheoryArith::requestArithVar(TNode x, bool basic){
Assert(isTheoryLeaf(x));
- Assert(!x.hasAttribute(ArithVarAttr()));
+ Assert(!hasArithVar(x));
ArithVar varX = d_variables.size();
d_variables.push_back(Node(x));
- x.setAttribute(ArithVarAttr(), varX);
-
+ setArithVar(x,varX);
d_activityMonitor.initActivity(varX);
d_basicManager.init(varX, basic);
Node n = variable.getNode();
Assert(isTheoryLeaf(n));
- Assert(n.hasAttribute(ArithVarAttr()));
+ Assert(hasArithVar(n));
- ArithVar av = n.getAttribute(ArithVarAttr());
+ ArithVar av = asArithVar(n);
coeffs.push_back(constant.getValue());
variables.push_back(av);
/* procedure AssertUpper( x_i <= c_i) */
bool TheoryArith::AssertUpper(TNode n, TNode original){
TNode nodeX_i = n[0];
- ArithVar x_i = nodeX_i.getAttribute(ArithVarAttr());
+ ArithVar x_i = asArithVar(nodeX_i);
Rational dcoeff = Rational(Integer(deltaCoeff(n.getKind())));
DeltaRational c_i(n[1].getConst<Rational>(), dcoeff);
/* procedure AssertLower( x_i >= c_i ) */
bool TheoryArith::AssertLower(TNode n, TNode original){
TNode nodeX_i = n[0];
- ArithVar x_i = nodeX_i.getAttribute(ArithVarAttr());
+ ArithVar x_i = asArithVar(nodeX_i);
Rational dcoeff = Rational(Integer(deltaCoeff(n.getKind())));
DeltaRational c_i(n[1].getConst<Rational>(),dcoeff);
bool TheoryArith::AssertEquality(TNode n, TNode original){
Assert(n.getKind() == EQUAL);
TNode nodeX_i = n[0];
- ArithVar x_i = nodeX_i.getAttribute(ArithVarAttr());
+ ArithVar x_i = asArithVar(nodeX_i);
DeltaRational c_i(n[1].getConst<Rational>());
Debug("arith") << "AssertEquality(" << x_i << " " << c_i << ")"<< std::endl;