Rational r = pi_factor.getConst<Rational>();
Rational r_abs = r.abs();
Rational rone = Rational(1);
- Node ntwo = nm->mkConstInt(Rational(2));
+ Rational rtwo = Rational(2);
if (r_abs > rone)
{
//add/substract 2*pi beyond scope
- Node ra_div_two = nm->mkNode(
- kind::INTS_DIVISION, mkRationalNode(r_abs + rone), ntwo);
+ Rational ra_div_two = (r_abs + rone) / rtwo;
Node new_pi_factor;
if( r.sgn()==1 ){
- new_pi_factor = nm->mkNode(
- kind::SUB, pi_factor, nm->mkNode(kind::MULT, ntwo, ra_div_two));
+ new_pi_factor = nm->mkConstReal(r - rtwo * ra_div_two.floor());
}else{
Assert(r.sgn() == -1);
- new_pi_factor =
- nm->mkNode(kind::PLUS,
- pi_factor,
- nm->mkNode(kind::MULT, ntwo, ra_div_two));
+ new_pi_factor = nm->mkConstReal(r + rtwo * ra_div_two.floor());
}
Node new_arg = nm->mkNode(kind::MULT, new_pi_factor, pi);
if (!rem.isNull())
ASSERT_THROW(s2.instantiate({s1}), CVC5ApiException);
}
+TEST_F(TestApiBlackSolver, proj_issue414)
+{
+ Solver slv;
+ Sort s2 = slv.getRealSort();
+ Term t1 = slv.mkConst(s2, "_x0");
+ Term t16 = slv.mkTerm(Kind::PI);
+ Term t53 = slv.mkTerm(Kind::MINUS, {t1, t16});
+ Term t54 = slv.mkTerm(Kind::SECANT, {t53});
+ ASSERT_NO_THROW(slv.simplify(t54));
+}
+
} // namespace test
} // namespace cvc5