Search in sources :

Example 26 with SmtExpr

use of org.evosuite.symbolic.solver.smt.SmtExpr in project evosuite by EvoSuite.

the class RegExpToCVC4Visitor method visitRepeatMinMax.

@Override
public SmtExpr visitRepeatMinMax(RegExp e, int min, int max) {
    SmtExpr regExpr = this.visitRegExp(e);
    if (regExpr == null) {
        return null;
    }
    SmtIntConstant minExpr = SmtExprBuilder.mkIntConstant(min);
    SmtIntConstant maxExpr = SmtExprBuilder.mkIntConstant(max);
    SmtExpr loopExpr = SmtExprBuilder.mkLoop(regExpr, minExpr, maxExpr);
    return loopExpr;
}
Also used : SmtIntConstant(org.evosuite.symbolic.solver.smt.SmtIntConstant) SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr)

Example 27 with SmtExpr

use of org.evosuite.symbolic.solver.smt.SmtExpr in project evosuite by EvoSuite.

the class CVC4QueryPrinter method print.

public String print(SmtCheckSatQuery smtQuery) {
    StringBuffer buff = new StringBuffer();
    buff.append("\n");
    buff.append("(set-logic " + CVC4_LOGIC + ")");
    buff.append("\n");
    buff.append("(set-option :produce-models true)");
    buff.append("\n");
    buff.append("(set-option :strings-exp true)");
    buff.append("\n");
    for (SmtFunctionDeclaration functionDeclaration : smtQuery.getFunctionDeclarations()) {
        String str = String.format("(declare-fun %s () %s)", functionDeclaration.getFunctionName(), functionDeclaration.getFunctionSort());
        buff.append(str);
        buff.append("\n");
    }
    for (SmtFunctionDefinition functionDeclaration : smtQuery.getFunctionDefinitions()) {
        String str = String.format("(define-fun %s)", functionDeclaration.getFunctionDefinition());
        buff.append(str);
        buff.append("\n");
    }
    SmtExprPrinter printer = new SmtExprPrinter();
    for (SmtAssertion smtAssertion : smtQuery.getAssertions()) {
        SmtExpr smtExpr = smtAssertion.getFormula();
        String smtExprStr = smtExpr.accept(printer, null);
        String str = String.format("(assert %s)", smtExprStr);
        buff.append(str);
        buff.append("\n");
    }
    buff.append("(check-sat)");
    buff.append("\n");
    buff.append("(get-model)");
    buff.append("\n");
    buff.append("(exit)");
    buff.append("\n");
    return buff.toString();
}
Also used : SmtFunctionDefinition(org.evosuite.symbolic.solver.smt.SmtFunctionDefinition) SmtAssertion(org.evosuite.symbolic.solver.smt.SmtAssertion) SmtExprPrinter(org.evosuite.symbolic.solver.smt.SmtExprPrinter) SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr) SmtFunctionDeclaration(org.evosuite.symbolic.solver.smt.SmtFunctionDeclaration)

Example 28 with SmtExpr

use of org.evosuite.symbolic.solver.smt.SmtExpr in project evosuite by EvoSuite.

the class ConstraintToZ3Visitor method visit.

@Override
public SmtExpr visit(StringConstraint c, Void arg) {
    ExprToZ3Visitor v = new ExprToZ3Visitor();
    StringComparison stringComparison = (StringComparison) c.getLeftOperand();
    IntegerConstant integerConstant = (IntegerConstant) c.getRightOperand();
    SmtExpr left = stringComparison.accept(v, null);
    SmtExpr right = integerConstant.accept(v, null);
    if (left == null || right == null) {
        return null;
    }
    Comparator cmp = c.getComparator();
    return mkComparison(left, cmp, right);
}
Also used : StringComparison(org.evosuite.symbolic.expr.bv.StringComparison) SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr) IntegerConstant(org.evosuite.symbolic.expr.bv.IntegerConstant) Comparator(org.evosuite.symbolic.expr.Comparator)

Example 29 with SmtExpr

use of org.evosuite.symbolic.solver.smt.SmtExpr in project evosuite by EvoSuite.

the class ConstraintToZ3Visitor method visit.

@Override
public SmtExpr visit(RealConstraint c, Void arg) {
    ExprToZ3Visitor v = new ExprToZ3Visitor();
    SmtExpr left = c.getLeftOperand().accept(v, null);
    SmtExpr right = c.getRightOperand().accept(v, null);
    if (left == null || right == null) {
        return null;
    }
    Comparator cmp = c.getComparator();
    SmtExpr boolExpr = mkComparison(left, cmp, right);
    return boolExpr;
}
Also used : SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr) Comparator(org.evosuite.symbolic.expr.Comparator)

Example 30 with SmtExpr

use of org.evosuite.symbolic.solver.smt.SmtExpr in project evosuite by EvoSuite.

the class ExprToZ3Visitor method visit.

@Override
public SmtExpr visit(RealToIntegerCast e, Void v) {
    SmtExpr realExpr = e.getArgument().accept(this, null);
    if (realExpr == null) {
        return null;
    }
    if (!realExpr.isSymbolic()) {
        long longValue = e.getConcreteValue();
        return SmtExprBuilder.mkIntConstant(longValue);
    }
    SmtExpr intExpr = SmtExprBuilder.mkReal2Int(realExpr);
    return intExpr;
}
Also used : SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr)

Aggregations

SmtExpr (org.evosuite.symbolic.solver.smt.SmtExpr)60 Operator (org.evosuite.symbolic.expr.Operator)14 LinkedList (java.util.LinkedList)8 Comparator (org.evosuite.symbolic.expr.Comparator)6 SmtAssertion (org.evosuite.symbolic.solver.smt.SmtAssertion)6 SmtIntConstant (org.evosuite.symbolic.solver.smt.SmtIntConstant)6 SmtConstantDeclaration (org.evosuite.symbolic.solver.smt.SmtConstantDeclaration)5 Expression (org.evosuite.symbolic.expr.Expression)4 IntegerBinaryExpression (org.evosuite.symbolic.expr.bv.IntegerBinaryExpression)4 IntegerUnaryExpression (org.evosuite.symbolic.expr.bv.IntegerUnaryExpression)4 RealUnaryToIntegerExpression (org.evosuite.symbolic.expr.bv.RealUnaryToIntegerExpression)4 StringBinaryToIntegerExpression (org.evosuite.symbolic.expr.bv.StringBinaryToIntegerExpression)4 StringMultipleToIntegerExpression (org.evosuite.symbolic.expr.bv.StringMultipleToIntegerExpression)4 StringUnaryToIntegerExpression (org.evosuite.symbolic.expr.bv.StringUnaryToIntegerExpression)4 RealBinaryExpression (org.evosuite.symbolic.expr.fp.RealBinaryExpression)4 RealUnaryExpression (org.evosuite.symbolic.expr.fp.RealUnaryExpression)4 GetFieldExpression (org.evosuite.symbolic.expr.ref.GetFieldExpression)4 StringBinaryExpression (org.evosuite.symbolic.expr.str.StringBinaryExpression)4 StringMultipleExpression (org.evosuite.symbolic.expr.str.StringMultipleExpression)4 StringUnaryExpression (org.evosuite.symbolic.expr.str.StringUnaryExpression)4