use of de.bmoth.parser.ast.nodes.PredicateNode 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 de.bmoth.parser.ast.nodes.PredicateNode in project bmoth by hhu-stups.
the class ConvertNotFormulaToNegatedBFormula method transformNode.
@Override
public Node transformNode(Node node) {
LTLPrefixOperatorNode notOperator = (LTLPrefixOperatorNode) node;
LTLNode argument = notOperator.getArgument();
LTLBPredicateNode bPredicateNode = (LTLBPredicateNode) argument;
PredicateNode negatedPredicate = bPredicateNode.getPredicate().getNegatedPredicateNode();
return new LTLBPredicateNode(negatedPredicate);
}
use of de.bmoth.parser.ast.nodes.PredicateNode in project bmoth by hhu-stups.
the class BuechiAutomatonNode method toString.
public String toString() {
StringJoiner nodeString = new StringJoiner("\n", "", "");
nodeString.add(this.name + ": ");
StringJoiner incomingString = new StringJoiner(", ", "{", "}");
for (BuechiAutomatonNode incomingNode : this.incoming) {
incomingString.add(incomingNode.name);
}
nodeString.add("Incoming: " + incomingString.toString());
StringJoiner successorString = new StringJoiner(", ", "{", "}");
for (BuechiAutomatonNode successorNode : this.successors) {
successorString.add(successorNode.name);
}
nodeString.add("Successors: " + successorString.toString());
StringJoiner unprocessedString = new StringJoiner("; ", "(", ")");
for (LTLNode subNode : this.unprocessed) {
unprocessedString.add(subNode.toString());
}
nodeString.add("Unprocessed: " + unprocessedString.toString());
StringJoiner processedString = new StringJoiner("; ", "(", ")");
for (LTLNode subNode : this.processed) {
processedString.add(subNode.toString());
}
nodeString.add("Processed: " + processedString.toString());
StringJoiner nextString = new StringJoiner("; ", "(", ")");
for (LTLNode subNode : this.next) {
nextString.add(subNode.toString());
}
nodeString.add("Next: " + nextString.toString());
StringJoiner labelString = new StringJoiner("; ", "(", ")");
for (PredicateNode predicate : labels) {
labelString.add(predicate.toString());
}
nodeString.add("Labels: " + labelString.toString());
nodeString.add("Initial state? " + isInitialState);
nodeString.add("Accepting state? " + isAcceptingState);
return nodeString.toString();
}
Aggregations