use of de.prob.statespace.Transition in project prob2 by bendisposto.
the class ConstraintBasedInvariantCheckCommand method extractExamples.
private List<InvariantCheckCounterExample> extractExamples(final ListPrologTerm ceTerm) {
List<InvariantCheckCounterExample> examples = new ArrayList<>();
for (final PrologTerm t : ceTerm) {
final CompoundPrologTerm term = (CompoundPrologTerm) t;
final String eventName = PrologTerm.atomicString(term.getArgument(1));
final Transition step1 = Transition.createTransitionFromCompoundPrologTerm(s, BindingGenerator.getCompoundTerm(term.getArgument(2), 4));
final Transition step2 = Transition.createTransitionFromCompoundPrologTerm(s, BindingGenerator.getCompoundTerm(term.getArgument(3), 4));
final InvariantCheckCounterExample ce = new InvariantCheckCounterExample(eventName, step1, step2);
newTransitions.add(step1);
newTransitions.add(step2);
examples.add(ce);
}
return examples;
}
use of de.prob.statespace.Transition in project prob2 by bendisposto.
the class ConstructTraceCommand method processResult.
@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
ListPrologTerm trace = BindingGenerator.getList(bindings.get(RESULT_VARIABLE));
for (PrologTerm term : trace) {
CompoundPrologTerm t = BindingGenerator.getCompoundTerm(term, 4);
Transition operation = Transition.createTransitionFromCompoundPrologTerm(stateSpace, t);
resultTrace.add(operation);
}
ListPrologTerm reportedErrors = BindingGenerator.getList(bindings.get(ERRORS_VARIABLE));
for (PrologTerm prologTerm : reportedErrors) {
this.errors.add(prologTerm.getFunctor());
}
}
use of de.prob.statespace.Transition 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);
}
}
use of de.prob.statespace.Transition in project prob2 by bendisposto.
the class ExecuteUntilCommand method processResult.
@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
ListPrologTerm trace = BindingGenerator.getList(bindings.get(TRACE_VARIABLE));
result = bindings.get(RESULT_VARIABLE);
for (PrologTerm term : trace) {
CompoundPrologTerm t = BindingGenerator.getCompoundTerm(term, 4);
Transition operation = Transition.createTransitionFromCompoundPrologTerm(statespace, t);
resultTrace.add(operation);
}
}
use of de.prob.statespace.Transition in project prob2 by bendisposto.
the class ExecuteModelCommand method processResult.
@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
PrologTerm prologTerm = bindings.get(TRANSITION_VARIABLE);
CompoundPrologTerm cpt = BindingGenerator.getCompoundTerm(prologTerm, 4);
Transition operation = Transition.createTransitionFromCompoundPrologTerm(statespace, cpt);
resultTrace.add(operation);
IntegerPrologTerm intPrologTerm = BindingGenerator.getInteger(bindings.get(EXECUTED_STEPS_VARIABLE));
BigInteger bigInt = intPrologTerm.getValue();
stepsExecuted = bigInt.intValue();
switch(bindings.get(RESULT_VARIABLE).getFunctor()) {
case "maximum_nr_of_steps_reached":
this.result = ExecuteModelResult.MAXIMUM_NR_OF_STEPS_REACHED;
break;
case "deadlock":
this.result = ExecuteModelResult.DEADLOCK;
break;
case "error":
this.result = ExecuteModelResult.ERROR;
break;
case "internal_error":
this.result = ExecuteModelResult.INTERNAL_ERROR;
break;
case "time_out":
this.result = ExecuteModelResult.TIME_OUT;
break;
default:
throw new AssertionError("Unexpected result of execute command.");
}
}
Aggregations