OWL 2 reasoning with SWRL rules
Asked Answered
H

1

1

I'm trying to use the HermiT reasoner to compute inferences for an ontology which contains a set of OWL axioms and a SWRL rule:

Ontology(
  ClassAssertion( :Student :Bob )
  ClassAssertion( :Professor :DrBoffin )
  ClassAssertion( :University :UF )
  ObjectPropertyAssertion( :supervises :DrBoffin :Bob )
  ObjectPropertyAssertion( :worksAt :DrBoffin :UF )

  EquivalentClasses( :Student ObjectHasSelf( :r1 ))
  EquivalentClasses(
    ObjectHasSelf( :r2 )
    ObjectSomeValuesFrom( :worksAt :University ))
  SubObjectPropertyOf(
    ObjectPropertyChain( :r2 :supervises :r1 ) :professorOf )

  DLSafeRule(Body(ObjectPropertyAtom( :professorOf Variable( ?x ) Variable( ?y )))
             Head(ObjectPropertyAtom( :instructorOf Variable( ?x ) Variable( ?y ))))
)

Basically, the OWL part is trying to express such a rule:

worksAt(x, y), University(y), supervises(x, z), Student(z) -> professorOf(x, z)

using property chain and rolification techniques:

rule

The SWRL part is:

professorOf(x, y) -> instructorOf(x, y)

The expected output should contain both ObjectPropertyAssertion( :professorOf :DrBoffin :Bob ) and ObjectPropertyAssertion( :instructorOf :DrBoffin :Bob ). However, the actual output is (showing only object properties)

ObjectPropertyAssertion( :r1 :Bob :Bob )
ObjectPropertyAssertion( :professorOf :DrBoffin :Bob )
ObjectPropertyAssertion( :r2 :DrBoffin :DrBoffin )
ObjectPropertyAssertion( :supervises :DrBoffin :Bob )
ObjectPropertyAssertion( :worksAt :DrBoffin :UF)

Why isn't the expected SWRL result showing up? Any suggestions?

Hackett answered 11/6, 2013 at 1:27 Comment(3)
I don't know whether this is the problem or not, but the HermiT homepage (which you linked to) does say , “Note that reasoning with DL Safe rules is incomplete if the ontology contains property chains or transitivity axioms and complex properties are used in the rule bodies.” There are object property chains here, so that might lead to a problem.Showker
In your ontology, you have SubObjectPropertyOf( ObjectPropertyChain( :r2 :supervises :r3 ) :professorOf ). However, :r3 does not appear to be used anywhere else. Is something missing?Showker
@JoshuaTaylor I'm sorry, it should be :r1. I've updated my post.Hackett
S
1

After re-reading your question, I realized that the rule you are trying to represent is

worksAt(x, y), University(y), supervises(x, z), Student(z) → professorOf(x, z)

but that you are trying to represent it, essentially by

(worksAt some University)(x), supervises(x, z), Student(z) → professorOf(x, z)

which is actually a valid SWRL rule, even though it has a complex class expression. (See Can OWL Class Expressions be used in SWRL Rules? for more information. Even though they're valid, the Protégé editor didn't accept that input, though it would display rules correctly if they are already in the ontology.)

