@Override public DependencySet getNodeDepends() { return getDepends(ATermUtils.TOP); }
@Override public DependencySet getNodeDepends() { return getDepends(ATermUtils.TOP); }
private static void sortDisjunctions(final Individual node, final ATermAppl[] disjunctions) { if (OpenlletOptions.USE_DISJUNCTION_SORTING == OpenlletOptions.OLDEST_FIRST) { final Comparator<ATermAppl> comparator = (d1, d2) -> node.getDepends(d1).max() - node.getDepends(d2).max(); Arrays.sort(disjunctions, comparator); } else throw new InternalReasonerException("Unknown _disjunction sorting option " + OpenlletOptions.USE_DISJUNCTION_SORTING); }
private static void sortDisjunctions(final Individual node, final ATermAppl[] disjunctions) { if (OpenlletOptions.USE_DISJUNCTION_SORTING == OpenlletOptions.OLDEST_FIRST) { final Comparator<ATermAppl> comparator = (d1, d2) -> node.getDepends(d1).max() - node.getDepends(d2).max(); Arrays.sort(disjunctions, comparator); } else throw new InternalReasonerException("Unknown _disjunction sorting option " + OpenlletOptions.USE_DISJUNCTION_SORTING); }
@Override public DependencySet check(final VariableBinding binding) { final Individual ind = binding.get(getArg()); return ind.getDepends(_c); }
@Override public DependencySet check(final VariableBinding binding) { final Individual ind = binding.get(getArg()); return ind.getDepends(_c); }
/** * Readd conjunction labels * * @param ind */ private void readdConjunctions(final Individual ind) { ind.types()// .filter(conj -> ATermUtils.isAnd(conj) && ind.hasType(conj))// .forEach(conj -> addType(ind, conj, ind.getDepends(conj))); }
/** * Readd conjunction labels * * @param ind */ private void readdConjunctions(final Individual ind) { ind.types()// .filter(conj -> ATermUtils.isAnd(conj) && ind.hasType(conj))// .forEach(conj -> addType(ind, conj, ind.getDepends(conj))); }
@Override public Iterator<WME> getInnerIterator(final Individual ind) { final DependencySet depends = ind.getDepends(_predicate); return (depends == null) ? IteratorUtils.<WME> emptyIterator() : IteratorUtils.<WME> singletonIterator(WME.createType(ind, _predicate, depends)); } };
@Override public Iterator<WME> getInnerIterator(final Individual ind) { final DependencySet depends = ind.getDepends(_predicate); return (depends == null) ? IteratorUtils.<WME> emptyIterator() : IteratorUtils.<WME> singletonIterator(WME.createType(ind, _predicate, depends)); } };
@Override public final void apply(final Individual node) { for (final ATermAppl c : new ArrayList<>(node.getTypes(Node.ATOM))) // 'applyAllValues' can change the underlying types of individual; so we make a copy to iterate { if (!OpenlletOptions.MAINTAIN_COMPLETION_QUEUE && null == node.getDepends(c)) continue; if (ATermUtils.isSelf(c)) { final ATermAppl predicate = (ATermAppl) c.getArgument(0); final Role role = _strategy.getABox().getRole(predicate); _logger.fine(() -> "SELF: " + node + "\trole:" + role + "\tdepends:" + node.getDepends(c) + "\tRSuccessor:" + node.hasRSuccessor(role, node)); _strategy.addEdge(node, role, node, node.getDepends(c)); if (_strategy.getABox().isClosed()) return; } } } }
@Override public final void apply(final Individual node) { for (final ATermAppl c : new ArrayList<>(node.getTypes(Node.ATOM))) // 'applyAllValues' can change the underlying types of individual; so we make a copy to iterate { if (!OpenlletOptions.MAINTAIN_COMPLETION_QUEUE && null == node.getDepends(c)) continue; if (ATermUtils.isSelf(c)) { final ATermAppl predicate = (ATermAppl) c.getArgument(0); final Role role = _strategy.getABox().getRole(predicate); _logger.fine(() -> "SELF: " + node + "\trole:" + role + "\tdepends:" + node.getDepends(c) + "\tRSuccessor:" + node.hasRSuccessor(role, node)); _strategy.addEdge(node, role, node, node.getDepends(c)); if (_strategy.getABox().isClosed()) return; } } } }
/** * Collects atomic concepts such that either that concept or its negation exist in the _types list without depending on any non-deterministic _branch. First * list is filled with _types and second list is filled with non-_types, i.e. this _individual can never be an instance of any element in the second list. * * @param types All atomic concepts found in types * @param nonTypes All atomic concepts */ public void getObviousTypes(final List<ATermAppl> types, final List<ATermAppl> nonTypes) { for (final ATermAppl c : getTypes(Node.ATOM)) if (getDepends(c).isIndependent()) if (ATermUtils.isPrimitive(c)) types.add(c); else if (ATermUtils.isNegatedPrimitive(c)) nonTypes.add((ATermAppl) c.getArgument(0)); }
/** * Collects atomic concepts such that either that concept or its negation exist in the _types list without depending on any non-deterministic _branch. First * list is filled with _types and second list is filled with non-_types, i.e. this _individual can never be an instance of any element in the second list. * * @param types All atomic concepts found in types * @param nonTypes All atomic concepts */ public void getObviousTypes(final List<ATermAppl> types, final List<ATermAppl> nonTypes) { for (final ATermAppl c : getTypes(Node.ATOM)) if (getDepends(c).isIndependent()) if (ATermUtils.isPrimitive(c)) types.add(c); else if (ATermUtils.isNegatedPrimitive(c)) nonTypes.add((ATermAppl) c.getArgument(0)); }
public boolean activateIndividual(final Individual ind) { // only named non-pruned individuals final boolean changed = false; if (!ind.isRootNominal() || ind.isPruned()) return false; final List<ATermAppl> types = ind.getTypes(Node.ATOM); for (int i = 0; i < types.size(); i++) { final ATermAppl type = types.get(i); activateType(ind, type, ind.getDepends(type)); } activateDifferents(ind); for (final Edge edge : new ArrayList<>(ind.getOutEdges())) if (edge.getTo().isRootNominal()) activateEdge(edge); return changed; }
public boolean activateIndividual(final Individual ind) { // only named non-pruned individuals final boolean changed = false; if (!ind.isRootNominal() || ind.isPruned()) return false; final List<ATermAppl> types = ind.getTypes(Node.ATOM); for (int i = 0; i < types.size(); i++) { final ATermAppl type = types.get(i); activateType(ind, type, ind.getDepends(type)); } activateDifferents(ind); for (final Edge edge : new ArrayList<>(ind.getOutEdges())) if (edge.getTo().isRootNominal()) activateEdge(edge); return changed; }
@Override public void apply(final Individual y) { final List<ATermAppl> types = y.getTypes(Node.NOM); final int size = types.size(); for (int j = 0; j < size; j++) { final ATermAppl nc = types.get(j); final DependencySet ds = y.getDepends(nc); if (!OpenlletOptions.MAINTAIN_COMPLETION_QUEUE && ds == null) continue; applyNominalRule(y, nc, ds); if (_strategy.getABox().isClosed()) return; if (y.isMerged()) { apply(y.getSame()); return; } } }
/** * @param name * @param nodeParam */ public CachedConceptNode(final ATermAppl name, final Individual nodeParam) { _name = name; Individual node = nodeParam; // if the _node is merged, get the representative _node and check // also if the merge depends on a _branch _isIndependent = node.getMergeDependency(true).isIndependent(); node = node.getSame(); _outEdges = copyEdgeList(node, true); _inEdges = copyEdgeList(node, false); // collect all transitive property values if (node.getABox().getKB().getExpressivity().hasNominal()) collectComplexPropertyValues(node); _types = CollectionUtils.makeIdentityMap(node.getDepends()); for (final Map.Entry<ATermAppl, DependencySet> e : _types.entrySet()) e.setValue(e.getValue().cache()); }
public DependencySet hasMax1(final Role r) { for (final ATermAppl mc : _types[MAX]) { // max(r, n, c) is in normalized form not(min(p, n + 1)) final ATermAppl maxCard = (ATermAppl) mc.getArgument(0); final Role maxR = _abox.getRole(maxCard.getArgument(0)); final int max = ((ATermInt) maxCard.getArgument(1)).getInt() - 1; final ATermAppl maxQ = (ATermAppl) maxCard.getArgument(2); // FIXME returned dependency set might be wrong // if there are two _types max(r,1) and max(p,1) where r subproperty of p // then the dependency set what we return might be wrong if (max == 1 && r.isSubRoleOf(maxR) && ATermUtils.isTop(maxQ)) return getDepends(mc).union(r.getExplainSub(maxR.getName()), _abox.doExplanation()); } return null; }
public DependencySet hasMax1(final Role r) { for (final ATermAppl mc : _types[MAX]) { // max(r, n, c) is in normalized form not(min(p, n + 1)) final ATermAppl maxCard = (ATermAppl) mc.getArgument(0); final Role maxR = _abox.getRole(maxCard.getArgument(0)); final int max = ((ATermInt) maxCard.getArgument(1)).getInt() - 1; final ATermAppl maxQ = (ATermAppl) maxCard.getArgument(2); // FIXME returned dependency set might be wrong // if there are two _types max(r,1) and max(p,1) where r subproperty of p // then the dependency set what we return might be wrong if (max == 1 && r.isSubRoleOf(maxR) && ATermUtils.isTop(maxQ)) return getDepends(mc).union(r.getExplainSub(maxR.getName()), _abox.doExplanation()); } return null; }