Hi Michel,

I am attaching a solution that should work for the general case. It defines a NodeShape that has owl:AllDifferent as its target class, and then does pairwise comparison of all mentioned classes, and then reports instances that have multiple of those types:

on

alldifferent:AllDifferent1
  rdf:type owl:AllDifferent ;
  rdfs:label "All different1" ;
  owl:members (
      schema:Person
      schema:Product
      schema:Event
    ) .

and sample instance

alldifferent:CarPerson
  rdf:type schema:Person ;
  rdf:type schema:Vehicle ;
  rdfs:label "Car Person" .

The main shape is


alldifferent:AllDifferentShape
  rdf:type sh:NodeShape ;
  rdfs:label "All different shape" ;
  sh:sparql [
      sh:message "{?class1} and {?class2} cannot share instances but {?value} has types {?type1} and {?type2}" ;
      sh:prefixes <http://example.org/alldifferent> ;
      sh:select """SELECT $this ?class1 ?class2 (?instance AS ?value) ?type1 ?type2
WHERE {
    {
        $this owl:members ?membersList .
        # Go through all combinations
        ?members rdf:rest*/rdf:first ?class1 .
        ?members rdf:rest*/rdf:first ?class2 .
        FILTER (?class1 != ?class2) .
        FILTER (str(?class1) < str(?class2)) # Avoid duplicates in both directions
    }
    ?type1 rdfs:subClassOf* ?class1 .
    ?instance a ?type1 .
    ?instance a ?type2 .
    ?type2 rdfs:subClassOf* ?class2 .
}""" ;
    ] ;
  sh:targetClass owl:AllDifferent ;
.

This solution simply reuses the OWL vocabulary, so you don't need to change your model. Any similar solution would need to introduce another vocabulary, so for those who don't want to reuse owl:AllDifferent here, just make up your own instance vocabulary.

HTH

Holger


On 10/03/2020 18:44, 'Bohms, H.M. (Michel)' via TopBraid Suite Users wrote:

Hi Holger

Would this become a global PropertyShape then?

For the smls upper ontology itself it holds but in general not for the userdefined ontologies importing smls.

(which will have subclasses for say PhysicalObject that are non-disjunst).

Thx Michel

        

Dr. ir. H.M. (Michel) Böhms
Senior Data Scientist

        

T +31888663107
M +31630381220
E [email protected] <mailto:[email protected]>

        

Location <https://www.google.com/maps/place/TNO+-+Locatie+Delft+-+Stieltjesweg/@52.000788,4.3745183,17z/data=!3m1!4b1!4m5!3m4!1s0x47c5b58c52869997:0x56681566be3b8c88!8m2!3d52.000788!4d4.376707>

<http://www.tno.nl/>

This message may contain information that is not intended for you. If you are not the addressee or if this message was sent to you by mistake, you are requested to inform the sender and delete the message. TNO accepts no liability for the content of this e-mail, for the manner in which you use it and for damage of any kind resulting from the risks inherent to the electronic transmission of messages.


*Van:*[email protected] <[email protected]> *Namens *Holger Knublauch
*Verzonden:* Monday, March 9, 2020 11:36 PM
*Aan:* [email protected]
*Onderwerp:* Re: [topbraid-users] shacl-rep?

Can any of them have multiple types at all? If not, just set sh:maxCount 1 at rdf:type.

As Irene indicated the scenario wasn't deemed important enough by the SHACL WG to include a built-in constraint type into the core language. However, it would be possible to define a custom constraint component in SHACL-SPARQL.

Holger

On 10/03/2020 04:55, 'Bohms, H.M. (Michel)' via TopBraid Suite Users wrote:

    Is there a shacl counterpart for:

    [

      a owl:AllDisjointClasses ;

      owl:members (

    smls:PhysicalObject

    smls:InformationObject

    smls:State

    smls:Event

    smls:TemporalRegion

    smls:SpatialRegion

    smls:Activity

    ) ;

    ].

    Thx Michel

        

    Dr. ir. H.M. (Michel) Böhms
    Senior Data Scientist


        

    T +31888663107
    M +31630381220
    E [email protected] <mailto:[email protected]>

        

    Location
    
