use of de.prob.prolog.term.CompoundPrologTerm in project prob2 by bendisposto.
the class ExpandedFormula method getValue.
private Object getValue(final PrologTerm v) {
String functor = v.getFunctor();
CompoundPrologTerm cpt = BindingGenerator.getCompoundTerm(v, 1);
switch(functor) {
case "p":
return cpt.getArgument(1).getFunctor().equals("true");
case "v":
return UnicodeTranslator.toUnicode(cpt.getArgument(1).getFunctor());
case "e":
hasError = true;
return cpt.getArgument(1).getFunctor();
default:
throw new IllegalArgumentException("Received unexpected result from Prolog. " + "Expected is either p, v or e as a functor, but Prolog returned " + functor);
}
}
use of de.prob.prolog.term.CompoundPrologTerm in project prob2 by bendisposto.
the class UnsatMinimalCoreCommand method processResult.
@Override
public void processResult(ISimplifiedROMap<String, PrologTerm> bindings) {
CompoundPrologTerm compoundTerm = BindingGenerator.getCompoundTerm(bindings.get(RESULT_VARIABLE), 0);
String code = compoundTerm.getFunctor();
if (pred instanceof EventB) {
core = new EventB(code, FormulaExpand.EXPAND);
} else {
core = new ClassicalB(code, FormulaExpand.EXPAND);
}
}
use of de.prob.prolog.term.CompoundPrologTerm in project prob2 by bendisposto.
the class PrimePredicateCommand method processResult.
@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
CompoundPrologTerm compoundTerm = BindingGenerator.getCompoundTerm(bindings.get(PRIMED_PREDICATE_VARIABLE), 0);
String code = compoundTerm.getFunctor();
if (evalElement instanceof EventB) {
result = new EventB(code, FormulaExpand.EXPAND);
} else {
result = new ClassicalB(code, FormulaExpand.EXPAND);
}
}
use of de.prob.prolog.term.CompoundPrologTerm in project probparsers by bendisposto.
the class PrologGeneratorTest method testDET.
@Test
public void testDET() throws Exception {
final PrologTerm transPred1 = new CompoundPrologTerm("bla");
final PrologTerm wrapped1 = new CompoundPrologTerm("dtrans", transPred1);
final PrologTerm transPred2 = new CompoundPrologTerm("argg");
final PrologTerm wrapped2 = new CompoundPrologTerm("dtrans", transPred2);
final PrologTerm args = new ListPrologTerm(wrapped1, wrapped2);
final PrologTerm det = new CompoundPrologTerm("det", args);
final PrologTerm expected = new CompoundPrologTerm("ap", det);
check("deterministic(bla , argg)", expected);
}
use of de.prob.prolog.term.CompoundPrologTerm in project probparsers by bendisposto.
the class PrologGeneratorTest method testOr.
@Test
public void testOr() throws Exception {
final PrologTerm expected = new CompoundPrologTerm("or", TERM_TRUE, TERM_FALSE);
check("true or false", expected);
}
Aggregations