for inst in onto.TestRelation1.instances():
for inst in onto.TestRelation2.instances():
Executing this code prints only "Some: onto.Flow1"
I would expect that as my "Relation" relates exactly two Entities, it would get classified as both TestRelation1 and TestRelation2, however, it only gets classified as TestRelation2. The same happens if I am using .min(2, Entity) or .max(2, Entity).
Could you explain why this is happening? How should I write this code to get "Relation" classified as "TestRelation1"?
This is a common "trap" in formal reasoning. Here, you asserted that the individual Relation is related to Actor1 and Actor2.
However, the reasoning works under the "open-world assumption" : every fact non asserted is not considered as false but as possible.
Here, there might be an (unasserted) Actor3 that is related to Relation, thus Relation is not classified in TestRelation1.
In addition, the reasoner also considers that Actor1 and Actor2 might be the same individual. Consequently, you cannot be sure that there is at least 2 * different * actors (this explain why you did not obtain the expected results with min(2,..)).
To solve this problem, you need :
First, to assert that the two Actors are different:
Second, to assert that Relation is not related to any other actors: