On 12.11.2015 16:30, Paul Houle wrote:
This is really great stuff that gets to the heart of the matter.
There is a horrible misconception that SPARQL is complex. People often show you queries that make your head spin, but it is astonishing how really simple they are. Here are a set of SPARQL queries that implement OWL 2 RL:
http://topbraid.org/spin/owlrl-all.html
this shorter and far more human readable than anything has been written about OWL.
As far as I can tell, this is a SPARQL-based copy of the inference rules given in the OWL standard [1], which, to be fair, should probably be counted as something that "has been written about OWL" ;-)
On a more technical note, it should be remarked that the queries do not really "implement OWL RL". First of all, you would need to run these queries recursively and add their results to the database in each step, which is not something you could do through a public SPARQL endpoint. The queries are actually SPARQL-encoded inference rules that need to be executed in a way that is not the usual mode of answering a SPARQL query.
Secondly, these rules only implement certain aspects of OWL RL (instance retrieval). They do not, in particular, correctly implement retrieval of subclass-of axioms. In fact, it is not possible to implement correct subclass-of reasoning for OWL RL by using RDF-based rules in this way, even if they are executed recursively [2]. It is possible to do it with rules, but these are beyond SPARQL CONSTRUCT, unless your "SPARQL rule engine" implements some more complex redundancy checking before adding CONSTRUCT results to the database.
On the other hand, it is entirely possible to implement correct OWL QL (note: *QL* not *RL*) reasoning in SPARQL without even using "rules" that need any recursive evaluation [3]. This covers all of RDFS, and indeed some of the patterns in these queries are quite well-known to Wikidata users too (e.g., using "subclassOf*" in a query). Depending on how much of OWL QL you want to support, the SPARQL queries you get in this case are more or less simple. This work also gives arguments as to why this style of SPARQL-based implementation does (most likely) not exist for OWL RL [3].
(I come to bury, not praise OWL -- if there are some OWL
features you like copy them into your rules. If your data gets "big" at all, you do not want to mindlessly infer facts that aren't part of expected reasoning chains.)
I am afraid that the rules you cited are actually an example of some such "mindless" inference. They infer some types of axioms, such as subclass of, that are not part of their intended output (that is: which are never inferred completely anyway). There are other inference rule sets that avoid this useless extra inferences and still obtain all instance-of relations in OWL RL.
I write this not to praise or "bury" any technology, just to clarify some apparent misconceptions. (In particular, I completely agree with the fact that SPARQL is not that hard to grok, and that nicer interfaces and maybe further tutorial-style introductions would be useful.)
Regards,
Markus
[1] http://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_usi... [2] http://korrekt.org/page/The_Not-So-Easy_Task_of_Computing_Class_Subsumptions... [3] http://korrekt.org/page/Schema-Agnostic_Query_Rewriting_in_SPARQL_1.1