Semantics of ZeroOrOnPath and ZeroOrMorePath of property paths

Hi everyone,

I have a question about the semantics of ZeroOrOnePath and ZeroOrMorePath of property paths. What are the correct query results in the following two situations?


1) ZeroOrOnePath

Let's consider the following graph G consisting of one triple:
<foaf:alice foaf:knows foaf:bob>

Now we want to answer the query Q1:
SELECT * WHERE {<foaf:chris> <foaf:knows>? ?o}

Based on the definition of ZeroOrOnePath with one variable in the W3C recommendation [1]
eval(Path(X:term, ZeroOrOnePath(P), Y:var)) = { (Y, yn) | yn = X or {(Y, yn)} in eval(Path(X,P,Y)) }
Q1 would return {(?o, <foaf:chris>)} since it is not checked whether <foaf:chris> is contained in G.

In contrast to this papers like [2] ZeroOrOnePath are defined in such a way that Q1 would return an empty result set.


2) ZeroOrMorePath

Let's assume the following query Q2 over the graph G shown above:
SELECT * WHERE {<foaf:chris> <foaf:knows>* ?o}

Based on the definition of ZeroOrMorePath with one variable in the W3C recommendation [1], the query Q2 would return {(?o, <foaf:chris>)} even though <foaf:chris> is not element of the graph. (The definitions and a more detailed explanation is at the end of this mail.) According to [2] this query would return an empty result set.


Can someone please explain to me, whether a subject not occurring in the graph should be contained in the result sets of ZeroOrOnePath and ZeroOrMorePath or not?

Thank you very much for your help.

Best regards,
Adrian

[1]https://www.w3.org/TR/sparql11-query/#PropertyPathPatterns
[2]https://users.dcc.uchile.cl/~mromero/papers/ppath.pdf


In [1]  ZeroOrMorePath with one variable is defined as
eval(Path(X:term, ZeroOrMorePath(path), vy:var)) ={ { (vy, n) } | n in ALP(X, path) }
and ALP is defined as:

ALP(x:term, path) =
     Let V = empty multiset
     ALP(x:term, path, V)
     return is V

# V is the set of nodes visited

ALP(x:term, path, V:set of RDF terms) =
     if ( x in V ) return
     add x to V
     X = eval(x,path)
     For n:term in X
         ALP(n, path, V)
         End

If I understand it correctly in the first iteration of ALP(x:term, path, V:set of RDF terms) x is added to V regardless of whether x is element of the graph or not. Thus, query Q2 would return {(?o, <foaf:chris>)} even though <foaf:chris> is not element of the graph.

Received on Monday, 22 January 2018 15:22:14 UTC