Search in sources :

Example 26 with Expr

use of com.google.api.expr.v1alpha1.Expr in project java-smt by sosy-lab.

the class CVC4NativeAPITest method checkSimpleLRAUnsat.

@Test
public void checkSimpleLRAUnsat() {
    // x + y = x * y AND x - 1 = 0
    Expr zero = exprMgr.mkConst(new Rational(0));
    Expr one = exprMgr.mkConst(new Rational(1));
    Expr varX = exprMgr.mkVar("x", exprMgr.realType());
    Expr varY = exprMgr.mkVar("y", exprMgr.realType());
    Expr assertion1 = exprMgr.mkExpr(Kind.EQUAL, exprMgr.mkExpr(Kind.NONLINEAR_MULT, varX, varY), exprMgr.mkExpr(Kind.PLUS, varX, varY));
    Expr assertion2 = exprMgr.mkExpr(Kind.EQUAL, exprMgr.mkExpr(Kind.MINUS, varX, one), zero);
    smtEngine.assertFormula(assertion1);
    smtEngine.assertFormula(assertion2);
    Result satCheck = smtEngine.checkSat();
    assertThat(satCheck.isSat()).isEqualTo(Sat.UNSAT);
}
Also used : CVC4.vectorExpr(edu.stanford.CVC4.vectorExpr) SExpr(edu.stanford.CVC4.SExpr) Expr(edu.stanford.CVC4.Expr) Rational(edu.stanford.CVC4.Rational) Result(edu.stanford.CVC4.Result) Test(org.junit.Test)

Example 27 with Expr

use of com.google.api.expr.v1alpha1.Expr in project java-smt by sosy-lab.

the class CVC4NativeAPITest method checkSimpleInequalitySat.

@Test
public void checkSimpleInequalitySat() {
    Expr zero = exprMgr.mkConst(new Rational(0));
    Expr one = exprMgr.mkConst(new Rational(1));
    Expr assertion = exprMgr.mkExpr(Kind.NOT, exprMgr.mkExpr(Kind.EQUAL, zero, one));
    smtEngine.assertFormula(assertion);
    Result satCheck = smtEngine.checkSat();
    assertThat(satCheck.isSat()).isEqualTo(Sat.SAT);
}
Also used : CVC4.vectorExpr(edu.stanford.CVC4.vectorExpr) SExpr(edu.stanford.CVC4.SExpr) Expr(edu.stanford.CVC4.Expr) Rational(edu.stanford.CVC4.Rational) Result(edu.stanford.CVC4.Result) Test(org.junit.Test)

Example 28 with Expr

use of com.google.api.expr.v1alpha1.Expr in project java-smt by sosy-lab.

the class CVC4NativeAPITest method checkLIAUfsUnsat.

@Test
public void checkLIAUfsUnsat() {
    // 0 <= f(x)
    // 0 <= f(y)
    // f(x) + f(y) = x
    // f(x) + f(y) = y
    // f(x) = x + 1
    // f(y) = y - 1
    Expr zero = exprMgr.mkConst(new Rational(0));
    Expr one = exprMgr.mkConst(new Rational(1));
    Type intType = exprMgr.integerType();
    // Type for UFs later
    Type intToInt = exprMgr.mkFunctionType(intType, intType);
    Expr xInt = exprMgr.mkVar("x", intType);
    Expr yInt = exprMgr.mkVar("y", intType);
    // declare UFs
    Expr f = exprMgr.mkVar("f", intToInt);
    // Apply UFs
    Expr fx = exprMgr.mkExpr(Kind.APPLY_UF, f, xInt);
    Expr fy = exprMgr.mkExpr(Kind.APPLY_UF, f, yInt);
    Expr plus = exprMgr.mkExpr(Kind.PLUS, fx, fy);
    // Make some assumptions
    Expr assumptions1 = exprMgr.mkExpr(Kind.AND, exprMgr.mkExpr(Kind.LEQ, zero, fx), exprMgr.mkExpr(Kind.LEQ, zero, fy));
    Expr assumptions2 = exprMgr.mkExpr(Kind.AND, exprMgr.mkExpr(Kind.EQUAL, fx, exprMgr.mkExpr(Kind.PLUS, xInt, one)), exprMgr.mkExpr(Kind.EQUAL, fy, exprMgr.mkExpr(Kind.MINUS, yInt, one)), exprMgr.mkExpr(Kind.EQUAL, plus, xInt), exprMgr.mkExpr(Kind.EQUAL, plus, yInt));
    smtEngine.assertFormula(assumptions1);
    smtEngine.assertFormula(assumptions2);
    Result satCheck = smtEngine.checkSat();
    assertThat(satCheck.isSat()).isEqualTo(Sat.UNSAT);
}
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) Rational(edu.stanford.CVC4.Rational) Result(edu.stanford.CVC4.Result) Test(org.junit.Test)

Example 29 with Expr

use of com.google.api.expr.v1alpha1.Expr in project java-smt by sosy-lab.

the class CVC4NativeAPITest method checkSimpleLIAEqualitySat.

@Test
public void checkSimpleLIAEqualitySat() {
    Expr one = exprMgr.mkConst(new Rational(1));
    Expr two = exprMgr.mkConst(new Rational(2));
    Expr assertion = exprMgr.mkExpr(Kind.EQUAL, exprMgr.mkExpr(Kind.PLUS, one, one), two);
    smtEngine.assertFormula(assertion);
    Result satCheck = smtEngine.checkSat();
    assertThat(satCheck.isSat()).isEqualTo(Sat.SAT);
}
Also used : CVC4.vectorExpr(edu.stanford.CVC4.vectorExpr) SExpr(edu.stanford.CVC4.SExpr) Expr(edu.stanford.CVC4.Expr) Rational(edu.stanford.CVC4.Rational) Result(edu.stanford.CVC4.Result) Test(org.junit.Test)

Example 30 with Expr

use of com.google.api.expr.v1alpha1.Expr in project java-smt by sosy-lab.

the class CVC4NativeAPITest method setupArrayQuant.

/**
 * Sets up array and quantifier based formulas for tests.
 */
public void setupArrayQuant() {
    Expr zero = exprMgr.mkConst(new Rational(0));
    Expr one = exprMgr.mkConst(new Rational(1));
    x = exprMgr.mkVar("x", exprMgr.integerType());
    ArrayType arrayType = exprMgr.mkArrayType(exprMgr.integerType(), exprMgr.integerType());
    array = exprMgr.mkVar("a", arrayType);
    aAtxEq0 = exprMgr.mkExpr(Kind.EQUAL, exprMgr.mkExpr(Kind.SELECT, array, x), zero);
    aAtxEq1 = exprMgr.mkExpr(Kind.EQUAL, exprMgr.mkExpr(Kind.SELECT, array, x), one);
}
Also used : ArrayType(edu.stanford.CVC4.ArrayType) CVC4.vectorExpr(edu.stanford.CVC4.vectorExpr) SExpr(edu.stanford.CVC4.SExpr) Expr(edu.stanford.CVC4.Expr) Rational(edu.stanford.CVC4.Rational)

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