use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class ConstraintBasedRefinementCheckCommand method processResult.
@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
final PrologTerm resultTerm = bindings.get(RESULT_VARIABLE);
final ListPrologTerm resultStringTerm = (ListPrologTerm) bindings.get(RESULT_STRINGS_VARIABLE);
final StringBuilder sb = new StringBuilder();
for (PrologTerm t : resultStringTerm) {
sb.append(PrologTerm.atomicString(t));
sb.append('\n');
}
resultsString = sb.toString();
if (resultTerm.hasFunctor("time_out", 0)) {
this.result = ResultType.INTERRUPTED;
} else if (resultTerm.hasFunctor("true", 0)) {
// Errors were found
this.result = ResultType.VIOLATION_FOUND;
// TODO extract message
} else if (resultTerm.hasFunctor("false", 0)) {
// Errors were not found
this.result = ResultType.NO_VIOLATION_FOUND;
} else {
throw new ProBError("unexpected result from refinement check: " + resultTerm);
}
}
use of de.prob.prolog.term.PrologTerm 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.prolog.term.PrologTerm 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.prolog.term.PrologTerm in project prob2 by bendisposto.
the class AbstractDotDiagramCmd method extractStates.
protected void extractStates(final ListPrologTerm s) {
for (PrologTerm prologTerm : s) {
if (prologTerm instanceof CompoundPrologTerm) {
CompoundPrologTerm cpt = (CompoundPrologTerm) prologTerm;
String id = Transition.getIdFromPrologTerm(cpt.getArgument(1));
List<String> labels = new ArrayList<>();
ListPrologTerm ls = BindingGenerator.getList(cpt.getArgument(4));
for (PrologTerm pt : ls) {
labels.add(pt.getFunctor());
}
int count = BindingGenerator.getInteger(cpt.getArgument(2)).getValue().intValue();
String color = cpt.getArgument(3).getFunctor();
DotNode n = new DotNode(id, labels, count, color);
nodes.put(id, n);
}
}
}
use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.
the class AbstractDotDiagramCmd method extractTransitions.
protected void extractTransitions(final ListPrologTerm trans) {
for (PrologTerm pt : trans) {
if (pt instanceof CompoundPrologTerm) {
CompoundPrologTerm cpt = (CompoundPrologTerm) pt;
String id = Transition.getIdFromPrologTerm(cpt.getArgument(1));
String src = Transition.getIdFromPrologTerm(cpt.getArgument(2));
String dest = Transition.getIdFromPrologTerm(cpt.getArgument(3));
String label = cpt.getArgument(4).toString();
String style = cpt.getArgument(5).getFunctor();
String color = cpt.getArgument(6).getFunctor();
DotEdge e = new DotEdge(id, src, dest, label, style, color);
edges.put(id, e);
}
}
}
Aggregations