RDFS entailment in SHACL validation in EDG?

67 views
Skip to first unread message

Fan Li

unread,
Oct 10, 2019, 11:41:00 AM10/10/19
to TopBraid Suite Users
Recently we encountered a situation where the validation error "Value must be an instance of [some class]" is raised, even though the individual has been declared an instance of a subclass of the class. We looked it up and it seems the error is related to the lack of RDFS entailment in the validation process: https://book.validatingrdf.com/bookHtml011.html#sec171


The referenced book also mentioned that entailment may be enabled during the validation process. Is it possible within EDG?

Irene Polikoff

unread,
Oct 10, 2019, 12:09:24 PM10/10/19
to topbrai...@googlegroups.com
Fan Li,

If :X rdf:type :A, :A rdfs:subClassOf :B, :Y :prop1 :X and you have a constraint :prop1 sh:class :B, you will NOT get a validation result. 

For example, if you look at one of the samples available for EDG - Geo Taxonomy, you will not that most resources in that taxonomy are not of type skos:Concept. Instead, they are members of classes Continent, City, etc., which are declared as subclasses of skos:Concept. 

There is a constraint on skos:broader:

skos:Concept-broader
  a sh:PropertyShape ;
  sh:path skos:broader ;
  sh:class skos:Concept ;
  sh:description "Relates a concept to a concept that is more general in meaning."@en ;
  sh:group skos:StandardRelationshipsPropertyGroup ;
  sh:name "broader concept" ;
  sh:order 0 ;
.

Data has, for example:

g:United_States
  a g:Country ;
  skos:broader g:North_America.

g:North_America
  a g:Continent.

And there are no violations. SubclassOf entailment is always applied automatically when sh:class constraints are evaluated and when target nodes are calculated if class target is used. This is described in the spec:

SHACL Type
The SHACL types of an RDF term in an RDF graph is the set of its values for rdf:type in the graph as well as the SHACL superclasses of these values in the graph.

If you are having a problem, the issue is not with this logic. Are you certain that the rdfs:subClassOf statement is present in the data graph? How are you running the validation?

Further, the book you are referencing has quite a number of inaccuracies in its description of SHACL - some are more subtle than others. 

I would not recommend it as a guide for understanding and using SHACL. If you do so, chances are you will have some key misconceptions that would prevent you from using SHACL effectively.

Irene

On Oct 10, 2019, at 11:41 AM, Fan Li <lifa...@gmail.com> wrote:

Recently we encountered a situation where the validation error "Value must be an instance of [some class]" is raised, even though the individual has been declared an instance of a subclass of the class. We looked it up and it seems the error is related to the lack of RDFS entailment in the validation process: https://book.validatingrdf.com/bookHtml011.html#sec171

The referenced book also mentioned that entailment may be enabled during the validation process. Is it possible within EDG?


-- 
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/f4ad53ab-2f70-402c-8d4d-4b906ac5d69e%40googlegroups.com.

Fan Li

unread,
Oct 10, 2019, 12:40:53 PM10/10/19
to TopBraid Suite Users
Hi Irene, thanks for your prompt response! I should be more clear that the error doesn't surface in the EDG editor interface but through the SHACL validation form (/edg/tbl/swp?_viewClass=tblshacl%3AValidationPage) as well as the public shacl playground (http://shacl.org). I have enclosed a simple example for you to reproduce.

shape:
# baseURI: urn:x-evn-master:mytest

@prefix metadata: <http://topbraid.org/metadata#> .
@prefix sh:    <http://www.w3.org/ns/shacl#> .
@prefix teamwork: <http://topbraid.org/teamwork#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
<urn:x-evn-master:mytest>
        a                owl:Ontology ;
        rdfs:label       "mytest" ;
        metadata:status  metadata:UnderDevelopmentStatus ;
                "http://example.org/ontologies/mytest#" ;
        teamwork:newInstancesUserCannotModifyURI
                false ;
        owl:imports      <http://datashapes.org/dash> , <http://datashapes.org/graphql> .

mytest:B  a              sh:NodeShape , owl:Class ;
        rdfs:label       "B" ;
        rdfs:subClassOf  owl:Thing .

mytest:A  a              sh:NodeShape , owl:Class ;
        rdfs:label       "A" ;
        rdfs:subClassOf  mytest:B .

mytest:C  a              sh:NodeShape , owl:Class ;
        rdfs:label       "C" ;
        rdfs:subClassOf  owl:Thing ;
        sh:property      mytest:C-prop1 .

