How to define the type of elements in an rdf:Seq?
Asked Answered
A

1

8

I want to create a property defining a rdf:Seq as a rdfs:range of an object :

eg:myProperty a rdf:Property;
    rdfs:range rdf:Seq;
    .

I'm looking for a way to define the type of the elements stored in the rdf:Seq. For example, I don't want this :

eg:typeOfElement a rdf:Class;
    .

eg:somethingElse a rdf:Class;
    .

[] eg:myProperty [
        a rdf:Seq;
        rdf:_1 [a eg:typeOfElement];   # It's the type I want
        rdf:_2 [a eg:typeOfElement];   # It's the type I want
        rdf:_3 [a eg:somethingElse];   # I don't want this type
    ];
    .

Is there a way to define that the rdf:Seq elements are only of the type of eg:typeOfElement when I define eg:myProperty?

(I can use owl if necessary.)

Appendectomy answered 29/5, 2015 at 12:42 Comment(0)
R
4

There are probably a number of ways to accomplish this, depending on your implementation preferences. My advice is to use the rdf:li special property in place of the arbitrary rdf:_nnn, which is easier to extend. rdf:li is equivalent to rdf:_1, rdf:_2 in order. So the following code blocks are equivalent:

:mySeq a rdf:Seq;
  rdf:_1 :foo;
  rdf:_2 :bar .

:mySeq a rdf:Seq;
  rdf:li :foo;
  rdf:li :bar .

Note that the order in the second block is significant.

To accomplish what you are asking, you can extend rdf:li with a new property and refine its domain/range (although these are only really meaningful to human readers, as the child property inherits the semantics of the parent):

:myItem rdfs:subPropertyOf rdf:li;
  rdfs:range :typeOfElement;
  rdfs:domain :mySeq .

:myItem inherits the semantics of rdf:li, so whatever implementatin logic you have can infer that the values of :myItem are in some meaningful order. Next define the :mySeq class via a property restriction:

:mySeq rdfs:subClassOf [ 
    a owl:Restriction; 
    owl:onProperty :myItem;
    owl:allValuesFrom :typeOfElement;].

which asserts that :mySeq is a class of all things where the property :myItem is explicitly used for values of :typeOfElement. You can now create lists with :mySeq.


To go a step further, you may define :mySeq as the intersection of the above rule and rdf:Seq:

:mySeq a owl:Class;
    owl:equivalentClass
    [ a owl:Class;
        owl:intersectionOf
          ( rdf:Seq
            [a owl:Restriction;
             owl:onProperty :myItem;
             owl:allValuesFrom :typeOfElement ]) ] .

Note the use owl:equivalentClass in place of rdfs:subClassOf. If we treat owl:equivalentClass as symmetric and subsumed by rdfs:subClassOf, eg:

owl:equivalentClass a owl:SymmetricProperty .
owl:equivalentClass rdfs:subPropertyOf rdfs:subClassOf .

then we can have equivalence that goes in both directions. Therefore all instances of rdf:Seq whose values for :myItem are of :typeOfElement are also instances of :mySeq. In this case you are inferring the type. So via the statement:

:x a rdf:Seq; :myItem :foo, :bar .

you may infer that :x a :mySeq.

Relinquish answered 2/6, 2015 at 13:21 Comment(2)
It's only a part of the answer. I can't say which of the property, rdf:_n or :myItem, I will use in :mySeq. My principal problem is to force :mySeq to only use :myItem. So I think I will have to define a sub-class of rdf:Seq or something like that.Appendectomy
Yes, you are correct. I've updated my answer. Hope it gets you on a better track. Also have a look at the ordered list ontology, which may be easier to work with than the rdf containers.Relinquish

© 2022 - 2024 — McMap. All rights reserved.