Trying to understand how the reasoner works

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

Trying to understand how the reasoner works

nerp
I am trying to understand if running the reasoner guarantees that I have the deductive closure of the ontology. In the example below, I say that Mother is a subclass of Female and Father is a subclass of Female, yet the individual (who has been explicitly said to be a Mother) is not said to be Female after I run the reasoner. Is this normal behavior?

Reply | Threaded
Open this post in threaded view
|

Re: Trying to understand how the reasoner works

Jiba
Administrator
If Mother is a direct subclass of Female, and individual x is a Mother, the reasoner will infer that it is a Female. However, this inference is considered as trivial (as it is a simple inheritance), and Owlready do not add the Female class to x.

If needed, you can obtain the Female class easily via inheritance. You may check whether x is a Female (with isinstance(x, Female)) or get all the indirect superclasses (with x.INDIRECT_is_a).

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Trying to understand how the reasoner works

nerp
Thank you. I don't think I still fully grasp how the .ancestor method works, though. If I have a restriction such as prop.P40.some(owl.Thing) (something like \exists p40.Thing in DL) and call prop.P40.some(owl.Thing).ancestors(include_self=True, include_constructs=True) it returns an empty set, but in my mind this should return at least a set with the element itself (every concept is a subset of itself). Is this not correct?
Reply | Threaded
Open this post in threaded view
|

Re: Trying to understand how the reasoner works

Jiba
Administrator
Yes, this is the case as show the following example:


from owlready2 import *
from fullpy.serializer import *

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

with onto:
  class C(Thing): pass
  class prop(Thing >> Thing): pass

print(prop.some(C).ancestors(True, True))
# => {onto.prop.some(onto.C)}