Implicitly consider restrictions from other class

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

Implicitly consider restrictions from other class

jayson
Hello together,

I was wondering if it is possible to consider restriction from concept A during the definition of concept B.
Let me illustrate this with an example.

from owlready2 import *

onto = get_ontology("test")

with onto:

        # "Concept A"
    class Substance(Thing):
        pass

    class Attribute(Thing):
        pass

    class Liquid(Attribute):
        pass

    class has_attribute(Substance >> Attribute):
        pass

        # "Concept B"
    class Cause(Thing):
        pass

    class cause_involves_attribute(Cause >> Attribute):
        pass

    class Leakage(Cause):
        equivalent_to = [Cause & cause_involves_attribute.some(Liquid)]

attr1 = Liquid()

cause1 = Cause(cause_involves_attribute=[attr1])

sync_reasoner()

print("debug")


For now, I am modeling a "Substance" with an "Attribute" like "Liquid".
After that, I defined another concept, e.g., "Cause" which can depend on this "Attribute", which is done using the relation "cause_involves_attribute".

Is it possible to model the "Substance" with all "Attribute"(s) and somehow access these attributes within the "Leakage" class to restrict it? So the reasoner could implicitly consider the restriction that are already contained in the "Substance" definition. So I would not need the "cause_involves_attribute" relation and could use a "cause_involves_substance" relation instead!?

Thank you for your time in advance,
Jayson
Reply | Threaded
Open this post in threaded view
|

Re: Implicitly consider restrictions from other class

Jiba
Administrator
Hi,

You can embed restrictions as follows:

    class Leakage(Cause):
        equivalent_to = [Cause & cause_involves_substance.some( has_attribute.some(Liquid) )]


Doing so, you can have a "cause_involves_substance" property. I'm not sure whether this answer your question or not?

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Implicitly consider restrictions from other class

jayson
Hi Jiba,

embedding the restriction did the trick and is exactly what I intended to do. Thank you very much.

Jayson