Search in sources :

Example 1 with SolutionFinder

use of de.bmoth.backend.z3.SolutionFinder in project bmoth by hhu-stups.

the class Issue73Test method testSatPredicateWithoutModel.

@Test
public void testSatPredicateWithoutModel() throws IOException {
    String formula = "1 < 2";
    BoolExpr constraint = translatePredicate(formula, z3Context);
    SolutionFinder finder = new SolutionFinder(z3Solver, z3Context);
    Set<Model> solutions = finder.findSolutions(constraint, 20);
    assertEquals(0, solutions.size());
}
Also used : BoolExpr(com.microsoft.z3.BoolExpr) Model(com.microsoft.z3.Model) SolutionFinder(de.bmoth.backend.z3.SolutionFinder) Test(org.junit.Test)

Example 2 with SolutionFinder

use of de.bmoth.backend.z3.SolutionFinder in project bmoth by hhu-stups.

the class FormulaEvaluationTest method testGreaterEqualFormula.

@Test
public void testGreaterEqualFormula() throws Exception {
    String formula = "x >= 4 & x < 8";
    // getting the translated z3 representation of the formula
    BoolExpr constraint = FormulaToZ3Translator.translatePredicate(formula, z3Context);
    z3Solver.add(constraint);
    SolutionFinder finder = new SolutionFinder(z3Solver, z3Context);
    Set<Model> solutions = finder.findSolutions(constraint, 20);
    assertEquals(4, solutions.size());
    for (Model solution : solutions) {
        String solutionAsString = z3ModelToString(solution);
        switch(solutionAsString) {
            case "{x=4}":
            case "{x=5}":
            case "{x=6}":
            case "{x=7}":
                break;
            default:
                fail(solutionAsString + " is not part of found solutions");
        }
    }
}
Also used : SolutionFinder(de.bmoth.backend.z3.SolutionFinder) Test(org.junit.Test)

Example 3 with SolutionFinder

use of de.bmoth.backend.z3.SolutionFinder in project bmoth by hhu-stups.

the class FormulaEvaluationTest method testLessEqualFormula.

@Test
public void testLessEqualFormula() throws Exception {
    String formula = "x <= 4 & x > 0";
    // getting the translated z3 representation of the formula
    BoolExpr constraint = FormulaToZ3Translator.translatePredicate(formula, z3Context);
    z3Solver.add(constraint);
    SolutionFinder finder = new SolutionFinder(z3Solver, z3Context);
    Set<Model> solutions = finder.findSolutions(constraint, 20);
    assertEquals(4, solutions.size());
    for (Model solution : solutions) {
        String solutionAsString = z3ModelToString(solution);
        switch(solutionAsString) {
            case "{x=1}":
            case "{x=2}":
            case "{x=3}":
            case "{x=4}":
                break;
            default:
                fail(solutionAsString + " is not part of found solutions");
        }
    }
}
Also used : SolutionFinder(de.bmoth.backend.z3.SolutionFinder) Test(org.junit.Test)

Example 4 with SolutionFinder

use of de.bmoth.backend.z3.SolutionFinder in project bmoth by hhu-stups.

the class SolutionFinderTest method setup.

@Before
@Override
public void setup() {
    super.setup();
    finder = new SolutionFinder(z3Solver, z3Context);
}
Also used : SolutionFinder(de.bmoth.backend.z3.SolutionFinder) Before(org.junit.Before)

Aggregations

SolutionFinder (de.bmoth.backend.z3.SolutionFinder)4 Test (org.junit.Test)3 BoolExpr (com.microsoft.z3.BoolExpr)1 Model (com.microsoft.z3.Model)1 Before (org.junit.Before)1