SHACL inferred data question

205 views
Skip to first unread message

cbur...@healthwise.org

unread,
Jan 18, 2022, 6:44:00 PM1/18/22
to TopBraid Suite Users
I have defined a property shape and am successfully inferring its objects using a sh:values rule.

Can you remind me whether it is possible to use this property and its inferred data in the sh:values rule for a different property shape? If so, is there a special way that it needs to be done -- like, does the data I inferred in the first property shape need to be materialized in some way before I can make use of it? 

Holger Knublauch

unread,
Jan 18, 2022, 7:03:32 PM1/18/22
to topbrai...@googlegroups.com


On 2022-01-19 9:44 am, cbur...@healthwise.org wrote:
I have defined a property shape and am successfully inferring its objects using a sh:values rule.

Can you remind me whether it is possible to use this property and its inferred data in the sh:values rule for a different property shape? If so, is there a special way that it needs to be done -- like, does the data I inferred in the first property shape need to be materialized in some way before I can make use of it?  --

In general, the RDF graphs that TopBraid operates on do not automatically "see" the extra inferred triples, so they are not computed as RDF triples on the fly. However, our higher level query languages GraphQL and JavaScript/ADS do see them whenever they are requested. The user interface goes through GraphQL and will therefore display these values as if they were materialized.

Now, within SHACL itself it depends on what you want to do. If you have SHACL-AF inference rules including other sh:values rules you can safely use path expressions https://w3c.github.io/shacl/shacl-af/#node-expressions-path and the values will be computed on the fly. For SHACL constraints there is no such mechanism unless you are expressing the constraints in SPARQL. There you can use the magic property

    (?focusNode ?predicate) tosh:values ?result

to query the inferred values.

The other option, of course, is to materialize the inferences, e.g. using the Inferences panel or the Transform tab.

Does this help?

Holger


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/d1fc11f5-f4a3-4d23-84b7-4a72666e6c3fn%40googlegroups.com.

cbur...@healthwise.org

unread,
Jan 20, 2022, 7:54:19 PM1/20/22
to TopBraid Suite Users
Thanks, Holger. My need in this case isn't to query inferred data using SPARQL or GraphQL, but rather to reuse the inferred data as an input for another EDG property shape with another sh:values rule in it. I think I'm hearing that that's not possible.

Can you point me to where I can read more about the materialization option and decide whether there's a way to make that work for this use case? Thanks.

Holger Knublauch

unread,
Jan 20, 2022, 8:01:18 PM1/20/22
to topbrai...@googlegroups.com


On 2022-01-21 10:54 am, cbur...@healthwise.org wrote:
Thanks, Holger. My need in this case isn't to query inferred data using SPARQL or GraphQL, but rather to reuse the inferred data as an input for another EDG property shape with another sh:values rule in it. I think I'm hearing that that's not possible.

That scenario IS possible. You just need to use a path node expression, see

    https://w3c.github.io/shacl/shacl-af/#node-expressions-path

So if ex:prop1 is inferred then you can reference it in the sh:values rule of another property using [ sh:path ex:prop1 ] and it will compute that inference on the fly. This assumes that the receiving property using a sh:values rule using SHACL node expressions, not SPARQL.

Holger



Can you point me to where I can read more about the materialization option and decide whether there's a way to make that work for this use case? Thanks.

On Tuesday, January 18, 2022 at 4:03:32 PM UTC-8 Holger Knublauch wrote:


On 2022-01-19 9:44 am, cbur...@healthwise.org wrote:
I have defined a property shape and am successfully inferring its objects using a sh:values rule.

Can you remind me whether it is possible to use this property and its inferred data in the sh:values rule for a different property shape? If so, is there a special way that it needs to be done -- like, does the data I inferred in the first property shape need to be materialized in some way before I can make use of it?  --

In general, the RDF graphs that TopBraid operates on do not automatically "see" the extra inferred triples, so they are not computed as RDF triples on the fly. However, our higher level query languages GraphQL and JavaScript/ADS do see them whenever they are requested. The user interface goes through GraphQL and will therefore display these values as if they were materialized.

