1 命名

命名采用驼峰命名法,通常:

  1. class(类)命名时,首字母大写,如Person,Place,Topping
  2. property(属性)命名时,首字母小写,如career,fullname
  3. 加同样的后缀,让人眼更容易判别:如MeatTopping,HamTopping都属于Topping。

2 OWL属性

OWL的属性代表着“关系”,主要有两种属性:

  • ObjectProperty (对象属性),link an individual to an individual
  • DatatypeProperty(数据属性) , link an individual to the data

还有一种属性是Annotation属性,用于补充信息。下图是各个属性的示例:

属性的命名建议:

  • 驼峰命名法,首字母小写;
  • 添加前缀"has",“is”,比如hasPart, isPartOf, hasManufacturer, isProducerOf
    这样不仅易于人眼分辨,而且连接起来符合英文表达,可读性高。

属性可以拥有子属性(无论object property 还是datatype property):

  • 添加子属性Add subproperty:比如hasIngredient的子属性可以是hasTopping和hasBase。
  • 属性类型不能混用,DatatypeProperty的子属性不能是ObjectProperty,反之亦然。

2.1 OWL对象属性 object property

逆属性(inverse properties)
每个对象属性可以拥有一个逆属性,“If some property links individual a to individual b then its inverse property will link individual b to individual a” 。下图是hasParent的属性和它的逆属性hasChild

protege中通过 inverse of 给一个object property添加逆属性:

2.1 OWL对象属性的特性

OWL通过 属性特征(property characteristics)使属性意义更加丰富,下面的部分讨论了object property可能具有的特性

2.1.1 单值属性 Functional Properties

If a property is functional, for a given individual, there can be at most one individual that is related to the individual via the property. 就是说,通过单值属性指向的个体至多为一个。以单值属性hasBirthMother为例,我们知道生母只可能有一位,所以通过hasBirthMother指向的个体应当为同一个体。但若是明确声明了两个个体不同,就会推出逻辑错误。

2.1.2 逆单值属性 Inverse Functional Properties

即,properties左侧的个体至多一个。这里以isBirthMotherOf为例,它是单值属性hasBirthMother的逆属性。

2.1.3 传递属性(Transitive Properties)

If a property is transitive, and the property relates individual a to individual b, and also individual b to individual c, then we can infer that individual a is related to individual c via property P

  • 传递属性的逆属性,也是传递属性
  • 传递属性不能是单值属性
2.1.4 对称属性(Symmetric Properties)

