@@ -195,13 +195,25 @@ bool ArithLogic::isLinearTerm(PTRef tr) const {
195195}
196196
197197bool ArithLogic::isNonlin (PTRef tr) const {
198+ if (isPlus (tr)) {
199+ Pterm const & term = getPterm (tr);
200+ for (auto subterm : term) {
201+ if (isNonlin (subterm)) return true ;
202+ }
203+ }
198204 if (isTimes (tr)) {
199205 Pterm const & term = getPterm (tr);
200- return (not isConstant (term[0 ]) && not isConstant (term[1 ]));
206+ if (not isConstant (term[0 ]) && not isConstant (term[1 ])) return true ;
207+ for (auto subterm : term) {
208+ if (isNonlin (subterm)) return true ;
209+ }
201210 }
202211 if (isRealDiv (tr) || isIntDiv (tr) || isMod (getPterm (tr).symb ())) {
203212 Pterm const & term = getPterm (tr);
204- return (not isConstant (term[1 ]));
213+ if (not isConstant (term[1 ])) return true ;
214+ for (auto subterm : term) {
215+ if (isNonlin (subterm)) return true ;
216+ }
205217 }
206218 return false ;
207219};
@@ -419,13 +431,12 @@ lbool ArithLogic::arithmeticElimination(vec<PTRef> const & top_level_arith, Subs
419431 PTRef lhs = logic.getPterm (eq)[0 ];
420432 PTRef rhs = logic.getPterm (eq)[1 ];
421433 PTRef polyTerm = lhs == logic.getZeroForSort (logic.getSortRef (lhs)) ? rhs : logic.mkMinus (rhs, lhs);
422- assert (logic.isLinearTerm (polyTerm));
423434 if (logic.isLinearFactor (polyTerm)) {
424435 auto [var, c] = logic.splitTermToVarAndConst (polyTerm);
425436 auto coeff = logic.getNumConst (c);
426437 poly.addTerm (var, std::move (coeff));
427438 } else {
428- assert (logic.isPlus (polyTerm));
439+ assert (logic.isPlus (polyTerm) || logic. isTimes (polyTerm) );
429440 for (PTRef factor : logic.getPterm (polyTerm)) {
430441 auto [var, c] = logic.splitTermToVarAndConst (factor);
431442 auto coeff = logic.getNumConst (c);
0 commit comments