Re: what is LDOM? (was Re: example of recursive shapes)

On 1/26/2015 11:20, Peter F. Patel-Schneider wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Indeed the wording you point out is in the document, but it does not speak
> to the ability of LDOM to handle recursion. It simply says that LDOM uses
> procedural recursion to handle nesting. Nesting is very different from
> recursion.

(Peter, I am picking up this thread because you still seem unconvinced 
that LDOM can handle recursion).

Maybe my PhD in Computer Science is not sufficient to understand the 
difference between nesting and recursion here. Do you have a definition 
of "nesting" in this context? Better: do you have an example that LDOM 
could not handle? I have added the Polentoni example to my test case 
library, and my SPARQL-based implementation returns the correct results. 
I have attached the Turtle file for your reference. The following query 
can be used to verify the two cases:

SELECT *
WHERE {
     BIND (ldom:violatesConstraints(ex:Diego, ex:Polentoni) AS ?diego) .
     BIND (ldom:violatesConstraints(ex:Enrico, ex:Polentoni) AS ?enrico) .
}

ex:Enrico violates constraints (?enrico is true), because he knows John 
who knows Maurizio who does not live in Northern Italy. ex:Diego does 
not violate constraints (and ?diego is false).

If you are talking about nesting, do you assume that the function 
ldom:violatesConstraints will somehow rewrite the surrounding SPARQL 
query and then contain nested calls to itself? But this is not the case 
and would indeed not work. It is simply a SPARQL function that is 
executed like this:

Entry point:
ldom:violatesConstraints(ex:Diego, ex:Polentoni)
-> triggers the LDOM engine which looks at all constraints of 
ex:Polentoni including the ldom:all:

ex:Polentoni
     a          rdfs:Class ;
     lion:constraint  [
         a               ldom:ShapeConstraint ;
         ldom:all        ex:Polentoni ;
         ldom:predicate  ex:knows
     ] ...

The LDOM engine executes all SPARQL queries attached to the constraints. 
The ldom:sparql of ldom:all is calling ldom:violatesConstraints again. 
This spawns off a new (recursive) LDOM engine, taking us back to the 
entry point.

Note that I had to add some logic to prevent endless recursion for the 
same combination of arguments of the ldom:violatesConstraints function 
within the same call stack.

Holger

Received on Tuesday, 10 February 2015 04:50:15 UTC