Skip to content

Commit

Permalink
[WIP] Checking in mkConst that every Number of sort Int is indeed…
Browse files Browse the repository at this point in the history
… integer
  • Loading branch information
Tomaqa committed Nov 16, 2024
1 parent c267e01 commit 3716a78
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/logics/ArithLogic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ PTRef ArithLogic::mkNeg(PTRef tr) {
}

PTRef ArithLogic::mkConst(SRef sort, Number const & c) {
assert(sort == sort_REAL or c.isInteger());
std::string str = c.get_str(); // MB: I cannot store c.get_str().c_str() directly, since that is a pointer
// inside temporary object -> crash.
char const * val = str.c_str();
Expand Down
9 changes: 9 additions & 0 deletions test/regression/base/QF_LIA/regression/lia_nosubst.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(set-logic QF_LIA)
(declare-fun x () Int)
(declare-fun y () Int)
(declare-fun a () Bool)

(assert (= (* 3 x) (* 4 y)))
(assert (=> a (= x 1)))
(assert (=> (not a) (= x 1)))
(check-sat)
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
unsat
21 changes: 21 additions & 0 deletions test/unit/test_Substitutions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,27 @@ TEST_F(LIASubstitutionsRegression, test_LIAsubstitution) {
ASSERT_EQ(res, s_False);
}

TEST_F(LIASubstitutionsRegression, test_LIANosubstitution) {
auto const osmt = getLIAOsmt();
auto & mainSolver = osmt->getMainSolver();
auto & lialogic = osmt->getLIALogic();
PTRef x = lialogic.mkIntVar("x");
PTRef y = lialogic.mkIntVar("y");
PTRef three = lialogic.mkIntConst(3);
PTRef four = lialogic.mkIntConst(4);
PTRef eq = lialogic.mkEq(lialogic.mkTimes(three, x), lialogic.mkTimes(four, y));
PTRef a = lialogic.mkBoolVar("a");
PTRef conj = lialogic.mkAnd(
lialogic.mkImpl(a, lialogic.mkEq(x, lialogic.getTerm_IntOne())),
lialogic.mkImpl(lialogic.mkNot(a), lialogic.mkEq(x, lialogic.getTerm_IntOne()))
);
PTRef fla = lialogic.mkAnd(conj, eq);
// 3x = 4y AND (a => x=1) AND (~a => x=1)
mainSolver.insertFormula(fla);
auto res = mainSolver.check();
ASSERT_EQ(res, s_False);
}

TEST_F(LIASubstitutionsRegression, test_InconsistentSubstitutions) {
auto const osmt = getLIAOsmt();
auto & lialogic = osmt->getLIALogic();
Expand Down

0 comments on commit 3716a78

Please sign in to comment.