Skip to content

Commit

Permalink
ArithLogic: Fix handling of minus operator with more than two arguments
Browse files Browse the repository at this point in the history
According to the SMT-LIB definition of theory of Ints, operator minus is
left associative. This means that it is allowed to create a function
application of minus to more than two arguments. This is than a
syntactic sugar that applies the operator recursively first to all the
arguments except the last one and then apply the operator to the result
and the last argument.
  • Loading branch information
blishko committed Apr 2, 2024
1 parent bda0e67 commit da8044b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 4 additions & 0 deletions regression/QF_LIA/issue_690.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(set-logic QF_LIA)
(set-info :status sat)
(assert (= 0 (- 3 2 1)))
(check-sat)
Empty file.
1 change: 1 addition & 0 deletions regression/QF_LIA/issue_690.smt2.expected.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sat
9 changes: 3 additions & 6 deletions src/logics/ArithLogic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,9 @@ PTRef ArithLogic::mkMinus(vec<PTRef> && args)
if (args.size() == 1) {
return mkNeg(args[0]);
}
assert(args.size() == 2);
if (args.size() > 2) { throw OsmtApiException("Too many terms provided to LALogic::mkNumMinus"); }

PTRef fact = mkNeg(args[1]);
assert(fact != PTRef_Undef);
args[1] = fact;
// Minus is left associative according to SMT-LIB
for (int i = 1; i < args.size(); ++i)
args[i] = mkNeg(args[i]);
return mkPlus(std::move(args));
}

Expand Down

0 comments on commit da8044b

Please sign in to comment.