I need to infer that one individual is the brother of other one if they have the same father.
So, if I have this:
Bart hasFather Homer.
A brother is a male sibling. Consequently, we should define both 'male' and being a sibling. But since a sibling is itself a non-identical child of the same parents, one should also define being a child. For simplicity, we'll treat half-siblings as siblings, restrict the domain to humans, and leave the explicit definition of related concepts like motherhood and fatherhood aside.
Human
classGender
class disjoint with the Human
class. Create male
and female
as individuals instantiating the Gender
type (there are other ways to do this, but this is a pretty simple one).hasGender
Object property, with Human
as domain and Gender
for its rangeMan
class as a subclass of Human
. Make it equivalent to Human and (hasGender value male)
.isChildOf
Object property with Human for both its domain and range (Optional: Define a Child
class as a subtype of human equivalent to isChildOf some Human
. In similar fashion, you can also create object properties, then classes for Mother
, Parent
, Daughter
, etc).isSiblingOf
object property in Protege with Human
for its domain and range.isChildOf(?sibling1, ?parent) ^ isChildOf(?sibling2, ?parent) ^ differentFrom(?sibling1, ?sibling2) -> isSiblingOf(?sibling1, ?sibling2)
You may also want to add rules for what you want to be able to infer from the siblinghood relation, e.g isSiblingOf(?x, ?y) ^ isChildOf(?x, z?) -> isChildOf(?y, ?z)
isBrotherOf
Object property in Protege with domain Man
and range Human
Man(?x) ^ isSiblingOf(?x, ?y) -> isBrotherOf(?x, ?y)
isBrotherOf(?x, ?y) -> Man(?x)
isBrotherOf(?x, ?y) -> isSiblingOf(?x, ?y)
The first rule states that any male sibling is a brother. The second and third infer maleness and siblinghood from brotherhood.
Brother
class equivalent to isBrotherOf some Human
to complete the rollification process.Antoine Zimmermann's answer is a very good start to this problem, and touches on the major point that you need to solve this sort of task:
From x to each of x's brothers, there is a path of the form hasFather o hasFather-1.
Now, that's actually not true of just brothers, though. That's true for all siblings and for x itself. This means you'll have the following definition of hasSibling:
hasSibling ≡ hasFather o hasFather-1
(Actually, that's really just hasPaternalSibling; a more refined definition would use hasParent.) Now, using this, you could ask for brothers, which are simply siblings who are men, of x with a query like:
(hasSibling value x) and Man
However, it would be nice to define a proper hasBrother property. You could do this with a property chain and hasSibling if you had a special property that linked each Man to himself, and only linked males to themselves:
hasBrother ≡ hasSibling o specialProperty
In fact, such a property is what we get from a technique called rolification, which has been described more in a question, OWL 2 rolification, and its answer. The idea is that for the class Man, we create a new property rMan and add the equivalence:
Man ≡ rMan some Self
which says that each Man is related to himself by the rMan property, and that only instances of Man are so connected. This is exactly the property that we need as specialProperty above. Thus, we end up with the following definitions of Man, hasSibling, and hasBrother:
Now we can ask for the brothers of x with a query like:
hasBrother-1 value x
For instance, we can ask for Greg's siblings, and get Peter, Greg (himself), and Bobby.
Here's that ontology in Turtle:
@prefix : <http://www.example.org/brady#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix brady: <http://www.example.org/brady#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
brady:hasSibling a owl:ObjectProperty ;
owl:propertyChainAxiom ( brady:hasFather [ owl:inverseOf
brady:hasFather ] ) .
brady:Carol a owl:NamedIndividual , brady:Woman .
brady:hasBrother a owl:ObjectProperty ;
owl:propertyChainAxiom ( brady:hasSibling brady:r_Man ) .
<http://www.example.org/brady>
a owl:Ontology .
brady:Woman a owl:Class ;
rdfs:subClassOf brady:Person ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty brady:r_Woman
] .
brady:hasFather a owl:ObjectProperty .
brady:Person a owl:Class .
brady:Man a owl:Class ;
rdfs:subClassOf brady:Person ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty brady:r_Man
] .
brady:r_Woman a owl:ObjectProperty .
brady:r_Man a owl:ObjectProperty .
brady:Marcia a owl:NamedIndividual , brady:Woman ;
brady:hasFather brady:Mike .
brady:Peter a owl:NamedIndividual , brady:Man ;
brady:hasFather brady:Mike .
brady:Jan a owl:NamedIndividual , brady:Woman ;
brady:hasFather brady:Mike .
brady:Cindy a owl:NamedIndividual , brady:Woman ;
brady:hasFather brady:Mike .
brady:Bobby a owl:NamedIndividual , brady:Man ;
brady:hasFather brady:Mike .
brady:Greg a owl:NamedIndividual , brady:Man ;
brady:hasFather brady:Mike .
brady:Mike a owl:NamedIndividual , brady:Man .
Assuming that everyone is their own brother, and that sisters are brothers too:
:hasBrother owl:propertyChainAxiom (:hasFather [ owl:inverseOf :hasFather ]) .
It is hardly possible to define :hasBrother more precisely, excluding female brothers and self-brotherhood. But you can infer all the brothers of Lisa as follows:
:Female a owl:Class .
:Male a owl:Class;
owl:disjointWith :Female .
:Lisa a :Female .
:Bart a :Male .
:Homer a :Male .
:hasFather a owl:ObjectProperty;
rdfs:range :Male .
:hasBrother a owl:ObjectProperty;
rdfs:range :Male .
:hasSiblingOrSelf owl:propertyChainAxiom ( :hasFather [ :hasFather ] ) .
:LisaBrother owl:equivalentClass [
a owl:Restriction;
owl:onProperty [ owl:inverseOf :hasBrother ];
owl:hasValue :Lisa
], [
a owl:Class;
owl:intersectionOf (
[ a owl:Restriction; owl:onProperty :hasSiblingOrSelf; owl:hasValue :Lisa ]
:Male
)
] .
One way to this is by using SWRL rules.
On protege:
Write rule:
isChildOf(?x,?y)^FatherOf(?y,?z)^differentFrom(?z,?x)->isBrotherOf(?x,?z)
This means that if "x is a child of y", and "y is also a parent of z" and "z and x are different" then "z and x are Brothers".