shacl-rep?

44 views
Skip to first unread message

Bohms, H.M. (Michel)

unread,
Mar 9, 2020, 2:55:27 PM3/9/20
to topbrai...@googlegroups.com

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

+31888663107
+31630381220
michel...@tno.nl

Location

 

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.

 

 

 

 

Irene Polikoff

unread,
Mar 9, 2020, 3:31:15 PM3/9/20
to topbrai...@googlegroups.com
Declaring disjoint classes is typically done when you are targeting your model for DL reasoning. DL reasoners rely on it and perform better with it. Outside of DL, it is seldom done.

You could, using inverse path on rdf:type say that for instances of smls:PhysicalObject, you can not have {?x a smls:InformationObject}, etc. You would do this for every class.


> On Mar 9, 2020, at 2:55 PM, 'Bohms, H.M. (Michel)' via TopBraid Suite Users <topbrai...@googlegroups.com> 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 michel...@tno.nl
> Location
>
>
> <image001.gif>
> 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 topbraid-user...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/32830e3367084dfbabe6fc80390c3962%40tno.nl.

Holger Knublauch

unread,
Mar 9, 2020, 6:36:36 PM3/9/20
to topbrai...@googlegroups.com

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

--

Bohms, H.M. (Michel)

unread,
Mar 10, 2020, 4:44:47 AM3/10/20
to topbrai...@googlegroups.com

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).

David Price

unread,
Mar 10, 2020, 8:44:46 AM3/10/20
to topbrai...@googlegroups.com
I think I investigated this a while back and if you really need disjointedness checked, then the best answer was to generate an sh:SPARQLConstraint from each owl:disjointWith statement and have that report a violation. I never finished the task, but that was the recommendation at the time. The complication in the general case is that you cannot just look at rdf:type(s) of the individual, you have to search up the superclasses to check for the class stated in the owl:disjointWith statement.

Cheers,
David


Irene Polikoff

unread,
Mar 10, 2020, 9:58:05 AM3/10/20
to topbrai...@googlegroups.com
That in itself does not necessarily require SHACL SPARQL. 

Instead, a complex path could be used - https://www.w3.org/TR/shacl/#property-path-zero-or-more.e.g., a path such as ^rdf:type/rdfs:subClassOf*

smls:InformationObject-invType
  a sh:PropertyShape ;
  sh:path (
      [
        sh:inversePath rdf:type ;
      ]
      [
        sh:zeroOrMorePath rdfs:subClassOf ;
      ]
    ) ;
  sh:hasValue smls:InformationObject ;

Throw in sh:not for this particular case to say that a smls:PhysicalObject can’t conform to this. Also, sh:or to cover other classes.

Holger Knublauch

unread,
Mar 10, 2020, 6:11:30 PM3/10/20
to topbrai...@googlegroups.com

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

alldifferent.shapes.ttl

Bohms, H.M. (Michel)

unread,
Mar 11, 2020, 5:13:43 AM3/11/20
to topbrai...@googlegroups.com

Guess that becomes even more troublesome for allddisjointclasses clause...

 

I hope for a nodeshape level construct like:

every instance of the target class is not a member of class X

Bohms, H.M. (Michel)

unread,
Mar 11, 2020, 5:40:07 AM3/11/20
to topbrai...@googlegroups.com

 

Thx

 

One thing I do not understand…why ^rdf:type and not just rdf:type?

 

Assume I have object :o1 and classes :PO (PhysicalObject) and :SPO (SpecializedPhysicalObject) and IO (InformationObject)

 

So if “:o1 rdf:type :IO” I want t make sure its not of type PO or any recursive subclass of PO like SPO.

 

Isnt this then :

 

NOT

{

 

smls:InformationObject-invType

  a sh:PropertyShape ;

  sh:path (

      [

        sh:path rdf:type ;

      ]

      [

        sh:zeroOrMorePath rdfs:subClassOf ;

      ]

    ) ;

  sh:hasValue smls:InformationObject ;

}

 

 

 

 

 

Van: topbrai...@googlegroups.com <topbrai...@googlegroups.com> Namens Irene Polikoff
Verzonden: Tuesday, March 10, 2020 2:58 PM
Aan: topbrai...@googlegroups.com
Onderwerp: Re: [topbraid-users] shacl-rep?

 

That in itself does not necessarily require SHACL SPARQL. 

--

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 topbraid-user...@googlegroups.com.

Bohms, H.M. (Michel)

unread,
Mar 11, 2020, 6:05:32 AM3/11/20
to topbrai...@googlegroups.com

 

Looks nice

But

 

Wrt

owl:AllDifferent

 

did you mean?:

 

owl:AllDisjointClasses

Holger Knublauch

unread,
Mar 11, 2020, 6:35:32 AM3/11/20
to topbrai...@googlegroups.com


On 11/03/2020 8:05 pm, 'Bohms, H.M. (Michel)' via TopBraid Suite Users wrote:

 

