问题
I'm new to protege and i have to model a grid with similar properties to soduku, in Manchester OWL syntax.
I have been searching but i can't seem to find a way to make an axiom that says "each column must have 4 cells, and must have each one of these values ". As in, assuming a 4x1 column, each cell must contain one number and the column must have all the numbers [1:4].
I have already set up some Objects , data properties and Object properties which i will leave here. I will leave the full .owl file here so it can be loaded thus making it easier to give help.
All help is highly appreciated.
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
EDIT: the point of this is that when i run the reasoner, values to some of the cells, it will infer the values of the other cells. e.x: cell1 = 1, cell2 =2, cell3 = 3 => the reasoner will infer that cell4's value is 4.
回答1:
Well, try this:
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
Is it adaptable to your needs? It works with Pellet, not with Hermit.
回答2:
I have come up with a solution for this project and this question in specific, by changing the approach. Instead of a Cell being a Class that has a Value, it can be done easily by thinking that a Value can be an entity that needs to be placed into a Cell.
Using this line of thinking it can all come down to logic expressions in the axions.
By having a class Value, a data property that adds a value to an individual, and individuals that represent the value with the proper Data property asserted, it can simply be said that, the Cell object (hasvalue value 1) or (hasValue value 2) ...
and hasvalue exactly 1 value
来源:https://stackoverflow.com/questions/44004882/protege-owl-class-must-have-one-of-each-value