String goal = pedicate.toString();
goal = goal.replace(p.toString(), "P") + ".";
if (logger.isDebugEnabled()) {
logger.debug(goal);
}
SolveInfo info;
try {
info = executeGoal(goal);
} catch (MalformedGoalException e) {
throw new IllegalStateException(e);
}
if (!info.isSuccess()) {
throw new IllegalStateException("Failed to call " + goal);
}
Term binding;
try {
binding = info.getTerm("P");
} catch (NoSolutionException e) {
throw new IllegalStateException("Failed to call " + goal, e);
} catch (UnknownVarException e) {
throw new IllegalStateException("Failed to call " + goal, e);
}