W3C home > Mailing lists > Public > public-sparql-dev@w3.org > July to September 2010

Re: negation as failure

From: Steve Harris <swh@ecs.soton.ac.uk>
Date: Tue, 3 Aug 2010 16:33:42 +0100
Cc: Lee Feigenbaum <lee@thefigtrees.net>, "public-sparql-dev@w3.org" <public-sparql-dev@w3.org>
Message-ID: <EMEW3|7c5d62a8416865a3f1e4c4a4bf34d758m72GZ203swh|ecs.soton.ac.uk|2769A65D-87D5-4B2D-B3D8-8239E27693C6@ecs.soton.ac.uk>
To: Matthew Pocock <matthew.pocock@ncl.ac.uk>
Matthew,

You should look at the text of the results, you might well be hitting 4store's complexity limiter. If you are there there will be a comment to that effect.

You can turn up the limit with soft_limit in the query params, default is about 1000. You can turn it off by setting it to -1. c.f. http://4store.org/trac/wiki/SparqlServer#SoftLimits and http://4store.org/trac/wiki/Query

- Steve

On 2010-08-03, at 16:10, Matthew Pocock wrote:

> [replied in public-sparql-dev only to avoid cluttering public-owl-dev]]
> 
> Thanks Lee, that got me started. However, I'm now seeing strange results when running this against my real data.
> 
> The simplest query finds all a,b,c as follows:
> 
> prefix rt: <http://cs.ncl.ac.uk/ib2010_data.1.2/relationType/>
> 
> select distinct ?a ?b ?c where
>   { ?a rt:sim ?b
>   . ?b rt:bi_to ?c
>   }
> 
> When I run this, I get 30,233 results. Now, if I search for all of those where in addition, a rt:bi_to c:
> 
> select distinct ?a ?b ?c where
>   { ?a rt:sim ?b
>   . ?b rt:bi_to ?c
>   . ?a rt:bi_to ?c
>   }
> 
> This returns 5,800 results.
> 
> Now, we try the negation-as-failure query to pull out things where a rt:bi_to c is not asserted:
> 
> select distinct ?a ?b ?c where
>   { ?a rt:sim ?b
>   . ?b rt:bi_to ?c
>   . OPTIONAL
>     { ?a rt:bi_to ?c2
>     . FILTER(?c = ?c2)
>     }
>   . FILTER (!BOUND(?c2))
>   }
> 
> This returns 29,078 results. Since in every case of the original query, either a does or a does not rt:bi_to c, I would expect 29,078 + 5,800 to sum to 30,233. However, this is obviously not the case. So perhaps it's something to do with this negation clause. Let's try again but flip the bound filter, to recover a query that should behave the same as the 2nd one above:
> 
> select DISTINCT ?a ?b ?c where
>   { ?a rt:sim ?b
>   . ?b rt:bi_to ?c
>   . OPTIONAL
>     { ?a rt:bi_to ?c2
>     . FILTER(?c = ?c2)
>     }
>   . FILTER (BOUND(?c2))
>   }
> 
> This returns only 2,734 results, which clearly is not equal to 5,800, and also does not get us to 30,233. Reassuringly, if we drop the filter..bound clause entirely, we get the count we'd expect.
> 
> select DISTINCT ?a ?b ?c where
>   { ?a rt:sim ?b
>   . ?b rt:bi_to ?c
>   . OPTIONAL
>     { ?a rt:bi_to ?c2
>     . FILTER(?c = ?c2)
>     }
>   }
> 
> This returns 30,233 hits.
> 
> I am now utterly perplexed. There's no fancy reasoning going on - this particular collection of triples have not been introduced to rdfs or owl reasoning of any sort, so same_as collapsing or any other trickery should not be happening.
> 
> I've been using 4store and its 4s-query application to execute the queries.
> 
> Matthew
> 
Received on Tuesday, 3 August 2010 15:35:46 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:15:50 UTC