use of su.litvak.chromecast.api.v2.Status 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 su.litvak.chromecast.api.v2.Status in project bmoth by hhu-stups.
the class ExplicitStateModelChecker method labelStateSpace.
private void labelStateSpace() {
Queue<State> statesToUpdate = new ArrayDeque<>();
statesToUpdate.addAll(stateSpace.vertexSet());
while (!statesToUpdate.isEmpty()) {
State current = statesToUpdate.poll();
final Set<BuechiAutomatonNode> buechiNodes = new HashSet<>();
final Set<BuechiAutomatonNode> candidates = new HashSet<>();
if (stateSpace.rootVertexSet().contains(current)) {
candidates.addAll(buechiAutomaton.getInitialStates());
} else {
Set<DefaultEdge> incomingEdges = stateSpace.incomingEdgesOf(current);
for (DefaultEdge incomingEdge : incomingEdges) {
State predecessor = stateSpace.getEdgeSource(incomingEdge);
predecessor.getBuechiNodes().forEach(n -> candidates.addAll(n.getSuccessors()));
}
}
for (BuechiAutomatonNode node : candidates) {
if (node.getLabels().isEmpty()) {
buechiNodes.add(node);
}
// TODO use all labels?
for (PredicateNode label : node.getLabels()) {
labelSolver.reset();
labelSolver.add(FormulaToZ3Translator.translatePredicate(label, getContext(), getMachineTranslator().getZ3TypeInference()));
labelSolver.add(current.getStateConstraint(getContext()));
Status status = labelSolver.check();
switch(status) {
case UNSATISFIABLE:
break;
case UNKNOWN:
throw new UnsupportedOperationException("should not be undefined");
case SATISFIABLE:
buechiNodes.add(node);
}
}
}
buechiNodes.stream().filter(n -> !current.getBuechiNodes().contains(n)).forEach(newBuechiNode -> {
// found a new node, need to update successors again
current.addBuechiNode(newBuechiNode);
Set<DefaultEdge> outgoingEdges = stateSpace.outgoingEdgesOf(current);
for (DefaultEdge outgoingEdge : outgoingEdges) {
State successor = stateSpace.getEdgeTarget(outgoingEdge);
if (!statesToUpdate.contains(successor)) {
statesToUpdate.add(successor);
}
}
});
}
}
use of su.litvak.chromecast.api.v2.Status 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 su.litvak.chromecast.api.v2.Status in project bmoth by hhu-stups.
the class InitialStateExistsChecker method doInitialStateExistsCheck.
static InitialStateExistsCheckingResult doInitialStateExistsCheck(MachineNode machine) {
Context ctx = new Context();
Solver solver = Z3SolverFactory.getZ3Solver(ctx);
MachineToZ3Translator machineTranslator = new MachineToZ3Translator(machine, ctx);
final BoolExpr invariant = machineTranslator.getInitialValueConstraint();
solver.add(invariant);
Status check = solver.check();
return new InitialStateExistsCheckingResult(check);
}
use of su.litvak.chromecast.api.v2.Status in project bmoth by hhu-stups.
the class InvariantSatisfiabilityChecker method doInvariantSatisfiabilityCheck.
static InvariantSatisfiabilityCheckingResult doInvariantSatisfiabilityCheck(MachineNode machine) {
Context ctx = new Context();
Solver solver = Z3SolverFactory.getZ3Solver(ctx);
MachineToZ3Translator machineTranslator = new MachineToZ3Translator(machine, ctx);
final BoolExpr invariant = machineTranslator.getInvariantConstraint();
solver.add(invariant);
Status check = solver.check();
return new InvariantSatisfiabilityCheckingResult(check);
}
Aggregations