Protégé-OWL/SWRL中的本体属性定义 [英] Ontology property definition in Protégé-OWL / SWRL

查看:98
本文介绍了Protégé-OWL/SWRL中的本体属性定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Protégé中实现OWL本体,它包含两个类:s1s2,它们都是System类的实例.这两个类由连接类s1_s2连接,该类包含属性omega.此属性必须根据以下法律取值:

omega = 1 * s1.complete

如何在Protégé中实现它,以便将来在SWRL规则中使用它?

解决方案

通常,您首先需要定义所需的类和属性:

这时,您可以添加一些公理,这些公理控制系统如何交互,属性如何工作等.例如,您可以在属性上声明域和范围.这是 hasS2 属性上的域和范围:

您可能还想说,每个 InterSystem 都只有一个关联的 S1 S2 :

要施加数学约束,您实际上需要SWRL;您将无法使用其他类型的OWL公理来强制执行约束.您要遵循的规则如下.如果您在谓词上声明域和范围,则不需要该规则中出现的所有类型谓词,因为可以从属性用法中推断出它们.

S1(?s1)∧ InterSystem(?i)∧ hasS1(?i,?s1)∧ hasComplete(?s1,?complete)乘法(?omega,1,?complete)→ hasOmega(?i,?omega)

这里的乘法实际上似乎是多余的,因为您要乘以1,所以omega = alpha,在这种情况下,该规则的开头可以简单地是 hasOmega(?i,?alpha).在Protégé中,规则如下所示:

