- From: Axel Polleres <axel.polleres@deri.org>
- Date: Tue, 29 Mar 2011 10:09:02 +0100
- To: Jeen Broekstra <jeen.broekstra@gmail.com>
- Cc: <public-rdf-dawg-comments@w3.org>
Dear Jeen,
thanks for your thorough and helpful feedback.
This addresses your comment on NOT EXISTS vs. MINUS [1] which
you later refined in [2]. Your other comments on aggregates
in [2] will be answered in a separate mail.
Essentially, it seems your concern boils down to the following
paragraph of your mail:
> This leaves us with two scenarios:
>
> 1. the two patterns share a variable, in this case the MINUS can be
> replaced with a NOT EXISTS;
> 2. the two patterns do not share a variable, in this case the MINUS
> can be ignored.
>
> All in all it seems to me that MINUS as currently defined does not add
> additional expressivity to the language and is only a syntactic variant.
Let me first emphasize that the reason we have two negation forms
is because it reflects two ways of thinking about negation. it's not
expressivity in the technical sense, it's more about how people think
about it and this has eventually evolved into two proposals in
the group which have different syntax.
Next, find an example where MINUS and NOT EXISTS are actually
different, despite variables are shared. The differences in this
example are based on NOT EXISTS relying on the variable
substitution that happens during filter function evaluation:
In this example, the ?n variable isn't bound (isn't in scope)
in the MINUS block, and so the FILTER inside the MINUS does
something different than FILTER inside the NOT EXISTS block.
### Data
@prefix : <http://example.com/> .
:a :p 1 ; :q 1,2 .
:b :p 3.0 ; :q 4.0, 5.0 .
### Query 1: NOT EXISTS
PREFIX : <http://example.com/>
SELECT * WHERE {
?a :p ?n
FILTER NOT EXISTS {
?a :q ?m .
FILTER(?n = ?m)
}
}
+------------------------+-----+
| a | n |
+------------------------+-----+
| <http://example.com/b> | 3.0 |
+------------------------+-----+
### Query 2: MINUS
PREFIX : <http://example.com/>
SELECT * WHERE {
?a :p ?n
MINUS {
?a :q ?m .
FILTER(?n = ?m)
}
}
+------------------------+-----+
| a | n |
+------------------------+-----+
| <http://example.com/a> | 1 |
| <http://example.com/b> | 3.0 |
+------------------------+-----+
Note that such differences are not restricted to cases where
the shared variables in the MINUS patttern *only* occur
in a FILTER. E.g., in the example above, make it
MINUS {
?a :q ?m .
OPTIONAL {?a :r ?n}
FILTER(?n = ?m))
}
Hope this helps for clarification. We'd appreciate if you
could indicate whether this response adequately addresses
your comment.
best regards,
Axel (on behalf of the SPARQL WG)
1. http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/2011Jan/0010.html
2. http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/2011Feb/0004.html
Received on Tuesday, 29 March 2011 09:09:36 UTC