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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations