Search in sources :

Example 1 with LTLOk

use of de.prob.check.LTLOk in project prob2 by bendisposto.

the class LtlCheckingCommand method processResult.

@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
    PrologTerm term = bindings.get(VARIABLE_NAME_RESULT);
    if (term.hasFunctor("ok", 0)) {
        LTLOk res = new LTLOk(ltlFormula);
        result = res;
        value = res;
    } else if (term.hasFunctor("nostart", 0)) {
        LTLError res = new LTLError(ltlFormula, "Could not find initialisation. Try to animating the model.");
        result = res;
        value = res;
    } else if (term.hasFunctor("typeerror", 0)) {
        LTLError res = new LTLError(ltlFormula, "Type error discovered in formula");
        result = res;
        value = res;
    } else if (term.hasFunctor("incomplete", 0)) {
        LTLNotYetFinished res = new LTLNotYetFinished(ltlFormula);
        result = res;
        value = res;
    } else if (term.hasFunctor("counterexample", 3)) {
        CompoundPrologTerm cpt = BindingGenerator.getCompoundTerm(term, 3);
        List<Transition> counterExample = BindingGenerator.getList(cpt.getArgument(1)).stream().filter(pt -> !pt.hasFunctor("none", 0)).map(pt -> Transition.createTransitionFromCompoundPrologTerm(s, BindingGenerator.getCompoundTerm(pt, 4))).collect(Collectors.toList());
        PathType pathType;
        int loopEntry;
        PrologTerm loopStatus = cpt.getArgument(2);
        if (loopStatus.hasFunctor("no_loop", 0)) {
            pathType = PathType.REDUCED;
            loopEntry = -1;
        } else if (loopStatus.hasFunctor("deadlock", 0)) {
            pathType = PathType.FINITE;
            loopEntry = -1;
        } else if (loopStatus.hasFunctor("loop", 1)) {
            pathType = PathType.INFINITE;
            loopEntry = ((IntegerPrologTerm) loopStatus.getArgument(1)).getValue().intValue();
        } else {
            throw new UnexpectedLoopStatusException("LTL model check returned unexpected loop status: " + loopStatus);
        }
        List<Transition> pathToCE = BindingGenerator.getList(cpt.getArgument(3)).stream().map(pt -> Transition.createTransitionFromCompoundPrologTerm(s, BindingGenerator.getCompoundTerm(pt, 4))).collect(Collectors.toList());
        LTLCounterExample res = new LTLCounterExample(ltlFormula, pathToCE, counterExample, loopEntry, pathType);
        result = res;
        value = res;
    } else {
        throw new UnknownLtlResult("Unknown result from LTL checking: " + term);
    }
}
Also used : LTLError(de.prob.check.LTLError) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) LTLNotYetFinished(de.prob.check.LTLNotYetFinished) Collectors(java.util.stream.Collectors) IModelCheckingResult(de.prob.check.IModelCheckingResult) ISimplifiedROMap(de.prob.parser.ISimplifiedROMap) LTL(de.prob.animator.domainobjects.LTL) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput) List(java.util.List) Transition(de.prob.statespace.Transition) PrologTerm(de.prob.prolog.term.PrologTerm) BindingGenerator(de.prob.parser.BindingGenerator) LTLOk(de.prob.check.LTLOk) StateSpace(de.prob.statespace.StateSpace) Collections(java.util.Collections) LTLCounterExample(de.prob.check.LTLCounterExample) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm) LTLNotYetFinished(de.prob.check.LTLNotYetFinished) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm) LTLError(de.prob.check.LTLError) LTLOk(de.prob.check.LTLOk) Transition(de.prob.statespace.Transition) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) LTLCounterExample(de.prob.check.LTLCounterExample) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm)

Aggregations

LTL (de.prob.animator.domainobjects.LTL)1 IModelCheckingResult (de.prob.check.IModelCheckingResult)1 LTLCounterExample (de.prob.check.LTLCounterExample)1 LTLError (de.prob.check.LTLError)1 LTLNotYetFinished (de.prob.check.LTLNotYetFinished)1 LTLOk (de.prob.check.LTLOk)1 BindingGenerator (de.prob.parser.BindingGenerator)1 ISimplifiedROMap (de.prob.parser.ISimplifiedROMap)1 IPrologTermOutput (de.prob.prolog.output.IPrologTermOutput)1 CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)1 IntegerPrologTerm (de.prob.prolog.term.IntegerPrologTerm)1 PrologTerm (de.prob.prolog.term.PrologTerm)1 StateSpace (de.prob.statespace.StateSpace)1 Transition (de.prob.statespace.Transition)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1