mytest:C-prop1  a  sh:PropertyShape ;
        sh:class  mytest:B ;
        sh:path   mytest:prop1 .

mytest:prop1  a     owl:ObjectProperty ;
        rdfs:label  "prop1" .


data:
# baseURI: urn:x-evn-master:mytest

@prefix metadata: <http://topbraid.org/metadata#> .
@prefix sh:    <http://www.w3.org/ns/shacl#> .
@prefix teamwork: <http://topbraid.org/teamwork#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
<urn:x-evn-master:mytest>
        a                owl:Ontology ;
        rdfs:label       "mytest" ;
        metadata:status  metadata:UnderDevelopmentStatus ;
                "http://example.org/ontologies/mytest#" ;
        teamwork:newInstancesUserCannotModifyURI
                false ;
        owl:imports      <http://datashapes.org/dash> , <http://datashapes.org/graphql> .

mytest:34640a83-2c1b-11b2-80f2-005056bba47c
        a           mytest:A ;
        rdfs:label  "a1" .

mytest:34640a85-2c1b-11b2-80f2-005056bba47c
        a             mytest:C ;
        rdfs:label    "c1" ;
        mytest:prop1  mytest:34640a83-2c1b-11b2-80f2-005056bba47c .



With regard to SHACL reference, I would be more than happy to know if you have any recommendations.

Thanks,
Fan
Fan Li,

Irene

To unsubscribe from this group and stop receiving emails from it, send an email to topbrai...@googlegroups.com.

Irene Polikoff

unread,
Oct 10, 2019, 1:51:31 PM10/10/19
to topbrai...@googlegroups.com
I am confused because it looks like the URI of the shapes graph is the same as the URI of the data graph - <urn:x-evn-master:mytest>

There  would be nothing wrong with this, but you are showing different triples under shapes and data graphs.

Could you clarify:

  • Are you using the same graph as data and as shapes?
  • If you do, does this graph contain a merge of all the triples you list below?
  • Or are you using two different graphs for shapes and data?
  • If so, does the data graph have access to rdfs:subClassOf triple?


Note that, according to the SHACL instance definition, all the rdfs:subClassOf declarations needed to walk the class hierarchy need to exist in the data graph


The data graph is expected to include all the ontology axioms related to the data and especially all the rdfs:subClassOf triples in order for SHACL to correctly identify class targets and validate Core SHACL constraints.

I believe having :dataGraph owl:imports :shapesGraph should be enough, but leave it to Holger to confirm

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/ef7c2a88-f029-43bd-9a80-ef4314110ed3%40googlegroups.com.

Fan Li

unread,
Oct 10, 2019, 2:35:23 PM10/10/19
to TopBraid Suite Users
Sorry for the confusion. I have the classes and instances in a single graph in EDG (attached). I separated them into two files in order to submit through the SHACL validation form (/edg/tbl/swp?_viewClass=tblshacl%3AValidationPage). This may have been the reason for the error, but I am not sure.
mytest.ttl

Irene Polikoff

unread,
Oct 10, 2019, 2:52:31 PM10/10/19
to topbrai...@googlegroups.com
You do not need to separate them into 2 graphs for the purposes of validation. Shape graph and data graph are just roles. You could use a single graph as both, shapes and data.

Try running validation again with a single graph in both roles and see if it works.

As a best practice, we recommend separating schema (shapes) from data (instances) and connecting a graph with instances with a graph that defines schema using Includes/owl:imports mechanism.

If you have an ontology that contains instances as well as schema, you can refactor instances into a separate graph using Transform-> Copy or Move Instances from Other Asset Collection:

First, create a new asset collection.
Include in it ontology that contains your schema and the instances you want to move.
Then, go to Transform tab and select a class to move instances from.

You do not have to include a collection with instances in order to move resources from it, but you do need to have the schema definitions included.
> 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/0c03228c-b996-4102-b0f8-0cadb0078423%40googlegroups.com.
> <mytest.ttl>

Fan Li

unread,
Oct 10, 2019, 2:58:16 PM10/10/19
to TopBraid Suite Users
Thanks, Irene. Using the same ttl file for both data and graph worked with no validation error. Thanks for all your suggestions.

Stefan Verweij

unread,
Jan 30, 2020, 5:04:55 AM1/30/20
to TopBraid Suite Users
Hi Irene,

