OWL Inference with RDF Gateway
This example demonstrates a query with inference against a RDF file on the web.
A query is run against the wine ontology (referenced in the OWL Web Ontology Language Guide)
to find all red wines.
Without inference support, the query results would be empty because the ontology does not explicitly state that any wines are red.
It does however say that a number of wines are subclasses of the class of things that have a value of red for the hasColor property.
The ontology also states that the hasColor property is a subproperty of the hasWineDescriptor property.
This knowledge combined with the rules for valid inference in OWL and RDF allow RDF Gateway to answer the query.
The query is demonstrated below: [Try It]
import "/std/owl.rql";
session.namespaces["wine"] = "http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#";
var ds = new datasource("inet?parsetype=rdf&url=http://www.w3.org/TR/owl-guide/wine.rdf");
select ?s using #ds rulebase owl where {[wine:hasWineDescriptor] ?s [wine:Red]};
RDF Gateway supports the semantics of OWL and RDF through LP-style rule-based inference.
This approach places RDF Gateway's OWL support in the OWL Full category
(as opposed to OWL Lite and OWL DL which are targeted at Description Logic Reasoners).
A portion of RDF Gateway's rule file for owl is shown below:
...
infer {?p ?a ?c} from {[rdf:type] ?p [owl:TransitiveProperty]} and {?p ?a ?b} and {?p ?b ?c};
infer {?p ?y ?x} from {[rdf:type] ?p [owl:SymmetricProperty]} and {?p ?x ?y};
infer {?p ?y ?x} from {[owl:inverseOf] ?p ?q} and {?q ?x ?y};
infer {?p ?s ?o} from {[owl:sameAs] ?x ?s} and {?p ?x ?o};
infer {[rdf:type] ?i ?c} from {[rdf:type] ?r [owl:Restriction]} and {[rdf:type] ?s ?r} and {[owl:onProperty] ?r ?p} and {[owl:allValuesFrom] ?r ?c} and {?p ?s ?i};
infer {[rdf:type] ?i ?c} from {[rdf:type] ?r [owl:Restriction]} and {[rdf:type] ?s ?r} and {[owl:onProperty] ?r ?p} and {[owl:someValuesFrom] ?r ?c} and ?i=newid(?r);
infer {?p ?s ?v} from {[owl:onProperty] ?r ?p} and {[rdf:type] ?r [owl:Restriction]} and {[rdf:type] ?s ?r} and {[owl:hasValue] ?r ?v};
infer {[rdfs:subClassOf] ?a ?b} from {[owl:equivalentClass] ?a ?b};
infer {?p ?a ?b} from {[owl:equivalentProperty] ?q ?p} and {?q ?a ?b};
infer {[rdfs:subPropertyOf] ?a ?b} from {[owl:equivalentProperty] ?a ?b};
infer {[rdfs:subClassOf] ?s ?c} from {[owl:intersectionOf] ?s ?l} and {[rdfs:member] ?l ?c};
infer {[rdfs:subClassOf] ?c ?u} from {[owl:unionOf] ?u ?l} and {[rdfs:member] ?l ?c};
infer {[rdf:type] ?s ?r} from {[rdf:type] ?r [owl:Restriction]} and {[owl:onProperty] ?r ?p} and {[owl:hasValue] ?r ?v} and {?p ?s ?v};
infer {[owl:sameAs] ?z ?y} from {?p ?x ?y} and {?p ?x ?z} and {[rdf:type] ?p [owl:FunctionalProperty]} and ?z <> ?y and uri(?z)=?z and uri(?y)=?y;
infer {[owl:sameAs] ?z ?y} from {?p ?y ?x} and {?p ?z ?x} and {[rdf:type] ?p [owl:InverseFunctionalProperty]} and ?z <> ?y;
infer {[owl:equivalentClass] ?a ?b} from {[rdfs:subClassOf] ?a ?b} and {[rdfs:subClassOf] ?b ?a};
infer {[owl:equivalentClass] ?c1 ?c2} from {[owl:sameAs] ?c1 ?c2};
infer {[owl:equivalentProperty] ?a ?b} from {[rdfs:subPropertyOf] ?a ?b} and {[rdfs:subPropertyOf] ?b ?a};
infer {[owl:differentFrom] ?x ?y} from {[rdf:type] ?y ?c2} and {[owl:complementOf] ?c1 ?c2} and {[rdf:type] ?x ?c1};
infer {[owl:differentFrom] ?x ?y} from {[rdf:type] ?y ?c2} and {[owl:disjointWith] ?c1 ?c2} and {[rdf:type] ?x ?c1};
infer {[owl:differentFrom] ?x ?y} from {[rdfs:member] ?l ?x} and {[owl:distinctMembers] ?dl ?l} and {[rdf:type] ?dl [owl:AllDifferent]} and {[rdfs:member] ?l ?y} and ?y <> ?x
infer {[rdf:type] ?p [owl:FunctionalProperty]} from {[rdf:type] ?q [owl:InverseFunctionalProperty]} and {[owl:inverseOf] ?p ?q};
infer {[rdf:type] ?p [owl:InverseFunctionalProperty]} from {[rdf:type] ?q [owl:FunctionalProperty]} and {[owl:inverseOf] ?p ?q};