Search in sources :

Example 31 with Expr

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");
}
Also used : BitVector(edu.stanford.CVC4.BitVector) CVC4.vectorExpr(edu.stanford.CVC4.vectorExpr) SExpr(edu.stanford.CVC4.SExpr) Expr(edu.stanford.CVC4.Expr) AssumptionViolatedException(org.junit.AssumptionViolatedException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Test(org.junit.Test)

Example 32 with Expr

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);
}
Also used : FloatingPointSize(edu.stanford.CVC4.FloatingPointSize) CVC4.vectorExpr(edu.stanford.CVC4.vectorExpr) SExpr(edu.stanford.CVC4.SExpr) Expr(edu.stanford.CVC4.Expr) Rational(edu.stanford.CVC4.Rational) RoundingMode(edu.stanford.CVC4.RoundingMode) FloatingPoint(edu.stanford.CVC4.FloatingPoint) Result(edu.stanford.CVC4.Result) Test(org.junit.Test)

Example 33 with Expr

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);
}
Also used : BitVector(edu.stanford.CVC4.BitVector) CVC4.vectorExpr(edu.stanford.CVC4.vectorExpr) SExpr(edu.stanford.CVC4.SExpr) Expr(edu.stanford.CVC4.Expr) Result(edu.stanford.CVC4.Result) Test(org.junit.Test)

Example 34 with Expr

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);
}
Also used : Type(edu.stanford.CVC4.Type) SortType(edu.stanford.CVC4.SortType) ArrayType(edu.stanford.CVC4.ArrayType) BitVectorType(edu.stanford.CVC4.BitVectorType) CVC4.vectorExpr(edu.stanford.CVC4.vectorExpr) SExpr(edu.stanford.CVC4.SExpr) Expr(edu.stanford.CVC4.Expr) Result(edu.stanford.CVC4.Result) Test(org.junit.Test)

Example 35 with Expr

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);
}
Also used : BitVector(edu.stanford.CVC4.BitVector) CVC4.vectorExpr(edu.stanford.CVC4.vectorExpr) SExpr(edu.stanford.CVC4.SExpr) Expr(edu.stanford.CVC4.Expr) Result(edu.stanford.CVC4.Result) Test(org.junit.Test)

Aggregations

Expr (edu.stanford.CVC4.Expr)57 Test (org.junit.Test)55 CVC4.vectorExpr (edu.stanford.CVC4.vectorExpr)49 SExpr (edu.stanford.CVC4.SExpr)42 Expr (com.microsoft.z3.Expr)32 Result (edu.stanford.CVC4.Result)32 Rational (edu.stanford.CVC4.Rational)28 Expr (com.google.api.expr.v1alpha1.Expr)23 BoolExpr (com.microsoft.z3.BoolExpr)22 ArrayType (edu.stanford.CVC4.ArrayType)12 BitVectorType (edu.stanford.CVC4.BitVectorType)12 Status (com.microsoft.z3.Status)11 Type (edu.stanford.CVC4.Type)11 HashMap (java.util.HashMap)11 Test (org.junit.jupiter.api.Test)11 ParsedExpr (com.google.api.expr.v1alpha1.ParsedExpr)10 CheckedExpr (com.google.api.expr.v1alpha1.CheckedExpr)9 ArithExpr (com.microsoft.z3.ArithExpr)8 BitVecExpr (com.microsoft.z3.BitVecExpr)8 Val (org.projectnessie.cel.common.types.ref.Val)7