Skip to content
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

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Nonlin LA preds #790

wants to merge 19 commits into from

Conversation

BritikovKI
Copy link
Contributor

@BritikovKI BritikovKI commented Oct 29, 2024

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

@BritikovKI BritikovKI force-pushed the nonlin-la-preds branch 8 times, most recently from d89fbf6 to b1f40d9 Compare October 31, 2024 11:43
@BritikovKI BritikovKI marked this pull request as ready for review October 31, 2024 15:09
@aehyvari
Copy link
Member

aehyvari commented Nov 4, 2024

The code fails with this input

(set-logic QF_LIA)
(define-fun uninterp_mul ((a Int) (b Int)) Int (mod a b))
(assert (= (uninterp_mul 1 2) 0))
(check-sat)
(exit)

Here's the output:

(error "Divisor must be constant in linear logic")

(error "define-fun returns an unknown sort")

(error "Unknown symbol `uninterp_mul Int Int'")

(error "assertion returns an unknown sort")

sat

src/itehandler/IteToSwitch.cc Outdated Show resolved Hide resolved
src/logics/ArithLogic.cc Outdated Show resolved Hide resolved
src/logics/ArithLogic.cc Outdated Show resolved Hide resolved
src/logics/ArithLogic.cc Outdated Show resolved Hide resolved
src/logics/ArithLogic.cc Show resolved Hide resolved
src/logics/ArithLogic.h Show resolved Hide resolved
src/logics/Logic.h Outdated Show resolved Hide resolved
test/regression/base/arithmetic/miniexample2.smt2 Outdated Show resolved Hide resolved
test/unit/test_ArithLogicApi.cc Outdated Show resolved Hide resolved
test/unit/test_Rewriting.cc Outdated Show resolved Hide resolved
@aehyvari
Copy link
Member

aehyvari commented Nov 4, 2024

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 .

@BritikovKI BritikovKI force-pushed the nonlin-la-preds branch 3 times, most recently from 46d12d9 to 8acd08a Compare November 4, 2024 10:25
@BritikovKI BritikovKI linked an issue Nov 4, 2024 that may be closed by this pull request
@BritikovKI BritikovKI force-pushed the nonlin-la-preds branch 11 times, most recently from 2810c10 to 32f3743 Compare November 5, 2024 13:51
@BritikovKI
Copy link
Contributor Author

BritikovKI commented Nov 5, 2024

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?

src/logics/Logic.h Outdated Show resolved Hide resolved
src/symbols/SymStore.cc Outdated Show resolved Hide resolved
src/logics/ArithLogic.h Outdated Show resolved Hide resolved
src/logics/ArithLogic.h Outdated Show resolved Hide resolved
src/logics/ArithLogic.h Outdated Show resolved Hide resolved
src/symbols/SymStore.h Outdated Show resolved Hide resolved
src/symbols/SymStore.h Outdated Show resolved Hide resolved
src/tsolvers/lasolver/LASolver.h Outdated Show resolved Hide resolved
src/rewriters/DivModRewriter.h Outdated Show resolved Hide resolved
src/logics/Logic.h Outdated Show resolved Hide resolved
src/logics/ArithLogic.h Outdated Show resolved Hide resolved
src/symbols/SymStore.h Outdated Show resolved Hide resolved
src/logics/ArithLogic.cc Outdated Show resolved Hide resolved
@BritikovKI
Copy link
Contributor Author

isNonlin is temporarily needed, we don't do RealDiv refinement in the DivModRefinement because we expect originally that by the time of refinement RealDiv no longer exist in the instance(removed during parsing). So we need to check if there is nonlin RealDiv in the formula as well as multiplication...

src/api/MainSolver.cc Outdated Show resolved Hide resolved
src/api/MainSolver.cc Outdated Show resolved Hide resolved
src/common/CMakeLists.txt Show resolved Hide resolved
src/logics/ArithLogic.h Outdated Show resolved Hide resolved
src/logics/ArithLogic.h Outdated Show resolved Hide resolved
src/simplifiers/LA.cc Outdated Show resolved Hide resolved
src/tsolvers/lasolver/LASolver.cc Outdated Show resolved Hide resolved
src/tsolvers/lasolver/LASolver.cc Outdated Show resolved Hide resolved
src/tsolvers/lasolver/LASolver.h Outdated Show resolved Hide resolved
test/regression/base/arithmetic/miniexample3.smt2 Outdated Show resolved Hide resolved
@BritikovKI BritikovKI force-pushed the nonlin-la-preds branch 7 times, most recently from f5e5502 to 00adce9 Compare November 28, 2024 17:07
src/common/CMakeLists.txt Show resolved Hide resolved
src/common/NonLinException.h Outdated Show resolved Hide resolved
src/logics/ArithLogic.h Outdated Show resolved Hide resolved
src/logics/ArithLogic.cc Outdated Show resolved Hide resolved
src/logics/ArithLogic.h Outdated Show resolved Hide resolved
src/logics/ArithLogic.cc Outdated Show resolved Hide resolved
src/logics/ArithLogic.cc Outdated Show resolved Hide resolved
src/logics/ArithLogic.cc Outdated Show resolved Hide resolved
src/logics/ArithLogic.h Outdated Show resolved Hide resolved
src/logics/ArithLogic.h Outdated Show resolved Hide resolved
src/logics/ArithLogic.cc Show resolved Hide resolved
Comment on lines 679 to 704
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;
Copy link
Member

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.

src/tsolvers/lasolver/LASolver.cc Outdated Show resolved Hide resolved
@BritikovKI BritikovKI force-pushed the nonlin-la-preds branch 4 times, most recently from eca54b4 to 7e441a2 Compare November 29, 2024 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opensmt rejects non-linear integer arithmetic too eagerly
4 participants