Skip to content

Commit 8acd08a

Browse files
committed
NonlinWork: added support for mod
1 parent b21554c commit 8acd08a

18 files changed

+49
-9
lines changed

src/logics/ArithLogic.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ bool ArithLogic::isLinearTerm(PTRef tr) const {
197197
bool ArithLogic::isNonlin(PTRef tr) const {
198198
if (isTimes(tr)) {
199199
Pterm const & term = getPterm(tr);
200-
return (!isConstant(term[0]) && !isConstant(term[1]));
200+
return (not isConstant(term[0]) && not isConstant(term[1]));
201201
}
202-
if (isRealDiv(tr) || isIntDiv(tr)) {
202+
if (isRealDiv(tr) || isIntDiv(tr) || isMod(getPterm(tr).symb())) {
203203
Pterm const & term = getPterm(tr);
204-
return (!isConstant(term[1]));
204+
return (not isConstant(term[1]));
205205
}
206206
return false;
207207
};
@@ -689,8 +689,6 @@ PTRef ArithLogic::mkTimes(vec<PTRef> && args) {
689689
SymRef s_new;
690690
simp.simplify(getTimesForSort(returnSort), flatten_args, s_new, args);
691691
PTRef tr = mkFun(s_new, std::move(args));
692-
// Either a real term or, if we constructed a multiplication of a
693-
// constant and a sum, a real sum.
694692
return tr;
695693
}
696694

@@ -808,11 +806,9 @@ PTRef ArithLogic::mkMod(vec<PTRef> && args) {
808806
checkSortInt(args);
809807
PTRef dividend = args[0];
810808
PTRef divisor = args[1];
811-
812-
if (not isNumConst(divisor)) { throw ApiException("Divisor must be constant in linear logic"); }
813809
if (isZero(divisor)) { throw ArithDivisionByZeroException(); }
814810
if (isOne(divisor) or isMinusOne(divisor)) { return getTerm_IntZero(); }
815-
if (isConstant(dividend)) {
811+
if (isConstant(dividend) && isConstant(divisor)) {
816812
auto const & dividendValue = getNumConst(dividend);
817813
auto const & divisorValue = getNumConst(divisor);
818814
assert(dividendValue.isInteger() and divisorValue.isInteger());
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(set-logic QF_LIA)
2+
(declare-fun x () Int)
3+
(define-fun uninterp_mul ((a Int) (b Int)) Int (* 2 a b))
4+
(assert (= (uninterp_mul 5 x) 10))
5+
(check-sat)
6+
(get-model)
7+
(exit)

test/regression/base/arithmetic/miniexample10.smt2.expected.err

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sat
2+
(
3+
(define-fun x () Int
4+
1)
5+
)

test/regression/base/arithmetic/miniexample2.smt2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
(set-logic QF_LIA)
22
(declare-fun x () Int)
33
(define-fun uninterp_mul ((a Int) (b Int)) Int (* a b))
4-
(assert (= x x))
54
(assert (= (uninterp_mul 2 x) (+ x x)))
65
(check-sat)
76
(get-model)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(set-logic QF_LIA)
2+
(declare-fun x () Int)
3+
(declare-fun y () Int)
4+
(define-fun uninterp_mul ((a Int) (b Int)) Int (mod a b))
5+
(assert (= (uninterp_mul x y) 0))
6+
(check-sat)
7+
(exit)

test/regression/base/arithmetic/miniexample8.smt2.expected.err

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(error "Nonlinear operations in the formula: (mod x y)")
2+
3+
sat
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(set-logic QF_LIA)
2+
(define-fun uninterp_mul ((a Int) (b Int)) Int (mod a b))
3+
(assert (= (uninterp_mul 1 2) 0))
4+
(check-sat)
5+
(exit)

test/regression/base/arithmetic/miniexample8_Ok.smt2.expected.err

Whitespace-only changes.

0 commit comments

Comments
 (0)