Re: Bnodes in DELETE templates (was: SPARQL Update 1.1 review part1)

Hi Paul,

Thanks, this example illustrates the actual difference between the two options [1,2]
quite nicely, so, let me play them through.

On data G:

:x :p 12 .
:x :r :z .
:x :q 10 .

Your query Q:

DELETE
 { _:a :p 12 .
   _:a :q ?o .
 }
WHERE {?s :r ?q OPTIONAL { ?q :s ?o } }


would in *version 1* of my proposed semantics/rewriting [1] be treated as Q1: 
-------------------------------------
DELETE
 { ?Var_B :p 12 .
   ?Var_B :q ?o .
 }
WHERE { {?s :r ?q OPTIONAL { ?q :s ?o } }
        { Q_Var_B } }

with

Q_Var_B = SELECT DISTINCT ?Var_B
             {  { ?Var_B ?Var_B1 ?Var_B2 } UNION
                { ?Var_B1 ?Var_B ?Var_B2 } UNION
                { ?Var_B1 ?Var_B2 ?Var_B } UNION
                { GRAPH ?Var_Bg {?Var_B ?Var_B1 ?Var_B2 } } UNION
                { GRAPH ?Var_Bg {?Var_B1 ?Var_B ?Var_B2 } } UNION
                { GRAPH ?Var_Bg {?Var_B1 ?Var_B2 ?Var_B } } }
-------------------------------------

whereas in *version 2* of my proposed semantics/rewriting [2] it would be treated as Q2:
-------------------------------------
DELETE
 { ?Var_B :p 12 .
   ?Var_B :q ?o .
 }
WHERE { {?s :r ?q OPTIONAL { ?q :s ?o } }
        { ?Var_B :p 12 . ?Var_B :q ?o . } } 
-------------------------------------

Now, on graph G, Q1 yields:
   
:x :r :z .
:x :q 10 .

whereas Q2 yields:

      :x :r :z .

> Is each part of the template treated as if it is a separate thing to
> be deleted, or does the re-use of the same blank node label (_:a in
> this case) have some kind of effect?

That is another interesting point. Again the two rewritings 
I suggested behave differently in this respect! 
Assume an additional triple t 

    :y :q 8 .

in the graph G and assume the following variant of your query Q':

DELETE
 { _:a :p 12 .
   _:a :q _:b .
 }
WHERE {}

In *version 1* of the rewriting which would yield 

DELETE
 { ?Var_A :p 12 .
   ?Var_A :q ?Var_B .
 }
WHERE { {Q_Var_A} {Q_Var_B} }

the triple t would be deleted, whereas in *version 2*, which would yield

DELETE
 { ?Var_A :p 12 .
   ?Var_A :q ?Var_B .
 }
WHERE { {?Var_A :p 12 . ?Var_A :q ?Var_B . } }

t wouldn't be deleted. 

If we assume those queries corner cases, the choice of version 1 or version 2 seems to be a coinflip decision.

So, we can define a semantics (either way). The more essential question this all boils down 
to is whether the use of bnodes as wildcards is actually understandable/intuitive. Particularly, since it 
seems most (all?) use cases can actually be achieved by some rewriting, if necessary. Opinions?

best,
Axel

1. http://lists.w3.org/Archives/Public/public-rdf-dawg/2011JanMar/0310.html
2. http://lists.w3.org/Archives/Public/public-rdf-dawg/2011JanMar/0307.html

On 22 Feb 2011, at 03:53, Paul Gearon wrote:

