RDFLib / OWL-RL

A simple implementation of the OWL2 RL Profile on top of RDFLib: it expands the graph with all possible triples that OWL RL defines. It can be used together with RDFLib to expand an RDFLib Graph object, or as a stand alone service with its own serialization.
http://www.ivan-herman.net/Misc/2008/owlrl/
Other
139 stars 30 forks source link

Introduce inference and optimization for dt-diff #27

Open wrobell opened 5 years ago

wrobell commented 5 years ago

The inference for dt-diff rule is missing in OWL-RL at the moment (see https://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_using_Rules for the rule definition).

The rule is important, because it allows to infer an error when a subject and predicate (data property) violate the 1 max cardinality. For example

Because dt-diff is not implemented we end up with (11, owl:sameAs, 12) in the graph only - this is without the (11, owl:differentFrom, 12) and the error.

We could implement inference for dt-diff, but it will create a lot of trivial triples in a graph. We should probably immediately optimise this and whenever we have triples like (s, p, l1) and (s, p, l2) generate an error avoiding generation of dt-diff and cls-maxc2 triples.

nicholascar commented 4 years ago

Hi @wrobell with the recent release of rdflib 5.0.0, we might look into OWL-RL Issues.

Can you comment on this code to test for what we should be seeing as a test for this (which will currently fail due to missing axiom:

from rdflib import Graph, URIRef, Literal
from rdflib.namespace import OWL
from owlrl import DeductiveClosure, OWLRL_Semantics

g = Graph()
g.add((
    URIRef("a:"),
    URIRef("b:"),
    Literal("11"),
))

g.add((
    URIRef("a:"),
    URIRef("b:"),
    Literal("12"),
))

DeductiveClosure(OWLRL_Semantics).expand(g)

assert ((Literal("11"), OWL.differentFrom, Literal("12"))) in g
assert ((Literal("11"), OWL.sameAs, Literal("12"))) not in g

both assert statements currently fail; not even the cls-maxc2 seems to be working in this test case.

Once we have the test case for what should be seen, we can work on implementing it then perhaps optimising it.

(I fear that the major work needed here is actually a check of the OWL-RL documentation to remind us (me) of what is and isn't supported now, before patches/updates are made.)