Skip to content

Improvements from rules document review#916

Draft
afs wants to merge 1 commit into
gh-pagesfrom
rules-doc-review
Draft

Improvements from rules document review#916
afs wants to merge 1 commit into
gh-pagesfrom
rules-doc-review

Conversation

@afs
Copy link
Copy Markdown
Contributor

@afs afs commented Jun 1, 2026

Improvements from rules document review

@afs afs added Rules For SHACL 1.2 Rules spec. labels Jun 1, 2026
@afs afs force-pushed the rules-doc-review branch 2 times, most recently from 4ab784a to a2fe08a Compare June 1, 2026 15:26
@afs afs force-pushed the rules-doc-review branch 3 times, most recently from 53f629d to fd47acc Compare June 2, 2026 13:25
Copy link
Copy Markdown
Contributor

@simonstey simonstey left a comment

Choose a reason for hiding this comment

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

also, the namespace of shnex should be http://www.w3.org/ns/shacl-node-expr# (at least that's what the nodeexpr test cases also use.

(needs fix to be fixed in rdf-syntax-shapes.ttl )


We use:

  • "SHACL Rules Language (SRL)" (line 182, line 680),
  • "Shape Rules Language (SRL)" (1317, 1322, 1388),
  • "Shapes Rules Language" (1957),
  • ("Shape Rules Abstract Syntax" (675))

what's the canonical final expansion of SRL?

Comment thread shacl12-rules/index.html
## Partition each level into once and general
let stratumLevels be a sequence of pairs of sets of rules.
for i = 0 to maxStratum:
let rules = stratumLevels.get(i)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
let rules = stratumRules.get(i)

shouldn't this be stratumRules?

Comment thread shacl12-rules/index.html
for each <var>μ</var><sub>1</sub> in X:
for each <var>μ</var><sub>2</sub> in SEQ:
if compatible(<var>μ</var><sub>1</sub>, <var>μ</var><sub>2</sub>)
<var>μ</var><sub>3</sub> = merge(<var>μ</var>1, <var>μ</var><sub>2</sub>)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
<var>μ</var><sub>3</sub> = merge(<var>μ</var><sub>1</sub>, <var>μ</var><sub>2</sub>)

broken subscript

Comment thread shacl12-rules/index.html Outdated
and in order befoer moving onm to the next [=stratum=].
A [=stratum=] is evaluated by first evaluating
each of the [=run-once rule=] of that stratum, and then evaluating
[=general rules=] of thestratum repeatedly until no new triples are produced.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we do not have a corresponding definition (i.e. ) for general rules yet

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
[=general rules=] of thestratum repeatedly until no new triples are produced.
[=general rules=] of the stratum repeatedly until no new triples are produced.

also

Comment thread shacl12-rules/index.html
of `R1` depends on `R2`.
The dependency is an [=open dependency=] if `R1` does not have an
[=assignment element=] and if all the [=triple patterns=]
of `R1` that depend `R2` occur only as [=triple pattern elements=]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
of `R1` that depend on `R2` occur only as [=triple pattern elements=]

Comment thread shacl12-rules/index.html
Comment on lines +636 to +637
:father rdfs:subClassOf: :familyRelationship .
:monther rdfs:subClassOf: :familyRelationship .
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
:father rdfs:subClassOf: :familyRelationship .
:monther rdfs:subClassOf: :familyRelationship .
:father rdfs:subClassOf :familyRelationship .
:mother rdfs:subClassOf :familyRelationship .

Comment thread shacl12-rules/index.html Outdated
<p>
Rules involving assignment are [=run-once rules=]. Rules with assignment
are run after all the rules that could produce the data that they depend on
Rules involving [assignments] and rules that create blank nodes in their [=rule head=] are [=run-once rules=].
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Rules involving [assignments] and rules that create blank nodes in their [=rule head=] are [=run-once rules=].
Rules involving [=assignment elements=] and rules that create blank nodes in their [=rule head=] are [=run-once rules=].

Comment thread shacl12-rules/index.html
[=stratification=] of the rule set, where each stratum is executed completely
and in order befoer moving onm to the next [=stratum=].
A [=stratum=] is evaluated by first evaluating
each of the [=run-once rule=] of that stratum, and then evaluating
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
each of the [=run-once rule=] of that stratum, and then evaluating
each of the [=run-once rules=] of that stratum, and then evaluating

Comment thread shacl12-rules/index.html

<p>A conforming
<dfn
data-lt="shapes rules language document|shapes rules document|ruleset document"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
data-lt="shapes rules language document|shapes rules document|ruleset document|shapes rules language documents|shapes rules documents|ruleset documents"

added plural forms

Comment thread shacl12-rules/index.html
Comment on lines 1847 to 1869
if rElt is a negation expression with body elements N:
SEQ1 = {}
for each solution <var>μ</var> in SEQ:
S = sequence{ <var>μ</var> }
NEG = evalRuleElements(N, S, G)
if NEG is empty
add <var>μ</var> to SEQ1
endif
endfor
endif

if rElt is an assignment with variable V and expression expr
SEQ1 = {}
for each solution S in SEQ:
let x = evalFunction(expr, S)
if x is not an error:
add(V, x) to S
add S to SEQ1
else
# Error: drop solution S
endif
endfor
endif
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the latter algo uses a bare S for a single solution, while S is also used as a one-element sequence in the negation branch => we should align those two

Comment thread shacl12-rules/index.html
Comment on lines 1843 to 1895
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

earlier we state:

let rule R = (H, B) where
             H is the sequence of triple templates in the head
             B is the sequence of triple pattern elements,
                condition elements, negation elements,
                and assignment elements in the body

which binds H to the head templates.

But here:

# Evaluate rule head
let H = empty set
for each <var>μ</var> in SEQ:

we then reuse H as the output-triple accumulator.

and here: for each triple template TT in head we refer to "head" (which is in theory not bound anymore)

suggestion:

Suggested change
# Evaluate rule head
let HOut = empty set
for each <var>μ</var> in SEQ:
for each triple template TT in H:
add subst(<var>μ</var>, TT) to HOut
result eval(R, G) is HOut

@afs
Copy link
Copy Markdown
Contributor Author

afs commented Jun 3, 2026

also, the namespace of shnex should be http://www.w3.org/ns/shacl-node-expr# (at least that's what the nodeexpr test cases also use.

Where is it wrong in the spec? I could only find it in the "Document Conventions" and it is shacl-node-expr#.

BTW:

#496 (comment)
says it's http://www.w3.org/ns/shnex#

(needs fix to be fixed in rdf-syntax-shapes.ttl )

Added to the changes.

@afs afs force-pushed the rules-doc-review branch from fd47acc to ad7a842 Compare June 3, 2026 10:42
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.

2 participants