0

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?

Scholle
  • 1,521
  • 2
  • 23
  • 44
  • What does this mean: **"There are multiple classes of type A (which are "managed by" other classes) and multiple classes of B."**? You mean *subclasses* of type A and B? Or *individuals* of type A and B? This is important, because later you write: **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.** But what do you mean? *Classes* don't have properties. properties relate individuals. You *might* mean something like... – Joshua Taylor Feb 23 '15 at 13:38
  • ..."iterate through the subclasses of B and check whether each subclass Bi is a subclass of the restriction class (isManagedBy some Ai) where Ai is a subclass of A" Is that what you're aiming for? – Joshua Taylor Feb 23 '15 at 13:40
  • @Joshua: By multiple classes (OWlClass) I mean there is not just one class of "type" A as shown in the example (#FunctionManagement). There are also other, lets say #FunctionManagement1, #FunctionManagement2, #FunctionManagement2. There also multiple classes of type B, not just one, as in the example, #SymposiumPlanner2013, #SymposiumPlanner2013b, #SymposiumPlanner2013c, #SymposiumPlanner2013d.... In addition, classes of type A and B also have a hierarchy. As shown in the example, #FunctionManagement is a child of some other class of type A, let's say #FunctionManagementParent... – Scholle Feb 23 '15 at 14:51
  • @Joshua: In the ontology, there are only classes (OWLClass) and object properties (OWLObjectProperty), nothing else (no individuals)... – Scholle Feb 23 '15 at 14:54
  • @Joshua: The term "type" might be a bit misleading, it doesn't mean there is an instance of of some type of class. It just means there are two "types", "sets", whatever of classes. Whereas type class A isManagedBy type class B. – Scholle Feb 23 '15 at 14:56
  • "Whereas type class A isManagedBy type class B." It's still not quite clear what you mean here. Do you mean that every *instance* of A will be managed by some *instance* of B? – Joshua Taylor Feb 23 '15 at 15:37
  • @Joshua As I said, there are NO instances (by instance I am referring to OWLNamedIndividual) in this ontology, only classes (OWLClass). So, this would be correct: "...every class of A will be managed by some class of B?" Again, "type" doesn't refer to a specific class, but rather a set of classes that are either on the left or right side of the "isManagedBy" dependency. – Scholle Feb 23 '15 at 15:53
  • I understand that there are no individuals declared in the ontology. However, *object properties **don't** relate classes, but individuals*. If you have class A and class B and object property P, you never have the assertion that "A P B". You can have the assertion "a P b" where a and b are instances of A and B. There are only a few relationships that classes can have to each other in OWL, and the most common is the subclass relationship. So you can say, for instance, that "AppleOrchard subClassOf (isManagedBy some AppleOrchardManager)". This means that every *instance* of – Joshua Taylor Feb 23 '15 at 16:33
  • AppleOrchard will be related to some *instance* of AppleOrchardManager by the isManagedBy property. The *instances*, not the *classes*, are related by the property. This is true, even if there are no declared instances in the ontology. It sounds like you're trying to ask: "given a class A, what are the possible classes B such that it's possible for "a isManagedBy b" where a and b are instances of A and B. – Joshua Taylor Feb 23 '15 at 16:34
  • Satistfiability *is* the right solution here, however, unless you've declared that some of your classes are disjoint, you'll get *many* results. E.g, if you say that "A subClassOf (isManagedBy only AManager)" and "B subClassOf (isManagedBy only BManager)", when it's not inconsistent if some a is managed by some BManager bm; it just means that bm is *also* an AManager. That would only be inconsistent if you've also declared that "AManager disjointWith BManager." – Joshua Taylor Feb 23 '15 at 16:39

2 Answers2

1

You don't want to check for satisfiability here, as it only tells you if you would be able to have an instance of that class. What you are after are actual instances of it. As there might be a hierarchy of classes, you want to use:

reasoner.getInstances(expression, false)

which will give you direct and indirect instances.

Edit: from comments, looks like you are after subclasses of A that are in the domain of isManagedBy, or for which restrictions over isManagedBy have subclasses of B as range.

Something like reasoner.getSubClasses(expression, false) might be closer to what you expect to see.

Ignazio
  • 10,504
  • 1
  • 14
  • 25
  • As far as I know, the method getInstances() is suitable for returning objects of type OWLNamedIndividual. There are only classes, no individuals on the ontology. I actually tried the change you suggested, but the return is empty, as expected. – Scholle Feb 23 '15 at 09:07
  • Sorry, I assumed that by classes managed by other classes you meant instances of those classes, as your example uses an object property. – Ignazio Feb 23 '15 at 19:28
1

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 */
    
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
Dmitry Tsarkov
  • 768
  • 4
  • 11
  • In your part (1), there's only an inconsistency if A must be managed by *something*. E.g., the class `A and (isManagedBy only (B and (not B)))` is not unsatisfiable on its own. It's just the subclass of A whose instances have no isManagedBy values; i.e., `A and (isManagedBy exactly 0)`. – Joshua Taylor Feb 24 '15 at 02:55
  • > In your part (1), there's only an inconsistency if A must be managed by something.>Yes, and that's exactly what the author wants to check (as far as I understand – Dmitry Tsarkov Feb 24 '15 at 08:26
  • > In your part (1), there's only an inconsistency if A must be managed by something. -- Yes, and that's exactly what the author wants to check (as far as I understand "whether a given A has an ObjectProperty `isManagedBy` (directly or inherited) to class B"). If there is nothing which `manages` A, then we should find no Bs. – Dmitry Tsarkov Feb 24 '15 at 08:35
  • Yes, that seems to be what the author wants to check. My point is that we haven't seen enough of the ontology to know whether the rest of the ontology implies it or not. That is, it's not clear whether OP is not getting the results OP wants because the *Java code* is wrong, or because something else is missing in the rest of the ontology. – Joshua Taylor Feb 24 '15 at 11:48