use of de.bmoth.modelchecker.State in project bmoth by hhu-stups.
the class StateTest method testStateEquals3.
@Test
public void testStateEquals3() throws Exception {
HashMap<String, Expr> map = new HashMap<>();
map.put("x", z3Context.mkInt(11));
State state = new State(map);
assertEquals(state, state);
assertNotEquals(state, new Object());
}
use of de.bmoth.modelchecker.State in project bmoth by hhu-stups.
the class BoundedModelChecker method doModelCheck.
@Override
protected ModelCheckingResult doModelCheck() {
for (int k = 0; k < maxSteps; k++) {
// get a clean solver
solver.reset();
// INIT(V0)
solver.add(init());
// CONJUNCTION i from 1 to k T(Vi-1, Vi)
for (int i = 1; i <= k; i++) {
solver.add(transition(i - 1, i));
}
// not INV(Vk)
solver.add(getContext().mkNot(invariant(k)));
// CONJUNCTION i from 1 to k, j from i + 1 to k (Vi != Vj)
solver.add(distinctVectors(k));
Status check = solver.check();
if (check == Status.SATISFIABLE) {
// counter example found!
State counterExample = getStateFromModel(solver.getModel(), k);
return ModelCheckingResult.createCounterExampleFound(k, counterExample, null);
}
}
// no counter example found after maxStep steps
return ModelCheckingResult.createExceededMaxSteps(maxSteps);
}
use of de.bmoth.modelchecker.State in project bmoth by hhu-stups.
the class KInductionModelChecker method doModelCheck.
@Override
protected ModelCheckingResult doModelCheck() {
for (int k = 0; k < maxSteps; k++) {
// get a clean baseSolver
baseSolver.reset();
// INIT(V0)
baseSolver.add(init());
// CONJUNCTION i from 1 to k T(Vi-1, Vi)
for (int i = 1; i <= k; i++) {
baseSolver.add(transition(i - 1, i));
}
// not INV(Vk)
baseSolver.add(getContext().mkNot(invariant(k)));
Status check = baseSolver.check();
if (check == Status.SATISFIABLE) {
// counter example found!
State counterExample = getStateFromModel(baseSolver.getModel(), k);
return createCounterExampleFound(k, counterExample, null);
} else {
stepSolver.reset();
stepSolver.add();
// CONJUNCTION i from 1 to k, j from i + 1 to k (Vi != Vj)
stepSolver.add(distinctVectors(k));
for (int i = 0; i <= k; i++) {
stepSolver.add(transition(i - 1, i));
}
for (int i = 0; i <= k; i++) {
stepSolver.add(invariant(i));
}
stepSolver.add(getContext().mkNot(invariant(k + 1)));
Status checkStep = stepSolver.check();
if (checkStep == Status.UNSATISFIABLE)
// TODO think about state space root!
return createVerified(k, null);
}
}
// no counter example found after maxStep steps
return createExceededMaxSteps(maxSteps);
}
use of de.bmoth.modelchecker.State in project bmoth by hhu-stups.
the class StateTest method testGetStateConstraint.
@Test
public void testGetStateConstraint() {
HashMap<String, Expr> map1 = new HashMap<>();
map1.put("x", z3Context.mkInt(11));
map1.put("y", z3Context.mkInt(12));
State state1 = new State(map1);
State state2 = new State(new HashMap<>());
assertEquals("(and (= x 11) (= y 12))", state1.getStateConstraint(z3Context).toString());
assertNull(state2.getStateConstraint(z3Context));
}
use of de.bmoth.modelchecker.State in project bmoth by hhu-stups.
the class StateTest method testToString.
@Test
public void testToString() throws Exception {
HashMap<String, Expr> map = new HashMap<>();
map.put("z", z3Context.mkInt(13));
map.put("x", z3Context.mkInt(11));
map.put("y", z3Context.mkInt(12));
map.put("a", z3Context.mkInt(-200));
State state = new State(map);
assertEquals("{a=-200, x=11, y=12, z=13}", state.toString());
}