Search in sources :

Example 21 with CompoundPrologTerm

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

the class PrologGeneratorTest method testForAllImplication.

@Test
public void testForAllImplication() throws Exception {
    final PrologTerm id = new CompoundPrologTerm("xyz");
    // ap(dpred(blubb))
    final PrologTerm pred = new CompoundPrologTerm("blubb");
    final PrologTerm dpred = new CompoundPrologTerm("dpred", pred);
    final PrologTerm ap = new CompoundPrologTerm("ap", dpred);
    // G [x]
    final PrologTerm transPred = new CompoundPrologTerm("x");
    final PrologTerm wrapped2 = new CompoundPrologTerm("dtrans", transPred);
    final PrologTerm action = new CompoundPrologTerm("action", wrapped2);
    final PrologTerm glob = new CompoundPrologTerm("globally", action);
    final PrologTerm expected = new CompoundPrologTerm("forall", id, ap, glob);
    check("!xyz. ( {blubb} => G [x])", expected);
}
Also used : CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Example 22 with CompoundPrologTerm

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

the class PrologGeneratorTest method testHistorically.

@Test
public void testHistorically() throws Exception {
    final PrologTerm expected = new CompoundPrologTerm("historically", TERM_TRUE);
    check("H true ", expected);
}
Also used : CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Example 23 with CompoundPrologTerm

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

the class PrologGeneratorTest method testComplex2.

@Test
public void testComplex2() throws Exception {
    final PrologTerm pred1 = new CompoundPrologTerm("xxx");
    final PrologTerm wrapped1 = new CompoundPrologTerm("dpred", pred1);
    final PrologTerm ap1 = new CompoundPrologTerm("ap", wrapped1);
    final PrologTerm pred2 = new CompoundPrologTerm("blubb");
    final PrologTerm wrapped2 = new CompoundPrologTerm("dpred", pred2);
    final PrologTerm ap2 = new CompoundPrologTerm("ap", wrapped2);
    final PrologTerm fin = new CompoundPrologTerm("finally", ap2);
    final PrologTerm glob = new CompoundPrologTerm("globally", fin);
    final PrologTerm imp = new CompoundPrologTerm("implies", ap1, glob);
    final PrologTerm expected = new CompoundPrologTerm("not", imp);
    check("not({xxx} => GF {blubb})", expected);
}
Also used : CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Example 24 with CompoundPrologTerm

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

the class StructuredPrologOutput method closeTerm.

public IPrologTermOutput closeTerm() {
    PrologTerm[] elements = getArguments();
    final String functor = currentFunctor;
    popFromStack();
    addArgument(new CompoundPrologTerm(functor, elements));
    return this;
}
Also used : CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) VariablePrologTerm(de.prob.prolog.term.VariablePrologTerm) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm)

Example 25 with CompoundPrologTerm

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

the class PrologTermGenerator method toPrologTerm.

private static PrologTerm toPrologTerm(final PTerm node) {
    PrologTerm term;
    if (node instanceof ANumberTerm) {
        String text = ((ANumberTerm) node).getNumber().getText();
        term = new IntegerPrologTerm(new BigInteger(text));
    } else if (node instanceof AAtomTerm) {
        String text = ((AAtomTerm) node).getName().getText();
        if ("[]".equals(text)) {
            term = new ListPrologTerm(EMPTY_PROLOG_LIST);
        } else {
            text = removeQuotes(text);
            term = new CompoundPrologTerm(text);
        }
    } else if (node instanceof ATerm) {
        ATerm aterm = (ATerm) node;
        int listSize = getListSize(node);
        if (listSize >= 0) {
            PrologTerm[] list = new PrologTerm[listSize];
            fillListWithElements(list, aterm);
            term = new ListPrologTerm(list);
        } else {
            String functor = removeQuotes(aterm.getFunctor().getText());
            PrologTerm[] params = evalParameters((AParams) aterm.getParams());
            term = new CompoundPrologTerm(functor, params);
        }
    } else if (node instanceof AVariableTerm) {
        String text = removeQuotes(((AVariableTerm) node).getVariable().getText());
        term = new VariablePrologTerm(text);
    } else
        throw new IllegalStateException("Unexpected subclass of PTerm: " + node.getClass().getCanonicalName());
    return term;
}
Also used : VariablePrologTerm(de.prob.prolog.term.VariablePrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) VariablePrologTerm(de.prob.prolog.term.VariablePrologTerm) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm) AAtomTerm(de.prob.core.sablecc.node.AAtomTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) ANumberTerm(de.prob.core.sablecc.node.ANumberTerm) ATerm(de.prob.core.sablecc.node.ATerm) BigInteger(java.math.BigInteger) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm) AVariableTerm(de.prob.core.sablecc.node.AVariableTerm)

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