use of de.bmoth.parser.ast.nodes.ltl.LTLPrefixOperatorNode.Kind.NOT 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);
}
}
});
}
}
Aggregations