Protege-OWL: Class must have one of each <value>
Asked Answered
M

1

7

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.

Magill answered 16/5, 2017 at 14:53 Comment(6)
Why not cell1 hasValue 1, cell2 hasValue 2, cell3 hasValue 4, cell4 hasValue 8? Just make all individuals different (Edit > Make all individuals different), then reasoner will infer that col hasCell cell1, col hasCell cell2, col hasCell cell3, col hasCell cell4,Cottbus
The make all individuals different only works for the scenario of having a single column/row , lets say i have two columns , there will be 2x1 , 2x2, 2x3, 2x4. Also, even tho the result of the reasoner you pointed out its very useful, its not what i pretend, what i would like to do is for example : cell1 hasValue 1 , cell2 hasValue 2, cell3 hasValue 3, and then as i turn on the reasoner it will infer that , since that column has thoose 4 cells and since it must have the values from 1 to 4, that cell4 hasValue 4. Sorry for the long reply.Magill
I think it is impossible. Working with data properties even harder than with object properties (which is harder than with classes). Data properties might be functional and might be keys. That's all, as far as I know. One can not create a property chain with data properties. See also this question.Cottbus
P.S. Probably, in cases like your a reasoner would be able to infer what you want, but it seems to be computationally expensive in more general case.Cottbus
it should be possible since it is part of our task ( a minor academic project), but maybe done some other way.I will try to remake this using more Objects and Object properties so the reasoner wont have to infer Data properties. Thank you very much for the answers, i will make sure to check that question.Magill
I've never seen any Sudoku solution for OWL - but it's possible via SPARQLWilliamsen
M
1

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

Magill answered 25/5, 2017 at 23:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.