Now, within SHACL itself it depends on what you want to do. If you have SHACL-AF inference rules including other sh:values rules you can safely use path expressions https://w3c.github.io/shacl/shacl-af/#node-expressions-path and the values will be computed on the fly. For SHACL constraints there is no such mechanism unless you are expressing the constraints in SPARQL. There you can use the magic property

    (?focusNode ?predicate) tosh:values ?result

to query the inferred values.

The other option, of course, is to materialize the inferences, e.g. using the Inferences panel or the Transform tab.

Does this help?

Holger


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/d1fc11f5-f4a3-4d23-84b7-4a72666e6c3fn%40googlegroups.com.
--
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.

cbur...@healthwise.org

unread,
Jan 25, 2022, 12:13:52 PM1/25/22
to TopBraid Suite Users
Holger,

I am able to create a second property shape, ex:shape2, that uses the values from my ex:shape1 in a very simple, non-transformative way and successfully returns the values of ex:shape1 for ex:shape2:

ex:Class-shape2
  a sh:PropertyShape ;
  sh:path ex:shape2 ;
  sh:class ex:Class
  sh:values [
      sh:path ex:shape1 ;
    ] ;
.

But the moment I try to introduce any more complexity, my sh:values statement stops returning any results. For example, I tried:

  sh:values [
    sh:path ( ex:shape1 skos:broader ) ;
    ]

and got back no values for ex:shape2. (All of the values returned for ex:shape1 have broader concepts, although they are defined in a different EDG asset collection.)

What am I doing wrong?

thanks,
Carl

Holger Knublauch

unread,
Jan 25, 2022, 5:55:05 PM1/25/22
to topbrai...@googlegroups.com


On 2022-01-26 3:13 am, cbur...@healthwise.org wrote:
Holger,

I am able to create a second property shape, ex:shape2, that uses the values from my ex:shape1 in a very simple, non-transformative way and successfully returns the values of ex:shape1 for ex:shape2:

ex:Class-shape2
  a sh:PropertyShape ;
  sh:path ex:shape2 ;
  sh:class ex:Class
  sh:values [
      sh:path ex:shape1 ;
    ] ;
.

But the moment I try to introduce any more complexity, my sh:values statement stops returning any results. For example, I tried:

  sh:values [
    sh:path ( ex:shape1 skos:broader ) ;
    ]

Right, complex path expressions don't work in that case. This would have required a much more complex implementation that would hook into the SPARQL-like path execution. Doable in principle, just not implemented yet.

The alternative to the above is to use nested sh:path expressions, try something like

sh:values [
    sh:path skos:broader ;
    sh:nodes [
        sh:path ex:shape1 ;
    ]
]

This is based on the optional second argument (sh:nodes) that https://w3c.github.io/shacl/shacl-af/#node-expressions-path takes and would first get all values of ex:shape1 and then get the broader values of those. I believe this corresponds to your chained path expression.

Hope this works, didn't test... :)

Holger


Carl Burnett

unread,
Jan 26, 2022, 8:03:03 PM1/26/22
to topbrai...@googlegroups.com

This helps! I now am able to create more complex sh:values rules that re-use the inferred values from a different property shape.

 

But I am now having some other problems with sh:values. I will probably need to move away from generalized examples now and show you one of my actual shapes:

 

concept_schema:Rollup_Concept-includedVideos

  a sh:PropertyShape ;

  sh:path enterprise_schemas:includedVideos ;

  dash:readOnly true ;

  sh:class content_asset_schema:Video ;

  sh:group tosh:InferencesPropertyGroup ;

  sh:name "included videos (SHACL)" ;

  sh:order "4"^^xsd:decimal ;

  sh:values [

      sh:path [

          sh:inversePath [

              sh:alternativePath (

                  content_asset_schema:level_1

                  content_asset_schema:level_2

                  content_asset_schema:level_3

                ) ;

            ] ;

        ] ;

      sh:filterShape [

          sh:property [

              sh:path content_asset_schema:lifecycle_stage ;

              sh:hasValue supplementary_concept_data:Active_Asset ;

            ] ;

        ] ;

      sh:nodes [

          sh:path enterprise_schemas:includedConcepts ;

        ] ;

    ] ;

