Skip to content

Consider bnode graph names in evaluation of Graph #221

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 41 additions & 22 deletions spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
div.defn p { margin-top: 1ex ; margin-bottom: 1.5ex ;}
div.defn ul { margin-top: 1ex ; margin-bottom: 1.5ex ; }
span.definedTerm {font-weight: bold;}
div.indentedFormula { margin-left: 5ex ; margin-top: 2mm ; margin-bottom: 2mm ; }

div.grammarExtract
{ border: thin solid #888888;
Expand Down Expand Up @@ -9448,8 +9449,6 @@ <h3>Basic Graph Patterns</h3>
<p>Write <var>Ω<sub>0</sub></var> for the multiset consisting of exactly the empty mapping
<var>μ<sub>0</sub></var>, with multiplicity 1. This is the join identity.</p>
<p>Write <var>μ</var>(<var>x</var>) for the solution mapping variable <var>x</var> to RDF term <var>t</var> : { (<var>x</var>, <var>t</var>) }.</p>
<p>Write <var>Ω</var>(<var>x</var>) for the multiset consisting of exactly <var>μ</var>(<var>?x</var>-&gt;<var>t</var>), that is, <code>{ { (x, t) } }</code>
with multiplicity 1.</p>
<div class="defn">
<p><b>Definition: <span id="defn_algCompatibleMapping">Compatible Mappings</span></b></p>
<p>Two solution mappings μ<sub>1</sub> and μ<sub>2</sub> are compatible if, for every
Expand Down Expand Up @@ -10288,9 +10287,8 @@ <h5>Sample</h5>
<h3>Evaluation Semantics</h3>
<p id="defn_eval">We define <a href="#defn_eval" class="evalFct">eval</a>(|D|(|G|), |A|) as the evaluation of an algebra expression |A| with
respect to a <a href="#sparqlDataset">dataset</a> |D| having <a href="#defn_ActiveGraph">active graph</a> |G|. The active graph is initially the default
graph of |D|. Further symbols and notation used in the following definitions are:</p>
graph of |D|. Further symbols used in the following definitions are:</p>
<ul>
<li>|D|[|i|] : Denotes the graph with IRI |i| in dataset |D|</li>
<li>|P|, <var>P<sub>1</sub></var>, <var>P<sub>2</sub></var> : graph patterns</li>
<li>|L| : a solution sequence</li>
<li>|F| : an expression</li>
Expand Down Expand Up @@ -10344,25 +10342,46 @@ <h3>Evaluation Semantics</h3>
</div>
<div class="defn">
<p><b>Definition: <span id="defn_evalGraph">Evaluation of Graph</span></b></p>
<pre class="code nohighlight">
if <var>IRI</var> is a graph name in <var>D</var>
<a href="#defn_eval" class="evalFct">eval</a>( <var>D</var>(<var>G</var>), Graph(<var>IRI</var>,<var>P</var>) ) = <a href="#defn_eval" class="evalFct">eval</a>( <var>D</var>(<var>D</var>[<var>IRI</var>]), <var>P</var> )
</pre>
<pre class="code nohighlight">
if <var>IRI</var> is not a graph name in <var>D</var>
<a href="#defn_eval" class="evalFct">eval</a>( <var>D</var>(<var>G</var>), Graph(<var>IRI</var>,<var>P</var>) ) = the empty multiset
</pre>
<pre class="code nohighlight">
<a href="#defn_eval" class="evalFct">eval</a>( <var>D</var>(<var>G</var>), Graph(<var>var</var>,<var>P</var>) ) =
Let <var>R</var> be the empty multiset
foreach IRI <var>i</var> in <var>D</var>
<var>R</var> := <a href="#defn_algUnion" class="algFct">Union</a>(<var>R</var>, <a href="#defn_algJoin" class="algFct">Join</a>( <a href="#defn_eval" class="evalFct">eval</a>(<var>D</var>(<var>D</var>[<var>i</var>]), <var>P</var>) , Ω(<var>var</var>-&gt;<var>i</var>) ) )
the result is <var>R</var>
</pre>
<p>For every |x| that is
an <a data-cite="RDF12-CONCEPTS#dfn-IRI">IRI</a> or
Copy link
Contributor

@afs afs May 18, 2025

Choose a reason for hiding this comment

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

Suggested change
an <a data-cite="RDF12-CONCEPTS#dfn-IRI">IRI</a> or
an <a data-cite="RDF12-CONCEPTS#dfn-IRI">IRI</a>,
a <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a> or

Should the definition of the evaluation of "graph" mention blank nodes?

It isn't necessary because they come in via variables but:

  1. It more clearly indicates that literal and triple terms can not be used
  2. The intuition of variable substitution applies

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@afs your edit suggestion is incorrect. The x in Graph(x, P) may indeed be only an IRI or a variable; not a blank node. While the algebraic syntax is not explicitly defined in the spec, it is clear from the grammar of the user-facing syntax that there can be no blank node---see the GraphGraphPatternproduction:

[62] GraphGraphPattern ::= 'GRAPH' VarOrIri GroupGraphPattern

Should the definition of the evaluation of "graph" mention blank nodes?

It isn't necessary because they come in via variables but:

  1. It more clearly indicates that literal and triple terms can not be used

Cannot be used for what exactly?

If you mean that they cannot be used as the x in the new version of this definition, I think stating that x may be an IRI or a variable (as done in this PR) is sufficient.

If you mean that they cannot be used as bindings for the variable x (in case x is a variable), I don't think that saying something like this belongs in this definition; maybe better suited for the informal text in Section 13.3 Querying the Dataset. Also, it is not entirely correct to say that literals and term maps cannot be assigned to variable x in incoming solution mappings; such solution mappings would just not survive the Join within the foreach loop. Perhaps one thing to make this more obvious would be to extend the foreach-line of the algorithm from (current form)

foreach graph name gn in D

to

foreach graph name gn in D (recall that a graph name may be an IRI or a blank node)

Would that address your concern?

  1. The intuition of variable substitution applies

I am not sure what you mean by this comment.

Copy link
Contributor

@afs afs May 20, 2025

Choose a reason for hiding this comment

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

  1. It more clearly indicates that literal and triple terms can not be used

Cannot be used for what exactly?

As graph names.

It does not cause any harm to be a little bit more general here.
The 1.1 text says "foreach IRI i in D"; the new text puts in a link so the cue isn't there.

"foreach graph name gn in D"

  1. The intuition of variable substitution applies

I am not sure what you mean by this comment.

In TriG, GRAPH _:label { ... } is legal so one can think of the query as a trig pattern, like BGPs are turtle patterns.

The variable may, visually, be defined in the query close-by.

(Yes, this actually happens when the "graph" evaluation is joined with the rest of the group graph pattern.)

a <a href="#defn_QueryVariable">variable</a>,
<a href="#defn_eval" class="evalFct">eval</a>( |D|(|G|), Graph(|x|, |P|) )
is defined as follows:</p>
<ul>
<li>If |x| is an IRI
that is a <a data-cite="RDF12-CONCEPTS#dfn-graph-name">graph name</a> in |D|,
<div class="indentedFormula">
<a href="#defn_eval" class="evalFct">eval</a>( |D|(|G|), Graph(|x|, |P|) )
=
<a href="#defn_eval" class="evalFct">eval</a>( |D|(<var>G<sub>|x|</sub></var>), |P| ),
</div>
where <var>G<sub>|x|</sub></var> is the RDF graph of the named graph with name |x| in |D|.
</li>
<li>If |x| is an IRI
that is not a <a data-cite="RDF12-CONCEPTS#dfn-graph-name">graph name</a> in |D|,
<div class="indentedFormula">
<a href="#defn_eval" class="evalFct">eval</a>( |D|(|G|), Graph(|x|, |P|) )
is the empty multiset.
</div>
</li>
<li>If |x| is a variable,
<div class="indentedFormula">
<a href="#defn_eval" class="evalFct">eval</a>( |D|(|G|), Graph(|x|, |P|) )
=
<var>Ω</var>,
</div>
where <var>Ω</var> is the multiset of solution mappings produced by the following algorithm:
<pre class="code nohighlight" style="font-family: sans-serif;">
<var>Ω</var> := the empty multiset
foreach <a data-cite="RDF12-CONCEPTS#dfn-graph-name">graph name</a> <var>gn</var> in <var>D</var>
<var>G'</var> := the RDF graph of the named graph with name <var>gn</var> in <var>D</var>
<var>Ω'</var> := <a href="#defn_eval" class="evalFct">eval</a>( <var>D</var>(<var>G'</var>), <var>P</var> )
<var>Ω</var> := <a href="#defn_algUnion" class="algFct">Union</a>( <var>Ω</var>, <a href="#defn_algJoin" class="algFct">Join</a>(<var>Ω'</var>, <var>μ</var>) ), where <var>μ</var> = {<var>x</var> → <var>gn</var>}
the result is <var>Ω</var>
</pre>
</li>
</ul>
</div>
<p>The evaluation of graph uses the <a href="#defn_algUnion" class="algFct">Union</a> operator. The multiplicity of a
solution mapping is the sum of the multiplicities of that solution mapping in each <a href="#defn_algJoin" class="algFct">Join</a>
operation.</p>
<div class="defn">
<div id="defn_evalGroup">
<b>Definition: Evaluation of Group</b>
Expand Down
Loading