public Object visit(Rule obj, Object arg) throws RIFException {
final Map<RuleVariable, Boolean> boundVariables = new HashMap<RuleVariable, Boolean>();
for (final RuleVariable var : obj.getDeclaredVariables())
boundVariables.put(var, false);
// 1. Determine bound variables
final RulePredicate head = (RulePredicate) obj.getHead();
for (int i = 0; i < head.termParams.size(); i++)
// TODO: Check whether or not constant values appear in the head
if (arg.toString().charAt(i) == 'b')
boundVariables.put((RuleVariable) head.termParams.get(i), true);
final List<IExpression> hornClause = new ArrayList<IExpression>();
if (obj.getBody() instanceof Conjunction)
hornClause.addAll(((Conjunction) obj.getBody()).exprs);
else
hornClause.add(obj.getBody());
final List<RulePredicate> predicates = sortInformationPassing(
hornClause, boundVariables);
debug("RULE -> " + obj.toString());
for (final IExpression expr : predicates) {
// Body contains only a RulePredicate
// Determine adornment
final RulePredicate body = (RulePredicate) expr;
final StringBuilder adornment = new StringBuilder();
for (final IExpression ex : body.termParams)
if (ex instanceof Constant
|| (ex instanceof RuleVariable && boundVariables
.get(ex)))
adornment.append("b");
else if (ex instanceof RuleVariable) {
adornment.append("f");
boundVariables.put((RuleVariable) ex, true);
}
String nextGoal = body.termName.toString() + "_"
+ adornment.toString();
if(this.goals.contains(nextGoal) && body.isRecursive()){
// Recursive call -> create magic rule
}
body.accept(this, adornment.toString());
}
return null;
}