.

 

This shape definition is accepted without errors by EDG’s values UI widget, which diagrams it like this:

 

This diagram seems incomplete, though, in two ways:

  1. The right-most box should read this (Video), because I have specified that sh:class.
  2. My sh:filterShape seems to be ignored.

 

Sure enough, the values produced by the shape, while respecting my sh:path and sh:nodes statements, seem to ignore the sh:class I specified and my sh:filterShape.

 

What am I doing wrong here?

 

 

From: topbrai...@googlegroups.com <topbrai...@googlegroups.com> On Behalf Of Holger Knublauch
Sent: Tuesday, January 25, 2022 2:55 PM
To: topbrai...@googlegroups.com
Subject: Re: [topbraid-users] SHACL inferred data question

 

*** External email: use caution ***

--
You received this message because you are subscribed to a topic in the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/topbraid-users/b4pARn09t3s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/38344e6d-c2b1-bf0f-e5df-3f77435cdedc%40topquadrant.com.

Holger Knublauch

unread,
Jan 26, 2022, 8:09:35 PM1/26/22
to topbrai...@googlegroups.com

You're mixing two node expressions into the same top level sh:values blank node. Either use sh:filterShape or sh:path but not both. I don't know what the chaining is supposed to look like, but if you want the values of the upper path to go through the filter shape, try

sh:values [
    sh:filterShape [ ... ] ;
    sh:nodes [
        sh:path [ sh:inversePath [ ... ] ]
    ]
]

See https://w3c.github.io/shacl/shacl-af/#node-expressions-filter-shape for the spec - sh:filterShape can only have exactly one sh:nodes as input.

The outer sh:class is unrelated to the sh:values rule and is only used for validation purposes, not inferencing.

Holger


cbur...@healthwise.org

unread,
Jan 27, 2022, 6:22:21 PM1/27/22
to TopBraid Suite Users
So, is there a way to combine both of the things we've discussed in this thread into one sh:values expression?
1. a nested path expression that reuses the inferred sh:values from another property shape (you had me represent this with nested sh:path expressions, which worked)
2. a sh:filterShape with a single sh:nodes expression

That is, is the real-world example in my last message expressible as a sh:values statement, or do I need to resort to SPARQL?

Holger Knublauch

unread,
Jan 27, 2022, 7:26:44 PM1/27/22
to topbrai...@googlegroups.com


On 2022-01-28 9:22 am, cbur...@healthwise.org wrote:
So, is there a way to combine both of the things we've discussed in this thread into one sh:values expression?
1. a nested path expression that reuses the inferred sh:values from another property shape (you had me represent this with nested sh:path expressions, which worked)
2. a sh:filterShape with a single sh:nodes expression

That is, is the real-world example in my last message expressible as a sh:values statement, or do I need to resort to SPARQL?

I honestly don't understand what exactly you are trying to model, but in principle yes, sh:values expressions can be nested to arbitrary depth, and include filterShapes along the way. I just don't see which path values you are trying to infer from your turtle code below. Maybe try to express this with an example instance tree first?

Holger


cbur...@healthwise.org

unread,
Feb 3, 2022, 2:12:23 PM2/3/22
to TopBraid Suite Users
Essentially, I am trying to take this property shape (where ex:inferredValueProp1 is a separately defined property shape with inferred values):

ex:Concept-inferredValueProp2
  a sh:PropertyShape ;
  sh:path ex:inferredValueProp2 ; 
  sh:values [
      sh:path [
          sh:inversePath [
              sh:alternativePath (
                  ex:p1
                  ex:p2
                ) ;
            ] ;
        ] ;
      sh:nodes [
          sh:path ex:inferredValueProp1 ;
        ] ;
    ] ;

and add in this filter shape: 

[
      sh:nodes [ sh:path ex:inferredValueProp2 ] ;
      sh:filterShape [
          sh:property [
              sh:path ex:filteredProperty ;
              sh:hasValue ex:Value ;
            ] ;
        ] ;
]
 
Where can I place the filter shape?
Reply all
Reply to author
Forward
0 new messages