【问题标题】:Inferencing in protegeprotege 中的推理
【发布时间】:2013-06-06 21:16:20
【问题描述】:

我有一个简单的本体如下

<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY assignment "http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#" >
]>

<rdf:RDF xmlns="http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#"
 xml:base="http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment"
 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
 xmlns:assignment="http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#"
 xmlns:owl="http://www.w3.org/2002/07/owl#"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<owl:Ontology rdf:about="http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment"/>

<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
 -->

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#channel_of -->
<owl:ObjectProperty rdf:about="&assignment;channel_of">
    <rdfs:domain rdf:resource="&assignment;Channels"/>
    <rdfs:range rdf:resource="&assignment;Television"/>
    <owl:inverseOf rdf:resource="&assignment;has_channels"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#has_channels -->
<owl:ObjectProperty rdf:about="&assignment;has_channels">
    <rdfs:range rdf:resource="&assignment;Channels"/>
    <rdfs:domain rdf:resource="&assignment;Television"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#has_inet_connection -->
<owl:ObjectProperty rdf:about="&assignment;has_inet_connection">
    <rdfs:range rdf:resource="&assignment;InternetConnection"/>
    <rdfs:domain rdf:resource="&assignment;Person"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#has_television -->
<owl:ObjectProperty rdf:about="&assignment;has_television">
    <rdfs:domain rdf:resource="&assignment;Person"/>
    <rdfs:range rdf:resource="&assignment;Television"/>
    <owl:inverseOf rdf:resource="&assignment;ownes_by"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#internet_connection_owned_by -->
<owl:ObjectProperty rdf:about="&assignment;internet_connection_owned_by">
    <rdfs:domain rdf:resource="&assignment;InternetConnection"/>
    <rdfs:range rdf:resource="&assignment;Person"/>
    <owl:inverseOf rdf:resource="&assignment;has_inet_connection"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#ownes_by -->
<owl:ObjectProperty rdf:about="&assignment;ownes_by">
    <rdfs:range rdf:resource="&assignment;Person"/>
    <rdfs:domain rdf:resource="&assignment;Television"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#watched_by -->
<owl:ObjectProperty rdf:about="&assignment;watched_by">
    <rdfs:domain rdf:resource="&assignment;Channels"/>
    <rdfs:range rdf:resource="&assignment;Person"/>
    <owl:inverseOf rdf:resource="&assignment;watches"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#watches -->
<owl:ObjectProperty rdf:about="&assignment;watches">
    <rdfs:range rdf:resource="&assignment;Channels"/>
    <rdfs:domain rdf:resource="&assignment;Person"/>
</owl:ObjectProperty>

<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
 -->

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#yh -->
<owl:DatatypeProperty rdf:about="&assignment;yh"/>

<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
 -->

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Advanced -->
<owl:Class rdf:about="&assignment;Advanced">
    <rdfs:subClassOf rdf:resource="&assignment;Coloured"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&assignment;ownes_by"/>
            <owl:allValuesFrom rdf:resource="&assignment;Rich"/>
        </owl:Restriction>
    </rdfs:subClassOf>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Antena -->
<owl:Class rdf:about="&assignment;Antena">
    <rdfs:subClassOf rdf:resource="&assignment;Channels"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#BlackAndWhite -->
<owl:Class rdf:about="&assignment;BlackAndWhite">
    <rdfs:subClassOf rdf:resource="&assignment;Television"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#CRT -->
<owl:Class rdf:about="&assignment;CRT">
    <rdfs:subClassOf rdf:resource="&assignment;Coloured"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&assignment;ownes_by"/>
            <owl:allValuesFrom rdf:resource="&assignment;Mid"/>
        </owl:Restriction>
    </rdfs:subClassOf>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Channels -->
<owl:Class rdf:about="&assignment;Channels"/>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Coloured -->
<owl:Class rdf:about="&assignment;Coloured">
    <rdfs:subClassOf rdf:resource="&assignment;Television"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#High -->
<owl:Class rdf:about="&assignment;High">
    <rdfs:subClassOf rdf:resource="&assignment;InternetConnection"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Internet -->
<owl:Class rdf:about="&assignment;Internet">
    <rdfs:subClassOf rdf:resource="&assignment;Channels"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&assignment;channel_of"/>
            <owl:allValuesFrom rdf:resource="&assignment;Advanced"/>
        </owl:Restriction>
    </rdfs:subClassOf>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#InternetConnection -->
<owl:Class rdf:about="&assignment;InternetConnection"/>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#LCD -->
<owl:Class rdf:about="&assignment;LCD">
    <rdfs:subClassOf rdf:resource="&assignment;Coloured"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&assignment;ownes_by"/>
            <owl:someValuesFrom rdf:resource="&assignment;Rich"/>
        </owl:Restriction>
    </rdfs:subClassOf>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#LED -->
