@Override public void visit(final IndividualPropertyAtom atom) { result = _abox.getRole(atom.getPredicate()).isSimple(); }
@Override public void visit(final IndividualPropertyAtom atom) { result = _abox.getRole(atom.getPredicate()).isSimple(); }
private void collectComplexPropertyValues(final Individual subj) { final Set<Role> collected = new HashSet<>(); for (final Edge edge : subj.getOutEdges()) { final Role role = edge.getRole(); // only collect non-simple, i.e. complex, roles // TODO we might not need to collect all non-simple roles // collecting only the base ones, i.e. minimal w.r.t. role // ordering, would be enough if (role.isSimple() || !collected.add(role)) continue; collected.add(role); collectComplexPropertyValues(subj, role); } for (final Edge edge : subj.getInEdges()) { final Role role = edge.getRole().getInverse(); if (role.isSimple() || !collected.add(role)) continue; collectComplexPropertyValues(subj, role); } }
private void collectComplexPropertyValues(final Individual subj) { final Set<Role> collected = new HashSet<>(); for (final Edge edge : subj.getOutEdges()) { final Role role = edge.getRole(); // only collect non-simple, i.e. complex, roles // TODO we might not need to collect all non-simple roles // collecting only the base ones, i.e. minimal w.r.t. role // ordering, would be enough if (role.isSimple() || !collected.add(role)) continue; collected.add(role); collectComplexPropertyValues(subj, role); } for (final Edge edge : subj.getInEdges()) { final Role role = edge.getRole().getInverse(); if (role.isSimple() || !collected.add(role)) continue; collectComplexPropertyValues(subj, role); } }
@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(); } }
@Test public void testInvalidTransitivity2() { final KBLoader[] loaders = { new JenaLoader() }; for (final KBLoader loader : loaders) { final KnowledgeBase kb = loader.createKB(_base + "invalidTransitivity.owl"); for (final Role r : kb.getRBox().getRoles().values()) if (!ATermUtils.isBuiltinProperty(r.getName())) { assertTrue(r.toString(), r.isSimple()); assertFalse(r.toString(), r.isTransitive()); } for (final ATermAppl p : kb.getObjectProperties()) if (!ATermUtils.isBuiltinProperty(p)) assertFalse(p.toString(), kb.isTransitiveProperty(p)); } }
@Test public void testInvalidTransitivity2() { final OWLOntology ont = loadOntology(OWLManager.createOWLOntologyManager(), _base + "invalidTransitivity.owl"); final OpenlletReasoner reasoner = OpenlletReasonerFactory.getInstance().createReasoner(ont); final KnowledgeBase kb = reasoner.getKB(); kb.prepare(); for (final Role r : kb.getRBox().getRoles().values()) if (!ATermUtils.isBuiltinProperty(r.getName())) { assertTrue(r.toString(), r.isSimple()); assertFalse(r.toString(), r.isTransitive()); } for (final ATermAppl p : kb.getObjectProperties()) if (!ATermUtils.isBuiltinProperty(p)) assertFalse(p.toString(), kb.isTransitiveProperty(p)); }
unknowns.add(value.getName()); if (!prop.isSimple())
unknowns.add(value.getName()); if (!prop.isSimple())
return false; if (!s.isSimple())
return false; if (!s.isSimple())
if (!role.isSimple()) return false;
if (!role.isSimple()) return false;
@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()); } }
assertFalse(kb.getRole(r).isSimple());
assertFalse(kb.getRole(p).isSimple());
assertTrue(kb.getRole(q).isSimple());
assertFalse(kb.getRole(r).isSimple());
assertTrue(kb.getRole(q).isSimple());