@Override public DependencySet getExplainSubOrInv(final Role r) { final DependencySet ds = _explainSub.get(r.getName()); if (ds == null) return _inverse.getExplainSub(r.getName()); return ds; }
applyAllValues(subj, pred, obj, allRC, finalDS.union(firstRole.getExplainSub(pred.getName()), _strategy.getABox().doExplanation()).union(s.getExplainSub(chain), _strategy.getABox().doExplanation()));
@Override public DependencySet getExplainSubOrInv(final Role r) { final DependencySet ds = _explainSub.get(r.getName()); if (ds == null) return _inverse.getExplainSub(r.getName()); return ds; }
@Override public void propogateRange(final Role role, final Map<ATermAppl, Set<Set<ATermAppl>>> ranges) { if (ranges == null || ranges.isEmpty()) return; for (final Map.Entry<ATermAppl, Set<Set<ATermAppl>>> e : ranges.entrySet()) { final Set<ATermAppl> explanation = e.getValue().iterator().next(); final ATermAppl range = e.getKey(); final ATermAppl normalized = ATermUtils.normalize(range); for (final Role s : role.getSubRoles()) { final DependencySet explainSub = role.getExplainSub(s.getName()); final DependencySet ds = explainSub.union(explanation, true); s.addRange(normalized, ds); } } }
@Override public void propogateRange(final Role role, final Map<ATermAppl, Set<Set<ATermAppl>>> ranges) { if (ranges == null || ranges.isEmpty()) return; for (final Map.Entry<ATermAppl, Set<Set<ATermAppl>>> e : ranges.entrySet()) { final Set<ATermAppl> explanation = e.getValue().iterator().next(); final ATermAppl range = e.getKey(); final ATermAppl normalized = ATermUtils.normalize(range); for (final Role s : role.getSubRoles()) { final DependencySet explainSub = role.getExplainSub(s.getName()); final DependencySet ds = explainSub.union(explanation, true); s.addRange(normalized, ds); } } }
@Override public void propogateDomain(final Role role, final Map<ATermAppl, Set<Set<ATermAppl>>> domains) { if (domains == null || domains.isEmpty()) return; for (final Map.Entry<ATermAppl, Set<Set<ATermAppl>>> e : domains.entrySet()) { final Set<ATermAppl> explanation = e.getValue().iterator().next(); final ATermAppl domain = e.getKey(); final ATermAppl normalized = ATermUtils.normalize(domain); for (final Role s : role.getSubRoles()) { final DependencySet explainSub = role.getExplainSub(s.getName()); final DependencySet ds = explainSub.union(explanation, true); s.addDomain(normalized, ds); } } }
@Override public void propogateDomain(final Role role, final Map<ATermAppl, Set<Set<ATermAppl>>> domains) { if (domains == null || domains.isEmpty()) return; for (final Map.Entry<ATermAppl, Set<Set<ATermAppl>>> e : domains.entrySet()) { final Set<ATermAppl> explanation = e.getValue().iterator().next(); final ATermAppl domain = e.getKey(); final ATermAppl normalized = ATermUtils.normalize(domain); for (final Role s : role.getSubRoles()) { final DependencySet explainSub = role.getExplainSub(s.getName()); final DependencySet ds = explainSub.union(explanation, true); s.addDomain(normalized, ds); } } }
@Override public void computeImmediateSubRoles(final Role r, final Map<ATerm, DependencySet> subs) { final Role invR = r.getInverse(); if (invR != null && invR != r) { for (final Role invSubR : invR.getSubRoles()) { final Role subR = invSubR.getInverse(); if (subR == null) _logger.fine(() -> "Property " + invSubR + " was supposed to be an ObjectProperty but it is not!"); else if (subR != r) subs.put(subR.getName(), invR.getExplainSub(invSubR.getName())); } for (final ATermList roleChain : invR.getSubRoleChains()) subs.put(inverse(roleChain), invR.getExplainSub(roleChain)); } for (final Role sub : r.getSubRoles()) subs.put(sub.getName(), r.getExplainSub(sub.getName())); for (final ATermList subChain : r.getSubRoleChains()) subs.put(subChain, r.getExplainSub(subChain)); }
@Override public void computeImmediateSubRoles(final Role r, final Map<ATerm, DependencySet> subs) { final Role invR = r.getInverse(); if (invR != null && invR != r) { for (final Role invSubR : invR.getSubRoles()) { final Role subR = invSubR.getInverse(); if (subR == null) _logger.fine(() -> "Property " + invSubR + " was supposed to be an ObjectProperty but it is not!"); else if (subR != r) subs.put(subR.getName(), invR.getExplainSub(invSubR.getName())); } for (final ATermList roleChain : invR.getSubRoleChains()) subs.put(inverse(roleChain), invR.getExplainSub(roleChain)); } for (final Role sub : r.getSubRoles()) subs.put(sub.getName(), r.getExplainSub(sub.getName())); for (final ATermList subChain : r.getSubRoleChains()) subs.put(subChain, r.getExplainSub(subChain)); }
protected WME createEdge(final Edge edge, final EdgeDirection dir) { if (_doExplanation) { final DependencySet ds = dir == EdgeDirection.FORWARD ? _role.getExplainSub(edge.getRole().getName()) : _role.getInverse().getExplainSub(edge.getRole().getName()); if (!ds.getExplain().isEmpty()) return WME.createEdge(new DefaultEdge(edge.getRole(), edge.getFrom(), edge.getTo(), edge.getDepends().union(ds, _doExplanation)), dir); } return WME.createEdge(edge, dir); }
protected WME createEdge(final Edge edge, final EdgeDirection dir) { if (_doExplanation) { final DependencySet ds = dir == EdgeDirection.FORWARD ? _role.getExplainSub(edge.getRole().getName()) : _role.getInverse().getExplainSub(edge.getRole().getName()); if (!ds.getExplain().isEmpty()) return WME.createEdge(new DefaultEdge(edge.getRole(), edge.getFrom(), edge.getTo(), edge.getDepends().union(ds, _doExplanation)), dir); } return WME.createEdge(edge, dir); }
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; }
public boolean checkMaxClash(final ATermAppl normalizedMax, final DependencySet maxDepends) { final ATermAppl maxCard = (ATermAppl) normalizedMax.getArgument(0); final Role maxR = _abox.getRole(maxCard.getArgument(0)); if (maxR == null) return false; final int max = ((ATermInt) maxCard.getArgument(1)).getInt() - 1; final ATermAppl maxC = (ATermAppl) maxCard.getArgument(2); for (final ATermAppl minCard : _types[MIN]) { final Role minR = _abox.getRole(minCard.getArgument(0)); if (minR == null) return false; final int min = ((ATermInt) minCard.getArgument(1)).getInt(); final ATermAppl minC = (ATermAppl) minCard.getArgument(2); if (max < min && minC.equals(maxC) && minR.isSubRoleOf(maxR)) { final DependencySet minDepends = getDepends(minCard); final DependencySet subDepends = maxR.getExplainSub(minR.getName()); final DependencySet ds = minDepends.union(maxDepends, _abox.doExplanation()).union(subDepends, _abox.doExplanation()); _abox.setClash(Clash.minMax(this, ds)); return true; } } return false; }
public boolean checkMaxClash(final ATermAppl normalizedMax, final DependencySet maxDepends) { final ATermAppl maxCard = (ATermAppl) normalizedMax.getArgument(0); final Role maxR = _abox.getRole(maxCard.getArgument(0)); if (maxR == null) return false; final int max = ((ATermInt) maxCard.getArgument(1)).getInt() - 1; final ATermAppl maxC = (ATermAppl) maxCard.getArgument(2); for (final ATermAppl minCard : _types[MIN]) { final Role minR = _abox.getRole(minCard.getArgument(0)); if (minR == null) return false; final int min = ((ATermInt) minCard.getArgument(1)).getInt(); final ATermAppl minC = (ATermAppl) minCard.getArgument(2); if (max < min && minC.equals(maxC) && minR.isSubRoleOf(maxR)) { final DependencySet minDepends = getDepends(minCard); final DependencySet subDepends = maxR.getExplainSub(minR.getName()); final DependencySet ds = minDepends.union(maxDepends, _abox.doExplanation()).union(subDepends, _abox.doExplanation()); _abox.setClash(Clash.minMax(this, ds)); return true; } } return false; }
getABox().setExplanation(role1.getExplainSuper(p2).union(role1.getExplainSub(p2), doExplanation())); return true;
getABox().setExplanation(role1.getExplainSuper(p2).union(role1.getExplainSub(p2), doExplanation())); return true;
final DependencySet subDepends = maxR.getExplainSub(minR.getName()); final DependencySet ds = minDepends.union(maxDepends, _abox.doExplanation()).union(subDepends, _abox.doExplanation());
final DependencySet subDepends = maxR.getExplainSub(minR.getName()); final DependencySet ds = minDepends.union(maxDepends, _abox.doExplanation()).union(subDepends, _abox.doExplanation());
for (final ATermList chain : subRoleChains) final DependencySet subChainDS = ds.union(s.getExplainSub(chain), _strategy.getABox().doExplanation()); if (!applyAllValuesPropertyChain(x, chain, c, subChainDS)) return;