Skip to content

Conversation

@liviorobaldo
Copy link

@liviorobaldo
Copy link
Author

My first PR ☺️

Some comments:

  • I wrote “for deriving new content” rather than “for deriving new RDF triples” because rules can also add new RDF resources and RDF literals.

  • I removed “beyond validation” because, as discussed in the last PR for SHACL Core, we should avoid over-emphasising validation and instead present it as one task among others. The same applies to the phrase “While SHACL Core focuses on constraint validation”.

  • Regarding “SHACL Rules only add content to the knowledge graph”, rules do not remove content. See the discussion here: allowing rules to remove content, although potentially useful, could introduce several issues, particularly with respect to guaranteeing termination of rule execution. For this reason, I think we should avoid this.

  • For the discussion on infer() and query(), see discussion here.

  • Concerning the statement “Well-formedness conditions in SHACL Rules prevent infinite loops”, see discussion here . However, I am not sure whether stratification also plays a role in preventing infinite loops; if so, we could consider stating this explicitly in the abstract as well.

@afs
Copy link
Contributor

afs commented Jan 14, 2026

“Well-formedness conditions in SHACL Rules prevent infinite loops"

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.
https://raw.githack.com/w3c/data-shapes/SHACL-rules-introduction/shacl12-rules/index.html#wellformed

Infinite loops: There is an open issue here related to term introduction where stratification may be part of the solution.

@liviorobaldo
Copy link
Author

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.

@afs
Copy link
Contributor

afs commented Jan 20, 2026

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.

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
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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.

Comment on lines +146 to +147
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:
Copy link
Contributor

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.

Copy link
Author

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.

Comment on lines +148 to +149
<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>
Copy link
Contributor

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.

Copy link
Author

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
Copy link
Contributor

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.

Copy link
Author

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.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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
Copy link
Contributor

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.

Copy link
Author

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.

@liviorobaldo
Copy link
Author

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.

liviorobaldo and others added 3 commits January 21, 2026 11:25
Co-authored-by: Andy Seaborne <andy@apache.org>
Co-authored-by: Andy Seaborne <andy@apache.org>
Co-authored-by: Andy Seaborne <andy@apache.org>
@afs afs added the Rules For SHACL 1.2 Rules spec. label Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Rules For SHACL 1.2 Rules spec.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants