diff options
author | Tim King <taking@cs.nyu.edu> | 2010-05-20 22:51:48 +0000 |
---|---|---|
committer | Tim King <taking@cs.nyu.edu> | 2010-05-20 22:51:48 +0000 |
commit | 5321d62fce6c747fa9d11e9df5b2ef8c4e25de21 (patch) | |
tree | 87685c6a9f32d99f09de28a02fc80378a94b6ec9 /src/theory/arith/arith_rewriter.cpp | |
parent | ff70395fd3dcde9f68eda1c6a8bd70e6491f7458 (diff) |
Added the division symbol to the parser, and minimal support for it in TheoryArith. Also directly hacked in support for theoryOf() to work for equalities where the left hand is a variable of type real.
Diffstat (limited to 'src/theory/arith/arith_rewriter.cpp')
-rw-r--r-- | src/theory/arith/arith_rewriter.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/theory/arith/arith_rewriter.cpp b/src/theory/arith/arith_rewriter.cpp index a20d187bd..13ee9183f 100644 --- a/src/theory/arith/arith_rewriter.cpp +++ b/src/theory/arith/arith_rewriter.cpp @@ -253,7 +253,7 @@ Node ArithRewriter::rewritePlus(TNode t){ 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; } @@ -386,6 +386,26 @@ Node ArithRewriter::rewriteMult(TNode t){ } } +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); @@ -395,6 +415,8 @@ Node ArithRewriter::rewriteTerm(TNode 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(); |