Search in sources :

Example 26 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm in project probparsers by bendisposto.

the class FastReadTransformer method fastwrite.

private void fastwrite(PrologTerm term) {
    if (term instanceof IntegerPrologTerm) {
        IntegerPrologTerm intTerm = (IntegerPrologTerm) term;
        write(intTerm);
    }
    if (term instanceof CompoundPrologTerm) {
        write(term);
    }
    if (term instanceof VariablePrologTerm) {
        write((VariablePrologTerm) term);
    }
    if (term instanceof ListPrologTerm) {
        ListPrologTerm list = (ListPrologTerm) term;
        write(list);
    }
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) VariablePrologTerm(de.prob.prolog.term.VariablePrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm)

Example 27 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm 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;
}
Also used : InvariantCheckCounterExample(de.prob.check.InvariantCheckCounterExample) ArrayList(java.util.ArrayList) Transition(de.prob.statespace.Transition) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm)

Example 28 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm 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());
    }
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) Transition(de.prob.statespace.Transition) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm)

Example 29 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm 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);
        }
    }
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) DotNode(de.prob.animator.domainobjects.DotNode) ArrayList(java.util.ArrayList) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm)

Example 30 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm 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);
        }
    }
}
Also used : DotEdge(de.prob.animator.domainobjects.DotEdge) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm)

Aggregations

CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)90 PrologTerm (de.prob.prolog.term.PrologTerm)79 ListPrologTerm (de.prob.prolog.term.ListPrologTerm)74 Test (org.junit.Test)62 IntegerPrologTerm (de.prob.prolog.term.IntegerPrologTerm)8 StructuredPrologOutput (de.prob.prolog.output.StructuredPrologOutput)7 ClassicalB (de.prob.animator.domainobjects.ClassicalB)6 VariablePrologTerm (de.prob.prolog.term.VariablePrologTerm)6 EventB (de.prob.animator.domainobjects.EventB)5 Transition (de.prob.statespace.Transition)5 ArrayList (java.util.ArrayList)4 AbstractEvalResult (de.prob.animator.domainobjects.AbstractEvalResult)3 EvalResult (de.prob.animator.domainobjects.EvalResult)3 IEvalElement (de.prob.animator.domainobjects.IEvalElement)3 ISimplifiedROMap (de.prob.parser.ISimplifiedROMap)3 ComputationNotCompletedResult (de.prob.animator.domainobjects.ComputationNotCompletedResult)2 IPrologTermOutput (de.prob.prolog.output.IPrologTermOutput)2 BigInteger (java.math.BigInteger)2 Collections (java.util.Collections)2 BParser (de.be4.classicalb.core.parser.BParser)1