Protege-OWL:Class必须具有每个<value>中的一个

时间:2017-05-16 14:53:54

标签: conditional-statements owl protege manchester-syntax

我是新手,我必须使用曼彻斯特OWL语法模拟一个与soduku具有相似属性的网格。

我一直在寻找,但我似乎无法找到一种方法来制作一个公理,上面写着“每列必须有4个单元格,并且必须具有这些值中的每一个”。 如在,假设一个4x1列,每个单元格必须包含一个数字,列必须包含所有数字[1:4]。

我已经设置了一些对象,数据属性和对象属性,我将在这里留下。我将完整的.owl文件留在这里,以便加载它,从而更容易提供帮助。

非常感谢所有帮助。

Prefix: dc: <http://purl.org/dc/elements/1.1/>
Prefix: owl: <http://www.w3.org/2002/07/owl#>
Prefix: rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
Prefix: rdfs: <http://www.w3.org/2000/01/rdf-schema#>
Prefix: GridTest: <http://www.semanticweb.org/existance/ontologies/2017/4/GridTest#>
Prefix: xml: <http://www.w3.org/XML/1998/namespace>
Prefix: xsd: <http://www.w3.org/2001/XMLSchema#>



Ontology: <http://www.semanticweb.org/existance/ontologies/2017/4/GridTest>


Datatype: xsd:int


Datatype: xsd:integer


ObjectProperty: GridTest:hasCell

    SubPropertyOf: 
        GridTest:hasRelation

    Domain: 
        GridTest:Grid

    InverseOf: 
        GridTest:isCellOf


ObjectProperty: GridTest:hasColum

    SubPropertyOf: 
        GridTest:hasRelation

    Domain: 
        GridTest:Grid

    Range: 
        GridTest:Grid

    InverseOf: 
        GridTest:isColumOf


ObjectProperty: GridTest:hasRelation


ObjectProperty: GridTest:isCellOf

    InverseOf: 
        GridTest:hasCell


ObjectProperty: GridTest:isColumOf

    InverseOf: 
        GridTest:hasColum


DataProperty: GridTest:hasValue

    Characteristics: 
        Functional

    Domain: 
        GridTest:Cell

    Range: 
        {"1"^^xsd:int , "2"^^xsd:int , "3"^^xsd:int , "4"^^xsd:int}


Class: GridTest:Cell

    SubClassOf: 
        GridTest:Grid,
        GridTest:hasValue exactly 1 xsd:int


Class: GridTest:Colum

    SubClassOf: 
        GridTest:Grid,
        GridTest:hasCell exactly 4 GridTest:Cell


Class: GridTest:Grid

    SubClassOf: 
        GridTest:hasColum exactly 4 GridTest:Colum


Individual: GridTest:cell1

    Facts:  
     GridTest:isCellOf  GridTest:col,
     GridTest:hasValue  1


Individual: GridTest:cell2

    Facts:  
     GridTest:isCellOf  GridTest:col


Individual: GridTest:cell3

    Facts:  
     GridTest:isCellOf  GridTest:col


Individual: GridTest:cell4

    Facts:  
     GridTest:isCellOf  GridTest:col


Individual: GridTest:col

    Facts:  
     GridTest:isColumOf  GridTest:grid


Individual: GridTest:grid

编辑:这一点是,当我运行推理器,某些单元格的值时,它将推断其他单元格的值。 e.x:cell1 = 1,cell2 = 2,cell3 = 3 =&gt;推理者会推断出cell4的值是4。

2 个答案:

答案 0 :(得分:1)

好吧,试试这个:

Prefix: : <http://www.example.org/semaphore#>
Prefix: owl: <http://www.w3.org/2002/07/owl#>
Prefix: xsd: <http://www.w3.org/2001/XMLSchema#>

Ontology: <http://www.example.org/semaphore>

Datatype: xsd:string

Class: Semaphore
    SubClassOf: 
        hasSignal exactly 3 Signal

ObjectProperty: hasSignal

Class: Signal
    EquivalentTo: 
      {greenSignal , redSignal , yellowSignal},
      hasColor exactly 1 Color
    DisjointUnionOf:
        hasColorName value "red"^^xsd:string,
        hasColorName value "yellow"^^xsd:string,
        hasColorName value "green"^^xsd:string
    HasKey: 
        hasColorName

ObjectProperty: hasColor
    Characteristics: 
        Functional,
        InverseFunctional

Class: Color
    EquivalentTo: 
        {greenColor , redColor , yellowColor}

DataProperty: hasColorName
    Characteristics: 
        Functional

Individual: semaphore
    Types: 
        Semaphore

Individual: redSignal
    Facts:  
     hasColor  redColor,
     hasColorName  "red"^^xsd:string
Individual: yellowSignal
    Facts:  
     hasColor  yellowColor,
     hasColorName  "yellow"^^xsd:string 
Individual: greenSignal


Individual: redColor
Individual: yellowColor
Individual: greenColor

DifferentIndividuals: 
    semaphore,
    redSignal,yellowSignal,greenSignal,
    redColor,yellowColor,greenColor

它是否适合您的需求?它适用于Pellet,而不适用于Hermit。

enter image description here

答案 1 :(得分:1)

通过改变方法,我已经为这个项目及具体问题提出了一个解决方案。而不是Cell是具有Value的类,可以通过认为Value可以是需要放入Cell的实体来轻松完成。

使用这种思路可以归结为轴上的逻辑表达式。

通过拥有一个类Value,一个向个人添加值的数据属性,以及表示具有正确Data属性的值的个体,可以简单地说,Cell对象(hasvalue value 1) or (hasValue value 2) ...和{ {1}}