| STAR_TOK { $kind = CVC4::kind::MULT; }
| TILDE_TOK { $kind = CVC4::kind::UMINUS; }
| MINUS_TOK { $kind = CVC4::kind::MINUS; }
+ | DIV_TOK { $kind = CVC4::kind::DIVISION; }
// Bit-vectors
| CONCAT_TOK { $kind = CVC4::kind::BITVECTOR_CONCAT; }
- | BVAND_TOK { $kind = CVC4::kind::BITVECTOR_AND; }
- | BVOR_TOK { $kind = CVC4::kind::BITVECTOR_OR; }
+ | BVAND_TOK { $kind = CVC4::kind::BITVECTOR_AND; }
+ | BVOR_TOK { $kind = CVC4::kind::BITVECTOR_OR; }
| BVXOR_TOK { $kind = CVC4::kind::BITVECTOR_XOR; }
| BVNOT_TOK { $kind = CVC4::kind::BITVECTOR_NOT; }
| BVNAND_TOK { $kind = CVC4::kind::BITVECTOR_NAND; }
| BVNEG_TOK { $kind = CVC4::kind::BITVECTOR_NEG; }
| BVUDIV_TOK { $kind = CVC4::kind::BITVECTOR_UDIV; }
| BVUREM_TOK { $kind = CVC4::kind::BITVECTOR_UREM; }
- | BVSDIV_TOK { $kind = CVC4::kind::BITVECTOR_SDIV; }
+ | BVSDIV_TOK { $kind = CVC4::kind::BITVECTOR_SDIV; }
| BVSREM_TOK { $kind = CVC4::kind::BITVECTOR_SREM; }
| BVSMOD_TOK { $kind = CVC4::kind::BITVECTOR_SMOD; }
| BVSHL_TOK { $kind = CVC4::kind::BITVECTOR_SHL; }
if(pnfs.size() == 1){
Node p_1 = *(pnfs.begin());
if(p_1[0].getConst<Rational>() == d_constants->d_ONE){
- if(accumulator == 0){ // 0 + (* 1 var) |-> var
+ if(accumulator == d_constants->d_ZERO){ // 0 + (* 1 var) |-> var
Node var = p_1[1];
return var;
}
}
}
+Node ArithRewriter::rewriteConstantDiv(TNode t){
+ Assert(t.getKind()== kind::DIVISION);
+
+ Node reLeft = rewrite(t[0]);
+ Node reRight = rewrite(t[1]);
+ Assert(reLeft.getKind()== kind::CONST_RATIONAL);
+ Assert(reRight.getKind()== kind::CONST_RATIONAL);
+
+ Rational num = reLeft.getConst<Rational>();
+ Rational den = reRight.getConst<Rational>();
+
+ Assert(den != d_constants->d_ZERO);
+
+ Rational div = num / den;
+
+ Node result = mkRationalNode(div);
+
+ return result;
+}
+
Node ArithRewriter::rewriteTerm(TNode t){
if(t.getMetaKind() == kind::metakind::CONSTANT){
return coerceToRationalNode(t);
return rewriteMult(t);
}else if(t.getKind() == kind::PLUS){
return rewritePlus(t);
+ }else if(t.getKind() == kind::DIVISION){
+ return rewriteConstantDiv(t);
}else{
Unreachable();
return Node::null();
Node multPnfByNonZero(TNode pnf, Rational& q);
+ Node rewriteConstantDiv(TNode t);
+
+
public:
ArithRewriter(ArithConstants* ac) :
d_constants(ac)
operator MULT 2: "arithmetic multiplication"
operator MINUS 2 "arithmetic binary subtraction operator"
operator UMINUS 1 "arithmetic unary negation"
+operator DIVISION 2 "arithmetic division"
constant CONST_RATIONAL \
::CVC4::Rational \
void ArithPartialModel::setUpperBound(TNode x, const DeltaRational& r){
Assert(x.getMetaKind() == CVC4::kind::metakind::VARIABLE);
+ Debug("partial_model") << "setUpperBound(" << x << "," << r << ")" << endl;
+
d_UpperBoundMap[x] = r;
}
void ArithPartialModel::setLowerBound(TNode x, const DeltaRational& r){
Assert(x.getMetaKind() == CVC4::kind::metakind::VARIABLE);
-
+ Debug("partial_model") << "setLowerBound(" << x << "," << r << ")" << endl;
d_LowerBoundMap[x] = r;
}
TheoryArith::TheoryArith(context::Context* c, OutputChannel& out) :
Theory(c, out),
+ d_preprocessed(c),
d_constants(NodeManager::currentNM()),
d_partialModel(c),
d_diseq(c),
- d_preprocessed(c),
d_rewriter(&d_constants)
{
uint64_t ass_id = partial_model::Assignment::getId();
- Debug("arithsetup") << "Assignment: " << ass_id
- << std::endl;
+ Debug("arithsetup") << "Assignment: " << ass_id << std::endl;
+}
+TheoryArith::~TheoryArith(){
+ for(vector<Node>::iterator i=d_variables.begin(); i!= d_variables.end(); ++i){
+ Node var = *i;
+ Debug("arithgc") << var << endl;
+ }
}
return result;
}
+
void TheoryArith::registerTerm(TNode tn){
Debug("arith") << "registerTerm(" << tn << ")" << endl;
if(tn.getKind() == kind::BUILTIN) return;
if(tn.getMetaKind() == metakind::VARIABLE){
- d_partialModel.setAssignment(tn,d_constants.d_ZERO_DELTA);
+ setupVariable(tn);
}
//TODO is an atom
//TODO
TypeNode real_type = NodeManager::currentNM()->realType();
slack = NodeManager::currentNM()->mkVar(real_type);
- d_partialModel.setAssignment(slack,d_constants.d_ZERO_DELTA);
+
+ setupVariable(slack);
+
left.setAttribute(Slack(), slack);
makeBasic(slack);
#include "theory/arith/arith_rewriter.h"
#include "theory/arith/partial_model.h"
+#include <vector>
+
namespace CVC4 {
namespace theory {
namespace arith {
class TheoryArith : public Theory {
private:
- ArithConstants d_constants;
- ArithPartialModel d_partialModel;
+ /* Chopping block begins */
- context::CDList<Node> d_diseq;
context::CDList<Node> d_preprocessed;
//TODO This is currently needed to save preprocessed nodes that may not
//currently have an outisde reference. Get rid of when preprocessing is occuring
//correctly.
+ std::vector<Node> d_variables;
+ //TODO get rid of this. Currently forces every variable and skolem constant that
+ // can hit the tableau to stay alive forever!
+ //This needs to come before d_partialModel and d_tableau in the file
+
+
+ /* Chopping block ends */
+ ArithConstants d_constants;
+ ArithPartialModel d_partialModel;
+
+ context::CDList<Node> d_diseq;
Tableau d_tableau;
ArithRewriter d_rewriter;
+
+
public:
TheoryArith(context::Context* c, OutputChannel& out);
+ ~TheoryArith();
Node rewrite(TNode n);
//TODO get rid of this!
Node simulatePreprocessing(TNode n);
+ void setupVariable(TNode x){
+ Assert(x.getMetaKind() == kind::metakind::VARIABLE);
+ d_partialModel.setAssignment(x,d_constants.d_ZERO_DELTA);
+ d_variables.push_back(Node(x));
+
+ Debug("arithgc") << "setupVariable("<<x<<")"<<std::endl;
+ };
};
if(lhs.getKind() == kind::VARIABLE) {
// FIXME: we don't yet have a Type-to-Theory map. When we do,
// look up the type of the LHS and return that Theory (?)
- return &d_uf;
- //Unimplemented();
+
+ //The following JUST hacks around this lack of a table
+ TypeNode type_of_n = lhs.getType();
+ if(type_of_n.isReal()){
+ return &d_arith;
+ }else{
+ return &d_uf;
+ //Unimplemented();
+ }
} else {
return theoryOf(lhs);
}
-(set-logic QF_LRA)
+(set-logic QF_UF)
(set-info :status unsat)
-(declare-fun x () Real)
-(declare-fun y () Real)
+(declare-sort U 0)
+(declare-fun x () U)
+(declare-fun y () U)
(assert (not (= x (ite true x y))))
(check-sat)