use of edu.stanford.CVC4.BitVector 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 edu.stanford.CVC4.BitVector 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 edu.stanford.CVC4.BitVector 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);
}
use of edu.stanford.CVC4.BitVector in project java-smt by sosy-lab.
the class CVC4NativeAPITest method checkQuantifierEliminationBV.
/**
* CVC4 does not support Bv quantifier elim. This is expected to fail!
*/
@Test
public void checkQuantifierEliminationBV() {
// build formula: exists y : bv[2]. x * y = 1
// quantifier-free equivalent: x = 1 | x = 3
// or extract_0_0 x = 1
int width = 2;
Expr xBv = exprMgr.mkVar("x_bv", exprMgr.mkBitVectorType(width));
Expr yBv = exprMgr.mkVar("y_bv", exprMgr.mkBitVectorType(width));
Expr body = exprMgr.mkExpr(Kind.EQUAL, exprMgr.mkExpr(Kind.MULT, xBv, yBv), exprMgr.mkConst(new BitVector(1)));
Expr xBound = exprMgr.mkBoundVar("y_bv", exprMgr.mkBitVectorType(width));
vectorExpr vec = new vectorExpr();
vec.add(xBound);
Expr quantifiedVars = exprMgr.mkExpr(Kind.BOUND_VAR_LIST, vec);
Expr bodySubst = body.substitute(yBv, xBound);
Expr assertion = exprMgr.mkExpr(Kind.EXISTS, quantifiedVars, bodySubst);
assertThrows(RuntimeException.class, () -> smtEngine.doQuantifierElimination(assertion, true));
}
use of edu.stanford.CVC4.BitVector in project java-smt by sosy-lab.
the class CVC4NativeAPITest method checkBvInvalidWidthCheckSat.
@Test
public void checkBvInvalidWidthCheckSat() {
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.checkSat(assertion));
assertThat(e.toString()).contains("constant of size 0");
}
Aggregations