use of com.google.api.expr.v1alpha1.Expr in project java-smt by sosy-lab.
the class CVC4NativeAPITest method checkBvInvalidWidthAssertion.
@Test
public void checkBvInvalidWidthAssertion() {
Expr bvOne = exprMgr.mkConst(new BitVector(0, 1));
Expr assertion = exprMgr.mkExpr(Kind.EQUAL, bvOne, bvOne);
Exception e = assertThrows(edu.stanford.CVC4.Exception.class, () -> smtEngine.assertFormula(assertion));
assertThat(e.toString()).contains("constant of size 0");
}
use of com.google.api.expr.v1alpha1.Expr 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 com.google.api.expr.v1alpha1.Expr in project java-smt by sosy-lab.
the class CVC4NativeAPITest method checkSimpleBvEqualitySat.
@Test
public void checkSimpleBvEqualitySat() {
// 1 + 0 = 1 with bitvectors
Expr bvOne = exprMgr.mkConst(new BitVector(16, 1));
Expr bvZero = exprMgr.mkConst(new BitVector(16, 0));
Expr assertion = exprMgr.mkExpr(Kind.EQUAL, exprMgr.mkExpr(Kind.BITVECTOR_PLUS, bvZero, bvOne), bvOne);
smtEngine.assertFormula(assertion);
Result satCheck = smtEngine.checkSat();
assertThat(satCheck.isSat()).isEqualTo(Sat.SAT);
}
use of com.google.api.expr.v1alpha1.Expr in project java-smt by sosy-lab.
the class CVC4NativeAPITest method checkBooleanUFDeclaration.
@Test
public void checkBooleanUFDeclaration() {
Type boolType = exprMgr.booleanType();
Type intType = exprMgr.integerType();
// arg is bool, return is int
Type ufType = exprMgr.mkFunctionType(boolType, intType);
Expr uf = exprMgr.mkVar("fun_bi", ufType);
Expr ufTrue = exprMgr.mkExpr(uf, exprMgr.mkConst(true));
Expr ufFalse = exprMgr.mkExpr(uf, exprMgr.mkConst(false));
Expr assumptions = exprMgr.mkExpr(Kind.NOT, exprMgr.mkExpr(Kind.EQUAL, ufTrue, ufFalse));
smtEngine.assertFormula(assumptions);
Result satCheck = smtEngine.checkSat();
assertThat(satCheck.isSat()).isEqualTo(Sat.SAT);
}
use of com.google.api.expr.v1alpha1.Expr in project java-smt by sosy-lab.
the class CVC4NativeAPITest method checkSimpleBvEqualityUnsat.
@Test
public void checkSimpleBvEqualityUnsat() {
// 0 + 1 = 2 UNSAT with bitvectors
Expr bvZero = exprMgr.mkConst(new BitVector(16, 0));
Expr bvOne = exprMgr.mkConst(new BitVector(16, 1));
Expr bvTwo = exprMgr.mkConst(new BitVector(16, 2));
Expr assertion = exprMgr.mkExpr(Kind.EQUAL, exprMgr.mkExpr(Kind.BITVECTOR_PLUS, bvZero, bvOne), bvTwo);
smtEngine.assertFormula(assertion);
Result satCheck = smtEngine.checkSat();
assertThat(satCheck.isSat()).isEqualTo(Sat.UNSAT);
}
Aggregations