Search in sources :

Example 86 with Expr

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;
}
Also used : FloatingPointType(org.sosy_lab.java_smt.api.FormulaType.FloatingPointType) CVC4.vectorType(edu.stanford.CVC4.vectorType) Type(edu.stanford.CVC4.Type) BitVectorType(edu.stanford.CVC4.BitVectorType) FormulaType(org.sosy_lab.java_smt.api.FormulaType) ArrayFormulaType(org.sosy_lab.java_smt.api.FormulaType.ArrayFormulaType) ArrayType(edu.stanford.CVC4.ArrayType) FunctionType(edu.stanford.CVC4.FunctionType) CVC4.vectorExpr(edu.stanford.CVC4.vectorExpr) Expr(edu.stanford.CVC4.Expr)

Example 87 with Expr

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);
}
Also used : Expr(edu.stanford.CVC4.Expr)

Example 88 with Expr

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);
}
Also used : BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Formula(org.sosy_lab.java_smt.api.Formula) Expr(edu.stanford.CVC4.Expr) ArrayList(java.util.ArrayList) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula)

Example 89 with Expr

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);
}
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 90 with Expr

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

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