public Set<ATermAppl> getExplanation(final RulesToATermTranslator translator) { if (_explanation == null) _explanation = singleton(translator.translate(this)); return _explanation; }
public Set<ATermAppl> getExplanation(final RulesToATermTranslator translator) { if (_explanation == null) _explanation = singleton(translator.translate(this)); return _explanation; }
public void visit(final Rule rule) { final ATermAppl[] head = new ATermAppl[rule.getHead().size()]; final ATermAppl[] body = new ATermAppl[rule.getBody().size()]; int i = 0; for (final RuleAtom atom : rule.getHead()) head[i++] = translate(atom); i = 0; for (final RuleAtom atom : rule.getBody()) body[i++] = translate(atom); _term = ATermUtils.makeRule(rule.getName(), head, body); }
public void visit(final Rule rule) { final ATermAppl[] head = new ATermAppl[rule.getHead().size()]; final ATermAppl[] body = new ATermAppl[rule.getBody().size()]; int i = 0; for (final RuleAtom atom : rule.getHead()) head[i++] = translate(atom); i = 0; for (final RuleAtom atom : rule.getBody()) body[i++] = translate(atom); _term = ATermUtils.makeRule(rule.getName(), head, body); }
/** * {@inheritDoc} */ @Override public void visit(final DataRangeAtom atom) { final ATermAppl d = atom.getPredicate(); final ATermAppl l = translate(atom.getArgument()); _term = ATermUtils.makeTypeAtom(l, d); }
/** * {@inheritDoc} */ @Override public void visit(final ClassAtom atom) { final ATermAppl c = atom.getPredicate(); final ATermAppl i = translate(atom.getArgument()); _term = ATermUtils.makeTypeAtom(i, c); }
/** * {@inheritDoc} */ @Override public void visit(final DataRangeAtom atom) { final ATermAppl d = atom.getPredicate(); final ATermAppl l = translate(atom.getArgument()); _term = ATermUtils.makeTypeAtom(l, d); }
/** * {@inheritDoc} */ @Override public void visit(final ClassAtom atom) { final ATermAppl c = atom.getPredicate(); final ATermAppl i = translate(atom.getArgument()); _term = ATermUtils.makeTypeAtom(i, c); }
/** * {@inheritDoc} */ @Override public void visit(final BuiltInAtom atom) { final int arity = atom.getAllArguments().size(); final ATermAppl[] args = new ATermAppl[arity + 1]; args[0] = ATermUtils.makeTermAppl(atom.getPredicate()); int i = 1; for (final AtomDObject arg : atom.getAllArguments()) args[i++] = translate(arg); _term = ATermUtils.makeBuiltinAtom(args); }
/** * {@inheritDoc} */ @Override public void visit(final BuiltInAtom atom) { final int arity = atom.getAllArguments().size(); final ATermAppl[] args = new ATermAppl[arity + 1]; args[0] = ATermUtils.makeTermAppl(atom.getPredicate()); int i = 1; for (final AtomDObject arg : atom.getAllArguments()) args[i++] = translate(arg); _term = ATermUtils.makeBuiltinAtom(args); }
@Test public void ruleInteractionWithInverses() { // Tests #446 classes(_A); objectProperties(_p, _q, _r, _f); dataProperties(_p); individuals(_a, _b, _c); final AtomIVariable x = new AtomIVariable("x"); final AtomIVariable y = new AtomIVariable("y"); final AtomIVariable z = new AtomIVariable("z"); _kb.addSymmetricProperty(_p); _kb.addInverseProperty(_q, _r); _kb.addPropertyValue(_p, _c, _a); _kb.addPropertyValue(_f, _a, _b); final List<RuleAtom> body = Arrays.<RuleAtom> asList(new IndividualPropertyAtom(_f, x, y), new IndividualPropertyAtom(_p, x, z)); final List<RuleAtom> head = Arrays.<RuleAtom> asList(new IndividualPropertyAtom(_r, z, y)); final Rule rule = new Rule(head, body); _kb.addRule(rule); explainEntailment(_kb.hasPropertyValue(_b, _q, _c), ATermUtils.makePropAtom(_p, _c, _a), ATermUtils.makePropAtom(_f, _a, _b), ATermUtils.makeSymmetric(_p), ATermUtils.makeInvProp(_q, _r), new RulesToATermTranslator().translate(rule)); }