/** * Return a dummy representation of this DependencySet such that <code>this.isIndependent() == this.copyForCache().isIndependent()</code> The returned copy * will not be accurate w.r.t. any other function call, e.g. <code>contains(int)</code> for the copy will return different results for the copy. This * function does not create a new DependencySet object so will not require additional memory. Caching this copy is more appropriate so we don't waste space * for storing the actual dependency set or the explanation which are not used in caches anyway. * * @return the dummy dependency set, the cache */ public DependencySet cache() { return isIndependent() ? DependencySet.INDEPENDENT : DependencySet.DUMMY; } }
/** * Return a dummy representation of this DependencySet such that <code>this.isIndependent() == this.copyForCache().isIndependent()</code> The returned copy * will not be accurate w.r.t. any other function call, e.g. <code>contains(int)</code> for the copy will return different results for the copy. This * function does not create a new DependencySet object so will not require additional memory. Caching this copy is more appropriate so we don't waste space * for storing the actual dependency set or the explanation which are not used in caches anyway. * * @return the dummy dependency set, the cache */ public DependencySet cache() { return isIndependent() ? DependencySet.INDEPENDENT : DependencySet.DUMMY; } }
public boolean hasObviousType(final Collection<ATermAppl> coll) { for (final ATermAppl c : coll) { final DependencySet ds = getDepends(c); if (ds != null && ds.isIndependent()) return true; } return false; }
public boolean hasObviousType(final Collection<ATermAppl> coll) { for (final ATermAppl c : coll) { final DependencySet ds = getDepends(c); if (ds != null && ds.isIndependent()) return true; } return false; }
/** * 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)); }
private static Bool checkSelfClash(final KnowledgeBase kb, final ATermAppl self, final CachedNode root, final CachedNode otherRoot) { final Role r = kb.getRole(self.getArgument(0)); for (final Edge e : otherRoot.getOutEdges()) if (e.getRole().isSubRoleOf(r) && e.getToName().equals(otherRoot.getName())) { if (_logger.isLoggable(Level.FINE)) _logger.fine(root + " has not(" + self + ") " + otherRoot + " has self edge"); final boolean allIndependent = root.isIndependent() && otherRoot.isIndependent() && e.getDepends().isIndependent(); return allIndependent ? Bool.FALSE : Bool.UNKNOWN; } return null; }
private static Bool checkSelfClash(final KnowledgeBase kb, final ATermAppl self, final CachedNode root, final CachedNode otherRoot) { final Role r = kb.getRole(self.getArgument(0)); for (final Edge e : otherRoot.getOutEdges()) if (e.getRole().isSubRoleOf(r) && e.getToName().equals(otherRoot.getName())) { if (_logger.isLoggable(Level.FINE)) _logger.fine(root + " has not(" + self + ") " + otherRoot + " has self edge"); final boolean allIndependent = root.isIndependent() && otherRoot.isIndependent() && e.getDepends().isIndependent(); return allIndependent ? Bool.FALSE : Bool.UNKNOWN; } return null; }
@Override public void getSames(final Individual ind, final Set<ATermAppl> knowns, final Set<ATermAppl> unknowns) { knowns.add(ind.getName()); final boolean thisMerged = ind.isMerged() && !ind.getMergeDependency(true).isIndependent(); for (final Node other : ind.getMerged()) { if (!other.isRootNominal()) continue; final boolean otherMerged = other.isMerged() && !other.getMergeDependency(true).isIndependent(); if (thisMerged || otherMerged) { unknowns.add(other.getName()); getSames((Individual) other, unknowns, unknowns); } else { knowns.add(other.getName()); getSames((Individual) other, knowns, unknowns); } } }
@Override public void getSames(final Individual ind, final Set<ATermAppl> knowns, final Set<ATermAppl> unknowns) { knowns.add(ind.getName()); final boolean thisMerged = ind.isMerged() && !ind.getMergeDependency(true).isIndependent(); for (final Node other : ind.getMerged()) { if (!other.isRootNominal()) continue; final boolean otherMerged = other.isMerged() && !other.getMergeDependency(true).isIndependent(); if (thisMerged || otherMerged) { unknowns.add(other.getName()); getSames((Individual) other, unknowns, unknowns); } else { knowns.add(other.getName()); getSames((Individual) other, knowns, unknowns); } } }
/** * Restore a clash dependency * * @param assertion * @param clash */ private void restoreClash(final ATermAppl assertion, final ClashDependency clash) { DependencyIndex._logger.fine(() -> " Restoring clash dependency clash: " + clash.getClash()); clash.getClash().getDepends().removeExplain(assertion); // remove the dependency if (clash.getClash().getDepends().getExplain().isEmpty() && clash.getClash().getDepends().isIndependent()) // undo clash if empty and is independent { DependencyIndex._logger.fine(() -> " Actually removing clash!"); _kb.getABox().setClash(null); } }
@Override public void getObviousTypes(final ATermAppl x, final List<ATermAppl> types, final List<ATermAppl> nonTypes) { assert isComplete() : "Initial consistency check has not been performed!"; Individual pNode = getIndividual(x); if (!pNode.getMergeDependency(true).isIndependent()) pNode = getIndividual(x); else pNode = pNode.getSame(); pNode.getObviousTypes(types, nonTypes); }
@Override public void getObviousTypes(final ATermAppl x, final List<ATermAppl> types, final List<ATermAppl> nonTypes) { assert isComplete() : "Initial consistency check has not been performed!"; Individual pNode = getIndividual(x); if (!pNode.getMergeDependency(true).isIndependent()) pNode = getIndividual(x); else pNode = pNode.getSame(); pNode.getObviousTypes(types, nonTypes); }
/** * Restore a clash dependency * * @param assertion * @param clash */ private void restoreClash(final ATermAppl assertion, final ClashDependency clash) { DependencyIndex._logger.fine(() -> " Restoring clash dependency clash: " + clash.getClash()); clash.getClash().getDepends().removeExplain(assertion); // remove the dependency if (clash.getClash().getDepends().getExplain().isEmpty() && clash.getClash().getDepends().isIndependent()) // undo clash if empty and is independent { DependencyIndex._logger.fine(() -> " Actually removing clash!"); _kb.getABox().setClash(null); } }
/** * @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()); }
/** * @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()); }
@Override public Bool isKnownType(final ATermAppl x, final ATermAppl c, final Collection<ATermAppl> subs) { assert isComplete() : "Initial consistency check has not been performed!"; Individual pNode = getIndividual(x); boolean isIndependent = true; if (pNode.isMerged()) { isIndependent = pNode.getMergeDependency(true).isIndependent(); pNode = pNode.getSame(); } final Bool isType = isKnownType(pNode, c, subs); if (isIndependent) return isType; else if (isType.isTrue()) return Bool.UNKNOWN; else return isType; }
@Override public Bool isKnownType(final ATermAppl x, final ATermAppl c, final Collection<ATermAppl> subs) { assert isComplete() : "Initial consistency check has not been performed!"; Individual pNode = getIndividual(x); boolean isIndependent = true; if (pNode.isMerged()) { isIndependent = pNode.getMergeDependency(true).isIndependent(); pNode = pNode.getSame(); } final Bool isType = isKnownType(pNode, c, subs); if (isIndependent) return isType; else if (isType.isTrue()) return Bool.UNKNOWN; else return isType; }
public boolean setDifferent(final Node node, final DependencySet dsParam) { DependencySet ds = dsParam; // add to effected list if (_abox.getBranchIndex() >= 0 && OpenlletOptions.TRACK_BRANCH_EFFECTS) _abox.getBranchEffectTracker().add(_abox.getBranchIndex(), node.getName()); if (isDifferent(node)) return false; if (isSame(node)) { ds = ds.union(getMergeDependency(true), _abox.doExplanation()); ds = ds.union(node.getMergeDependency(true), _abox.doExplanation()); _abox.setClash(Clash.nominal(this, ds, node.getName())); if (!ds.isIndependent()) return false; } ds = ds.copy(_abox.getBranchIndex()); _differents.put(node, ds); node.setDifferent(this, ds); _abox.setChanged(true); return true; }
public boolean setDifferent(final Node node, final DependencySet dsParam) { DependencySet ds = dsParam; // add to effected list if (_abox.getBranchIndex() >= 0 && OpenlletOptions.TRACK_BRANCH_EFFECTS) _abox.getBranchEffectTracker().add(_abox.getBranchIndex(), node.getName()); if (isDifferent(node)) return false; if (isSame(node)) { ds = ds.union(getMergeDependency(true), _abox.doExplanation()); ds = ds.union(node.getMergeDependency(true), _abox.doExplanation()); _abox.setClash(Clash.nominal(this, ds, node.getName())); if (!ds.isIndependent()) return false; } ds = ds.copy(_abox.getBranchIndex()); _differents.put(node, ds); node.setDifferent(this, ds); _abox.setChanged(true); return true; }