rdfsshaclrdfs+

Shacl handling of rdfs:subPropertyOf


I have the following shacl spec

efdn:Relation
  rdf:type owl:Class ;
  rdf:type sh:NodeShape ;
  rdfs:label "Relation"@en ;
  sh:property [
    sh:path efdn:nondirectionalLinkWith ;
    sh:NodeKind sh:IRI ;
    sh:maxCount 2 ;
    sh:minCount 2 ;
  ] ;
.

My Goal is to express that a Relation must be connected by exactly "nondirectionalLinkWith" object property. More specifically I would like to express that it can be any subPropertyOf of "nondirectionalLinkWith". In other words, one can say, a Relation object is such that it must be connected by 2 non directional Link. Where non directional link are any object property that is a subPropertyOf "nondirectionalLinkWith".

1 ) I wonder how one can express that using shacl.

So far the only possibility i saw is to use an RDFS Reasoner Explicitly. That is, while Shacl handle rdfs:subClassOf Gracefully, and therefore there is no need to use a RDFS Reasoner, rdfs:SubPropertyOf seems to have no support.

Am I correct here, or there is a way to express such a constraint in shacl directly.

With an RDFS Reasoner we have:

Construct {
  :x1 :p1 :x2
} Where {
  :x1 :p2. :x2
  :p2 rdfs:subPropertyOf :p1. 
}

Which allows to then validate the Relation. However, I wonder if i can avoid the use of an RDFS Reasoner altogether to handle such a simple case ? If it can be expressed in pure shacl somehow, or any other workaround would be much appreciated.


Solution

  • First, note that the constraint property sh:nodeKind must start with a lower-case n

    SHACL does not directly support rdfs:subPropertyOf, so you are right that requiring RDFS reasoning is one way to go. You can use sh:entailment for that purpose, see https://www.w3.org/TR/shacl/#shacl-rdfs

    If you know the sub-properties in advance, you could also use an alternative path and enumerate all sub-properties in an | list, see https://www.w3.org/TR/shacl/#property-path-alternative