-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nonlin LA preds #790
base: master
Are you sure you want to change the base?
Nonlin LA preds #790
Conversation
d89fbf6
to
b1f40d9
Compare
b1f40d9
to
b300ed9
Compare
The code fails with this input
Here's the output:
|
c0605cd
to
78b01bc
Compare
For our limited form of axioms this might actually be just enough. One thing is missing before I can put this to our production: To be sure that we're running the correct version, I'd need to have the version information from opensmt. See issue #800 . |
46d12d9
to
8acd08a
Compare
2810c10
to
32f3743
Compare
Ok, I think generally PR is over Though, we definitely need some sort of error handling, LANonLinearException produces errors with different format under different complilers rn. Should it be a different issue though? |
|
dcfff4e
to
68062a8
Compare
f5e5502
to
00adce9
Compare
00adce9
to
c34e1ba
Compare
src/logics/ArithLogic.cc
Outdated
simp.simplify(getTimesLinForSort(returnSort), flatten_args, s_new, args); | ||
if (!isTimes(s_new)) return mkFun(s_new, std::move(args)); | ||
PTRef coef = PTRef_Undef; | ||
std::vector<PTRef> vars; | ||
// return mkFun(s_new, std::move(args)); | ||
// Splitting Multiplication into constant and variable subterms | ||
for (int i = 0; i < args.size(); i++) { | ||
if (isConstant(args[i])) { | ||
assert(coef == PTRef_Undef); | ||
coef = args[i]; | ||
continue; | ||
} | ||
vars.push_back(args[i]); | ||
} | ||
assert(!vars.empty()); | ||
PTRef tr; | ||
if (vars.size() > 1) { | ||
if (coef == PTRef_Undef) { | ||
tr = mkFun(getTimesNonlinForSort(returnSort), vars); | ||
} else { | ||
tr = mkFun(s_new, {coef, mkFun(getTimesNonlinForSort(returnSort), vars)}); | ||
} | ||
} else { | ||
tr = mkFun(s_new, {coef, vars[0]}); | ||
} | ||
return tr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to myself. It would be good if we can avoid this complicated piece of code. It feels like the code in simplify
should take care of most of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally simplify
would order args in some way
(For example, if there is a constant, it would be always in new_args[0]
)
Then, indeed, pretty much everything can be handled with simplify
...
eca54b4
to
7e441a2
Compare
7e441a2
to
adaea42
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more comments.
|
||
if (config.dump_query()) printCurrentAssertionsAsQuery(); | ||
|
||
if (rval == s_Undef) { | ||
try { | ||
rval = solve(); | ||
} catch (std::overflow_error const & error) { rval = s_Error; } | ||
} catch (std::overflow_error const & error) { rval = s_Error; } catch (NonLinException const & error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} catch (std::overflow_error const & error) { rval = s_Error; } catch (NonLinException const & error) { | |
} catch (std::overflow_error const & error) { | |
rval = s_Error; | |
} catch (NonLinException const & error) { |
Is this some formatter thing? The two catch clauses should not be on the same line.
@@ -380,6 +388,9 @@ class ArithLogic : public Logic { | |||
PTRef mkBinaryGeq(PTRef lhs, PTRef rhs) { return mkBinaryLeq(rhs, lhs); } | |||
PTRef mkBinaryLt(PTRef lhs, PTRef rhs) { return mkNot(mkBinaryGeq(lhs, rhs)); } | |||
PTRef mkBinaryGt(PTRef lhs, PTRef rhs) { return mkNot(mkBinaryLeq(lhs, rhs)); } | |||
SymRef declareFun_Multiplication_LinNonlin(std::string const & s, SRef rsort, vec<SRef> const & args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a better place for this method than between mkBinaryGt
and mkBinaryEq
.
assert(logic.isPlus(polyTerm) || logic.isTimesNonlin(polyTerm)); | ||
for (PTRef factor : logic.getPterm(polyTerm)) { | ||
auto [var, c] = logic.splitTermToVarAndConst(factor); | ||
auto [var, c] = logic.splitPolyTerm(factor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nonlinear multiplication should be handled as a factor, not as a sum, no? I think this is not correct.
assert(logic.isNumVar(sum) || logic.isPlus(sum) || logic.isTimes(sum)); | ||
assert(!logic.isTimes(sum) || ((logic.isNumVar(logic.getPterm(sum)[0]) && logic.isOne(logic.mkNeg(logic.getPterm(sum)[1]))) || | ||
(logic.isNumVar(logic.getPterm(sum)[1]) && logic.isOne(logic.mkNeg(logic.getPterm(sum)[0]))))); | ||
assert(logic.isNumVar(sum) || logic.isPlus(sum) || logic.isTimesLinOrNonlin(sum)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this express the cases better?
assert(logic.isNumVar(sum) || logic.isPlus(sum) || logic.isTimesLinOrNonlin(sum)); | |
assert(logic.isPlus(sum) or logic.isTimesLin(sum) or logic.isMonomial(sum); |
x = getLAVar_single(v); | ||
assert(logic.isNumVar(v) || (laVarMapper.isNegated(v) && logic.isNumVar(logic.mkNeg(v)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why has the assert moved? Just keep it in the original place, no?
Allows to create nonlin functions
Removed all of the constraints for the creation of nonlin predicates inside of the functions.
Only the assertions are checked for nonlinearity