Unknown and false (solved)

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

Unknown and false (solved)

William
This post was updated on .
See the following code

from owlready2 import *

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


with test:
    class Human(Thing):
        pass

    class Man(Human):
        pass

    class Woman(Human):
        pass

    class love(Man >> Woman):
        pass

    Man.is_a.append(love.max(1, Woman))  # Man.love.append(Woman)

    a = Man('a')
    b = Woman('b')
    c = Woman('c')
    a.love.append(b)
    AllDifferent([b,c])
    AllDisjoint([Man, Woman])

# close_world(test)
sync_reasoner(debug=0)
print(a.love)
print(a.INDIRECT_is_a)
print(c.INDIRECT_is_a)


Whenever I use Man.is_a.append(love.max(1, Woman))  or Man.love.append(Woman), the result is the same: c is not in a.love. But in the first case, c is indeed not in a.love, but in the second case, it is just unknown whether a loves c. How do I distinguish the two cases? How do I conclude that c is indeed not loved by a?
Reply | Threaded
Open this post in threaded view
|

Re: Unknown and false

Jiba
Administrator
Hi,

If you want to assert that a does not love c, you may do:

    a.is_a.append(Not(love.value(c)))

And if you want to infer all individuals that does not love c, you may use:

    class R(Thing): equivalent_to = [ Not(love.value(c)) ]

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Unknown and false

William
Hi ~ Thank you for your reply

But I think the engine should get that a dose not love c with the following facts, in a purely logical way, instead of informing it a.is_a.append(Not(love.value(c))) explicitly. It is the task of the restriction "love.max".

   Man.is_a.append(love.max(1, Woman))  # a man loves no more than one woman
    a = Man('a')
    b = Woman('b')
    c = Woman('c')
    a.love.append(b)  # a loves b != c, implying a does not love c obviously.
    AllDifferent([b,c])
Reply | Threaded
Open this post in threaded view
|

Re: Unknown and false

Jiba
Administrator
Hi,

In fact, the reasoner can deduce that a does not love c. However, if "not loving c" is not a class, this inference will not appear in the results of the classification. Actually, the reasoner may even not compute it, because if "not loving c" is not a class, there is no need to deduce that a does not love c. This is an optimization present in some reasoners (including tableau-based ones such as Pellet and Hermit), known as "goal-driven".

Jiba