role.setSubRolesAndChains(subRoles, subRoleChains, subExplain); final DependencySet explainSub = role.getExplainSub(s.getName()); s.addSuperRole(role, explainSub); role.setHasComplexSubRole(true); complexRoles.add(role); break; final Role invR = role.getInverse(); if (invR != null) if (invR.isTransitive() && !role.isTransitive()) role.setTransitive(true, invR.getExplainTransitive()); else if (role.isTransitive() && !invR.isTransitive()) invR.setTransitive(true, role.getExplainTransitive()); if (invR.isFunctional() && !role.isInverseFunctional()) role.setInverseFunctional(true, invR.getExplainFunctional()); if (role.isFunctional() && !invR.isInverseFunctional()) invR.setInverseFunctional(true, role.getExplainFunctional()); if (invR.isInverseFunctional() && !role.isFunctional()) role.setFunctional(true, invR.getExplainInverseFunctional()); if (invR.isAsymmetric() && !role.isAsymmetric()) role.setAsymmetric(true, invR.getExplainAsymmetric()); if (role.isAsymmetric() && !invR.isAsymmetric()) invR.setAsymmetric(true, role.getExplainAsymmetric()); if (invR.isReflexive() && !role.isReflexive()) role.setReflexive(true, invR.getExplainReflexive());
protected boolean interactsWithInversesComplex(final KnowledgeBase kb, final Role role) { for (final ATermAppl p : _expressivity.getAnonInverses()) { final Role anonRole = kb.getRole(p); if (anonRole.hasComplexSubRole() && anonRole.getFSM().getAlpahabet().contains(role)) return true; } return false; }
public void applyFunctionality(final Individual subj, final Role pred, final Node obj) { DependencySet maxCardDS = pred.isFunctional() ? pred.getExplainFunctional() : subj.hasMax1(pred); if (maxCardDS != null) _maxRule.applyFunctionalMaxRule(subj, pred, ATermUtils.getTop(pred), maxCardDS); if (pred.isDatatypeRole() && pred.isInverseFunctional()) applyFunctionalMaxRule((Literal) obj, pred, DependencySet.INDEPENDENT); else if (pred.isObjectRole()) { final Individual val = (Individual) obj; final Role invR = pred.getInverse(); maxCardDS = invR.isFunctional() ? invR.getExplainFunctional() : val.hasMax1(invR); if (maxCardDS != null) _maxRule.applyFunctionalMaxRule(val, invR, ATermUtils.TOP, maxCardDS); } }
protected EdgeDirection edgeMatches(final Edge edge) { final Role edgeRole = edge.getRole(); final boolean isFwd = edgeRole.isSubRoleOf(_role); final boolean isBwd = _role.getInverse() != null && edgeRole.isSubRoleOf(_role.getInverse()); return isFwd ? isBwd ? EdgeDirection.BOTH : EdgeDirection.FORWARD : isBwd ? EdgeDirection.BACKWARD : null; }
default void ignoreTransitivity(final Role role) { final Role namedRole = role.isAnon() ? role.getInverse() : role; final String msg = "Unsupported axiom: Ignoring transitivity and/or complex subproperty axioms for " + namedRole; if (!OpenlletOptions.IGNORE_UNSUPPORTED_AXIOMS) throw new UnsupportedFeatureException(msg); getLogger().warning(msg); role.removeSubRoleChains(); role.setHasComplexSubRole(false); role.setSimple(true); role.setFSM(null); role.getInverse().removeSubRoleChains(); role.getInverse().setHasComplexSubRole(false); role.getInverse().setSimple(true); role.getInverse().setFSM(null); }
if (r.isBuiltin()) continue; if (r.isDatatypeRole()) if (r.isInverseFunctional()) _expressivity.setHasKeys(true); if (r.isAnon()) for (final Role subRole : r.getSubRoles()) if (!subRole.isAnon() && !subRole.isBottom()) _expressivity.setHasInverse(true); if (r.isAnon() && r.isFunctional()) _expressivity.setHasInverse(true); if (r.isFunctional()) if (r.isDatatypeRole()) _expressivity.setHasFunctionalityD(true); else if (r.isObjectRole()) _expressivity.setHasFunctionality(true); if (r.isTransitive()) _expressivity.setHasTransitivity(true); if (r.isReflexive()) _expressivity.setHasReflexivity(true); if (r.isIrreflexive()) _expressivity.setHasIrreflexivity(true); if (r.isAsymmetric()) _expressivity.setHasAsymmetry(true);
final SimpleProperty why = _simpleProperties.get(r.getName()); if (why != null) if (r.isTransitive()) msg = "transitivity axiom"; else if (r.hasComplexSubRole()) msg = "complex sub property axiom"; r.removeSubRoleChains(); if (r.isUntypedRole()) final Set<Role> roles = SetUtils.union(r.getSubRoles(), r.getSuperRoles()); for (final Role sub : roles) switch (sub.getType()) defineObjectProperty(r.getName()); break; case DATATYPE: defineDatatypeProperty(r.getName()); rangeToDatatype = true; break; defineObjectProperty(r.getName()); final Set<ATermAppl> ranges = r.getRanges(); if (ranges != null) if (rangeToDatatype)
if (role1.isSubRoleOf(role2) && role2.isSubRoleOf(role1)) getABox().setExplanation(role1.getExplainSuper(p2).union(role1.getExplainSub(p2), doExplanation())); return true; if (role1.isAnnotationRole() || role2.isAnnotationRole()) return false; if (role1.getType() != role2.getType()) return false; if (role1.isObjectRole()) final ATermAppl c = !role1.getRanges().isEmpty() ? role1.getRanges().iterator().next() : !role2.getRanges().isEmpty() ? role2.getRanges().iterator().next() : ATermUtils.makeTermAppl("_C_"); final ATermAppl notC = ATermUtils.makeNot(c); test = ATermUtils.makeOr(ATermUtils.makeAnd(ATermUtils.makeSomeValues(p1, c), ATermUtils.makeAllValues(p2, notC)), ATermUtils.makeAnd(ATermUtils.makeSomeValues(p2, c), ATermUtils.makeAllValues(p1, notC))); if (role1.isDatatypeRole())
if (role.isFunctional()) types.add(OWL.FunctionalProperty.asNode()); if (role.isInverseFunctional()) types.add(OWL.InverseFunctionalProperty.asNode()); if (role.isTransitive()) types.add(OWL.TransitiveProperty.asNode()); if (role.isSymmetric()) types.add(OWL.SymmetricProperty.asNode()); if (role.isAsymmetric()) types.add(OWL2.AsymmetricProperty.asNode()); if (role.isReflexive()) types.add(OWL2.ReflexiveProperty.asNode()); if (role.isIrreflexive()) types.add(OWL2.IrreflexiveProperty.asNode()); if (role.isFunctional()) types.add(OWL.FunctionalProperty.asNode()); if (role.isInverseFunctional()) types.add(OWL.InverseFunctionalProperty.asNode());
continue; // FIXME : this should not occur but it does in ME.owl ME2.owl if (s.isTop() && s.isObjectRole()) if (pred.isSubRoleOf(s)) finalDS = finalDS.union(s.getExplainSubOrInv(pred).getExplain(), true); if (s.isTransitive()) final ATermAppl allRC = ATermUtils.makeAllValues(s.getName(), c); finalDS = ds.union(subj.getDepends(av), _strategy.getABox().doExplanation()); if (_strategy.getABox().doExplanation()) finalDS = finalDS.union(s.getExplainTransitive().getExplain(), true);
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; } }
default boolean isTransitiveProperty(final ATermAppl r) { if (null == r) return false; final Role role = getRole(r); if (role == null) { Base.handleUndefinedEntity(r + _isNotAnKnowProperty); return false; } if (role.isTransitive()) { if (doExplanation()) getABox().setExplanation(role.getExplainTransitive()); return true; } else if (!role.isObjectRole() || role.isFunctional() || role.isInverseFunctional()) return false; ensureConsistency(); final ATermAppl c = ATermUtils.makeTermAppl("_C_"); final ATermAppl notC = ATermUtils.makeNot(c); final ATermAppl test = ATermUtils.makeAnd(ATermUtils.makeSomeValues(r, ATermUtils.makeSomeValues(r, c)), ATermUtils.makeAllValues(r, notC)); return !getABox().isSatisfiable(test); }
@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)); }
/** * @return the set of all properties. */ public default Set<ATermAppl> getProperties() { final Set<ATermAppl> set = new HashSet<>(); for (final Role role : getRBox().getRoles().values()) { final ATermAppl p = role.getName(); if (ATermUtils.isPrimitive(p) && (role.isObjectRole() || role.isDatatypeRole() || role.isAnnotationRole())) set.add(p); } return set; }
@Override public void getTransitivePropertyValues(final Individual subj, final Role prop, final Set<ATermAppl> knowns, final Set<ATermAppl> unknowns, final boolean getSames, final Map<Individual, Set<Role>> visited, final boolean isIndependent) if (!MultiMapUtils.addAll(visited, subj, prop.getSubRoles())) return; final DependencySet ds = edge.getDepends(); final Individual value = (Individual) edge.getNeighbor(subj); final Role edgeRole = edge.getFrom().equals(subj) ? edge.getRole() : edge.getRole().getInverse(); if (value.isRootNominal()) if (isIndependent && ds.isIndependent()) unknowns.add(value.getName()); if (!prop.isSimple()) final Set<Role> transRoles = SetUtils.intersection(edgeRole.getSuperRoles(), prop.getTransitiveSubRoles()); for (final Role transRole : transRoles) getTransitivePropertyValues(value, transRole, knowns, unknowns, getSames, visited, isIndependent && ds.isIndependent());
@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); } } }
for (final Edge edge : edges) final Role role = checkInverses ? edge.getRole().getInverse() : edge.getRole(); final DependencySet ds = edge.getDepends(); final ATermAppl val = checkInverses ? edge.getFromName() : edge.getToName(); if (!role.isObjectRole()) found = pNode.hasRNeighbor(role); else if (!isRootNominal(kb, val)) if (!role.hasComplexSubRole()) found = pNode.hasRNeighbor(role); else final TransitionGraph<Role> tg = role.getFSM(); final Iterator<Transition<Role>> it = tg.getInitialState().getTransitions().iterator(); while (!found && it.hasNext()) if (role.isSimple() || !(pNode instanceof Individual)) found = intersectsRNeighbors(getABoxSames(kb, val), pNode, role); else
@Test public void testPropertyChainInvalid() { final OntModel model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); model.read(_base + "propertyChainInvalid.owl"); model.prepare(); final KnowledgeBase kb = ((PelletInfGraph) model.getGraph()).getKB(); for (final Role r : kb.getRBox().getRoles().values()) if (!ATermUtils.isBuiltinProperty(r.getName())) { assertTrue(r + " is not simple", r.isSimple()); assertFalse(r + " is transitive", r.isTransitive()); assertFalse(r + " has complex sub roles", r.hasComplexSubRole()); } }
default boolean addInverseRole(final ATerm s, final ATerm r, final DependencySet ds) { final Role roleS = getRole(s); final Role roleR = getRole(r); if (roleS == null || roleR == null || !roleS.isObjectRole() || !roleR.isObjectRole()) return false; else addEquivalentRole(roleS.getInverse().getName(), r, ds); return true; }