对称属性的逆属性,是它自身(If a property P is symmetric, and the property relates individual a to individual b then individual b is also related to individual a via property P.

2.1.5 非对称属性(Asymmetric Properties)

即其逆属性不为自己的属性

2.1.6 自反属性(Reflexive properties)

A property P is said to be reflexive when the property must relate individual a to itself

  • 自反属性一定可以指向个体自身
  • 也可以指向其他个体
2.1.7 非自反属性(Reflexive properties)

只能指向其他个体,不能指向自己

SuperProperty of(chain)
比如nearby属性包括hasLocatedIn 和 borders ,那么创建nearby对象属性后,点击Description下SuperProperty of(chain)的+号,输入:
hasLocatedIn o(小写字母o) borders

2.2 属性的域和范围(Domains and Ranges)

属性可以指定 定义域和取值范围,将定义域(Domains)中的个体连接到取值域(ranges)的个体。

  • Domains 是指属性左侧的个体所属的类
  • Ranges 是指属性右侧的个体所属的类
    即:domain individual ObjectProperty range individual,比如属性hasTopping将属于Pizza类的个体,连接到属于PizzaTopping类的个体。


一般来说,某个属性的Domain是它的逆属性的Range,比如 hasTopping的定义域是Pizza类,取值范围是PizzaTopping类,而它的逆属性PizzaTopping则正好相反:

需要注意的是,Domains和Ranges并不作为限制,比方说我们创建了个体icecream,而把hasTopping的domain设成了它,那推理机就认为icecream是Pizza类的实例。这显然逻辑上是不对的,但并不会报错。所以,并不建议设置属性的domain和range,以免在大型本体中引起难以察觉的错误。

2.2 描述和定义类(Describing And Defining Classes)

创建了这些属性之后,我们可以用这些属性来描述和定义类。我们将所有含有相同属性的个体,归到一个匿名类中,这种匿名类称为限制(Restrictions). OWL的限制分为三类:

- Quantifier Restrictions
- Cardinality Restrictions
- hasValue Restrictions
要创建一个限制,我们有3件事要做:

  1. 输入要添加上限制(restriction)的属性
  2. 输入限制的类型,比如存在性限制是‘some’
  3. 指定限制的填充

    (自动补全功能:在expression editor,按tab键可自动列出候选)
    我们先来介绍Quantifier限制,Quantifier限制又可分为存在性限制(existential restrictions)和
    普遍性限制(universal restrictions)。 
2.2.1 存在性限制

存在性限制:使用some关键字,描述最起码有一种,使用符号(∃)。在OWL中也叫做SomeValuesFrom Restrictions
An existential restriction describes a class of individuals that have at least one (some) relationship along a specified property to an individual that is a member of a specified class.
比如,我们要给Pizza类添加一个限制,说 a Pizza must have a PizzaBase
步骤:
1 在类的层级图中选中Pizza类
2 在右侧的’class description view’中,点击‘Subclass of’右侧的加号+
3 在弹出的对话框中,切换到‘class expression editor’,输入hasBase或将它从属性列表中拖拽进来
4 添加 restriction 的类型,这里我们输入some
5 指定filler,这里输入PizzaBase(可按Tab键自动补全)

2.2.2 充要条件 Necessary And Sufficient Conditions (Primitive and Defined Classes)

必要条件:目前我们仅使用必要条件来描述类,必要条件就是说如果某个东西是这个类的一员,那么它必须满足这些条件。我们知道,仅有必要条件是无法反推的。仅具有必要条件的类,称为原始类(Primitive class)。在protege 中,subclass of 下的都是必要条件

充要条件:想要来定义一个类,必须使用充要条件。包含至少一组充要条件的类称为定义类(Defined class),在Protege中图标是黄色圆形,中间三道白杠。Protege中,Equivalent To下是充要条件

必要 转 充要:Edit – Convert to defined class

充要条件的主要作用是帮助reasoner推理类的层级结构,并且reasoner只负责推理defined class的层级关系。
推理机reasoner:Reasoner – Start Reasoner ,如果有错误会有提示。在OWLViz能查看断言层(就是我们输入的),和推理层(推理机infer出来的)

2.2.3 普遍性限制

普遍性限制: 使用only关键词,描述只有这一种,使用符号(∀)。在OWL中也叫做 AllValuesFrom Restrictions

注意:universal restriction包含两个含义:For example the universal restriction ∀ hasTopping MozzarellaTopping
1、describes the individuals all of whose hasTopping relationships are to members of the class MozzarellaTopping
 
2、describes the individuals do not have a hasTopping relationships to individuals that aren’t members of the class MozzarellaTopping.

(没有通过hasTopping关系连接到非MozzarellaTopping类的个体,如果一个个体压根没设置hasTopping属性,自然没法通过hasTopping和非MozzarellaTopping类的个体产生联系,这也满足universal restriction的条件)

例1:我们想要创建一个名为VegetarianPizza的类,这个类的所有个体只能包含两种馅:CheeseTopping or VegetableTopping。大概步骤如下:
1、在Pizza类下创建一个子类,起名VegetarianPizza
2、选中VegetarianPizza类,在右下侧的‘Class Description View’点击Subclass of旁的Add 加号
3、输入‘hasTopping’
4、输入‘only’,即只能
5、输入‘(CheeseTopping or VegetableTopping) ’
这里要特别注意:

  • or 表示 unions(和 ),上面的例子一定要用or
  • and表示 intersection (且),这是classes的交集,如果classes之间是disjoint的,交集为空

这个例子的有两个含义:

特别注意第2点,它还包括了没有参与hasTopping属性的Pizzas,因为它压根没hasTopping属性,自然无法通过这个属性连接到非VegetableTopping类的个体。“没馅的Pizza,也是素pizza”在这个例子是成立的,但是后面我们会遇到,有些情况得剔除这第2点。

2.2.4 开放世界假设与封闭公理

Reasoning in OWL (Description Logics) is based on what is known as the open world assumption (OWA). It is frequently referred to as open world reasoning (OWR). The open world assumption means that we cannot assume something doesn’t exist until it is explicitly stated that it does not exist.
推理机的推理基于开放世界假设,即something没有被声明是真的,它并不能假定为假,只能说该知识尚未被添加进知识库。
比如,MargheritaPizza的描述是这样的:

这是说,MargheritaPizza馅料最起码得有Mozzarella馅和Tomato馅,就好比猪肉大葱饺子得有猪肉和大葱吧。此外,根据开放世界假设,MargheritaPizza并没说不含其他Topping,或许还没添加进来呢。所以想要MargheritaPizza只有这两种馅的话,就得加上‘only’这种约束,也即构造‘closure axiom’。
添加的方法如下:

对上图的解释如下:

尤其注意第2段,只添加 only restriction 而没有 some 的话,就落入了普遍性限制的第2个含义的坑里了,即没有任何馅的Pizza也是MargheritaPizza,这显然是错的。所以切记,封闭公理only和some都得有

更多推荐

Protege 学习笔记