Skip to content

Commit 23651e9

Browse files
committed
NonlinWork: Nonlin Real division is no longer supported
1 parent 6a72bae commit 23651e9

File tree

10 files changed

+11
-32
lines changed

10 files changed

+11
-32
lines changed

src/api/MainSolver.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ sstat MainSolver::check() {
337337
sstat rval;
338338
try {
339339
rval = simplifyFormulas();
340-
} catch (opensmt::NonLinException const & error) {
340+
} catch (NonLinException const & error) {
341341
reasonUnknown = error.what();
342342
return s_Undef;
343343
}
@@ -347,7 +347,7 @@ sstat MainSolver::check() {
347347
if (rval == s_Undef) {
348348
try {
349349
rval = solve();
350-
} catch (std::overflow_error const & error) { rval = s_Error; } catch (opensmt::NonLinException const & error) {
350+
} catch (std::overflow_error const & error) { rval = s_Error; } catch (NonLinException const & error) {
351351
reasonUnknown = error.what();
352352
return s_Undef;
353353
}

src/logics/ArithLogic.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <common/ApiException.h>
44
#include <common/InternalException.h>
5+
#include <common/NonLinException.h>
56
#include <common/StringConv.h>
67
#include <common/TreeOps.h>
78
#include <pterms/PtStore.h>
@@ -680,8 +681,7 @@ PTRef ArithLogic::mkTimes(vec<PTRef> && args) {
680681
if (!isTimes(s_new)) return mkFun(s_new, std::move(args));
681682
PTRef coef = PTRef_Undef;
682683
std::vector<PTRef> vars;
683-
// return mkFun(s_new, std::move(args));
684-
// Splitting Multiplication into constant and variable subterms
684+
// Splitting Multiplication into constant and monomial subterms
685685
for (int i = 0; i < args.size(); i++) {
686686
if (isConstant(args[i])) {
687687
assert(coef == PTRef_Undef);
@@ -863,7 +863,9 @@ PTRef ArithLogic::mkRealDiv(vec<PTRef> && args) {
863863
vec<PTRef> args_new;
864864
SymRef s_new;
865865
simp.simplify(get_sym_Real_DIV(), args, s_new, args_new);
866-
if (isRealDiv(s_new) && (isNumTerm(args_new[0]) || isPlus(args_new[0])) && isConstant(args_new[1])) {
866+
// TODO: Currently creation of nonlinear Real divison is not supported
867+
if (isRealDiv(s_new) && (isNumTerm(args_new[0]) || isPlus(args_new[0]))) {
868+
if (!isConstant(args_new[1])) throw NonLinException(pp(args[0]) + "/" + pp(args[1]));
867869
args_new[1] = mkRealConst(getNumConst(args_new[1]).inverse()); // mkConst(1/getRealConst(args_new[1]));
868870
return mkTimes(args_new);
869871
}

src/tsolvers/lasolver/LASolver.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void LASolver::isProperLeq(PTRef tr)
9292
assert(logic.isLeq(tr));
9393
auto [cons, sum] = logic.leqToConstantAndTerm(tr);
9494
assert(logic.isConstant(cons));
95-
assert(logic.isNumVar(sum) || logic.isPlus(sum) || logic.isTimesLinOrNonlin(sum) || logic.isRealDiv(sum));
95+
assert(logic.isNumVar(sum) || logic.isPlus(sum) || logic.isTimesLinOrNonlin(sum));
9696
(void) cons; (void)sum;
9797
}
9898

@@ -243,7 +243,7 @@ LVRef LASolver::getVarForLeq(PTRef ref) const {
243243
}
244244

245245
LVRef LASolver::getLAVar_single(PTRef expr_in) {
246-
if (logic.isTimesNonlin(expr_in) || logic.isRealDiv(expr_in)) throw NonLinException(logic.pp(expr_in));
246+
if (logic.isTimesNonlin(expr_in)) throw NonLinException(logic.pp(expr_in));
247247
assert(logic.isLinearTerm(expr_in));
248248
PTId id = logic.getPterm(expr_in).getId();
249249

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(set-logic QF_LRA)
2-
(define-fun uninterp_div ((a Real) (b Real)) Real (/ a b))
3-
(assert (= (uninterp_div 1 2) 0.5))
2+
(define-fun uninterp_div ((a Real) (b Real)) Real (* a b))
3+
(assert (= (uninterp_div 0.25 2) 0.5))
44
(check-sat)
55
(exit)

test/regression/base/arithmetic/miniexample4.smt2

Lines changed: 0 additions & 7 deletions
This file was deleted.

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

Whitespace-only changes.

test/regression/base/arithmetic/miniexample4.smt2.expected.out

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/regression/base/arithmetic/miniexample4_Ok.smt2

Lines changed: 0 additions & 8 deletions
This file was deleted.

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

Whitespace-only changes.

test/regression/base/arithmetic/miniexample4_Ok.smt2.expected.out

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)