(在我使用的Protégé版本(不是最新版本)中,我必须依次选择窗口">创建新选项卡"以创建规则" 选项卡,然后选择窗口">视图">本体视图">将规则"列表添加到界面的规则.)

此OWL本体的RDF表示形式的Turtle序列化(您可以将其保存并加载到Protégé中)是

@prefix :      <http://stackoverflow.com/q/21499126/1281433/systems#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix swrl:  <http://www.w3.org/2003/11/swrl#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix swrlb: <http://www.w3.org/2003/11/swrlb#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

<urn:swrl#s1>  a  swrl:Variable .

:hasComplete  a  owl:DatatypeProperty .

[ a          swrl:Imp ;
  swrl:body  [ a          swrl:AtomList ;
               rdf:first  [ a                    swrl:ClassAtom ;
                            swrl:argument1       <urn:swrl#i> ;
                            swrl:classPredicate  :InterSystem
                          ] ;
               rdf:rest   [ a          swrl:AtomList ;
                            rdf:first  [ a                    swrl:ClassAtom ;
                                         swrl:argument1       <urn:swrl#s1> ;
                                         swrl:classPredicate  :S1
                                       ] ;
                            rdf:rest   [ a          swrl:AtomList ;
                                         rdf:first  [ a                       swrl:IndividualPropertyAtom ;
                                                      swrl:argument1          <urn:swrl#i> ;
                                                      swrl:argument2          <urn:swrl#s1> ;
                                                      swrl:propertyPredicate  :hasS1
                                                    ] ;
                                         rdf:rest   [ a          swrl:AtomList ;
                                                      rdf:first  [ a                       swrl:DatavaluedPropertyAtom ;
                                                                   swrl:argument1          <urn:swrl#s1> ;
                                                                   swrl:argument2          <urn:swrl#complete> ;
                                                                   swrl:propertyPredicate  :hasComplete
                                                                 ] ;
                                                      rdf:rest   [ a          swrl:AtomList ;
                                                                   rdf:first  [ a               swrl:BuiltinAtom ;
                                                                                swrl:arguments  [ a          rdf:List ;
                                                                                                  rdf:first  <urn:swrl#omega> ;
                                                                                                  rdf:rest   [ a          rdf:List ;
                                                                                                               rdf:first  1 ;
                                                                                                               rdf:rest   ( <urn:swrl#complete> )
                                                                                                             ]
                                                                                                ] ;
                                                                                swrl:builtin    swrlb:multiply
                                                                              ] ;
                                                                   rdf:rest   ()

                                                                 ]
                                                    ]
                                       ]
                          ]
             ] ;
  swrl:head  [ a          swrl:AtomList ;
               rdf:first  [ a                       swrl:DatavaluedPropertyAtom ;
                            swrl:argument1          <urn:swrl#i> ;
                            swrl:argument2          <urn:swrl#omega> ;
                            swrl:propertyPredicate  :hasOmega
                          ] ;
               rdf:rest   ()

             ]
] .

:S2     a                owl:Class ;
        rdfs:subClassOf  :System .

<urn:swrl#omega>  a  swrl:Variable .

:S1     a                owl:Class ;
        rdfs:subClassOf  :System .

:InterSystem  a          owl:Class ;
        rdfs:subClassOf  [ a                         owl:Restriction ;
                           owl:onClass               :S1 ;
                           owl:onProperty            :hasS1 ;
                           owl:qualifiedCardinality  "1"^^xsd:nonNegativeInteger
                         ] ;
        rdfs:subClassOf  [ a                         owl:Restriction ;
                           owl:onClass               :S2 ;
                           owl:onProperty            :hasS2 ;
                           owl:qualifiedCardinality  "1"^^xsd:nonNegativeInteger
                         ] .

<urn:swrl#complete>  a  swrl:Variable .

<http://stackoverflow.com/q/21499126/1281433/systems>
        a       owl:Ontology .

:hasS2  a       owl:ObjectProperty .

:hasOmega  a    owl:DatatypeProperty .

:System  a      owl:Class .

:hasS1  a       owl:ObjectProperty .

<urn:swrl#i>  a  swrl:Variable .

这是一个好的开始,但是值得一看.要查看可以应用规则的地方,我们需要一些实例数据和推理器.您提到可以在Protégé中使用Pellet,因此我们都以此为出发点.对于某些实例数据,让我们创建并创建 InterSystem 及其 S1 ,并分配 S1 的完整值.

您需要从Reasoner菜单中选择Pellet推理机,然后选择Reasoner> Start Reasoner.此时,您可以对"hasOmega 42"运行DL查询,以确认个人具有所需的属性(请确保选中了右侧的个人"复选框):

如果您导航到 intersystem 个人,则可能看不到推断的值.要显示它,请转到Reasoner> Configure…,然后检查Data Property Assertions选项:

此后,您可能需要重新启动推理程序(推理程序">无";推理程序">颗粒";推理程序">启动推理程序"),但是之后,您将能够看到推断的值:

I need to implement an OWL-ontology in Protégé, which contains a two classes: s1 and s2, both are the instances of System class. These two classes are connected by the connection class s1_s2, which contains property omega. This property has to take a value according to the following law:

omega = 1 * s1.complete

How can I implement it in Protégé, such way I could use it in SWRL-rule in the future?

解决方案

In general, you'd start by defining the classes and the properties that you need:

At this point you could add some axioms that govern how the systems have to interact, how the properties work, etc. E.g., you might declare domains and ranges on your properties. Here's a domain and range on the hasS2 property:

You might also want to say that each InterSystem has exactly one associate S1 and S2:

To put in the mathematical constraints, you'll actually need SWRL; you won't be able to enforce the constraint using other kinds of OWL axioms. The rule you'd want is along the lines of the following. If you declare domains and ranges on your predicates, then you won't need all the type predicates that appear in this rule, since they could be inferred from the property usage.

S1(?s1) ∧ InterSystem(?i) ∧ hasS1(?i,?s1) ∧ hasComplete(?s1,?complete) multiply(?omega,1,?complete) → hasOmega(?i,?omega)

The multiplication here actually seems redundant, since you're multiplying by 1, so omega = alpha, in which case the head of that rule could simply be hasOmega(?i,?alpha). In Protégé the rule looks like this:

(In the version of Protégé that I'm using (not the latest), I had to Window > Create New Tab to create a Rules tab, and then Window > Views > Ontology Views > Rules to add the Rules list to the interface.)

The Turtle serialization of the RDF representation of this OWL ontology (which you can save and load into Protégé) is:

@prefix :      <http://stackoverflow.com/q/21499126/1281433/systems#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix swrl:  <http://www.w3.org/2003/11/swrl#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix swrlb: <http://www.w3.org/2003/11/swrlb#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

<urn:swrl#s1>  a  swrl:Variable .

:hasComplete  a  owl:DatatypeProperty .

[ a          swrl:Imp ;
  swrl:body  [ a          swrl:AtomList ;
               rdf:first  [ a                    swrl:ClassAtom ;
                            swrl:argument1       <urn:swrl#i> ;
                            swrl:classPredicate  :InterSystem
                          ] ;
               rdf:rest   [ a          swrl:AtomList ;
                            rdf:first  [ a                    swrl:ClassAtom ;
                                         swrl:argument1       <urn:swrl#s1> ;
                                         swrl:classPredicate  :S1
                                       ] ;
                            rdf:rest   [ a          swrl:AtomList ;
                                         rdf:first  [ a                       swrl:IndividualPropertyAtom ;
                                                      swrl:argument1          <urn:swrl#i> ;
                                                      swrl:argument2          <urn:swrl#s1> ;
                                                      swrl:propertyPredicate  :hasS1
                                                    ] ;
                                         rdf:rest   [ a          swrl:AtomList ;
                                                      rdf:first  [ a                       swrl:DatavaluedPropertyAtom ;
                                                                   swrl:argument1          <urn:swrl#s1> ;
                                                                   swrl:argument2          <urn:swrl#complete> ;
                                                                   swrl:propertyPredicate  :hasComplete
                                                                 ] ;
                                                      rdf:rest   [ a          swrl:AtomList ;
                                                                   rdf:first  [ a               swrl:BuiltinAtom ;
                                                                                swrl:arguments  [ a          rdf:List ;
                                                                                                  rdf:first  <urn:swrl#omega> ;
                                                                                                  rdf:rest   [ a          rdf:List ;
                                                                                                               rdf:first  1 ;
                                                                                                               rdf:rest   ( <urn:swrl#complete> )
                                                                                                             ]
                                                                                                ] ;
                                                                                swrl:builtin    swrlb:multiply
                                                                              ] ;
                                                                   rdf:rest   ()

                                                                 ]
                                                    ]
                                       ]
                          ]
             ] ;
  swrl:head  [ a          swrl:AtomList ;
               rdf:first  [ a                       swrl:DatavaluedPropertyAtom ;
                            swrl:argument1          <urn:swrl#i> ;
                            swrl:argument2          <urn:swrl#omega> ;
                            swrl:propertyPredicate  :hasOmega
                          ] ;
               rdf:rest   ()

             ]
] .

:S2     a                owl:Class ;
        rdfs:subClassOf  :System .

<urn:swrl#omega>  a  swrl:Variable .

:S1     a                owl:Class ;
        rdfs:subClassOf  :System .

:InterSystem  a          owl:Class ;
        rdfs:subClassOf  [ a                         owl:Restriction ;
                           owl:onClass               :S1 ;
                           owl:onProperty            :hasS1 ;
                           owl:qualifiedCardinality  "1"^^xsd:nonNegativeInteger
                         ] ;
        rdfs:subClassOf  [ a                         owl:Restriction ;
                           owl:onClass               :S2 ;
                           owl:onProperty            :hasS2 ;
                           owl:qualifiedCardinality  "1"^^xsd:nonNegativeInteger
                         ] .

<urn:swrl#complete>  a  swrl:Variable .

<http://stackoverflow.com/q/21499126/1281433/systems>
        a       owl:Ontology .

:hasS2  a       owl:ObjectProperty .

:hasOmega  a    owl:DatatypeProperty .

:System  a      owl:Class .

:hasS1  a       owl:ObjectProperty .

<urn:swrl#i>  a  swrl:Variable .

That's a good start, but it's worthwhile to see how it all works. To see a place where the rules could be applied, we'll need some instance data and a reasoner. You mentioned that you can use Pellet from within Protégé, so we're all set on that count. For some instance data, let's create and InterSystem, its S1, and assign the S1's complete value.

You'll need to select the Pellet reasoner from the Reasoner menu, and then select Reasoner > Start Reasoner. At this point, you could run a DL query for "hasOmega value 42" to confirm that the individual has the desired property (make sure that you check the "Individuals" checkbox on the right):

If you navigate to the intersystem individual, you probably won't see the inferred value though. To show it, go to Reasoner > Configure… and check the Data Property Assertions option:

After that, you may need to restart the reasoner (Reasoner > None; Reasoner > Pellet; Reasoner > Start Reasoner), but afterward you'll be able to see the inferred values:

这篇关于Protégé-OWL/SWRL中的本体属性定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