我需要推断一个人是另一个人的兄弟,如果他们有同一个父亲。
所以,如果我有这个:
巴特有霍默神父。
丽莎有荷马神父。
因为Bart
和Lisa
有同一个父亲,我想推断:
丽莎有巴特哥哥。
有没有使用任何属性特征的方法来做到这一点?
Antoine Zimmermann 的回答是这个问题的一个很好的开端,并触及了解决此类任务所需的要点:
从x到 x 的每个兄弟,都有一条hasFather o hasFather -1形式的路径。
但是,现在,这实际上并非仅适用于兄弟。对于所有兄弟姐妹和x本身都是如此。这意味着您将拥有hasSibling的以下定义:
hasSibling ≡ hasFather o hasFather -1
(实际上,这实际上只是hasPaternalSibling;更精确的定义将使用hasParent。)现在,使用它,您可以通过如下查询询问兄弟,他们只是男性的兄弟姐妹:
(hasSibling 值 x) 和 Man
但是,最好定义一个适当的hasBrother属性。如果你有一个特殊的属性将每个Man与他自己联系起来,并且只将男性与他们自己联系起来,你可以使用属性链和hasSibling来做到这一点:
hasBrother ≡ hasSibling o specialProperty
事实上,这样的属性是我们从一种称为rolification的技术中得到的,该技术在一个问题OWL 2 rolification及其答案中得到了更多的描述。这个想法是,对于类Man,我们创建一个新属性r Man并添加等价:
Man ≡ r Man some Self
它说每个Man都通过r Man属性与他自己相关,并且只有Man的实例是这样连接的。这正是我们在上面的specialProperty中需要的属性。因此,我们最终得到了Man、hasSibling和hasBrother的以下定义:
现在我们可以通过如下查询询问x的兄弟:
hasBrother -1值 x
例如,我们可以询问Greg的兄弟姐妹,并得到Peter、Greg(他自己)和Bobby。
这是 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 .
假设每个人都是自己的兄弟,姐妹也是兄弟:
:hasBrother owl:propertyChainAxiom (:hasFather [ owl:inverseOf :hasFather ]) .
几乎不可能更准确地定义 :hasBrother,不包括女性兄弟和自兄弟。但是你可以推断出 Lisa 的所有兄弟如下:
: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
)
] .
一种方法是使用 SWRL 规则。
关于门徒:
写规则:
isChildOf(?x,?y)^FatherOf(?y,?z)^differentFrom(?z,?x)->isBrotherOf(?x,?z)
这意味着如果“x 是 y 的子代”,并且“y 也是 z 的父代”并且“z 和 x 不同”,则“z 和 x 是兄弟”。
兄弟是男性兄弟姐妹。因此,我们应该同时定义“男性”和兄弟姐妹。但由于兄弟姐妹本身是同一父母的不同孩子,因此也应该定义为孩子。为简单起见,我们将同父异母的兄弟姐妹视为兄弟姐妹,将领域限制为人类,并将相关概念(如母性和父性)的明确定义放在一边。
Human
类Gender
与类不相交的Human
类。创建male
并female
作为个体实例化Gender
类型(还有其他方法可以做到这一点,但这是一个非常简单的方法)。hasGender
对象属性,Human
作为域Gender
及其范围Man
类作为Human
. 使其等价于Human and (hasGender value male)
.isChildOf
使用 Human 为其域和范围创建一个Object 属性(可选:将Child
类定义为等效于 的人类的子类型isChildOf some Human
。以类似的方式,您还可以创建对象属性,然后为Mother
、Parent
、Daughter
等创建类)。isSiblingOf
首先,在 ProtegeHuman
中为其域和范围创建一个非自反的对称对象属性。isChildOf(?sibling1, ?parent) ^ isChildOf(?sibling2, ?parent) ^ differentFrom(?sibling1, ?sibling2) -> isSiblingOf(?sibling1, ?sibling2)
您可能还想为您希望能够从兄弟关系中推断出的内容添加规则,例如isSiblingOf(?x, ?y) ^ isChildOf(?x, z?) -> isChildOf(?y, ?z)
isBrotherOf
在 Protege 中创建对象属性Man
Human
Man(?x) ^ isSiblingOf(?x, ?y) -> isBrotherOf(?x, ?y)
isBrotherOf(?x, ?y) -> Man(?x)
isBrotherOf(?x, ?y) -> isSiblingOf(?x, ?y)
第一条规则规定任何男性兄弟姐妹都是兄弟。第二个和第三个从兄弟情谊中推断出男性和兄弟情谊。
Brother
等效于的类isBrotherOf some Human
来完成滚动过程。