use of com.google.api.expr.v1alpha1.Expr in project java-smt by sosy-lab.
the class CVC4FormulaCreator method makeBoundCopy.
/**
* Makes a bound copy of a variable for use in quantifier. Note that all occurrences of the free
* var have to be substituted by the bound once it exists.
*
* @param var Variable you want a bound copy of.
* @return Bound Variable
*/
public Expr makeBoundCopy(Expr var) {
Type type = var.getType();
String name = getName(var);
Expr boundCopy = exprManager.mkBoundVar(name, type);
return boundCopy;
}
use of com.google.api.expr.v1alpha1.Expr in project java-smt by sosy-lab.
the class CVC4IntegerFormulaManager method modularCongruence.
@Override
protected Expr modularCongruence(Expr pNumber1, Expr pNumber2, BigInteger pModulo) {
// ((_ divisible n) x) <==> (= x (* n (div x n)))
if (BigInteger.ZERO.compareTo(pModulo) < 0) {
Expr n = makeNumberImpl(pModulo);
Expr x = subtract(pNumber1, pNumber2);
return exprManager.mkExpr(Kind.EQUAL, x, exprManager.mkExpr(Kind.MULT, n, exprManager.mkExpr(Kind.INTS_DIVISION, x, n)));
}
return exprManager.mkConst(true);
}
use of com.google.api.expr.v1alpha1.Expr in project java-smt by sosy-lab.
the class CVC4Model method getAssignment.
private ValueAssignment getAssignment(Expr pKeyTerm) {
List<Object> argumentInterpretation = new ArrayList<>();
for (Expr param : pKeyTerm) {
argumentInterpretation.add(evaluateImpl(param));
}
// extract UF name
Expr name = pKeyTerm.hasOperator() ? pKeyTerm.getOperator() : pKeyTerm;
String nameStr = name.toString();
if (nameStr.startsWith("|") && nameStr.endsWith("|")) {
nameStr = nameStr.substring(1, nameStr.length() - 1);
}
Expr valueTerm = getValue(pKeyTerm);
Formula keyFormula = creator.encapsulateWithTypeOf(pKeyTerm);
Formula valueFormula = creator.encapsulateWithTypeOf(valueTerm);
BooleanFormula equation = creator.encapsulateBoolean(creator.getEnv().mkExpr(Kind.EQUAL, pKeyTerm, valueTerm));
Object value = creator.convertValue(pKeyTerm, valueTerm);
return new ValueAssignment(keyFormula, valueFormula, equation, nameStr, value, argumentInterpretation);
}
use of com.google.api.expr.v1alpha1.Expr in project java-smt by sosy-lab.
the class CVC4NativeAPITest method checkSimpleInequalityUnsat.
@Test
public void checkSimpleInequalityUnsat() {
Expr one = exprMgr.mkConst(new Rational(1));
Expr assertion = exprMgr.mkExpr(Kind.NOT, exprMgr.mkExpr(Kind.EQUAL, one, one));
smtEngine.assertFormula(assertion);
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 checkSimpleLIASat.
@Test
public void checkSimpleLIASat() {
// x + y = 4 AND x * y = 4
Expr four = exprMgr.mkConst(new Rational(4));
Expr varX = exprMgr.mkVar("x", exprMgr.integerType());
Expr varY = exprMgr.mkVar("y", exprMgr.integerType());
Expr assertion1 = exprMgr.mkExpr(Kind.EQUAL, exprMgr.mkExpr(Kind.MULT, varX, varY), four);
Expr assertion2 = exprMgr.mkExpr(Kind.EQUAL, exprMgr.mkExpr(Kind.PLUS, varX, varY), four);
smtEngine.assertFormula(assertion1);
smtEngine.assertFormula(assertion2);
Result satCheck = smtEngine.checkSat();
assertThat(satCheck.isSat()).isEqualTo(Sat.SAT);
assertThat(getInt(varX) + getInt(varY)).isEqualTo(4);
assertThat(getInt(varX) * getInt(varY)).isEqualTo(4);
}
Aggregations