Looks nice

But

 

Wrt

owl:AllDifferent

 

did you mean?:

 

owl:AllDisjointClasses

Ah yes of course...

Holger


Irene Polikoff

unread,
Mar 11, 2020, 8:26:56 AM3/11/20
to topbrai...@googlegroups.com
Yes, you are right. I was thinking of two or three possible solutions at the same time and got them a bit mixed up.

You can use sh:not and drop the inverse if your target are all class members.

Sent from my iPhone

Bohms, H.M. (Michel)

unread,
Mar 11, 2020, 12:55:44 PM3/11/20
to topbrai...@googlegroups.com

One more issue

 

Normally I would use RDFS+SHACL without owl

 

Now I have to keep however owl:AllDisjointClasses and its instances because it is the targetclass.

 

Guess there no way around this?

 

Or could I attach the shacl shape to the available classes somehow:

 

smls:PhysicalObject a rdfs:Class .

smls:InformationObject a rdfs:Class .

smls:Activity a rdfs:Class .

Etc.

 

Or does this actually go into the direction of Irene’s solution?

Irene Polikoff

unread,
Mar 11, 2020, 1:34:16 PM3/11/20
to topbrai...@googlegroups.com
Holger’s solution assumes that your starting point is OWL - you have OWL axioms and are trying to detect contradictions to it using SHACL.

My solution does not assume this. 

I have to go back to the question as to why make this constraint at all? This style of modeling is specific to OWL (for reasons related to how tableau reasoners operate) and is absent from any other modeling language I could think of e.g., XML Schema, JSON Schema, UML, EntityRelationships, etc.

One reason this is uncommon outside of OWL is because if you have different objects, their characteristics (properties and property values) will be different. And any possible issue are likely to be caught as a result of it - through other property shapes. For example, if you say that people must have father and a mother and organizations must have ‘year established’ and you have a resource that is both a person and an organization, you will get a violation one way or another. Another reason is that these kind of errors in data are pretty unusual. Data will come from some sources that typically have different data structures and identity for the different type of objects.

What are you trying to accomplish? It may be that in your data, you want each resource to have only one rdf:type statement. You can do it with sh:maxCount on rdf:type. You may want to say that if a resource is a member of class X transitively, it can’t be a member of any class that is not a subclass of X. This would allow multiple types, but all resolving to the same parent class.

If you do want, for some reason, to stay with the disjoint idea, then you have the solution I described where you would need for each class explicitly specify disjoint classes. If you want something more terse ala owl:AllDisjointClasses where you can say that a list of classes is all disjoint, then Holger’s solution. It is generic in that it can work with any ontology but it relies on having some statements that identify the list of disjoint classes. Holger used OWL vocabulary for these statements. You could invent your own vocabulary and modify the query accordingly.

On Mar 11, 2020, at 12:55 PM, 'Bohms, H.M. (Michel)' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:

One more issue
 
Normally I would use RDFS+SHACL without owl
 
Now I have to keep however owl:AllDisjointClasses and its instances because it is the targetclass.
 
Guess there no way around this?
 
Or could I attach the shacl shape to the available classes somehow:
 
smls:PhysicalObject a rdfs:Class .
smls:InformationObject a rdfs:Class .
smls:Activity a rdfs:Class .
Etc.
 
Or does this actually go into the direction of Irene’s solution?
 
 
Dr. ir. H.M. (Michel) Böhms
Senior Data Scientist

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: topbrai...@googlegroups.com <topbrai...@googlegroups.com> Namens Holger Knublauch
Verzonden: Wednesday, March 11, 2020 11:35 AM
Aan: topbrai...@googlegroups.com
Onderwerp: Re: [topbraid-users] shacl-rep?
 

 

On 11/03/2020 8:05 pm, 'Bohms, H.M. (Michel)' via TopBraid Suite Users wrote:
 
Looks nice
But
 
Wrt
owl:AllDifferent
 
did you mean?:
 
owl:AllDisjointClasses

Ah yes of course...

Holger

 

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


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: topbrai...@googlegroups.com <topbrai...@googlegroups.com> Namens Holger Knublauch
Verzonden: Tuesday, March 10, 2020 11:11 PM
Aan: topbrai...@googlegroups.com
Onderwerp: Re: [topbraid-users] shacl-rep?
 

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:

<image002.png>

Thx Michel
 
 

Bohms, H.M. (Michel)

unread,
Mar 11, 2020, 2:35:54 PM3/11/20
to topbrai...@googlegroups.com

 

Holger’s solution assumes that your starting point is OWL - you have OWL axioms and are trying to detect contradictions to it using SHACL.

 

My solution does not assume this. 

 

> yes, I see. Guess holgers approach applied to explicit rdfs classes will be similar to your solution, right?

 