> Hi Axel,
> 
> This is along the lines of what I was first thinking of, though I did
> forget about the named GRAPH portions. However, does it address the
> question that Andy raised about re-use of the blank node, particularly
> where an OPTIONAL binding is introduced? I'll reproduce his example
> here:
> 
> DELETE
>  { _:a :p 12 .
>    _:a :q ?o .
>  }
> WHERE {?s :r ?q OPTIONAL { ?q :s ?o } }
> 
> So when that is applied to the following data:
> 
> :x :p 12 .
> :x :r :z .
> :x :q 10 .
> 
> The model you've proposed will certainly match the first triple in the
> template for removal, but the ?o will be unbound, so what happens to
> that part of the template? Does it get ignored, or does it prevent the
> entire template from matching? (The latter is more in line with
> CONSTRUCT and INSERT, but doesn't really work well with the proposed
> formal model).
> 
> Is each part of the template treated as if it is a separate thing to
> be deleted, or does the re-use of the same blank node label (_:a in
> this case) have some kind of effect?
> 
> Regards,
> Paul
> 
> On Mon, Feb 21, 2011 at 3:10 AM, Axel Polleres <axel.polleres@deri.org> wrote:
> > Thanks Greg for spotting this! Actually, there were two mistakes in the P_B
> > pattern below...  see inline.
> >
> >
> > On 20 Feb 2011, at 23:40, Gregory Williams wrote:
> >
> > On Feb 18, 2011, at 1:31 PM, Axel Polleres wrote:
> >
> >> For any unnamed bnode _:B in a modify_template_DEL
> >> (i) new variables ?Var_B ?Var_B1 ?Var_B2 ?Var_Bg are introduced,
> >> (ii) _:B is replaced by ?Var_B in a modify_template_DEL,
> >> (iii) Pattern P is replaced by P_B such that
> >>
> >>  P_B =  { P } UNION {
> >>          SELECT DISTINCT ?Var_B
> >>            {  { ?Var_B ?Var_B1 ?Var_B2 } UNION
> >>               { ?Var_B1 ?Var_B ?Var_B2 } UNION
> >>               { ?Var_B1 ?Var_B2 ?Var_B } UNION
> >>               { GRAPH ?Var_Bg {?Var_B1 ?Var_B2 ?Var_B } } UNION
> >>               { GRAPH ?Var_Bg {?D1 ?Var_B2 ?Var_B } } UNION
> >>               { GRAPH ?Var_Bg {?Var_B1 ?Var_B2 ?Var_B } } }
> >>
> >> That is, ?Var_B binds to all possible values in the vocabulary of GS.
> >
> > I'm not totally swapped in on this issue, but I don't understand how this
> > pattern aligns with the description. In all three named graph union
> > branches, ?Var_B appears in the object position. Since ?Var_B is the only
> > projected variable, don't these three branches return the same results?
> >
> > yes, that was a copy-paste error from an earlier version I had. The correct
> > one should be
> >     P_B =  { { P } { Q } }
> > i.e. join, not UNION (thanks Andy, for pointing me to that offlist), where Q
> > is defined as below...
> >
> >> I know that the definition of P_B doesn't look very nice, but this
> >> definition should cover the intended semantics of [2].
> >> In principle, the idea is that bnodes, that should behave as wildcard
> >> should bind to *any* element in the signature of GS,
> >> which is what is returned by the subquery
> >>        Q = SELECT DISTINCT ?D
> >>            {  { ?D ?D1 ?D2 } UNION
> >>               { ?D1 ?D ?D2 } UNION
> >>               { ?D1 ?D2 ?D } UNION
> >>               { GRAPH ?Dg {?D1 ?D2 ?D } } UNION
> >>               { GRAPH ?Dg {?D1 ?D2 ?D } } UNION
> >>               { GRAPH ?Dg {?D1 ?D2 ?D } } }
> >
> > ...corrected version of Q:
> >
> >         Q = SELECT DISTINCT ?Var_B
> >
> >             {  { ?Var_B ?Var_B1 ?Var_B2 } UNION
> >
> >                { ?Var_B1 ?Var_B ?Var_B2 } UNION
> >
> >                { ?Var_B1 ?Var_B2 ?Var_B } UNION
> >
> >                { GRAPH ?Var_Bg {?Var_B ?Var_B1 ?Var_B2 } } UNION
> >
> >                { GRAPH ?Var_Bg {?Var_B1 ?Var_B ?Var_B2 } } UNION
> >                { GRAPH ?Var_Bg {?Var_B1 ?Var_B2 ?Var_B } } }
> >
> > Even more obvious in this one. Am I missing something?
> >
> >
> > Hope I got it right now ;-)
> >
> > Thanks,
> > Axel
> >
> > thanks,
> > .greg
> >
> >
> >
> >
> >
> 

Received on Tuesday, 22 February 2011 09:07:43 UTC