differentFrom atom in swrl with owlready 2

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

differentFrom atom in swrl with owlready 2

pg76
Hi,

I'm quite new to the owlready 2. I encouter the following issue.

I would like to use differentFrom in a rule. However, it behaves strange. The reasoner seems not to execute the rule since no relations are added. I would expect that the reasoner would add a 'is_also_person_as' between John and Jane and between Jane en John. If you remove the differentFrom form the rule or replace it by sameAs it behaves like expected.

Is there anyone who can help me? I'm using version owlready2 0.47. Thank you very much!

Below you find a piece of code to illustrate my question.

from owlready2 import *

onto = get_ontology("http://test.org/onto.owl")

set_log_level(9)

with onto:
    class Person(Thing): pass
    class is_also_person_as(Person >> Person): pass

    rule = Imp()
    rule.set_as_rule("Person(?x) ^ Person(?y) ^ differentFrom(?x,?y)-> is_also_person_as(?x, ?y)")

set_log_level(0)

John = Person("John")
Jane = Person("Jane")

with onto:
     sync_reasoner(infer_property_values=True, debug=2)
Reply | Threaded
Open this post in threaded view
|

Re: differentFrom atom in swrl with owlready 2

pg76
Hi,

I found my mistake. You need to define explicitly that John and Jane are different persons by adding:

AllDifferent([John, Jane])

in that case differentFrom(?x,?y) is triggered and the rule is executed as expected. Meaning a is_also_person_as relation is added between John and Jane and between Jane and John as expected.