Although it can be expressed in SWRL, that will only cover cases where the individuals are named, so the rolification based solution will cover more cases. So, the idea is to create a role rWorksAtSomeUniversity (the rolification of worksAt some University) and a role rStudent (the rolification of Student, and then to assert that

rWorksAtSomeUniversity o supervises o rStudent SubPropertyOf professorOf

Then, to relate professorOf and instructorOf, you can either use a SWRL rule

professorOf(x,y) → instructorOf(x,y)

or a subproperty axiom

professorOf SubPropertyOf instructorOf

As with rolification-based rule, the non-SWRL rule will cover more cases, and does not require that the reasoner have SWRL support.

Here's an ontology that contains these classes and axioms, in the OWL functional syntax. It's not wonderfully human readable, but it's complete; you should be able to download it and test it out with your reasoner.

Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(ex:=<http://www.example.com/university#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)

Ontology(<http://www.example.com/university>

Declaration(Class(ex:Professor))
Declaration(Class(ex:Student))
EquivalentClasses(ex:Student ObjectHasSelf(ex:rStudent))
Declaration(Class(ex:University))
Declaration(ObjectProperty(ex:instructorOf))
Declaration(ObjectProperty(ex:professorOf))
SubObjectPropertyOf(ex:professorOf ex:instructorOf)
Declaration(ObjectProperty(ex:rStudent))
Declaration(ObjectProperty(ex:rWorksAtSomeUniversity))
Declaration(ObjectProperty(ex:supervises))
Declaration(ObjectProperty(ex:worksAt))
Declaration(NamedIndividual(ex:Bob))
ClassAssertion(ex:Student ex:Bob)
Declaration(NamedIndividual(ex:DrBoffin))
ClassAssertion(ex:Professor ex:DrBoffin)
ObjectPropertyAssertion(ex:supervises ex:DrBoffin ex:Bob)
ObjectPropertyAssertion(ex:worksAt ex:DrBoffin ex:UF)
Declaration(NamedIndividual(ex:UF))
ClassAssertion(ex:University ex:UF)
EquivalentClasses(ObjectHasSelf(ex:rWorksAtSomeUniversity) ObjectSomeValuesFrom(ex:worksAt ex:University))
SubObjectPropertyOf(ObjectPropertyChain(ex:rWorksAtSomeUniversity ex:supervises ex:rStudent) ex:professorOf)
)

Both Pellet and HermiT 1.3.7 can produce the inferences:

DrBoffin professorOf Bob
DrBoffin instructorOf Bob
Showker answered 11/6, 2013 at 3:8 Comment(13)
Hi Joshua, I tried both syntax to make sure that HermiT is working well with either syntax.Hackett
@Hackett I'm not sure what you mean about syntax, but I do think I made a mistake in my answer, because I think I misread your question, so I'm taking another look…Showker
@Hackett OK, sorry about the first answer. If you did read it, I was wrong when I said that the rule couldn't be expressed using rolification and subproperty chain axioms. In fact, it can be expressed, and the updated answer includes an ontology that expresses it, and I confirmed that the desired inferences are produced by Pellet and HermiT.Showker
Yes, that's what I want, but you include both SubObjectPropertyOf(ex:professorOf ex:instructorOf) and the equivalent SWRL rule. Why the SWRL rule alone does not produce DrBoffin instructorOf Bob?Hackett
@Hackett Ooops, that was just an accident. I'd added the rule early on, and forgot to remove it. I just removed it, and the reasoners still make the correct inferences using just the subproperty chain axioms. Sorry about that! I've removed the SWRL rule from the ontology in the answer.Showker
If you remove the subproperty and keep SWRL rule, does it work?Hackett
@Hackett In this case, you can keep the SWRL rule and remove the subproperty axiom and still get the same results. In more complicated scenarios, subproperty chain axioms and SWRL rules are not necessarily interchangeable.Showker
It didn't work in this case. My original ontology has the SWRL rule but not the subproperty axiom, and doesn't work as expected. That's what confuses me.Hackett
@Hackett when you say “the subproperty axiom”, you mean the professorOf SubPropertyOf instructorOf, right? Replacing that subproperty axiom with the SWRL rule professorOf(x,y) → instructorOf(x,y) is not a problem, because we are only concerned with named individuals. If something else isn't working, I expect it's either in the version of the reasoner (I'm using HermiT 1.3.7 and Pellet 2.2.0) or the in the way that you're querying your ontology. If you use the ontology in the answer, do you get the results I've described?Showker
Yes, your ontology gives the expected answer. I'll try to find my problems.Hackett
@JoshuaTaylor: I am also trying to use the same solution for my problem in protege, but I don't understand: EquivalentClasses(ObjectHasSelf(ex:rWorksAtSomeUniversity) ObjectSomeValuesFrom(ex:worksAt ex:University)). how should i define it? do I need to create a class or is it a GCA?Exaggeration
That looks like a GCA. You can load the file from the answer into Protege and see how it appears there. The location of GCAs in Protege is a little bit unintuitive. See, e.g., this answer.Showker
@JoshuaTaylor: Thanks. I did as you said and yes it is GCA. I tried to adapt this answer and some other to my problem but still have problem with my ontology. don't know how to fix it. I am sorry to ask you here but could you plz check this question out. #31457844. I have read many answers regarding rolification and SWRL, but mostly are with two relations while mine is a long chain!!!!Exaggeration

© 2022 - 2024 — McMap. All rights reserved.