Search in sources :

Example 26 with Result

use of com.walmartlabs.concord.plugins.s3.Result 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 27 with Result

use of com.walmartlabs.concord.plugins.s3.Result 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 28 with Result

use of com.walmartlabs.concord.plugins.s3.Result 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)

Example 29 with Result

use of com.walmartlabs.concord.plugins.s3.Result in project java-smt by sosy-lab.

the class CVC4NativeAPITest method checkSimpleEqualityUnsat.

@Test
public void checkSimpleEqualityUnsat() {
    Expr zero = exprMgr.mkConst(new Rational(0));
    Expr one = exprMgr.mkConst(new Rational(1));
    Expr assertion = exprMgr.mkExpr(Kind.EQUAL, zero, one);
    smtEngine.assertFormula(assertion);
    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 30 with Result

use of com.walmartlabs.concord.plugins.s3.Result 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);
}
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)

Aggregations

Test (org.junit.Test)46 Result (edu.stanford.CVC4.Result)35 Expr (edu.stanford.CVC4.Expr)32 SExpr (edu.stanford.CVC4.SExpr)32 CVC4.vectorExpr (edu.stanford.CVC4.vectorExpr)31 Rational (edu.stanford.CVC4.Rational)25 Result (com.opensymphony.xwork2.Result)18 List (java.util.List)15 ArrayList (java.util.ArrayList)13 ArrayType (edu.stanford.CVC4.ArrayType)8 CompletableFuture (java.util.concurrent.CompletableFuture)8 TimeUnit (java.util.concurrent.TimeUnit)8 DataSource (jdk.incubator.sql2.DataSource)8 Result (jdk.incubator.sql2.Result)8 Session (jdk.incubator.sql2.Session)8 AfterClass (org.junit.AfterClass)8 BeforeClass (org.junit.BeforeClass)8 BitVectorType (edu.stanford.CVC4.BitVectorType)6 SortType (edu.stanford.CVC4.SortType)6 Type (edu.stanford.CVC4.Type)6