<owl:Class rdf:about="&assignment;LED">
    <rdfs:subClassOf rdf:resource="&assignment;Coloured"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&assignment;ownes_by"/>
            <owl:someValuesFrom rdf:resource="&assignment;Rich"/>
        </owl:Restriction>
    </rdfs:subClassOf>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Medium -->
<owl:Class rdf:about="&assignment;Medium">
    <rdfs:subClassOf rdf:resource="&assignment;InternetConnection"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Mid -->
<owl:Class rdf:about="&assignment;Mid">
    <rdfs:subClassOf rdf:resource="&assignment;Person"/>
    <owl:disjointWith rdf:resource="&assignment;Rich"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Person -->
<owl:Class rdf:about="&assignment;Person"/>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Rich -->
<owl:Class rdf:about="&assignment;Rich">
    <rdfs:subClassOf rdf:resource="&assignment;Person"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Television -->
<owl:Class rdf:about="&assignment;Television"/>

<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
 -->

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#John -->
<owl:NamedIndividual rdf:about="&assignment;John"/>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#SLTA -->
<owl:NamedIndividual rdf:about="&assignment;SLTA">
    <rdf:type rdf:resource="&assignment;Advanced"/>
</owl:NamedIndividual>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Youtube -->
<owl:NamedIndividual rdf:about="&assignment;Youtube">
    <rdf:type rdf:resource="&assignment;Internet"/>
    <watched_by rdf:resource="&assignment;John"/>
</owl:NamedIndividual>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.4.2) http://owlapi.sourceforge.net -->

现在,我要推断John 是一个富人。我尝试了各种限制,但只有我得到了“约翰是一个人”。

我最初的本体想法是这样的,如果一个人从他的电视上看一个互​​联网频道,那么他就有一台高级电视,高级电视只有owned_by有钱人。

现在在我们的实例中,John 看 YouTube,YouTube 是一个互联网频道,所以互联网频道只在高级电视中可用,而高级电视只有富人拥有,因此约翰应该是有钱的。但如前所述,我一直认为约翰是一个人

【问题讨论】:

  • 你用的是什么推理机?你是如何查询推理者的?
  • 我使用了 Protege 内置的推理器,也是耶拿推理器。两者都给出相同的结果
  • Protégé 可以使用许多推理器,包括 Pellet、FaCT++ 和 HermiT。他们都应该使用我提供的答案。

标签: rdf semantic-web owl protege


【解决方案1】:

我认为您不能仅使用 OWL 在当前的类层次结构中表达这一点。如果我理解正确,您已经掌握了公理

John watches YouTube
YouTube a InternetChannel
InternetChannel availableOn only AdvancedTV
AdvancedTV inverse owns only RichPerson

但不能推断出中间推理 John a (owns some AdvancedTV) 会让你得出结论 John a RichPerson

如果您有额外的公理“如果某人 P 观看某个频道 C,则 P 拥有一些电视 T 并且 C 在 T 上可用”,那么推理将如下所示:“既然约翰看 YouTube,约翰就会拥有一些可以使用 YouTube 的电视。由于 YouTube 是一个互联网频道,因此电视必须是高级电视。既然约翰将拥有一台先进的电视,他将成为一个有钱的人。”

OWL 中的限制

但是,我认为这个公理不能用 OWL 来表达。描述逻辑(OWL就是其中之一)是一阶逻辑的一个子集,只能表达只使用两个变量的一阶语句。上面的公理似乎需要三个:

  • ∀ p, c: 手表(p,c) → (∃ t: 拥有(p,t) &wedge; availableOn(c,t))

我无法以只使用两个变量的方式重写它,所以我认为它不能用 OWL 表示。这意味着您将需要更改本体中的某些内容才能使其工作。在我看来,有几个选择:

  • 您可以转换您的频道类层次结构并引入一些个人来代表频道类型。
  • 您可以使用三处关系 watchesOn,而不是使用仅关联人员和频道的 watches 关系,将人员、他们观看的频道和他们观看该频道的电视。

第一个选项实施起来可能会更快一些,但我认为从长远来看,第二个选项更灵活一些,更好地代表手头的信息,并使整体表示更清晰。

用个人表示渠道类型

如果您将频道子类层次结构更改为频道类型的集合,例如,而不是YouTube a InternetChannel,您应该说YouTube hasChannelType Internet,那么您会说类似

watches some (hasChannelType value Internet) SubClassOf owns some AdvancedTV

它说“如果有人观看具有频道类型互联网的东西,那么这个人就拥有一台先进的电视。”由于 John 观看 YouTube,并且 YouTube 具有频道类型 Internet,因此 John 拥有一台高级电视。由于先进的电视机只有富人拥有,约翰一定是个有钱人。

该公理是一般类公理。它的左侧没有简单的类名,而是一个类表达式。这些并不经常出现,但正如 Being complex on the left-hand-side: General Concept Inclusion 中所讨论的,它们有时非常很有用。
那篇文章也提供了在 Protégé 中创建它们的示例。要在 Protégé 中输入通用类公理,请转到 Active Ontology 选项卡,并在其中找到 通用类公理 选项卡。然后就可以逐字输入公理了,应该是这样的:

