// resulting rational here. This also is applied for integral real values
// like 5.0 which are converted to (/ 5 1) to distinguish them from
// integer constants. We must ensure numerator and denominator are
- // constant and the denominator is non-zero.
- if (constVal.getKind() == api::DIVISION)
+ // constant and the denominator is non-zero. A similar issue happens for
+ // negative integers and reals, with unary minus.
+ bool isNeg = false;
+ if (constVal.getKind() == api::UMINUS)
+ {
+ isNeg = true;
+ constVal = constVal[0];
+ }
+ if (constVal.getKind() == api::DIVISION
+ && constVal[0].getKind() == api::CONST_RATIONAL
+ && constVal[1].getKind() == api::CONST_RATIONAL)
{
std::stringstream sdiv;
- sdiv << constVal[0] << "/" << constVal[1];
+ sdiv << (isNeg ? "-" : "") << constVal[0] << "/" << constVal[1];
constVal = d_solver->mkReal(sdiv.str());
}
+ else if (constVal.getKind() == api::CONST_RATIONAL && isNeg)
+ {
+ std::stringstream sneg;
+ sneg << "-" << constVal;
+ constVal = d_solver->mkInteger(sneg.str());
+ }
+ else
+ {
+ constVal = args[0];
+ }
if (!p.d_type.getArrayElementSort().isComparableTo(constVal.getSort()))
{
regress0/arrays/issue3813-massign-assert.smt2
regress0/arrays/issue3814.smt2
regress0/arrays/issue4927-unsat-cores.smt2
+ regress0/arrays/issue7596-define-array-uminus.smt2
regress0/arrays/swap_t1_np_nf_ai_00005_007.cvc.smtv1.smt2
regress0/arrays/x2.smtv1.smt2
regress0/arrays/x3.smtv1.smt2