summaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorTim King <taking@cs.nyu.edu>2012-04-17 16:07:22 +0000
committerTim King <taking@cs.nyu.edu>2012-04-17 16:07:22 +0000
commitccd77233892ace44fd4852999e66534d1c2283ea (patch)
treea856cacd24508a5839fcdbe728583ff055b64e34 /test/unit
parent9644b6e12fbd3b649daafa43c5400d272e27bfb4 (diff)
Merges branches/arithmetic/atom-database r2979 through 3247 into trunk. Below is a highlight of the changes:
- This introduces a new normal form to arithmetic. -- Equalities and disequalities are in solved form. Roughly speaking this means: (= x (+ y z)) is in normal form. (See the comments in normal_form.h for what this formally requires.) -- The normal form for inequality atoms always uses GEQ and GT instead of GEQ and LEQ. Integer atoms always use GEQ. - Constraint was added to TheoryArith. -- A constraint is a triple of (k x v) where: --- k is the type of the constraint (either LowerBound, UpperBound, Equality or Disequality), --- x is an ArithVar, and --- v is a DeltaRational value. -- Constraints are always attached to a ConstraintDatabase. -- A Constraint has its negation in the ConstraintDatabase [at least for now]. -- Every constraint belongs to a set of constraints for each ArithVar sorted by the delta rational values. -- This set can be iterated over and provides efficient access to other constraints for this variable. -- A literal may be attached to a constraint. -- Constraints with attached literals may be marked as being asserted to the theory (sat context dependent). -- Constraints can be propagated. -- Every constraint has a proof (sat context dependent). -- Proofs can be explained for either conflicts or propagations (if the node was propagated). (These proofs may be different.) -- Equalities and disequalities can be marked as being split (user context dependent) - This removes and replaces: -- src/theory/arith/arith_prop_manager.* -- src/theory/arith/atom_database.* -- src/theory/arith/ordered_set.h - Added isZero(), isOne() and isNegativeOne() to Rational and Integer. - Added operator+ to CDList::const_iterator. - Added const_iterator to CDQueue. - Changes to regression tests.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/theory/theory_arith_white.h96
1 files changed, 47 insertions, 49 deletions
diff --git a/test/unit/theory/theory_arith_white.h b/test/unit/theory/theory_arith_white.h
index 41d370aac..c6d6e3e2e 100644
--- a/test/unit/theory/theory_arith_white.h
+++ b/test/unit/theory/theory_arith_white.h
@@ -125,7 +125,8 @@ public:
Node x = d_nm->mkVar(*d_realType);
Node c = d_nm->mkConst<Rational>(d_zero);
- Node leq = d_nm->mkNode(LEQ, x, c);
+ Node gt = d_nm->mkNode(GT, x, c);
+ Node leq = gt.notNode();
fakeTheoryEnginePreprocess(leq);
d_arith->assertFact(leq, true);
@@ -149,37 +150,36 @@ public:
Node c0 = d_nm->mkConst<Rational>(d_zero);
Node c1 = d_nm->mkConst<Rational>(d_one);
- Node leq0 = d_nm->mkNode(LEQ, x, c0);
- Node leq1 = d_nm->mkNode(LEQ, x, c1);
+ Node gt0 = d_nm->mkNode(GT, x, c0);
+ Node gt1 = d_nm->mkNode(GT, x, c1);
Node geq1 = d_nm->mkNode(GEQ, x, c1);
- Node lt1 = d_nm->mkNode(NOT, geq1);
- Node gt0 = d_nm->mkNode(NOT, leq0);
- Node gt1 = d_nm->mkNode(NOT, leq1);
+ Node leq0 = gt0.notNode();
+ Node leq1 = gt1.notNode();
+ Node lt1 = geq1.notNode();
fakeTheoryEnginePreprocess(leq0);
fakeTheoryEnginePreprocess(leq1);
fakeTheoryEnginePreprocess(geq1);
+ d_arith->presolve();
d_arith->assertFact(lt1, true);
-
-
d_arith->check(d_level);
d_arith->propagate(d_level);
- Node gt1ThenGt0 = NodeBuilder<2>(IMPLIES) << gt1 << gt0;
- Node geq1ThenGt0 = NodeBuilder<2>(IMPLIES) << geq1 << gt0;
- Node lt1ThenLeq1 = NodeBuilder<2>(IMPLIES) << lt1 << leq1;
- TS_ASSERT_EQUALS(d_outputChannel.getNumCalls(), 3u);
+ Node gt0Orlt1 = NodeBuilder<2>(OR) << gt0 << lt1;
+ Node geq0OrLeq1 = NodeBuilder<2>(OR) << geq1 << leq1;
+
+ cout << d_outputChannel.getIthNode(0) << endl;
+ cout << d_outputChannel.getIthNode(1) << endl;
+
+ TS_ASSERT_EQUALS(d_outputChannel.getNumCalls(), 2u);
TS_ASSERT_EQUALS(d_outputChannel.getIthCallType(0), LEMMA);
- TS_ASSERT_EQUALS(d_outputChannel.getIthNode(0), gt1ThenGt0);
+ TS_ASSERT_EQUALS(d_outputChannel.getIthNode(0), gt0Orlt1);
TS_ASSERT_EQUALS(d_outputChannel.getIthCallType(1), LEMMA);
- TS_ASSERT_EQUALS(d_outputChannel.getIthNode(1), geq1ThenGt0);
-
- TS_ASSERT_EQUALS(d_outputChannel.getIthCallType(2), LEMMA);
- TS_ASSERT_EQUALS(d_outputChannel.getIthNode(2), lt1ThenLeq1);
+ TS_ASSERT_EQUALS(d_outputChannel.getIthNode(1), geq0OrLeq1);
}
@@ -188,72 +188,70 @@ public:
Node c0 = d_nm->mkConst<Rational>(d_zero);
Node c1 = d_nm->mkConst<Rational>(d_one);
- Node leq0 = d_nm->mkNode(LEQ, x, c0);
- Node leq1 = d_nm->mkNode(LEQ, x, c1);
+ Node gt0 = d_nm->mkNode(GT, x, c0);
+ Node gt1 = d_nm->mkNode(GT, x, c1);
Node geq1 = d_nm->mkNode(GEQ, x, c1);
- Node lt1 = d_nm->mkNode(NOT, geq1);
- Node gt0 = d_nm->mkNode(NOT, leq0);
- Node gt1 = d_nm->mkNode(NOT, leq1);
+ Node leq0 = gt0.notNode();
+ Node leq1 = gt1.notNode();
+ Node lt1 = geq1.notNode();
fakeTheoryEnginePreprocess(leq0);
fakeTheoryEnginePreprocess(leq1);
fakeTheoryEnginePreprocess(geq1);
+ d_arith->presolve();
d_arith->assertFact(leq0, true);
-
-
d_arith->check(d_level);
+ d_arith->propagate(d_level);
- Node gt1ThenGt0 = NodeBuilder<2>(IMPLIES) << gt1 << gt0;
- Node geq1ThenGt0 = NodeBuilder<2>(IMPLIES) << geq1 << gt0;
- Node lt1ThenLeq1 = NodeBuilder<2>(IMPLIES) << lt1 << leq1;
+ Node gt0Orlt1 = NodeBuilder<2>(OR) << gt0 << lt1;
+ Node geq0OrLeq1 = NodeBuilder<2>(OR) << geq1 << leq1;
- TS_ASSERT_EQUALS(d_outputChannel.getNumCalls(), 3u);
+ cout << d_outputChannel.getIthNode(0) << endl;
+ cout << d_outputChannel.getIthNode(1) << endl;
+
+ TS_ASSERT_EQUALS(d_outputChannel.getNumCalls(), 2u);
TS_ASSERT_EQUALS(d_outputChannel.getIthCallType(0), LEMMA);
- TS_ASSERT_EQUALS(d_outputChannel.getIthNode(0), gt1ThenGt0);
+ TS_ASSERT_EQUALS(d_outputChannel.getIthNode(0), gt0Orlt1);
TS_ASSERT_EQUALS(d_outputChannel.getIthCallType(1), LEMMA);
- TS_ASSERT_EQUALS(d_outputChannel.getIthNode(1), geq1ThenGt0);
-
- TS_ASSERT_EQUALS(d_outputChannel.getIthCallType(2), LEMMA);
- TS_ASSERT_EQUALS(d_outputChannel.getIthNode(2), lt1ThenLeq1);
+ TS_ASSERT_EQUALS(d_outputChannel.getIthNode(1), geq0OrLeq1);
}
+
void testTPLeq1() {
Node x = d_nm->mkVar(*d_realType);
Node c0 = d_nm->mkConst<Rational>(d_zero);
Node c1 = d_nm->mkConst<Rational>(d_one);
- Node leq0 = d_nm->mkNode(LEQ, x, c0);
- Node leq1 = d_nm->mkNode(LEQ, x, c1);
+ Node gt0 = d_nm->mkNode(GT, x, c0);
+ Node gt1 = d_nm->mkNode(GT, x, c1);
Node geq1 = d_nm->mkNode(GEQ, x, c1);
- Node lt1 = d_nm->mkNode(NOT, geq1);
- Node gt0 = d_nm->mkNode(NOT, leq0);
- Node gt1 = d_nm->mkNode(NOT, leq1);
+ Node leq0 = gt0.notNode();
+ Node leq1 = gt1.notNode();
+ Node lt1 = geq1.notNode();
fakeTheoryEnginePreprocess(leq0);
fakeTheoryEnginePreprocess(leq1);
fakeTheoryEnginePreprocess(geq1);
+ d_arith->presolve();
d_arith->assertFact(leq1, true);
-
-
d_arith->check(d_level);
d_arith->propagate(d_level);
- Node gt1ThenGt0 = NodeBuilder<2>(IMPLIES) << gt1 << gt0;
- Node geq1ThenGt0 = NodeBuilder<2>(IMPLIES) << geq1 << gt0;
- Node lt1ThenLeq1 = NodeBuilder<2>(IMPLIES) << lt1 << leq1;
+ Node gt0Orlt1 = NodeBuilder<2>(OR) << gt0 << lt1;
+ Node geq0OrLeq1 = NodeBuilder<2>(OR) << geq1 << leq1;
+
+ cout << d_outputChannel.getIthNode(0) << endl;
+ cout << d_outputChannel.getIthNode(1) << endl;
- TS_ASSERT_EQUALS(d_outputChannel.getNumCalls(), 3u);
+ TS_ASSERT_EQUALS(d_outputChannel.getNumCalls(), 2u);
TS_ASSERT_EQUALS(d_outputChannel.getIthCallType(0), LEMMA);
- TS_ASSERT_EQUALS(d_outputChannel.getIthNode(0), gt1ThenGt0);
+ TS_ASSERT_EQUALS(d_outputChannel.getIthNode(0), gt0Orlt1);
TS_ASSERT_EQUALS(d_outputChannel.getIthCallType(1), LEMMA);
- TS_ASSERT_EQUALS(d_outputChannel.getIthNode(1), geq1ThenGt0);
-
- TS_ASSERT_EQUALS(d_outputChannel.getIthCallType(2), LEMMA);
- TS_ASSERT_EQUALS(d_outputChannel.getIthNode(2), lt1ThenLeq1);
+ TS_ASSERT_EQUALS(d_outputChannel.getIthNode(1), geq0OrLeq1);
}
};
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback