Search code examples
rdfsemantic-webowlowl-apireasoning

How to check if OWLObjectPropertyExpression between classes exists?


Assuming two types of classes, one (A) "isManagedBy" by the other (B). The following owl snipped illustrates this scenario. There are multiple classes of type A (which are "managed by" other classes) and multiple classes of B. In fact, there is also a hierarchy between between classes bot of type A and B.

<owl:ObjectProperty rdf:about="#isManagedBy"/>


<owl:Class rdf:about="#FunctionManagement">
 <rdfs:subClassOf rdf:resource="..."/>
 <rdfs:subClassOf>
   <owl:Restriction>
    <owl:onProperty rdf:resource="#isManagedBy"/>
    <owl:someValuesFrom rdf:resource="#SymposiumPlanner2013"/>
   </owl:Restriction>
  </rdfs:subClassOf>
</owl:Class>


<owl:Class rdf:about="#SymposiumPlanner2013"/>
...

Problem: Get all classes of type B given an arbitrary class A.

Idea: Iterate over all classes of type B. For each class B, check whether a given A has an ObjectProperty "isManagedBy" (directly or inherited) to class B by using a Reasoner's isSatisfiable() method.

OWLObjectProperty objProp = df.getOWLObjectProperty(IRI.create("#isManagedBy"));
OWLClassExpression expression;
for (OWLClass B : SetOfAllBs) {
 expression = df.getOWLObjectIntersectionOf(A, df.getOWLObjectSomeValuesFrom(objProp, B));
 if (reasoner.isSatisfiable(expression)) {
   // do something
 }
}

Unfortunately, the reasoner returns satisfiable for all classes of type B.

Question: How to solve this problem?


Solution

  • I can suggest two solutions to your problem:

    1. Go through all Bs, but instead check satisfiability of A and (isManagedBy only (not B)). If this expression is unsatisfiable for some B, then such B has to be connected with a given A via isManagedBy.

    2. If you are using FaCT++ for reasoning, you can use the OWLKnowledgeExplorerReasoner interface to explore the models produced during the satisfiability check of a class A. The idea is that if such B present in the model, then it has to be connected to A. There are some limitations (it might not work for Bs defined via EquivalentClasses(B,...), it is not always true for non-deterministic labels (see flag true in the getObjectLabel() call), but here is an idea. The code might looks like:

      OWLReasoner factplusplus = new FactPlusPluReasonerFactore().createReasoner(o);
      OWLKnowledgeExplorerReasoner ke = (OWLKnowledgeExplorerReasoner) factplusplus;
      RootNode nodeForA = ke.getRoot(A);
      for (RootNode filler: ke.getObjectNeighbours(nodeForA, isManagedBy))
          for (OWLClassExpression cls: ke.getObjectLabel(filler,true)
              if ( SetAllBs.contains(cls) )
                  /* cls is what you are looking for */