Skip to content

Commit b300ed9

Browse files
committed
NonlinWork: PR cleanup
1 parent 1518467 commit b300ed9

File tree

7 files changed

+6
-58
lines changed

7 files changed

+6
-58
lines changed

src/api/Interpret.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ void Interpret::interp(ASTNode& n) {
239239
}
240240
break;
241241
}
242-
// TODO: insertFormula
243242
case t_definefun: {
244243
if (isInitialized()) {
245244
defineFun(n);
@@ -426,13 +425,6 @@ PTRef Interpret::resolveTerm(const char* s, vec<PTRef>&& args, SRef sortRef, Sym
426425
return logic->resolveTerm(s, std::move(args), sortRef, symbolMatcher);
427426
}
428427

429-
//bool Interpret::checkNonlin(const PTRef formula) {
430-
// if(isTimes(formula)){
431-
//
432-
// }
433-
//
434-
//}
435-
436428
PTRef Interpret::parseTerm(const ASTNode& term, LetRecords& letRecords) {
437429
ASTType t = term.getType();
438430
if (t == TERM_T) {

src/api/MainSolver.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ sstat MainSolver::simplifyFormulas() {
147147
continue;
148148
}
149149
theory->afterPreprocessing(preprocessor.getPreprocessedFormulas());
150-
std::cout << "FLA Formulas: ";
151150
for (PTRef fla : frameFormulas) {
152-
std::cout << "Before:" << logic.pp(fla) << "\n";
153151
if (fla == logic.getTerm_true()) { continue; }
154152
assert(pmanager.getPartitionIndex(fla) != -1);
155153
// Optimize the dag for cnfization
@@ -160,7 +158,6 @@ sstat MainSolver::simplifyFormulas() {
160158
}
161159
assert(pmanager.getPartitionIndex(fla) != -1);
162160
pmanager.propagatePartitionMask(fla);
163-
std::cout << "After:" << logic.pp(fla) << "\n";
164161
status = giveToSolver(fla, frames[i].getId());
165162
if (status == s_False) { break; }
166163
}

src/api/MainSolver.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ class MainSolver {
108108
vec<PTRef> const & getAssertionsAtCurrentLevel() const { return getAssertionsAtLevel(getAssertionLevel()); }
109109
vec<PTRef> const & getAssertionsAtLevel(std::size_t) const;
110110

111-
[[deprecated("Use printCurrentAssertionsAsQuery")]] void printFramesAsQuery() const {
111+
[[deprecated("Use printCurrentAssertionsAsQuery")]]
112+
void printFramesAsQuery() const {
112113
printCurrentAssertionsAsQuery();
113114
}
114115
void printCurrentAssertionsAsQuery() const;

src/logics/ArithLogic.cc

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,6 @@ bool ArithLogic::isLinearFactor(PTRef tr) const {
182182
return term.size() == 2 &&
183183
((isNumConst(term[0]) && (isNumVarLike(term[1]))) || (isNumConst(term[1]) && (isNumVarLike(term[0]))));
184184
}
185-
if (isRealDiv(tr) || isIntDiv(tr)) {
186-
Pterm const & term = getPterm(tr);
187-
return (isNumConst(term[1]));
188-
}
189185
return false;
190186
}
191187

@@ -226,7 +222,6 @@ pair<Number, vec<PTRef>> ArithLogic::getConstantAndFactors(PTRef sum) const {
226222
assert(constant == PTRef_Undef);
227223
constant = arg;
228224
} else {
229-
// assert(isLinearFactor(arg) || isNonlinearFactor(arg));
230225
varFactors.push(arg);
231226
}
232227
}
@@ -237,12 +232,6 @@ pair<Number, vec<PTRef>> ArithLogic::getConstantAndFactors(PTRef sum) const {
237232
return {std::move(constantValue), std::move(varFactors)};
238233
}
239234

240-
pair<PTRef, PTRef> ArithLogic::splitTerm(PTRef term) const {
241-
PTRef fac = getPterm(term)[0];
242-
PTRef var = getPterm(term)[1];
243-
return {var, fac};
244-
}
245-
246235
pair<PTRef, PTRef> ArithLogic::splitTermToVarAndConst(PTRef term) const {
247236
assert(isTimes(term) || isNumVarLike(term) || isConstant(term));
248237
if (isTimes(term)) {
@@ -506,9 +495,8 @@ pair<lbool, Logic::SubstMap> ArithLogic::retrieveSubstitutions(vec<PtAsgn> const
506495

507496
uint32_t LessThan_deepPTRef::getVarIdFromProduct(PTRef tr) const {
508497
assert(l.isTimes(tr));
509-
auto [v1, v2] = l.splitTermToVarAndConst(tr);
510-
if (l.isNumVarLike(v1)) return v1.x;
511-
return v2.x;
498+
auto [v, c] = l.splitTermToVarAndConst(tr);
499+
return v.x;
512500
}
513501

514502
bool LessThan_deepPTRef::operator()(PTRef x_, PTRef y_) const {
@@ -561,7 +549,6 @@ PTRef ArithLogic::mkNeg(PTRef tr) {
561549
}
562550
if (isTimes(symref)) { // constant * var-like
563551
assert(getPterm(tr).size() == 2);
564-
// TODO: KB: NEG of TIMES
565552
auto [var, constant] = splitTermToVarAndConst(tr);
566553
return constant == getMinusOneForSort(getSortRef(symref)) ? var : mkFun(symref, {var, mkNeg(constant)});
567554
}
@@ -633,6 +620,7 @@ PTRef ArithLogic::mkPlus(vec<PTRef> && args) {
633620
};
634621
std::vector<Entry> simplified;
635622
simplified.reserve(args.size());
623+
636624
for (PTRef arg : args) {
637625
auto [v, c] = splitTermToVarAndConst(arg);
638626
assert(c != PTRef_Undef);
@@ -703,12 +691,7 @@ PTRef ArithLogic::mkTimes(vec<PTRef> && args) {
703691
PTRef tr = mkFun(s_new, std::move(args));
704692
// Either a real term or, if we constructed a multiplication of a
705693
// constant and a sum, a real sum.
706-
// if (isNumTerm(tr) || isPlus(tr) || isUF(tr) || isIte(tr))
707694
return tr;
708-
// else {
709-
// auto termStr = pp(tr);
710-
// throw LANonLinearException(termStr.c_str());
711-
// }
712695
}
713696

714697
SymRef ArithLogic::getLeqForSort(SRef sr) const {
@@ -848,7 +831,6 @@ PTRef ArithLogic::mkIntDiv(vec<PTRef> && args) {
848831
assert(args.size() == 2);
849832
PTRef dividend = args[0];
850833
PTRef divisor = args[1];
851-
// if (not isConstant(divisor)) { throw LANonLinearException("Divisor must be constant in linear logic"); }
852834
if (isZero(divisor)) { throw ArithDivisionByZeroException(); }
853835
if (isOne(divisor)) { return dividend; }
854836
if (isMinusOne(divisor)) { return mkNeg(dividend); }
@@ -869,18 +851,10 @@ PTRef ArithLogic::mkRealDiv(vec<PTRef> && args) {
869851
checkSortReal(args);
870852
if (args.size() != 2) { throw ApiException("Division operation requires exactly 2 arguments"); }
871853
if (isZero(args[1])) { throw ArithDivisionByZeroException(); }
872-
// if (not isConstant(args[1])) {
873-
// throw LANonLinearException("Only division by constant is permitted in linear arithmetic!");
874-
// }
875854
SimplifyConstDiv simp(*this);
876855
vec<PTRef> args_new;
877856
SymRef s_new;
878857
simp.simplify(get_sym_Real_DIV(), args, s_new, args_new);
879-
// if (isRealDiv(s_new)) {
880-
// assert((isNumTerm(args_new[0]) || isPlus(args_new[0])) && isConstant(args_new[1]));
881-
// args_new[1] = mkRealConst(getNumConst(args_new[1]).inverse()); // mkConst(1/getRealConst(args_new[1]));
882-
// return mkTimes(args_new);
883-
// }
884858
if (isRealDiv(s_new) && (isNumTerm(args_new[0]) || isPlus(args_new[0])) && isConstant(args_new[1])) {
885859
args_new[1] = mkRealConst(getNumConst(args_new[1]).inverse()); // mkConst(1/getRealConst(args_new[1]));
886860
return mkTimes(args_new);

src/logics/ArithLogic.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@
88
#include <numeric>
99

1010
namespace opensmt {
11-
class LANonLinearException : public std::runtime_error {
12-
public:
13-
LANonLinearException(char const * reason_) : runtime_error(reason_) {
14-
msg = "Term " + std::string(reason_) + " is non-linear";
15-
}
16-
virtual char const * what() const noexcept override { return msg.c_str(); }
17-
18-
private:
19-
std::string msg;
20-
};
2111

2212
class ArithDivisionByZeroException : public std::runtime_error {
2313
public:
@@ -461,7 +451,6 @@ class ArithLogic : public Logic {
461451
SymRef sym_Int_GT;
462452
SymRef sym_Int_ITE;
463453
SymRef sym_Int_DISTINCT;
464-
pair<PTRef, PTRef> splitTerm(PTRef term) const;
465454
};
466455

467456
// Determine for two multiplicative terms (* k1 v1) and (* k2 v2), v1 !=

src/logics/Logic.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ std::string Logic::disambiguateName(std::string const & protectedName, SRef sort
113113
assert(not protectedName.empty());
114114
if (not isNullary or isInterpreted) { return protectedName; }
115115

116-
auto isQuoted = [](std::string const & s) {
117-
return s.size() > 2 and * s.begin() == '|' and * (s.end() - 1) == '|';
118-
};
116+
auto isQuoted = [](std::string const & s) { return s.size() > 2 and *s.begin() == '|' and *(s.end() - 1) == '|'; };
119117
auto name = isQuoted(protectedName) ? std::string_view(protectedName.data() + 1, protectedName.size() - 2)
120118
: std::string_view(protectedName);
121119

src/rewriters/DivModRewriter.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ class DivModConfig : public DefaultRewriterConfig {
3737
PTRef rewritten = logic.isIntDiv(symRef) ? divVar : modVar;
3838
if (not inCache) {
3939
// collect the definitions to add
40-
if (!logic.isConstant(divisor)) {
41-
throw ApiException("Nonlinear expression in the SMT:" + logic.pp(term));
42-
}
4340
assert(logic.isConstant(divisor));
4441
auto divisorVal = logic.getNumConst(divisor);
4542
assert(divisorVal.isInteger());

0 commit comments

Comments
 (0)