-
Notifications
You must be signed in to change notification settings - Fork 42
Rewrite the SHACL Rules introduction, incorporating all the topics we have discussed so far and that we want the spec to cover #722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh-pages
Are you sure you want to change the base?
Conversation
liviorobaldo
commented
Jan 14, 2026
- See this document rendered online here
|
My first PR Some comments:
|
The well-formedness conditions are not about loops. They are "set variable before use" where use is needing the variable setting - a filter or a head - or for stopping re-assignment. Infinite loops: There is an open issue here related to term introduction where stratification may be part of the solution. |
|
Hi Andy, okay. My understanding is that this should still be implemented as part of the Rule Set Evaluation (§5). Perhaps the abstract should not go into these details, but I think it is important to at least state that correct implementations of SHACL Rules prevent infinite loops and non-deterministic behaviour. By the way, I have just noticed that what I called the "initial knowledge graph" in the current version of the abstract is referred to as the "base graph" in §5. I am going to update index.html in this branch to keep the terminology consistent with §5. |
Introduction - the abstract is a more general and shorter section in the standard W3C spec template. I think the introduction is a scene-setting general outline. It is for the first-time reader. It does not have to have every detail. The rest of section 2, the description/tutorial, can cover items at a deeper level. Mentioning deep details in the introduction does not do the details justice nor is the first-time reader yet in a position to pick up on these details. |
| These rules extend SHACL's capabilities by enabling reasoning and data enrichment. The document complements other SHACL 1.2 specifications, | ||
| such as SHACL Core, by defining the syntax and semantics of rule-based inference. The SHACL Rules specification provides a standardized way | ||
| to express and evaluate rules that generate new data.</p> | ||
| <p>SHACL Rules only <i>add</i> content to the knowledge graph to which they are applied, referred to as the 'base graph', producing a new graph |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rules produce an inference graph - they don't add to the input graph. You say this later but this text contradicts that.
A user may choose to add the inferences but that is not a requirement of SHACL Rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is important to make clear that the inferred graph includes all triples from the base graph, i.e., that these triples are preserved and not removed (see issue #728).
Other readers might wonder whether SHACL Rules only add triples to the base graph or whether they can also remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can not remove them.
| called the 'inferred graph'. In particular, rules may add new RDF triples but they may also <i>create</i> and add new RDF resources and literals | ||
| that were not present in the base graph. While most rule operators are monotonic, the grammar also includes two non-monotonic operators: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think an introduction needs to say "monotonic" which has a very precise meaning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should instead mention monotonic vs non-monotonic operators in the Introduction. The intended audience for SHACL Rules consists of people with a basic background in logic, for whom the term "monotone" is already part of the standard vocabulary. In other words, this term is not "too technical" for them.
Readers approaching this document will naturally start wondering how SHACL Rules differ from OWL, SWRL, N3, RuleML, and similar formalisms. In light of this, in my view readers should be informed from the outset that SHACL Rules allow for NAF, aggregates, and the creation of new RDF resources and literals, while controlling their effects, e.g., through stratification.
| <i>negation as failure</i> and <i>aggregates</i> (e.g., `SUM`, `COUNT`). Negation as failure allows testing whether certain triples are absent | ||
| from the base graph, whereas aggregates generate new literals that can be subsequently added to the inferred graph.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
People are reading the working draft. This is good!
There is still significant work time needed just to get the specification to one that covers negation, which IMO is more important.
While it is unfortunate not to go further, a worse outcome is to rush and put something in which turns out to be wrong or not the bast design. There is opportunity to add features later; removing features is very painful for the spec and for users.
So I'm uncomfortable with putting anything about aggregation in the introduction at this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I agree that NAF is more important than aggregates (in the sense that there are many more use cases requiring NAF than those requiring aggregates) I still think that both are necessary.
I was planning to open a new PR on aggregates, including them in the grammar and describing them in the relevant section (they are currently mentioned in §3). Let’s discuss negation and aggregates further in the forthcoming TF meetings.
| that were not present in the base graph. While most rule operators are monotonic, the grammar also includes two non-monotonic operators: | ||
| <i>negation as failure</i> and <i>aggregates</i> (e.g., `SUM`, `COUNT`). Negation as failure allows testing whether certain triples are absent | ||
| from the base graph, whereas aggregates generate new literals that can be subsequently added to the inferred graph.</p> | ||
| <p>Well-formedness conditions in SHACL Rules prevent infinite loops that could arise from the creation of new RDF resources and literals, while |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This first part of this paragraph is getting into more detail than an introduction needs to.
To me, an introduction sets the scene - the common use. Error conditions etc are details for later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. Instead of explicitly mentioning well-formedness conditions, stratification, and similar technical details, we could just state more generally that: "implementations are expected to prevent infinite loops arising from the creation of new RDF resources and literals, as well as non-deterministic behaviour introduced by non-monotonic operators (see §3)."
However, as I mentioned above, I believe it is important to make clear from the outset that non-monotonic operators are part of the design and that their potential "collateral effects" have been considered.
shacl12-rules/index.html
Outdated
| from the base graph, whereas aggregates generate new literals that can be subsequently added to the inferred graph.</p> | ||
| <p>Well-formedness conditions in SHACL Rules prevent infinite loops that could arise from the creation of new RDF resources and literals, while | ||
| non-deterministic behavior introduced by non-monotonic operators is avoided through the well-known technique of <i>stratification</i>, which must | ||
| be applied within implementations. Implementations of the rules must also support two operations: <i>infer()</i>, which applies rules using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| be applied within implementations. Implementations of the rules must also support two operations: <i>infer()</i>, which applies rules using | |
| be applied within implementations. | |
| </p> | |
| <p>Implementations of the rules provide two possible operations: <i>infer()</i>, which applies rules using |
The "Implementations .. provide" text is important for an introduction - move it up.
Avoid, where possible, may/should/must language because, even if written as plain text, they suggest RFC 2119 meaning. Sometimes it is natural to use the words (lowercase) but if possible, reword.
shacl12-rules/index.html
Outdated
| non-deterministic behavior introduced by non-monotonic operators is avoided through the well-known technique of <i>stratification</i>, which must | ||
| be applied within implementations. Implementations of the rules must also support two operations: <i>infer()</i>, which applies rules using | ||
| forward chaining, so that for all rules whose bodies match the base graph, the content in their heads is added to the inferred graph, | ||
| and <i>query()</i>, which applies rules using backward chaining, determining whether a given goal pattern can be inferred from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the introduction needs to mention "backward-chaining"/"forward-chaining". They are implementation strategies.
Text later can get into the details and say either can be used - and the spec defines outcomes using one possible forward-chaining approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Unless anyone else disagrees (let’s wait a couple of days for comments), I’ll update the text accordingly.
|
Yes, sorry, here we are dealing with the "introduction", not the "abstract". Every time I wrote "abstract" above I meant "introduction". Totally agree about "I think the introduction is a scene-setting general outline. It is for the first-time reader". I will have a look at all your revisions asap. |
Co-authored-by: Andy Seaborne <andy@apache.org>
Co-authored-by: Andy Seaborne <andy@apache.org>
Co-authored-by: Andy Seaborne <andy@apache.org>