@Override public DependencySet check(final VariableBinding binding) { final Individual ind1 = binding.get(_arg1); final Individual ind2 = binding.get(_arg2); if (ind1.isSame(ind2)) { // we might be returning a super set of the actual dependency // set for the sameness since it is not straight-forward to come // up with the exact dependency set if there are other // individuals involved in this sameAs inference final DependencySet ds1 = ind1.getMergeDependency(true); final DependencySet ds2 = ind2.getMergeDependency(true); return ds1 == null ? ds2 : ds2 == null ? ds1 : ds1.union(ds2, true); } else return null; }
@Override public DependencySet check(final VariableBinding binding) { final Individual ind1 = binding.get(_arg1); final Individual ind2 = binding.get(_arg2); if (ind1.isSame(ind2)) { // we might be returning a super set of the actual dependency // set for the sameness since it is not straight-forward to come // up with the exact dependency set if there are other // individuals involved in this sameAs inference final DependencySet ds1 = ind1.getMergeDependency(true); final DependencySet ds2 = ind2.getMergeDependency(true); return ds1 == null ? ds2 : ds2 == null ? ds1 : ds1.union(ds2, true); } else return null; }
private void addType(final ATermAppl ind, final ATermAppl cls) { DependencySet nodeDS = _ds; Individual node = _abox.getIndividual(ind); if (node.isMerged()) { nodeDS = node.getMergeDependency(true); node = node.getSame(); } _strategy.addType(node, _negated ? ATermUtils.negate(cls) : cls, nodeDS); }
private void addType(final ATermAppl ind, final ATermAppl cls) { DependencySet nodeDS = _ds; Individual node = _abox.getIndividual(ind); if (node.isMerged()) { nodeDS = node.getMergeDependency(true); node = node.getSame(); } _strategy.addType(node, _negated ? ATermUtils.negate(cls) : cls, nodeDS); }
@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); }
@Override public void getObjectPropertyValues(final ATermAppl s, final Role role, final Set<ATermAppl> knowns, final Set<ATermAppl> unknowns, final boolean getSames) { assert isComplete() : "Initial consistency check has not been performed!"; Individual subj = getIndividual(s); boolean isIndependent = true; if (subj.isMerged()) { isIndependent = subj.getMergeDependency(true).isIndependent(); subj = subj.getSame(); } if (role.isSimple()) getSimpleObjectPropertyValues(subj, role, knowns, unknowns, getSames); else if (!role.hasComplexSubRole()) getTransitivePropertyValues(subj, role, knowns, unknowns, getSames, new HashMap<Individual, Set<Role>>(), true); else { final TransitionGraph<Role> tg = role.getFSM(); getComplexObjectPropertyValues(subj, tg.getInitialState(), tg, knowns, unknowns, getSames, new HashMap<Individual, Set<State<Role>>>(), true); } if (!isIndependent) { unknowns.addAll(knowns); knowns.clear(); } }
@Override public void getObjectPropertyValues(final ATermAppl s, final Role role, final Set<ATermAppl> knowns, final Set<ATermAppl> unknowns, final boolean getSames) { assert isComplete() : "Initial consistency check has not been performed!"; Individual subj = getIndividual(s); boolean isIndependent = true; if (subj.isMerged()) { isIndependent = subj.getMergeDependency(true).isIndependent(); subj = subj.getSame(); } if (role.isSimple()) getSimpleObjectPropertyValues(subj, role, knowns, unknowns, getSames); else if (!role.hasComplexSubRole()) getTransitivePropertyValues(subj, role, knowns, unknowns, getSames, new HashMap<Individual, Set<Role>>(), true); else { final TransitionGraph<Role> tg = role.getFSM(); getComplexObjectPropertyValues(subj, tg.getInitialState(), tg, knowns, unknowns, getSames, new HashMap<Individual, Set<State<Role>>>(), true); } if (!isIndependent) { unknowns.addAll(knowns); knowns.clear(); } }
/** * @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 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); } } }
@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; }
@Override public void addType(final ATermAppl x, final ATermAppl cParam, final DependencySet dsParam) { ATermAppl c = cParam; DependencySet ds = dsParam; c = ATermUtils.normalize(c); // when a type is being added to // an ABox that has already been completed, the _branch // of the dependency set will automatically be set to // the _current _branch. We need to set it to the initial // _branch number to make sure that this type assertion // will not be removed during backtracking final int remember = _branchIndex; setBranchIndex(DependencySet.NO_BRANCH); Individual node = getIndividual(x); node.addType(c, ds, false); while (node.isMerged()) { ds = ds.union(node.getMergeDependency(false), _doExplanation); node = (Individual) node.getMergedTo(); node.addType(c, ds, !node.isMerged()); } setBranchIndex(remember); }
@Override public void addType(final ATermAppl x, final ATermAppl cParam, final DependencySet dsParam) { ATermAppl c = cParam; DependencySet ds = dsParam; c = ATermUtils.normalize(c); // when a type is being added to // an ABox that has already been completed, the _branch // of the dependency set will automatically be set to // the _current _branch. We need to set it to the initial // _branch number to make sure that this type assertion // will not be removed during backtracking final int remember = _branchIndex; setBranchIndex(DependencySet.NO_BRANCH); Individual node = getIndividual(x); node.addType(c, ds, false); while (node.isMerged()) { ds = ds.union(node.getMergeDependency(false), _doExplanation); node = (Individual) node.getMergedTo(); node.addType(c, ds, !node.isMerged()); } setBranchIndex(remember); }
@Override public Bool hasObviousDataPropertyValue(final ATermAppl s, final ATermAppl p, final Object value) { assert isComplete() : "Initial consistency check has not been performed!"; Individual subj = getIndividual(s); final Role prop = getRole(p); if (prop.isTop()) return Bool.TRUE; else if (prop.isBottom()) return Bool.FALSE; // if onlyPositive is set then the answer returned is sound but not // complete so we cannot return negative answers boolean onlyPositive = false; if (!subj.getMergeDependency(true).isIndependent()) { onlyPositive = true; subj = getIndividual(s); } else subj = subj.getSame(); final Bool hasValue = subj.hasDataPropertyValue(prop, value); if (onlyPositive && hasValue.isFalse()) return Bool.UNKNOWN; return hasValue; }
@Override public Bool hasObviousDataPropertyValue(final ATermAppl s, final ATermAppl p, final Object value) { assert isComplete() : "Initial consistency check has not been performed!"; Individual subj = getIndividual(s); final Role prop = getRole(p); if (prop.isTop()) return Bool.TRUE; else if (prop.isBottom()) return Bool.FALSE; // if onlyPositive is set then the answer returned is sound but not // complete so we cannot return negative answers boolean onlyPositive = false; if (!subj.getMergeDependency(true).isIndependent()) { onlyPositive = true; subj = getIndividual(s); } else subj = subj.getSame(); final Bool hasValue = subj.hasDataPropertyValue(prop, value); if (onlyPositive && hasValue.isFalse()) return Bool.UNKNOWN; return hasValue; }
private void addEdge(final ATermAppl p, final ATermAppl s, final ATermAppl o) { DependencySet edgeDS = _ds; Individual node1 = _abox.getIndividual(s); if (node1.isMerged()) { edgeDS = node1.getMergeDependency(true); node1 = node1.getSame(); } if (_negated) { final ATermAppl cls = all(p, not(value(o))); _strategy.addType(node1, cls, _ds); } else { Node node2 = _abox.getNode(o); if (node2.isMerged()) { edgeDS = node2.getMergeDependency(true); node2 = node2.getSame(); } _strategy.addEdge(node1, _abox.getRole(p), node2, edgeDS); } }
private void addEdge(final ATermAppl p, final ATermAppl s, final ATermAppl o) { DependencySet edgeDS = _ds; Individual node1 = _abox.getIndividual(s); if (node1.isMerged()) { edgeDS = node1.getMergeDependency(true); node1 = node1.getSame(); } if (_negated) { final ATermAppl cls = all(p, not(value(o))); _strategy.addType(node1, cls, _ds); } else { Node node2 = _abox.getNode(o); if (node2.isMerged()) { edgeDS = node2.getMergeDependency(true); node2 = node2.getSame(); } _strategy.addEdge(node1, _abox.getRole(p), node2, edgeDS); } }