Skip to content

Commit

Permalink
NonlinWork: Nonlin Real division is no longer supported
Browse files Browse the repository at this point in the history
  • Loading branch information
BritikovKI committed Nov 29, 2024
1 parent 1668eff commit 7e441a2
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/api/MainSolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ sstat MainSolver::check() {
sstat rval;
try {
rval = simplifyFormulas();
} catch (opensmt::NonLinException const & error) {
} catch (NonLinException const & error) {
reasonUnknown = error.what();
return s_Undef;
}
Expand All @@ -347,7 +347,7 @@ sstat MainSolver::check() {
if (rval == s_Undef) {
try {
rval = solve();
} catch (std::overflow_error const & error) { rval = s_Error; } catch (opensmt::NonLinException const & error) {
} catch (std::overflow_error const & error) { rval = s_Error; } catch (NonLinException const & error) {
reasonUnknown = error.what();
return s_Undef;
}
Expand Down
5 changes: 4 additions & 1 deletion src/logics/ArithLogic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <common/ApiException.h>
#include <common/InternalException.h>
#include <common/NonLinException.h>
#include <common/StringConv.h>
#include <common/TreeOps.h>
#include <pterms/PtStore.h>
Expand Down Expand Up @@ -863,7 +864,9 @@ PTRef ArithLogic::mkRealDiv(vec<PTRef> && args) {
vec<PTRef> args_new;
SymRef s_new;
simp.simplify(get_sym_Real_DIV(), args, s_new, args_new);
if (isRealDiv(s_new) && (isNumTerm(args_new[0]) || isPlus(args_new[0])) && isConstant(args_new[1])) {
// TODO: Currently creation of nonlinear Real divison is not supported
if (isRealDiv(s_new) && (isNumTerm(args_new[0]) || isPlus(args_new[0]))) {
if (!isConstant(args_new[1])) throw NonLinException(pp(args[0]) + "/" + pp(args[1]));
args_new[1] = mkRealConst(getNumConst(args_new[1]).inverse()); // mkConst(1/getRealConst(args_new[1]));
return mkTimes(args_new);
}
Expand Down
4 changes: 2 additions & 2 deletions src/tsolvers/lasolver/LASolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void LASolver::isProperLeq(PTRef tr)
assert(logic.isLeq(tr));
auto [cons, sum] = logic.leqToConstantAndTerm(tr);
assert(logic.isConstant(cons));
assert(logic.isNumVar(sum) || logic.isPlus(sum) || logic.isTimesLinOrNonlin(sum) || logic.isRealDiv(sum));
assert(logic.isNumVar(sum) || logic.isPlus(sum) || logic.isTimesLinOrNonlin(sum));
(void) cons; (void)sum;
}

Expand Down Expand Up @@ -243,7 +243,7 @@ LVRef LASolver::getVarForLeq(PTRef ref) const {
}

LVRef LASolver::getLAVar_single(PTRef expr_in) {
if (logic.isTimesNonlin(expr_in) || logic.isRealDiv(expr_in)) throw NonLinException(logic.pp(expr_in));
if (logic.isTimesNonlin(expr_in)) throw NonLinException(logic.pp(expr_in));
assert(logic.isLinearTerm(expr_in));
PTId id = logic.getPterm(expr_in).getId();

Expand Down
4 changes: 2 additions & 2 deletions test/regression/base/arithmetic/miniexample1.smt2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(set-logic QF_LRA)
(define-fun uninterp_div ((a Real) (b Real)) Real (/ a b))
(assert (= (uninterp_div 1 2) 0.5))
(define-fun uninterp_div ((a Real) (b Real)) Real (* a b))
(assert (= (uninterp_div 0.25 2) 0.5))
(check-sat)
(exit)
7 changes: 0 additions & 7 deletions test/regression/base/arithmetic/miniexample4.smt2

This file was deleted.

Empty file.

This file was deleted.

8 changes: 0 additions & 8 deletions test/regression/base/arithmetic/miniexample4_Ok.smt2

This file was deleted.

Empty file.

This file was deleted.

0 comments on commit 7e441a2

Please sign in to comment.