I have a question regarding this topic: I cannot find any documentation about importing an ontology with the owl:import mechanism in a data graph with instances and how this data graph would look like then, e.g. if we look at the examples Fan gave (or one in JSON-LD format?). In the https://shacl.org/playground/ the data graph does not seem to import the ontology if I am not mistaken?

Stefan

Op donderdag 10 oktober 2019 20:52:31 UTC+2 schreef Irene Polikoff:
You do not need to separate them into 2 graphs for the purposes of validation. Shape graph and data graph are just roles. You could use a single graph as both, shapes and data. 
As a best practice, we recommend separating schema (shapes) from data (instances) and connecting a graph with instances with a graph that defines schema using Includes/owl:imports mechanism.
 
>> On Oct 10, 2019, at 12:40 PM, Fan Li <lifa...@gmail.com> wrote:

Irene Polikoff

unread,
Jan 30, 2020, 11:54:22 AM1/30/20
to topbrai...@googlegroups.com
Stefan,

Is your question about EDG or about SHACL playground?

  • In EDG, Data Graph is a type of asset collection that contains only instance data. When you create a data graph in EDG, you will be asked for an ontology to base it on. The dialog will give you a selection of ontologies that are available in your environment.
  • It is important that there is a class in that ontology that is declared to be public. This should be a class for which you will have data. If your data will belong to multiple classes, make a common parent public. Please see https://doc.topquadrant.com/6.3/ontologies/#SHACL_requirements_for_working_with_Reference_Datasets_and_Data_Graphs
  • Once this is set up, you can use Import RDF to load your data in JSON-LD serialization or any other serialization. The ontology you chose should, of course, correspond to this data. In other words, have SHACL Shapes for it.

In SHACL, there are two terms, “shapes graph” and “data graph”. These are roles that any graph can play. A SHACL engine will use a shapes graph as a source for SHACL Shapes and it will use a data graph as a source of data to be validated against these shapes. These are just roles and you can have the same graph playing both roles. You can also use as a data graph a graph containing just shapes, not “instance data” . This can be useful to validate your shapes declarations against the meta shapes for SHACL. If your graphs contain any owl:imports, SHACL engines should act on them, but you are not required to have them.

SHACL playground is a sample implementation of SHACL in JavaScript.


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

Holger Knublauch

unread,
Jan 30, 2020, 5:47:57 PM1/30/20
to topbrai...@googlegroups.com

I have also responded to the similar question at https://github.com/TopQuadrant/shacl-js/issues/22

Holger

Stefan Verweij

unread,
Jan 31, 2020, 10:43:01 AM1/31/20
to TopBraid Suite Users
A bit of both: I am trying to understand how the ontologies in EDG work by messing around with the SHACL syntax in the playground. Thanks both of you for your fast reaction.

Op donderdag 30 januari 2020 23:47:57 UTC+1 schreef Holger Knublauch:

I have also responded to the similar question at https://github.com/TopQuadrant/shacl-js/issues/22

Holger


Op donderdag 30 januari 2020 17:54:22 UTC+1 schreef Irene Polikoff:
Stefan,

Is your question about EDG or about SHACL playground?

  • In EDG, Data Graph is a type of asset collection that contains only instance data. When you create a data graph in EDG, you will be asked for an ontology to base it on. The dialog will give you a selection of ontologies that are available in your environment.
  • It is important that there is a class in that ontology that is declared to be public. This should be a class for which you will have data. If your data will belong to multiple classes, make a common parent public. Please see https://doc.topquadrant.com/6.3/ontologies/#SHACL_requirements_for_working_with_Reference_Datasets_and_Data_Graphs
  • Once this is set up, you can use Import RDF to load your data in JSON-LD serialization or any other serialization. The ontology you chose should, of course, correspond to this data. In other words, have SHACL Shapes for it.

In SHACL, there are two terms, “shapes graph” and “data graph”. These are roles that any graph can play. A SHACL engine will use a shapes graph as a source for SHACL Shapes and it will use a data graph as a source of data to be validated against these shapes. These are just roles and you can have the same graph playing both roles. You can also use as a data graph a graph containing just shapes, not “instance data” . This can be useful to validate your shapes declarations against the meta shapes for SHACL. If your graphs contain any owl:imports, SHACL engines should act on them, but you are not required to have them.

SHACL playground is a sample implementation of SHACL in JavaScript.
To unsubscribe from this group and stop receiving emails from it, send an email to topbrai...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages