@@ -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-
246235pair<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
507496uint32_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
514502bool 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
714697SymRef 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);
0 commit comments