Extending SHACL

While browsing the web, I found this interesting web page titled DASH Constraint Components. It defines some new constraint components for SHACL. As my research at the moment revolves a lot around the expressiveness of SHACL, this really interests me.

The first thing I tried to do was to express these extensions with existing core SHACL. However, I quickly noticed a small extension is required to make it all work out: sh:equals needs to support full path expressions. I've seen this being mentioned in the SHACL Discord server. Let's go over the extensions proposed by dash and try to express them:

So, to recap, the dash constraints that are expressible in the current SHACL are: dash:rootClass, dash:stem, dash:singleLine, dash:coExistsWith, dash:subSetOf, dash:closedByType, dash:hasValueIn, dash:hasValueWithClass and dash:uniqueValueForClass. The constraints that are not expressible in the current SHACL but are expressible when we allow for equality between paths are dash:nonRecursive and dash:symmetric. The only constraint that is not expressible is dash:uriStart.

It is obvious that some of these translations are not practical as they require a lot of duplication. However, features are added to a language because there is some need for it. It could be an abbreviation of a common pattern (and adding explicit keywords can help optimizing these shapes), or it could be something that seems not to be expressible but nevertheless desired by practitioners. I'm interested in solving the question whether these newly proposed features are already expressible. If they are, then it is useful to know, for example, to people who write SHACL validators as they can make use of existing code to implement new features. If the proposed features are not already expressible, it is also interesting to know that its addition really adds expressive power. In our own work for example, we found out that sh:equals and sh:disjoint really add expressive power to SHACL.

In my view, this hints at the extension of SHACL with equality (and disjointness) constraints that support full paths. This is a natural extension and will give more expressive power as is desired by dash.

Another idea is to have some kind of macro system for SHACL. This way, we can add constraints like the ones expressible in the current SHACL and proposed by dash. SHACL can be complex to write and users may want to write macros for constraints they find interesting.

Hopefully, this was an interesting read. As I'm only human, there may be some mistakes in my interpretation of the dash constraints. Any feedback is welcome.