Reasoning - Infer multiple things

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

Reasoning - Infer multiple things

jayson
Hi Together,

I recently started using owlready and build ontologies. Now I want to infer multiple facts which are modeled and are feasible, but the reasoner returns just one, even if other should be possible.

(The questions are below the code)

Here the code snippet:
=========================================================================
onto = get_ontology("http://test.org/onto.owl")

with onto:
    class Cause(Thing):
        def infer(self):
            print("None")


    class Deviation(Thing):
        pass


    class NoFlow(Deviation):
        pass


    class Vacuum(Deviation):
        pass


    class HighPressure(Deviation):
        pass


    class isCauseOf(Cause >> Deviation):
        python_name = "is_cause_of"


    class SuctionValveClosed(Cause):
        equivalent_to = [Cause & isCauseOf.some(NoFlow | Vacuum)]

        def infer(self):
            print("SuctionValveClosed")


    class DischargeValveClosed(Cause):
        equivalent_to = [Cause & isCauseOf.some(NoFlow | HighPressure)]

        def infer(self):
            print("DischargeValveClosed")


deviation = NoFlow(None)

cause = Cause(is_cause_of=[deviation])

sync_reasoner()

cause.infer()
=========================================================================

And the result:

* Owlready2 * HermiT took 1.135000467300415 seconds
DischargeValveClosed

=========================================================================

How is it possible to receive both classes (DischargeValveClosed and SuctionValveClosed) since both are valid results?

Or is my way to model these coherences with owl wrong by default?

Thanks for your help in advance.

jayson
Reply | Threaded
Open this post in threaded view
|

Re: Reasoning - Infer multiple things

Jiba
Administrator
Hi,

As far as I know, ontology reasoners only determine new facts when these new facts are sure and proveable, not when they are "feasible" or "possible but not necessarily true".

Here, it seems that the "cause" individual can be classified in both SuctionValveClosed and DischargeValveClosed. In this case, Owlready create a new class that inherits from both, however, this new class does not have method, and thus the infer() method is one of the parent's one arbitrary choice).

I think you should rather do:

print(cause.is_a)

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Reasoning - Infer multiple things

jayson
Hi,

thanks a lot, that simple hint solved it for me!

Best regards
Jayson