<https://www.google.com/maps/place/TNO+-+Locatie+Delft+-+Stieltjesweg/@52.000788,4.3745183,17z/data=!3m1!4b1!4m5!3m4!1s0x47c5b58c52869997:0x56681566be3b8c88!8m2!3d52.000788!4d4.376707>

    <http://www.tno.nl/>

    This message may contain information that is not intended for you.
    If you are not the addressee or if this message was sent to you by
    mistake, you are requested to inform the sender and delete the
    message. TNO accepts no liability for the content of this e-mail,
    for the manner in which you use it and for damage of any kind
    resulting from the risks inherent to the electronic transmission
    of messages.


-- You received this message because you are subscribed to the Google
    Groups "TopBraid Suite Users" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to [email protected]
    <mailto:[email protected]>.
    To view this discussion on the web visit
    
https://groups.google.com/d/msgid/topbraid-users/32830e3367084dfbabe6fc80390c3962%40tno.nl
    
<https://groups.google.com/d/msgid/topbraid-users/32830e3367084dfbabe6fc80390c3962%40tno.nl?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/05a8285a-0491-0057-63e9-42fd4c1f245b%40topquadrant.com <https://groups.google.com/d/msgid/topbraid-users/05a8285a-0491-0057-63e9-42fd4c1f245b%40topquadrant.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/70f21a2c16a847a88361cf890bacc73e%40tno.nl <https://groups.google.com/d/msgid/topbraid-users/70f21a2c16a847a88361cf890bacc73e%40tno.nl?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "TopBraid 
Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/75d31960-9bb6-129b-cdbf-1a40701118a4%40topquadrant.com.
# baseURI: http://example.org/alldifferent
# imports: http://datashapes.org/dash
# imports: http://datashapes.org/schema
# prefix: alldifferent

@prefix alldifferent: <http://example.org/alldifferent#> .
@prefix dash: <http://datashapes.org/dash#> .
@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 schema: <http://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://example.org/alldifferent>
  a owl:Ontology ;
  owl:imports <http://datashapes.org/dash> ;
  owl:imports <http://datashapes.org/schema> ;
  owl:versionInfo "Created with TopBraid Composer" ;
.
alldifferent:Action1
  a schema:Action ;
  rdfs:label "Action1" ;
.
alldifferent:AllDifferent1
  a owl:AllDifferent ;
  rdfs:label "All different1" ;
  owl:members (
      schema:Person
      schema:Product
      schema:Event
    ) ;
.
alldifferent:AllDifferentShape
  a sh:NodeShape ;
  rdfs:label "All different shape" ;
  sh:sparql [
      sh:message "{?class1} and {?class2} cannot share instances but {?value} 
has types {?type1} and {?type2}" ;
      sh:prefixes <http://example.org/alldifferent> ;
      sh:select """SELECT $this ?class1 ?class2 (?instance AS ?value) ?type1 
?type2
WHERE {
        {
        $this owl:members ?membersList .
                # Go through all combinations
                ?members rdf:rest*/rdf:first ?class1 .
                ?members rdf:rest*/rdf:first ?class2 .
                FILTER (?class1 != ?class2) .
                FILTER (str(?class1) < str(?class2)) # Avoid duplicates in both 
directions
        }
        ?type1 rdfs:subClassOf* ?class1 .
        ?instance a ?type1 .
        ?instance a ?type2 .
        ?type2 rdfs:subClassOf* ?class2 .
}""" ;
    ] ;
  sh:targetClass owl:AllDifferent ;
.
alldifferent:CarPerson
  a schema:Person ;
  a schema:Vehicle ;
  rdfs:label "Car Person" ;
.
alldifferent:Person1
  a schema:Person ;
  rdfs:label "Person1" ;
.
alldifferent:Person2
  a schema:Person ;
  rdfs:label "Person2" ;
.

Reply via email to