|
Hi,
I am very new to ontologies, so I learn at the same time writing ontologies and owlready2 :)
I try to define a 1-n relation between two classes. Here is the code snippet:
class Robot(Thing):
pass
class Resource(Thing):
pass
class belongs_to(Resource >> Robot):
pass
class has_resource(Robot >> Resource):
inverse_property = belongs_to
Resource.is_a = [belongs_to.max(1, Robot)]
AllDisjoint([Resource, Robot])
I hope this to define that a Robot can have multiple resources, but that a resource can belong to only 1 robot.
Then I define individuals for those:
a = Robot("a")
b = Robot("b")
r = Resource("r")
v = Resource("v")
r.belongs_to(a)
v.belongs_to(a)
r.belongs_to(b)
Then, if I call the reasoner, it results in saying that v also belongs to r, which was a bit surprising at the first time, but now I understand that it is the consequence of saying that a and b must be the same object :)
Then I added a AllDifferent([a, b, r, v]) in the ontology, and it results in a Inconsistency error.
The point is that now I don't know how to find the origin or explanation of the inconsistency (I would except the belongs_to property to be blamed) once I have catched the exception. The inconsistent_classes() list is empty.
Thanks,
Charles
|