Search in sources :

Example 1 with SmtExprPrinter

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

the class Z3QueryPrinter method print.

public String print(SmtCheckSatQuery smtQuery, long timeout) {
    StringBuffer buff = new StringBuffer();
    buff.append("(set-option :timeout " + timeout + ")");
    buff.append("\n");
    for (SmtConstantDeclaration constantDeclaration : smtQuery.getConstantDeclarations()) {
        String str = String.format("(declare-const %s %s)", constantDeclaration.getConstantName(), constantDeclaration.getConstantSort());
        buff.append(str);
        buff.append("\n");
    }
    SmtExprPrinter printer = new SmtExprPrinter();
    for (SmtAssertion assertionDeclaration : smtQuery.getAssertions()) {
        SmtExpr formula = assertionDeclaration.getFormula();
        String formulaStr = formula.accept(printer, null);
        String str = String.format("(assert %s)", formulaStr);
        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 : SmtAssertion(org.evosuite.symbolic.solver.smt.SmtAssertion) SmtExprPrinter(org.evosuite.symbolic.solver.smt.SmtExprPrinter) SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr) SmtConstantDeclaration(org.evosuite.symbolic.solver.smt.SmtConstantDeclaration)

Example 2 with SmtExprPrinter

use of org.evosuite.symbolic.solver.smt.SmtExprPrinter 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 3 with SmtExprPrinter

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

the class Z3Str2QueryPrinter method print.

public String print(SmtCheckSatQuery smtQuery) {
    StringBuffer buff = new StringBuffer();
    buff.append("\n");
    for (SmtConstantDeclaration constantDeclaration : smtQuery.getConstantDeclarations()) {
        String str = String.format("(declare-const %s %s)", constantDeclaration.getConstantName(), constantDeclaration.getConstantSort());
        buff.append(str);
        buff.append("\n");
    }
    for (SmtFunctionDefinition smtFunctionDefinition : smtQuery.getFunctionDefinitions()) {
        String str = String.format("(define-fun %s)", smtFunctionDefinition.getFunctionDefinition());
        buff.append(str);
        buff.append("\n");
    }
    SmtExprPrinter printer = new SmtExprPrinter();
    for (SmtAssertion assertionDeclaration : smtQuery.getAssertions()) {
        SmtExpr formula = assertionDeclaration.getFormula();
        String formulaStr = formula.accept(printer, null);
        String str = String.format("(assert %s)", formulaStr);
        buff.append(str);
        buff.append("\n");
    }
    buff.append("(check-sat)");
    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) SmtConstantDeclaration(org.evosuite.symbolic.solver.smt.SmtConstantDeclaration)

Aggregations

SmtAssertion (org.evosuite.symbolic.solver.smt.SmtAssertion)3 SmtExpr (org.evosuite.symbolic.solver.smt.SmtExpr)3 SmtExprPrinter (org.evosuite.symbolic.solver.smt.SmtExprPrinter)3 SmtConstantDeclaration (org.evosuite.symbolic.solver.smt.SmtConstantDeclaration)2 SmtFunctionDefinition (org.evosuite.symbolic.solver.smt.SmtFunctionDefinition)2 SmtFunctionDeclaration (org.evosuite.symbolic.solver.smt.SmtFunctionDeclaration)1