@Override public void apply(final Individual x) { final List<ATermAppl> allValues = x.getTypes(Node.ALL); int size = allValues.size(); Iterator<ATermAppl> i = allValues.iterator(); while (i.hasNext()) { final ATermAppl av = i.next(); final DependencySet avDepends = x.getDepends(av); if (!OpenlletOptions.MAINTAIN_COMPLETION_QUEUE && avDepends == null) continue; applyAllValues(x, av, avDepends); if (x.isMerged() || _strategy.getABox().isClosed()) return; // if there are self links through transitive properties restart if (size != allValues.size()) { i = allValues.iterator(); size = allValues.size(); } } }
@Override public void apply(final Individual x) { final List<ATermAppl> allValues = x.getTypes(Node.ALL); int size = allValues.size(); Iterator<ATermAppl> i = allValues.iterator(); while (i.hasNext()) { final ATermAppl av = i.next(); final DependencySet avDepends = x.getDepends(av); if (!OpenlletOptions.MAINTAIN_COMPLETION_QUEUE && avDepends == null) continue; applyAllValues(x, av, avDepends); if (x.isMerged() || _strategy.getABox().isClosed()) return; // if there are self links through transitive properties restart if (size != allValues.size()) { i = allValues.iterator(); size = allValues.size(); } } }
/** * Apply max rule to the individual. */ @Override public void apply(final Individual ind) { if (!ind.canApply(Node.MAX)) return; final List<ATermAppl> maxCardinality = ind.getTypes(Node.MAX); for (int i = 0; i < maxCardinality.size(); i++) { final ATermAppl mc = maxCardinality.get(i); applyMaxRule(ind, mc); if (_strategy.getABox().isClosed()) return; if (ind.isMerged()) return; } ind._applyNext[Node.MAX] = maxCardinality.size(); }
/** * Apply max rule to the individual. */ @Override public void apply(final Individual ind) { if (!ind.canApply(Node.MAX)) return; final List<ATermAppl> maxCardinality = ind.getTypes(Node.MAX); for (int i = 0; i < maxCardinality.size(); i++) { final ATermAppl mc = maxCardinality.get(i); applyMaxRule(ind, mc); if (_strategy.getABox().isClosed()) return; if (ind.isMerged()) return; } ind._applyNext[Node.MAX] = maxCardinality.size(); }
@Override public void apply(final Individual node) { if (!node.canApply(Node.OR)) return; final List<ATermAppl> types = node.getTypes(Node.OR); final int size = types.size(); final ATermAppl[] disjunctions = new ATermAppl[size - node._applyNext[Node.OR]]; types.subList(node._applyNext[Node.OR], size).toArray(disjunctions); if (OpenlletOptions.USE_DISJUNCTION_SORTING != OpenlletOptions.NO_SORTING) sortDisjunctions(node, disjunctions); for (final ATermAppl disjunction : disjunctions) { applyDisjunctionRule(node, disjunction); if (_strategy.getABox().isClosed() || node.isMerged()) return; } node._applyNext[Node.OR] = size; }
@Override public void apply(final Individual node) { if (!node.canApply(Node.OR)) return; final List<ATermAppl> types = node.getTypes(Node.OR); final int size = types.size(); final ATermAppl[] disjunctions = new ATermAppl[size - node._applyNext[Node.OR]]; types.subList(node._applyNext[Node.OR], size).toArray(disjunctions); if (OpenlletOptions.USE_DISJUNCTION_SORTING != OpenlletOptions.NO_SORTING) sortDisjunctions(node, disjunctions); for (final ATermAppl disjunction : disjunctions) { applyDisjunctionRule(node, disjunction); if (_strategy.getABox().isClosed() || node.isMerged()) return; } node._applyNext[Node.OR] = size; }
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 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; } } }
@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; } } }
public void applyUniversalRestrictions(final Individual node) { addType(node, ATermUtils.TOP, DependencySet.INDEPENDENT); final Set<Role> reflexives = _abox.getKB().getRBox().getReflexiveRoles(); for (final Role r : reflexives) { _logger.fine(() -> "REF : " + node + " " + r); addEdge(node, r, node, r.getExplainReflexive()); if (node.isMerged()) return; } final Role topObjProp = _abox.getKB().getRole(ATermUtils.TOP_OBJECT_PROPERTY); for (final ATermAppl domain : topObjProp.getDomains()) { addType(node, domain, topObjProp.getExplainDomain(domain)); if (node.isMerged()) continue; } for (final ATermAppl range : topObjProp.getRanges()) { addType(node, range, topObjProp.getExplainRange(range)); if (node.isMerged()) continue; } }
@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 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 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; }
protected boolean applyAllValuesPropertyChain(final Individual x, final ATermList chain, final ATermAppl c, final DependencySet ds) { final Role r = _strategy.getABox().getRole(chain.getFirst()); final EdgeList edges = x.getRNeighborEdges(r); if (!edges.isEmpty()) { final ATermAppl allRC = ATermUtils.makeAllValues(chain.getNext(), c); for (int e = 0; e < edges.size(); e++) { final Edge edgeToY = edges.get(e); final Node y = edgeToY.getNeighbor(x); final DependencySet finalDS = ds.union(edgeToY.getDepends(), _strategy.getABox().doExplanation()); applyAllValues(x, r, y, allRC, finalDS); if (x.isMerged() || _strategy.getABox().isClosed()) return false; } } return true; }
protected boolean applyAllValuesPropertyChain(final Individual x, final ATermList chain, final ATermAppl c, final DependencySet ds) { final Role r = _strategy.getABox().getRole(chain.getFirst()); final EdgeList edges = x.getRNeighborEdges(r); if (!edges.isEmpty()) { final ATermAppl allRC = ATermUtils.makeAllValues(chain.getNext(), c); for (int e = 0; e < edges.size(); e++) { final Edge edgeToY = edges.get(e); final Node y = edgeToY.getNeighbor(x); final DependencySet finalDS = ds.union(edgeToY.getDepends(), _strategy.getABox().doExplanation()); applyAllValues(x, r, y, allRC, finalDS); if (x.isMerged() || _strategy.getABox().isClosed()) return false; } } return true; }