Question about sh:or and the other logical operators

Hi,

I’ve received some questions about how the RDF4J SHACL implementation handles sh:or. These have lead me down a path of trying to figure out how things are supposed to work, and now I’m wondering a bit about why.

The main issue is how using the logical operators introduce a new contextual level.

Essentially how:

ex:shape1
       a sh:NodeShape ;
       sh:targetClass ex:Test ;
       sh:property [
              sh:path ex:info ;
              sh:and ([ sh:hasValue "blue" ; ] ) ;
       ] ;
       .

is different from:

ex:shape1
       a sh:NodeShape ;
       sh:targetClass ex:Test ;
       sh:property [
              sh:path ex:info ;
              sh:hasValue "blue" ;
       ] ;
       .
The first says: “if there is a node of type ex:Test and it happens to have a value for ex:info, then all those values must be “blue””.

The second says: “if there is a node of type ex:Test, then it must have “blue” as a value for ex:info and by extension at least one value for ex:info”.

I remember the discussion that lead to the introduction of dash:hasValueIn, where we used sh:or ( [ sh:hasValue V1 ] [ sh:hasValue V2 ] ) as a simplification for dash:hasValueIn. But this was obviously wrong, since using the sh:or means that each value must be either V1 or V2. 

Essentially this use of sh:or is equivalent to sh:in. As in that:

sh:or ([ sh:hasValue "blue" ; ] [ sh:hasValue "red" ; ] [ sh:hasValue "purple" ; ] ) ;

is the same as
sh:in ("blue" "red" "purple");

Am I understanding all this correctly? 

Cheers,
Håvard

Received on Thursday, 20 August 2020 20:09:58 UTC