GH-829: Stratification and evaluation for run-once rules#865
GH-829: Stratification and evaluation for run-once rules#865
Conversation
|
This is the correct URI for the githack render: |
6772250 to
0a288c0
Compare
simonstey
left a comment
There was a problem hiding this comment.
how would following corner cases be classified?
- A rule with an assignment element AND a negation element ->
.onceor.general? - A rule with blank nodes in the head AND a recursive positive dependency ->
.onceor.general? If.once, the recursion is lost; if.general, blank nodes generate infinitely. - A rule with no assignment elements and no blank nodes in head -> presumably
.general, but not stated. - A rule with
BNODE()in an assignment expression but not in the head ->.onceor.general?
| A [=stratification layer=], also called a "stratum", | ||
| is a pair of sets of rules. | ||
| The pair consists of a set of rules that are executed once, for assignment | ||
| and blank nodes created in a [=rule head=], and a set of rules | ||
| that are evaluated, possibly involving recursion, until there are | ||
| no more inferred triples. | ||
| A stratum pair <var>P</var> has components <var>P.once</var> | ||
| and <var>P.general</var>. | ||
| <div class="ednote">create a notation section?</div> | ||
| </dd> | ||
| <dt><dfn>Stratification</dfn></dt> | ||
| <dd> | ||
| A [=stratification=] of a [=rule set=] is a sequence of [=stratification layers=]. | ||
| Each rule in a [=rule set=] appears in exactly one of the sets of one of | ||
| the [=stratification layers=]. |
There was a problem hiding this comment.
this def says a "stratum" it is "a pair of sets of rules": one for rules "executed once" (for assignments and blank nodes in head) and one for general rules. However, there is no normative definition anywhere in the spec that specifies how a rule is classified into .once or .general.
it's somewhat hinted at via: "for assignment and blank nodes created in a [=rule head=]" but I think we should add a precise normative statement such as:
A rule belongs to `P.once` if it contains an [=assignment element=] in its body or a blank node in its [=rule head=]; otherwise it belongs to `P.general`.
There was a problem hiding this comment.
See comment on updating the stratification algorithm.
| to ensure that [=negation elements=], [=assignment elements=], and | ||
| blank nodes created in a [=rule head=] depend only on results computed | ||
| using earlier (lower) [=strata=] and the [=base graph=]. | ||
| This guarantees a single, well-defined, and finite |
There was a problem hiding this comment.
now that this paragraph got expanded, shouldn't the strat condition section be expanded accordingly as well?
<section id="stratification-condition">
<h4>Stratification Condition</h4>
<p>
[=Stratification=] is only defined when the following condition is
satisfied. If a [=rule set=] does not meet this condition, then this
specification does not define the outcome of [=rule set=] evaluation.
</p>
<dl>
<dt><dfn>Stratification Condition</dfn></dt>
<dd>
The [=stratification condition=] requires that
there is no [=recursive dependency=] involving a
<em>negative</em> dependency
in the [=dependency graph=] for a [=rule set=].
</dd>
</dl>
<p>
In other words, there is no `NOT` used in any rule that
transitively depends on itself.
</p>
</section>
this still only forbids negative cycles, but says nothing about assignment elements or blank-node-generating rules. There is no condition that requires a rule with assignments or blank nodes in its head to be in a lower stratum than rules it depends on (or that such rules cannot be depending on itsedlf).
bug or feature?
There was a problem hiding this comment.
now that this paragraph got expanded, shouldn't the strat condition section be expanded accordingly as well?
Yes.
| let S = {R} ∪︀ stratumLevel.get(stratumNum) | ||
| stratumLevel.set(stratumNum, S) | ||
| endfor | ||
|
|
There was a problem hiding this comment.
maybe add:
## Partition each level into once and general
for i = 0 to maxStratum:
let rules = stratumLevels.get(i)
let once = { R in rules | R is a run-once rule }
let general = rules \ once
stratumLevels.set(i, pair(once, general))
endfor
"once" - that takes precedence.
Reject.
Will update the stratification algorithm
Once. |
recalcitrantsupplant
left a comment
There was a problem hiding this comment.
one suggested wording for updating the stratification algorithm
| </dd> | ||
| </dl> |
There was a problem hiding this comment.
| </dd> | |
| <dd> | |
| In addition, every rule in `P.once` depends only on rules in lower | |
| [=stratification layers=]. | |
| </dd> | |
| </dl> |
Co-authored-by: simon <simon.steyskal@siemens.com>
Closes #829