Search in sources :

Example 1 with NOT

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);
                }
            }
        });
    }
}
Also used : Status(com.microsoft.z3.Status) Z3SolverFactory(de.bmoth.backend.z3.Z3SolverFactory) de.bmoth.modelchecker(de.bmoth.modelchecker) java.util(java.util) FormulaToZ3Translator(de.bmoth.backend.z3.FormulaToZ3Translator) DefaultEdge(org.jgrapht.graph.DefaultEdge) Solver(com.microsoft.z3.Solver) MachineNode(de.bmoth.parser.ast.nodes.MachineNode) SolutionFinder(de.bmoth.backend.z3.SolutionFinder) ModelCheckingResult(de.bmoth.modelchecker.ModelCheckingResult) NOT(de.bmoth.parser.ast.nodes.ltl.LTLPrefixOperatorNode.Kind.NOT) TarjanSimpleCycles(org.jgrapht.alg.cycle.TarjanSimpleCycles) Model(com.microsoft.z3.Model) PredicateNode(de.bmoth.parser.ast.nodes.PredicateNode) de.bmoth.parser.ast.nodes.ltl(de.bmoth.parser.ast.nodes.ltl) BoolExpr(com.microsoft.z3.BoolExpr) LTLTransformations(de.bmoth.backend.ltl.LTLTransformations) Status(com.microsoft.z3.Status) TranslationOptions(de.bmoth.backend.TranslationOptions) BMothPreferences(de.bmoth.preferences.BMothPreferences) PredicateNode(de.bmoth.parser.ast.nodes.PredicateNode) DefaultEdge(org.jgrapht.graph.DefaultEdge)

Aggregations

BoolExpr (com.microsoft.z3.BoolExpr)1 Model (com.microsoft.z3.Model)1 Solver (com.microsoft.z3.Solver)1 Status (com.microsoft.z3.Status)1 TranslationOptions (de.bmoth.backend.TranslationOptions)1 LTLTransformations (de.bmoth.backend.ltl.LTLTransformations)1 FormulaToZ3Translator (de.bmoth.backend.z3.FormulaToZ3Translator)1 SolutionFinder (de.bmoth.backend.z3.SolutionFinder)1 Z3SolverFactory (de.bmoth.backend.z3.Z3SolverFactory)1 de.bmoth.modelchecker (de.bmoth.modelchecker)1 ModelCheckingResult (de.bmoth.modelchecker.ModelCheckingResult)1 MachineNode (de.bmoth.parser.ast.nodes.MachineNode)1 PredicateNode (de.bmoth.parser.ast.nodes.PredicateNode)1 de.bmoth.parser.ast.nodes.ltl (de.bmoth.parser.ast.nodes.ltl)1 NOT (de.bmoth.parser.ast.nodes.ltl.LTLPrefixOperatorNode.Kind.NOT)1 BMothPreferences (de.bmoth.preferences.BMothPreferences)1 java.util (java.util)1 TarjanSimpleCycles (org.jgrapht.alg.cycle.TarjanSimpleCycles)1 DefaultEdge (org.jgrapht.graph.DefaultEdge)1