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.)
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With