/** Given a simplifiedKind this returns the corresponding ConstraintType. */
//ConstraintType constraintTypeOfLiteral(Kind k);
-ConstraintType constraintTypeOfComparison(const Comparison& cmp){
+ConstraintType Constraint::constraintTypeOfComparison(const Comparison& cmp){
Kind k = cmp.comparisonKind();
switch(k){
case LT:
Assert(!hasLiteral(negationNode));
Comparison posCmp = Comparison::parseNormalForm(atomNode);
- ConstraintType posType = constraintTypeOfComparison(posCmp);
+ ConstraintType posType = Constraint::constraintTypeOfComparison(posCmp);
Polynomial nvp = posCmp.normalizedVariablePart();
ArithVar v = d_avariables.asArithVar(nvp.getNode());
}else{
Comparison negCmp = Comparison::parseNormalForm(negationNode);
- ConstraintType negType = constraintTypeOfComparison(negCmp);
+ ConstraintType negType = Constraint::constraintTypeOfComparison(negCmp);
DeltaRational negDR = negCmp.normalizedDeltaRational();
ConstraintP negC = new Constraint(v, negType, negDR);
Node sum = toSumNode(d_partialModel, lhs);
if(sum.isNull()){ return make_pair(NullConstraint, added); }
- Node norm = Rewriter::rewrite(sum);
- DeltaRational dr(rhs);
+ Debug("approx::constraint") << "replayGetConstraint " << sum
+ << " " << k
+ << " " << rhs
+ << endl;
- ConstraintType t = (k == kind::LEQ) ? UpperBound : LowerBound;
+ Assert( k == kind::LEQ || k == kind::GEQ );
+
+ Node comparison = NodeManager::currentNM()->mkNode(k, sum, mkRationalNode(rhs));
+ Node rewritten = Rewriter::rewrite(comparison);
+ if(!(Comparison::isNormalAtom(rewritten))){
+ return make_pair(NullConstraint, added);
+ }
+
+ Comparison cmp = Comparison::parseNormalForm(rewritten);
+ if(cmp.isBoolean()){ return make_pair(NullConstraint, added); }
+
+ Polynomial nvp = cmp.normalizedVariablePart();
+ if(nvp.isZero()){ return make_pair(NullConstraint, added); }
+
+ Node norm = nvp.getNode();
+
+ ConstraintType t = Constraint::constraintTypeOfComparison(cmp);
+ DeltaRational dr = cmp.normalizedDeltaRational();
+
+ Debug("approx::constraint") << "rewriting " << rewritten << endl
+ << " |-> " << norm << " " << t << " " << dr << endl;
Assert(!branch || d_partialModel.hasArithVar(norm));
ArithVar v = ARITHVAR_SENTINEL;
return make_pair(imp, added);
}
}
+
+
ConstraintP newc = d_constraintDatabase.getConstraint(v, t, dr);
d_replayConstraints.push_back(newc);
return make_pair(newc, added);
// }
Node toSumNode(const ArithVariables& vars, const DenseMap<Rational>& sum){
+ Debug("arith::toSumNode") << "toSumNode() begin" << endl;
NodeBuilder<> nb(kind::PLUS);
NodeManager* nm = NodeManager::currentNM();
DenseMap<Rational>::const_iterator iter, end;
if(!vars.hasNode(x)){ return Node::null(); }
Node xNode = vars.asNode(x);
const Rational& q = sum[x];
- nb << nm->mkNode(kind::MULT, mkRationalNode(q), xNode);
+ Node mult = nm->mkNode(kind::MULT, mkRationalNode(q), xNode);
+ Debug("arith::toSumNode") << "toSumNode() " << x << " " << mult << endl;
+ nb << mult;
}
+ Debug("arith::toSumNode") << "toSumNode() end" << endl;
return safeConstructNary(nb);
}