@@ -152,7 +152,7 @@ <h3>Terminology</h3>
152152 < p class ="ednote "> Connect to definitions in RDF 1.2 Concepts.</ p >
153153
154154 < p >
155- The following definitions from other specications are used in this document: @@
155+ The following definitions from other specifications are used in this document: @@
156156 </ p >
157157 </ section >
158158
@@ -190,7 +190,7 @@ <h3>Document Conventions</h3>
190190 </ tr >
191191 < tr >
192192 < td > < code > ex:</ code > </ td >
193- < td > < code > http://example.com/ns# </ code > </ td >
193+ < td > < code > http://example.com/</ code > </ td >
194194 </ tr >
195195 </ table >
196196 < p >
@@ -269,7 +269,7 @@ <h3>Basic Usage</h3>
269269RULE { ?x :descendedFrom ?y } WHERE { ?x :childOf ?z . ?z :childOf ?y }
270270</ pre >
271271 </ div >
272- < p > The above rules, applied ot the data, will conclude
272+ < p > The above rules, applied to the data, will conclude
273273 that: `:X` is the `:childOf` `:A` and `:B`, and that `:X` is `:descendedFrom` `:C`.
274274 </ p >
275275 </ section >
@@ -320,7 +320,7 @@ <h2>Shape Rules Abstract Syntax</h2>
320320 < a > Expressions</ a > are compatible with
321321 < a data-cite ="shacl12-node-expr#dfn-list-parameter-function "
322322 > SHACL list parameter functions</ a >
323- and with < a data-cite ="sparql12-query#expressions "> SPARQL expressions</ a > .
323+ and with < a data-cite ="sparql12-query#expressions "> SPARQL expressions</ a > .</ p >
324324 </ dd >
325325
326326 < dt > < dfn data-lt ="data-block "> data block</ dfn > </ dt >
@@ -332,15 +332,17 @@ <h2>Shape Rules Abstract Syntax</h2>
332332 < dt > < dfn > triple template</ dfn > </ dt >
333333 < dd >
334334 A [=triple template=] is 3-tuple where each element is either
335- a variable or an RDF term (which might be a triple term).
335+ a [=variable=] or an [=RDF term] (which might be a [=triple term=]).
336+ The second element of the tuple must be an [=IRI=] or a [=variable=].
336337 [=Triple templates=] appear in the [=head=] of a [=rule=].
337338 </ dd >
338339
339340 < dt > < dfn > triple pattern</ dfn > </ dt >
340341 < dd >
341342 A [=triple pattern=] is 3-tuple where each element is either a
342- variable, or an RDF term (which might be a triple term).
343- [=Triple patterns=] appear in the [=body=] of a [=rule=].
343+ [=variable=], or an [=RDF term=] (which might be a triple term).
344+ The second element of the tuple must be an [=IRI=].
345+ [=Triple patterns=] appear in the [=body=] of a [=rule=].
344346 </ dd >
345347
346348 < dt > < dfn > condition expression</ dfn > </ dt >
@@ -372,7 +374,7 @@ <h2>Shape Rules Abstract Syntax</h2>
372374
373375 < dt > < dfn data-lt ="rule body element|rule element|element "> rule body element</ dfn > </ dt >
374376 < dd >
375- A [=rule body element=] (often just "rule element") is one of elements that
377+ A [=rule body element=] (often just "rule element") is any element that
376378 can appear in a [=rule body=];
377379 a [=triple pattern=],
378380 a [=condition expression=],
@@ -391,7 +393,7 @@ <h2>Shape Rules Abstract Syntax</h2>
391393 < dfn data-lt ="rule body|body "> rule body</ dfn >
392394 </ dt >
393395 < dd >
394- A [=rule body=] is a sequence of [=rule body elements=].</ dfn >
396+ A [=rule body=] is a sequence of [=rule body elements=].
395397 </ dd >
396398
397399 < dt > < dfn > rule</ dfn > </ dt >
@@ -426,7 +428,7 @@ <h3>Stratification</h3>
426428 < dt > < dfn data-lt ="stratification layer|layer "> stratification layer</ dfn > </ dt >
427429 < dd >
428430 A stratification layer, usually, just "layer", is the set of rules
429- with same straification labelling.
431+ with same stratification labelling.
430432 < a > stratification layer</ a > , < a > layer</ a >
431433 </ dd >
432434
@@ -520,7 +522,7 @@ <h3>Well-formedness Conditions</h3>
520522
521523 < section id ="concrete-syntax ">
522524 < h2 > Concrete Syntax forms for Shapes Rules</ h2 >
523- < P > There are two concrete syntaxes.</ p >
525+ < p > There are two concrete syntaxes.</ p >
524526 < ul >
525527 < li > < a href ="#shape-rules-syntax "> Shape Rules Language syntax</ a > </ li >
526528 < li > < a href ="#rdf-rules-syntax "> RDF Rules syntax</ a > </ li >
@@ -566,7 +568,7 @@ <h2>Concrete Syntax forms for Shapes Rules</h2>
566568 rdf:type shrl:Rule;
567569 shrl:head (
568570 [ shrl:subject [ shrl:var "x" ] ; shrl:predicate :bothPositive; shrl:object true ]
569- )
571+ ) ;
570572 shrl:body (
571573 [ shrl:subject [ shrl:var "x" ]; shrl:predicate :p; shrl:object [ shrl:var "v1" ] ]
572574 [ shrl:expr [ sparql:greaterThan ( [ shrl:var "v1" ] 0 ) ] ]
@@ -578,7 +580,7 @@ <h2>Concrete Syntax forms for Shapes Rules</h2>
578580 rdf:type shrl:Rule;
579581 shrl:head (
580582 [ shrl:subject [ shrl:var "x" ] ; shrl:predicate :oneIsZero ; shrl:object true ]
581- )
583+ ) ;
582584 shrl:body (
583585 [ shrl:subject [ shrl:var "x" ] ; shrl:predicate :p ; shrl:object [ shrl:var "v1" ] ]
584586 [ shrl:subject [ shrl:var "x" ] ; shrl:predicate :q ; shrl:object [ shrl:var "v2" ] ]
@@ -603,7 +605,7 @@ <h4>Shape Rules Language Abbreviations</h4>
603605 < p > Additional helpers (short-hand abbreviations):</ p >
604606
605607 < p class =note >
606- These allow for well-known rul epatterns and also specialised implementations in basic engines
608+ These allow for well-known rule patterns and also specialised implementations in basic engines
607609 </ p >
608610
609611 < ul >
@@ -690,7 +692,7 @@ <h4>Evaluation Definitions</h4>
690692 < dt > < dfn data-lt ="solution|sparql12-query#defn_sparqlSolutionMapping "> solution mapping</ dfn > </ dt >
691693 < dd >
692694 A < a data-lt ="sparql12-query#defn_sparqlSolutionMapping "> solution mapping</ a > ,
693- < var > μ</ var > , is a partial function < code > < var > μ</ var > : V → T </ code > ,
695+ < var > μ</ var > , is a partial function < code > < var > μ</ var > : < var > V </ var > → < var > T </ var > </ code > ,
694696 where < var > V</ var > is the set of all variables and < var > T</ var > is the set of all RDF terms.
695697 The domain of < var > μ</ var > is denoted by < code > < var > dom</ var > (< var > μ</ var > )</ code > ,
696698 and it is the subset of < var > V</ var > for which < var > μ</ var > is defined.
@@ -767,13 +769,18 @@ <h4>Evaluation Definitions</h4>
767769 that maps variables of each solution to the [=RDF term=]
768770 from one or other of the solutions.
769771 < div class ="def ">
770- Let S1 and S2 be solution sequences.
772+ Let < var > μ</ var > < sub > 1</ sub > , < var > μ</ var > < sub > 2</ sub >
773+ be solution mappings, and S1 and S2 be solution sequences.
771774 < pre >
775+ merge(< var > μ</ var > < sub > 1</ sub > , < var > μ</ var > < sub > 2</ sub > ) = { < var > μ</ var > |
776+ μ(v) = μ1(v) if v in dom(μ1)
777+ μ(v) = μ2(v) otherwise }</ pre >
778+
779+ < pre >
772780merge(S1, S2) = { < var > μ</ var > |
773781 < var > μ</ var > < sub > 1</ sub > in S1, < var > μ</ var > < sub > 2</ sub > in S2
774782 and compatible(< var > μ</ var > < sub > 1</ sub > , < var > μ</ var > < sub > 2</ sub > )
775- μ(v) = μ1(v) if v in dom(μ1)
776- μ(v) = μ2(v) if v in dom(μ2) }</ pre >
783+ μ(v) = merge(< var > μ</ var > < sub > 1</ sub > , < var > μ</ var > < sub > 2</ sub > )</ pre >
777784 </ div >
778785 < div class ="ednote ">
779786 < p >
@@ -842,14 +849,13 @@ <h4>Evaluation of a Rule</h4>
842849variable that does not occur in the rule body.
843850
844851# Evaluate rule body
845- for each rule element rElt in B
846- let S1 = { }
847852
853+ for each rule element rElt in B
848854 if rElt is a triple pattern TP:
849855 X = graphMatch(G, TP)
850- SEQ1 = { < var > μ </ var > < sub > 0 </ sub > }
856+ SEQ1 = {}
851857 for each < var > μ</ var > < sub > 1</ sub > in X:
852- for each < var > μ</ var > < sub > 2</ sub > in T :
858+ for each < var > μ</ var > < sub > 2</ sub > in SEQ :
853859 if compatible(< var > μ</ var > < sub > 1</ sub > , < var > μ</ var > < sub > 2</ sub > )
854860 < var > μ</ var > < sub > 3</ sub > = merge(< var > μ</ var > 1, < var > μ</ var > < sub > 2</ sub > )
855861 add < var > μ</ var > < sub > 3</ sub > to SEQ1
@@ -870,7 +876,7 @@ <h4>Evaluation of a Rule</h4>
870876 if rElt is an assignment(V, expr)
871877 SEQ1 = {}
872878 for each solution S in SEQ:
873- let x = eval(expr, < var > μ </ var > )
879+ let x = eval(expr, S )
874880 add(V, x) to S
875881 add S to SEQ1
876882 endfor
@@ -887,18 +893,18 @@ <h4>Evaluation of a Rule</h4>
887893
888894# Evaluate rule head
889895let H = empty set
890- for each < var > μ</ var > in T :
891- Let S = {}
896+ for each < var > μ</ var > in SEQ :
897+ let S = {}
892898 for each triple template TT in head
893- Let triple = subst(< var > μ</ var > , TT)
899+ let triple = subst(< var > μ</ var > , TT)
894900 Add triple to S
895901 H = H union S
896902 endfor
897903
898904result eval(R, G) is H
899905
900906</ pre >
901- < p > Note that `H` may contain triples that are also in the data grapoh .</ p >
907+ < p > Note that `H` may contain triples that are also in the data graph .</ p >
902908 </ section >
903909
904910 < section id ="eval-rule-set ">
@@ -907,24 +913,23 @@ <h4>Evaluation of a Rule Set</h4>
907913 < p class =ednote > Sketch</ p >
908914
909915< pre class ="algorithm ">
910- Let G0 be the input RDF graph.
911- Let GI be the set of triples generated by evaluation
912- Let RS be a rule set
916+ let G0 be the input RDF graph.
917+ let RS be the rule set
913918Apply stratification to RS
914- Let L be the sequence of layers after stratification
919+ let L be the sequence of layers after stratification
915920
916- for each layer in L
917- Let finished = false
921+ let GI = G0
922+ for each layer in L:
923+ let finished = false
918924 while !finished:
919925 finished = true
920- foreach rule in RS
921- let GI = G0 ∪ GI
926+ for each rule in layer:
922927 let X = eval(rule, GI)
923- let Y = those triples in X that are not in G0
928+ let Y = { t ∈ X | t ∉ in GI }
924929 if Y is not empty:
925930 finished = false
926931 endif
927- let GI = Y &cup ; GI
932+ let GI = Y &cups ; GI
928933 endfor
929934 endwhile
930935 endfor
0 commit comments