W3C home > Mailing lists > Public > public-rdf-dawg-comments@w3.org > March 2005

Unbound vars as blank nodes

From: Geoff Chappell <geoff@sover.net>
Date: Tue, 22 Mar 2005 15:23:12 -0500
To: <public-rdf-dawg-comments@w3.org>
Message-ID: <010701c52f1c$f90373f0$6401a8c0@gsclaptop>

Has the working group considered treating the unbound vars that arise from
malformed queries, optionals, and disjunctions as blank nodes? At first
glance, it seems to make logical sense, gets rid of the need for the
logically ugly isbound function, and provides a sound path to resolving
ordering dependencies with optionals.

(all examples assume graph {:BK1 dc10:title "Moby Dick"})


SELECT ?x ?y
   WHERE  { ?book dc10:title ?x }

Logically speaking projection vars are existentially quantified, right? And
that's what a blank node is, so it seems logically correct to return: 

	?x="Moby Dick", ?y=_:b1. 

I.e. the sentence:
	There exists ?x,?y such that ?x is the title of something
essentially becomes:
	There exists ?y such that "Moby Dick" is the title of BK1 

The same applies for disjunctions:

SELECT ?x ?y
   WHERE  ({ ?book dc10:title ?x } union { ?book dc10:title ?y }}

?x="Moby Dick"  	?y=_:b1
?x=_:b2 		?y="Moby Dick"

Now for optionals....

SELECT ?x ?y
   WHERE  { ?book dc10:title ?x. OPTIONAL  ?book ex:author ?y.}

The result:

	?x="Moby Dick"  	?y=_:b1

seems reasonable - i.e. we know the book has an author (that's what we've
implied by using optional) we just don't know what it is.

Now consider:

SELECT ?x ?y
   WHERE  { ?book dc10:title ?x. OPTIONAL  ?book ex:author ?y. 
	?book ex:author ?y.}

This should return no results (regardless of execution order). Note it's
just wrong to treat ?y as a free var after the first two triple patterns
(assuming execution order = query order) because that means discarding the
prior constraints on it's value.

Ordering dependencies arise when a var comes out of a pattern element (in
grammar terms) without a value. Binding to a blank node resolves the problem
without resorting to null values (and also thereby avoids the null == null
question -- since no blank node will equal another).

Also, this approach has no problems with pattern like:

	(?x ?p ?a) optional(?x ?y ?z) optional (?a ?b ?y)

(they're essentially treated as if the optional doesn't exist rather than
being tossed due to unresolvable order dependencies).

-Geoff Chappell
Received on Tuesday, 22 March 2005 20:23:38 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:52:05 UTC