use of edu.stanford.CVC4.RoundingMode in project java-smt by sosy-lab.
the class CVC4NativeAPITest method checkSimpleFPUnsat.
@Test
public void checkSimpleFPUnsat() {
// x * y = 1/4 AND x > 0 AND y < 0
RoundingMode rm = RoundingMode.roundNearestTiesToAway;
Expr rmExpr = exprMgr.mkConst(rm);
Expr oneFourth = exprMgr.mkConst(new FloatingPoint(new FloatingPointSize(8, 24), rm, new Rational(1, 4)));
Expr zero = exprMgr.mkConst(new FloatingPoint(new FloatingPointSize(8, 24), RoundingMode.roundNearestTiesToAway, new Rational(0)));
Expr varX = exprMgr.mkVar("x", exprMgr.mkFloatingPointType(8, 24));
Expr varY = exprMgr.mkVar("y", exprMgr.mkFloatingPointType(8, 24));
Expr assertion1 = exprMgr.mkExpr(Kind.FLOATINGPOINT_EQ, exprMgr.mkExpr(Kind.FLOATINGPOINT_MULT, rmExpr, varX, varY), oneFourth);
Expr assertion2 = exprMgr.mkExpr(Kind.FLOATINGPOINT_GT, varX, zero);
Expr assertion3 = exprMgr.mkExpr(Kind.FLOATINGPOINT_LT, varY, zero);
smtEngine.assertFormula(assertion1);
smtEngine.assertFormula(assertion2);
smtEngine.assertFormula(assertion3);
Result satCheck = smtEngine.checkSat();
assertThat(satCheck.isSat()).isEqualTo(Sat.UNSAT);
}
use of edu.stanford.CVC4.RoundingMode in project java-smt by sosy-lab.
the class CVC4NativeAPITest method checkSimpleFPSat.
/**
* Do not ever try to use decimals in a new Rational that has only a 0 as decimal. This will
* SIGSEV CVC4!
*/
@Test
public void checkSimpleFPSat() {
// x * y = 1/4
RoundingMode rm = RoundingMode.roundNearestTiesToAway;
Expr rmExpr = exprMgr.mkConst(rm);
Expr oneFourth = exprMgr.mkConst(new FloatingPoint(new FloatingPointSize(8, 24), rm, new Rational(1, 4)));
Expr varX = exprMgr.mkVar("x", exprMgr.mkFloatingPointType(8, 24));
Expr varY = exprMgr.mkVar("y", exprMgr.mkFloatingPointType(8, 24));
Expr assertion1 = exprMgr.mkExpr(Kind.FLOATINGPOINT_EQ, exprMgr.mkExpr(Kind.FLOATINGPOINT_MULT, rmExpr, varX, varY), oneFourth);
smtEngine.assertFormula(assertion1);
Result satCheck = smtEngine.checkSat();
assertThat(satCheck.isSat()).isEqualTo(Sat.SAT);
}
Aggregations