Skip to content

Commit 78b01bc

Browse files
committed
NonlinWork: added support for mod
1 parent b21554c commit 78b01bc

17 files changed

+48
-7
lines changed

src/logics/ArithLogic.cc

Lines changed: 4 additions & 6 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
};
@@ -808,11 +808,9 @@ PTRef ArithLogic::mkMod(vec<PTRef> && args) {
808808
checkSortInt(args);
809809
PTRef dividend = args[0];
810810
PTRef divisor = args[1];
811-
812-
if (not isNumConst(divisor)) { throw ApiException("Divisor must be constant in linear logic"); }
813811
if (isZero(divisor)) { throw ArithDivisionByZeroException(); }
814812
if (isOne(divisor) or isMinusOne(divisor)) { return getTerm_IntZero(); }
815-
if (isConstant(dividend)) {
813+
if (isConstant(dividend) && isConstant(divisor)) {
816814
auto const & dividendValue = getNumConst(dividend);
817815
auto const & divisorValue = getNumConst(divisor);
818816
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)