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
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/logics/ArithLogic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ ArithLogic::ArithLogic(Logic_t type)
sym_Real_PLUS(declareFun_Commutative_NoScoping_LeftAssoc(tk_real_plus, sort_REAL, {sort_REAL, sort_REAL})),
sym_Real_TIMES(declareFun_Commutative_NoScoping_LeftAssoc(tk_real_times, sort_REAL, {sort_REAL, sort_REAL})),
sym_Real_TIMES_NONLIN(
declareFun_Commutative_NoScoping_LeftAssoc(tk_real_times, sort_REAL, {sort_REAL, sort_REAL})),
declareFun_Commutative_NoScoping_LeftAssoc(tk_real_times, sort_REAL, {sort_REAL, sort_REAL}, true)),
sym_Real_DIV(declareFun_NoScoping_LeftAssoc(tk_real_div, sort_REAL, {sort_REAL, sort_REAL})),
sym_Real_EQ(sortToEquality[sort_REAL]),
sym_Real_LEQ(declareFun_NoScoping_Chainable(tk_real_leq, sort_BOOL, {sort_REAL, sort_REAL})),
Expand All @@ -136,7 +136,8 @@ ArithLogic::ArithLogic(Logic_t type)
sym_Int_MINUS(declareFun_NoScoping_LeftAssoc(tk_int_minus, sort_INT, {sort_INT, sort_INT})),
sym_Int_PLUS(declareFun_Commutative_NoScoping_LeftAssoc(tk_int_plus, sort_INT, {sort_INT, sort_INT})),
sym_Int_TIMES(declareFun_Commutative_NoScoping_LeftAssoc(tk_int_times, sort_INT, {sort_INT, sort_INT})),
sym_Int_TIMES_NONLIN(declareFun_Commutative_NoScoping_LeftAssoc(tk_int_times, sort_INT, {sort_INT, sort_INT})),
sym_Int_TIMES_NONLIN(
declareFun_Commutative_NoScoping_LeftAssoc(tk_int_times, sort_INT, {sort_INT, sort_INT}, true)),
sym_Int_DIV(declareFun_NoScoping_LeftAssoc(tk_int_div, sort_INT, {sort_INT, sort_INT})),
sym_Int_MOD(declareFun_NoScoping(tk_int_mod, sort_INT, {sort_INT, sort_INT})),
sym_Int_EQ(sortToEquality[sort_INT]),
Expand Down
4 changes: 2 additions & 2 deletions src/logics/Logic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -728,11 +728,11 @@ PTRef Logic::mkSelect(vec<PTRef> && args) {
}

SymRef Logic::declareFun(std::string const & fname, SRef rsort, vec<SRef> const & args,
SymbolConfig const & symbolConfig) {
SymbolConfig const & symbolConfig, bool duplicate) {
assert(rsort != SRef_Undef);
assert(std::find(args.begin(), args.end(), SRef_Undef) == args.end());

SymRef sr = sym_store.newSymb(fname.c_str(), rsort, args, symbolConfig);
SymRef sr = sym_store.newSymb(fname.c_str(), rsort, args, symbolConfig, duplicate);
return sr;
}

Expand Down
8 changes: 5 additions & 3 deletions src/logics/Logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ class Logic {
virtual PTRef mkConst(char const *);
virtual PTRef mkConst(SRef, char const *);

SymRef declareFun(std::string const & fname, SRef rsort, vec<SRef> const & args, SymbolConfig const & symbolConfig);
SymRef declareFun(std::string const & fname, SRef rsort, vec<SRef> const & args, SymbolConfig const & symbolConfig,
bool duplicate = false);
BritikovKI marked this conversation as resolved.
Show resolved Hide resolved
SymRef declareFun(std::string const & fname, SRef rsort, vec<SRef> const & args) {
return declareFun(fname, rsort, args, SymConf::Default);
}
Expand All @@ -183,8 +184,9 @@ class Logic {
SymRef declareFun_NoScoping_Pairwise(std::string const & s, SRef rsort, vec<SRef> const & args) {
return declareFun(s, rsort, args, SymConf::NoScopingPairwise);
}
SymRef declareFun_Commutative_NoScoping_LeftAssoc(std::string const & s, SRef rsort, vec<SRef> const & args) {
return declareFun(s, rsort, args, SymConf::CommutativeNoScopingLeftAssoc);
SymRef declareFun_Commutative_NoScoping_LeftAssoc(std::string const & s, SRef rsort, vec<SRef> const & args,
bool duplicate = false) {
return declareFun(s, rsort, args, SymConf::CommutativeNoScopingLeftAssoc, duplicate);
}
SymRef declareFun_Commutative_NoScoping_Chainable(std::string const & s, SRef rsort, vec<SRef> const & args) {
return declareFun(s, rsort, args, SymConf::CommutativeNoScopingChainable);
Expand Down
9 changes: 4 additions & 5 deletions src/symbols/SymStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,19 @@ SymStore::~SymStore() {
free(idToName[i]);
}

SymRef SymStore::newSymb(char const * fname, SRef rsort, vec<SRef> const & args, SymbolConfig const & symConfig) {
SymRef SymStore::newSymb(char const * fname, SRef rsort, vec<SRef> const & args, SymbolConfig const & symConfig,
bool duplicate) {
BritikovKI marked this conversation as resolved.
Show resolved Hide resolved
// Check if there already is a term called fname with same number of arguments of the same sort
auto * symrefs = getRefOrNull(fname);

if (symrefs) {
if (symrefs && !duplicate) {
vec<SymRef> const & trs = *symrefs;
for (SymRef symref : trs) {
auto const & symbol = ta[symref];
if (symbol.rsort() == rsort and symbol.nargs() == args.size_() and
symbol.commutes() == symConfig.commutes and symbol.noScoping() == symConfig.noScoping and
symbol.isInterpreted() == symConfig.isInterpreted) {
if (std::equal(symbol.begin(), symbol.end(), args.begin()) && (strcmp(fname, "*") != 0)) {
return symref;
}
if (std::equal(symbol.begin(), symbol.end(), args.begin())) { return symref; }
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/symbols/SymStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class SymStore {
SymStore(SymStore &&) = default;
SymStore & operator=(SymStore &&) = default;
// Constructs a new symbol.
SymRef newSymb(char const * fname, SRef rsort, vec<SRef> const & args, SymbolConfig const & symConfig);
SymRef newSymb(char const * fname, SRef rsort, vec<SRef> const & args, SymbolConfig const & symConfig,
BritikovKI marked this conversation as resolved.
Show resolved Hide resolved
bool ignoreDuplicates = false);
SymRef newSymb(char const * fname, SRef rsort, vec<SRef> const & args) {
return newSymb(fname, rsort, args, SymConf::Default);
}
Expand Down