类表达式(class expressions)

来源:互联网 发布:mac的qq管家不能登陆 编辑:程序博客网 时间:2024/06/05 06:18

类表达式用于描述具有相同特征的个体,它由类名和一个复杂的类表达式两部分。类表达式可以嵌套到任意深度,以便建立对被建模域的丰富描述。一个完整的类表达式会用到some、value、only、min、max、exactly、and几个关键字,下面通过一个例子来说明这几个关键字的用法。

1  some
hasPet some Dog 这是最常用的一个类表达式,意思是Things(个体) that have a pet that is a Dog(类)
        2 value
hasPet value Tibbs 意思是Things that have a pet that is Tibbs(个体).
3 only
hasPet only Cat 意思是Things that have pets that are only Cats(Note that this does not mean that these things must have a Cat, but if they do have a pet then it will be a Cat. Also known as an "AllValuesFrom restriction" or a "Universal restriction"
4 min hasPet min 3 Cat意思是 Things that have at least three pets that are Cats(Things that have at least three pets that are Cats. Also known as a "Min cardinality restriction"
5 max hasPet max 5 Dog 意思是 Things that have at most five pets that are Dogs(Note that there may be more than five pets in total e.g. three Cats and five Dogs, but the number of Dogs will not be more than five. This class expression also means that there may be no pets at all. Also known as a "Max cardinality restriction"
6 exactly hasPet exactly 2 GoldFish 意思是Things that have exactly 2 GoldFish as pets(Note that there may be more than two pets, but two of the pets are GoldFish - no more and no less. Also known as an "Exact cardinality restriction"
7 and Person and(hasPet some Cat)意思是People that have a pet that's a Cat(Here we have a class name and a complex class expression combined with the and keyword. The brackets are optional in this particular case, but have been included for clarity. Also known as an "Intersection" or a "Conjunction". We also say that each class expression in the conjunction is a "conjunct".
8 or (hasPet some Cat)or (hasPet some Dog)意思是 Things that have a pet that's a Cat or have a pet that's a Dog(Note that the or is not exclusive. That is, this class includes the things that have a Cat as a pet, or have a Dog as a pet, or have both a pet Dot and a pet Cat. Note that we could have also written this example as (hasPet some (Cat or Dog)) Also known as a "Union" or a "Disjunction". We also say that each class expression in the disjunction is a "disjunct".
9 not  not(hasPet some Dog)意思是Things taht do not have a pet that's a dog(This includes things that either do not have any pet, or if they have a pet then it's not a Dog. Note that this is logically equivalent to (hasPet only (not Dog)) Also known as a "negation".