2

So this is my first question on this board, please forgive me if it is naive.

Basically, it seems to me that the reasoning engine of GraphDB takes all triples inside named graphs and duplicates them within the nil graph, and then proceeds to make inferences directly inside the nil graph only. I do not know exactly, but it does not seem the correct way to handle inferences.

Consider the following trivial example:

INSERT DATA {
    :Dog rdfs:subClassOf :Mammal.
    GRAPH :G1 {
        :Lassie a :Dog.
    }
}

I am using the OWL2-RL ruleset for inferences. If I query it with inferences on, it returns 805 statements, not shown here, but if I filter just the interesting ones with the following query:

SELECT *  WHERE {
    {
        {
            GRAPH ?g { ?s ?p ?o. }
        } UNION {
            GRAPH <http://rdf4j.org/schema/rdf4j#nil> { ?s ?p ?o. }
            BIND ("-" AS ?g)
        }    
    } 
    FILTER ( !(
        strstarts(str(?s), "http://www.w3.org/2002/07/owl#") ||  
        strstarts(str(?s), "http://www.w3.org/2000/01/rdf-schema#") ||  
        strstarts(str(?s), "http://www.w3.org/2001/XMLSchema#") ||  
        strstarts(str(?s), "http://www.w3.org/1999/02/22-rdf-syntax-ns#") ||
        strstarts(str(?o), "http://www.w3.org/2002/07/owl#Thing") ||
        false
    ))
}

the reasoning engine returns 9 statements, and interestingly one appears twice:

g s p o
:G1 :Lassie rdf:type :Dog
"-" :Lassie rdf:type :Dog

(The BIND ("-" as ?g) hack in the second branch of the UNION is to make sure the "-" results actually come from the 'nil' graph and they are not artefacts of the SPARQL query)

Basically, there are now TWO statements :Lassie a :Dog., one inside :G1 and the other in the "nil" graph. The second one is clearly the result of the inference engine, since if I deactivate it I correctly only receive the original statements. So it is an inference.

Yet, I was unable to identify the rule in the file "builtin_owl2-rl.pie" that controls this inference (which I find it is unwarranted and ultimately incorrect).

Is there a way to exclude the generation of the statement in the 'nil' graph, or at least to activate-deactivate it in the ruleset?

Thank you

FV

The Proof plugin is not able to help either, since proof:explain only allows three instead of four parameters, and therefore it does not allow to specify the context of the statement to be proofed. As such it simply returns twice that the statement :Lassie a :Dog. is explicit, which is ALSO WRONG.

PREFIX proof: <http://www.ontotext.com/proof/>

SELECT * WHERE {
        {
            GRAPH ?g { ?s ?p ?o. }
        } UNION {
            GRAPH <http://rdf4j.org/schema/rdf4j#nil> { ?s ?p ?o. }
            BIND ("-" AS ?g)
        }    
    FILTER ( !(
        strstarts(str(?s), "http://www.w3.org/2002/07/owl#") ||  
        strstarts(str(?s), "http://www.w3.org/2000/01/rdf-schema#") ||  
        strstarts(str(?s), "http://www.w3.org/2001/XMLSchema#") ||  
        strstarts(str(?s), "http://www.w3.org/1999/02/22-rdf-syntax-ns#") ||
        strstarts(str(?o), "http://www.w3.org/2002/07/owl#Thing") ||
        false
    ))
        ?ctx proof:explain (?s ?p ?o) .
        ?ctx proof:rule ?rule .
}

returns

g s p o ctx rule
:G1 :Lassie rdf:type :Dog _:8017b441a12c4c6eab8466163d0587c7154718 "explicit"
"-" :Lassie rdf:type :Dog _:8017b441a12c4c6eab8466163d0587c7154719 "explicit"
Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
almotasim
  • 21
  • 2
  • From their [documentation](https://graphdb.ontotext.com/documentation/10.0/query-behaviour.html#how-to-manage-explicit-and-implicit-statements): "Inferred statements are ALWAYS created in the database’s default graph", "The same statement can exist in several graphs - as explicit in graph `G` and implicit in the default graph". – Stanislav Kralin May 29 '23 at 19:17
  • 1
    Agreed, but a) their creation should be the result of the application of a specific rule from the ruleset, and b) it should be possible to distinguish the "real" S P O from the "inferred" S P O, especially when they are identical except for the context they're in. – almotasim May 29 '23 at 21:12
  • 1
    The rule is `A ⊢ A` :-). – Stanislav Kralin May 29 '23 at 21:33
  • Right! :-) ... still not present in the *builtin_owl2-rl.pie* file, as far as I can tell. – almotasim May 30 '23 at 07:34

0 Answers0