I have to go back to the question as to why make this constraint at all? This style of modeling is specific to OWL (for reasons related to how tableau reasoners operate) and is absent from any other modeling language I could think of e.g., XML Schema, JSON Schema, UML, EntityRelationships, etc.

 

One reason this is uncommon outside of OWL is because if you have different objects, their characteristics (properties and property values) will be different. And any possible issue are likely to be caught as a result of it - through other property shapes. For example, if you say that people must have father and a mother and organizations must have ‘year established’ and you have a resource that is both a person and an organization, you will get a violation one way or another. Another reason is that these kind of errors in data are pretty unusual. Data will come from some sources that typically have different data structures and identity for the different type of objects.

 

What are you trying to accomplish? It may be that in your data, you want each resource to have only one rdf:type statement. You can do it with sh:maxCount on rdf:type. You may want to say that if a resource is a member of class X transitively, it can’t be a member of any class that is not a subclass of X. This would allow multiple types, but all resolving to the same parent class.

 

> in our (use) case we exchange data according to ontologies (often called object type libraries in nl) that share a common top level taxonomy (smls).

> in the exchange we want to check the disjointness for classes in the top level or subclasses (say: the archetypes)

> still there can be multiple typing in the OTL (under the same smls archetype)

> maxCount=1 is therefore too restrictive

> we have 4 profiles: SKOS, RDFS, RDF+OWL, RDFS+SHACL

> so for data verification we are in the last one and that is the context of my question (so no owl here)

 

 

If you do want, for some reason, to stay with the disjoint idea, then you have the solution I described where you would need for each class explicitly specify disjoint classes. If you want something more terse ala owl:AllDisjointClasses where you can say that a list of classes is all disjoint, then Holger’s solution. It is generic in that it can work with any ontology but it relies on having some statements that identify the list of disjoint classes. Holger used OWL vocabulary for these statements. You could invent your own vocabulary and modify the query accordingly.

 

> indeed when I talked about a work around I was thinking about something like that, but maybe also not elegant

> guess your way would be more applicable then....

 

> thx for your extensive answers! Michel

Irene Polikoff

unread,
Mar 11, 2020, 4:23:11 PM3/11/20
to topbrai...@googlegroups.com

On Mar 11, 2020, at 2:35 PM, 'Bohms, H.M. (Michel)' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:

 
Holger’s solution assumes that your starting point is OWL - you have OWL axioms and are trying to detect contradictions to it using SHACL.
 
My solution does not assume this. 
 
> yes, I see. Guess holgers approach applied to explicit rdfs classes will be similar to your solution, right?

Holger’s solution requires that there is a statement like this:

example:AllDisjoint1
  rdf:type owl:AllDisjointClasses ;
  rdfs:label "All disjoint 1" ;


  owl:members (
      schema:Person
      schema:Product
      schema:Event
    ) .



I don’t think it matters to this example whether schema:Person is rdfs:Class or owl:Class. I do not believe Holger's SPARQL query uses the fact that something is of type owl:Class. Even if it did, it could be changed accordingly.

Further, instead of using owl:AllDisjoint and owl:members, it could also be

example:AllDisjoint1
  rdf:type my:AllDisjointClasses ;
  rdfs:label "All disjoint 1" ;
  my:members (


      schema:Person
      schema:Product
      schema:Event
    ) .

I have to go back to the question as to why make this constraint at all? This style of modeling is specific to OWL (for reasons related to how tableau reasoners operate) and is absent from any other modeling language I could think of e.g., XML Schema, JSON Schema, UML, EntityRelationships, etc.
 
One reason this is uncommon outside of OWL is because if you have different objects, their characteristics (properties and property values) will be different. And any possible issue are likely to be caught as a result of it - through other property shapes. For example, if you say that people must have father and a mother and organizations must have ‘year established’ and you have a resource that is both a person and an organization, you will get a violation one way or another. Another reason is that these kind of errors in data are pretty unusual. Data will come from some sources that typically have different data structures and identity for the different type of objects.
 
What are you trying to accomplish? It may be that in your data, you want each resource to have only one rdf:type statement. You can do it with sh:maxCount on rdf:type. You may want to say that if a resource is a member of class X transitively, it can’t be a member of any class that is not a subclass of X. This would allow multiple types, but all resolving to the same parent class.
 
> in our (use) case we exchange data according to ontologies (often called object type libraries in nl) that share a common top level taxonomy (smls).
> in the exchange we want to check the disjointness for classes in the top level or subclasses (say: the archetypes)
> still there can be multiple typing in the OTL (under the same smls archetype)
> maxCount=1 is therefore too restrictive

I do not have enough info on what your model looks like - what are the instance and what are the classes and how they are used. One idea could be to consider giving your classes different types e.g., smls:PhysicalObject a smls:PhysicalObjectClass.

We use this in EDG models where each EDG class is an instance of edg:AssetClass. But this is going beyond what I would have time to discuss.

Reply all
Reply to author
Forward
0 new messages