watches 更改为 watchesOn

或者,您可以将二元关系 watches 替换为 3 位关系 watchesOn,它将一个人与他们观看的频道和电视相关联他们看着它。这有一个很好的优势,即在一个人拥有多台电视的情况下,一些仍然是原始的,而另一些则是先进的。 (第一个解决方案只是说,如果有人观看互联网频道,那么他们拥有一台高级电视,但它没有捕捉到该人使用该电视观看互联网频道的事实。)替换二元关系 watchs(Person,Channel) 和第三个 watchesOn(Person,Channel,Television) 我们遵循 W3C 工作组说明 Defining N-ary Relations on the Semantic Web 中给出的方法。我们引入了一个class(不是属性)watchesOn,它的每一个实例都代表watchesOn关系的一次出现,以及三个属性,hasWatcherhasWatchedChannelhasWatchedTelevision,分别将 watchesOn 的实例与所涉及的人员、频道和电视相关联在关系中。 watchesOn 的实例通常是空白节点。例如,watchesOn(John,YouTube,JohnsTelevision) 在 RDF 中可以表示为:

[] a :watchesOn ;
   :hasWatcher :John ;
   :hasWatchedChannel :YouTube ;
   :hasWatchedTelevision :JohnsTelevision .

通过这种表示,我们可以陈述许多有用的事实。例如,如果一个人在电视上观看某物,那么他们就拥有该电视,我们断言:

inverse(hasWatcher) o hasWatchedTelevision SubPropertyOf owns

这就像在说

hasWatcher(?w,?person) &wedge; hasWatchedTelevision(?w,?television) → 拥有(?person,?television)。

您也可以说观看互联网频道的电视是高级电视。这需要一个通用类公理,就像在第一个解决方案中一样,但在这种情况下,它是:

inverse (hasWatchedTelevision) some (hasWatchedChannel some InternetChannel) SubClassOf AdvancedTV

这就像说

hasWatchedTelevision(?w,?television) &wedge; hasWatchedChannel(?w,?channel) &wedge; InternetChannel(?channel) → AdvancedTV(?television)。

有了这两个公理,我们可以推断出John owns JohnsTelevisionJohnsTelevision a AdvancedTV。如果我们再添加一个类公理,即如果一个人拥有一台先进的电视,那么他们就是富有的,即

owns some AdvancedTV SubClassOf RichPerson

那么我们可以推断出John a RichPerson

这种表示方式很好,因为使用限制,我们可以断言,例如,约翰在某台电视上观看 YouTube,而无需说明他在哪台电视上观看。这需要给 John 添加一个类型断言,即:

John a inverse hasWatcher some (hasWatchedChannel value YouTube and
                                hasWatchedTelevision some Television)

这表示约翰在某些电视上观看 YouTube,但没有说 哪个 电视。根据我们之前的公理,推理者仍然可以推断出,无论它碰巧是什么电视,它都必须是一台先进的电视,而约翰必须拥有它。推理者仍然可以推断出约翰是个有钱人。

这甚至更进一步。我们甚至不需要指定 John 观看了哪个频道,只需说明它是一个互联网频道:

John a inverse hasWatcher some (hasWatchedChannel some InternetChannel and
                                hasWatchedTelevision some Television)

推理者仍然可以推断出约翰是有钱人。最重要的是,类表达式

inverse hasWatcher some (hasWatchedChannel some InternetChannel and
                         hasWatchedTelevision some Television)

由那些在某些电视上观看某些互联网频道的人组成。推理器可以告诉我们这个类表达式是RichPerson 的子类,这意味着这些类型的推理不仅适用于John,而且适用于这个类中的任何东西:

【讨论】:

  • 您好,谢谢您的回复,不过现在我还有一个问题,那就是(watches some (hasChannelType value Internet)) SubClassOf (owns some AdvancedTV)在protege 中如何表达?
  • @user1479203 它被称为一般包含公理或一般类公理。 (它们已在其他一些问题中讨论过,例如OWL Instance Participation LogicRepresenting if-then sentence in OWL。在 Protégé 4.x 中,您可以在 Active Ontology 主选项卡下添加通用类公理,其中包含 General class axioms 标签。我会用一个例子来更新我的答案。
  • @user1479203 我突然想到解决这个问题的另一种方法是用三位置关系watchesOn 替换二进制watches 关系,这样可以更准确地捕获关系。我已经更新了答案以包括早期的方法和这个新的方法。
  • 感谢大家的帮助。完美运行
  • @user1479203 很高兴听到这个消息!这类问题很棒,因为通常在我遇到类似问题之前不超过几个月,并且这些技术中的每一个最终都会出现在众所周知的工具箱中。推理愉快!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-08
  • 1970-01-01
  • 1970-01-01
  • 2020-08-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多