A simple SPIN rule doesn't work in RDF4J

324 Views Asked by At

I've just started using the triple store RDF4J (I am using its workbench, version 2.3.1, run on Windows 10 with Tomcat 9.0)

I want to use the SPIN rules in RDF4J. Therefore, I created a new repository (In memory with RDFS+SPIN support).

I wanted to start with the SPIN example in RDF4J documentation concerning how to add SPIN rules. That is, I added the data (in Turtle, and imported to RDF4J)

@prefix ex: <http://example.org/>.
        ex:John a ex:Father ;
ex:parentOf ex:Lucy .
ex:Lucy a ex:Person .

And the rule:

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix sp: <http://spinrdf.org/sp#>.
@prefix spin: <http://spinrdf.org/spin#>.
@prefix ex: <http://example.org/>.
ex:Person a rdfs:Class ;
    spin:rule [
        a sp:Construct ;
    sp:text """PREFIX ex: <http://example.org/>
               CONSTRUCT { ?this ex:childOf ?parent . }
               WHERE { ?parent ex:parentOf ?this . }"""
] .

And as instructed in the documentation, I exposed the query (with the checkbox 'Include inferred statements' checked),

PREFIX ex: <http://example.org/>
SELECT ?child 
WHERE { ?child ex:childOf ?parent }

However, no result returned:

no result

Could someone, please tell me am I doing something wrong, why the SPIN rule doesn't work in my RDF4J workbench, have I missed something?

1

There are 1 best solutions below

0
On

(reposting my comment as an answer for future readers)

The SPIN reasoner currently assumes that all data is in the default context, I think. Make sure that your data was not added to a named graph.