OWL 2 RL — what the reasoner entails
OWL 2 RL is the profile of OWL 2 designed for forward-chaining rule engines, with reasoning in polynomial time. pgRDF's default
'owl-rl'profile runs it with thereasonablereasoner.
What materializes
Each row shows asserted triples and a triple that materialize adds.
| Vocabulary | Asserted | Inferred |
|---|---|---|
rdfs:subClassOf | ex:Engineer rdfs:subClassOf ex:Person, ex:alice a ex:Engineer | ex:alice a ex:Person, across the whole chain |
rdfs:subPropertyOf | ex:hasParent rdfs:subPropertyOf ex:hasRelative, ex:ann ex:hasParent ex:bea | ex:ann ex:hasRelative ex:bea |
rdfs:domain / rdfs:range | ex:teaches rdfs:domain ex:Teacher ; rdfs:range ex:Course, ex:tom ex:teaches ex:maths | ex:tom a ex:Teacher, ex:maths a ex:Course |
owl:equivalentClass | ex:Human owl:equivalentClass ex:Person, ex:hal a ex:Human | ex:hal a ex:Person |
owl:equivalentProperty | ex:likes owl:equivalentProperty ex:fancies, ex:ann ex:likes ex:tea | ex:ann ex:fancies ex:tea |
owl:inverseOf | ex:knows owl:inverseOf ex:knownBy, ex:alice ex:knows ex:bob | ex:bob ex:knownBy ex:alice |
owl:TransitiveProperty | ex:tyre ex:partOf ex:wheel, ex:wheel ex:partOf ex:car | ex:tyre ex:partOf ex:car |
owl:SymmetricProperty | ex:carol ex:marriedTo ex:dave | ex:dave ex:marriedTo ex:carol |
owl:sameAs | ex:ali owl:sameAs ex:alice, ex:ali ex:worksAt ex:acme | ex:alice ex:worksAt ex:acme |
owl:FunctionalProperty | ex:kid ex:hasMother ex:m1 , ex:m2 | ex:m1 owl:sameAs ex:m2 |
owl:InverseFunctionalProperty | ex:x1 ex:hasSSN "123", ex:x2 ex:hasSSN "123" | ex:x1 owl:sameAs ex:x2 |
owl:hasValue restriction | ex:RedThing ≡ things with ex:colour ex:red; ex:apple ex:colour ex:red | ex:apple a ex:RedThing |
owl:someValuesFrom restriction | ex:Parent ≡ things with some ex:hasChild that is an ex:Person; ex:pat ex:hasChild ex:hal | ex:pat a ex:Parent |
owl:allValuesFrom restriction | every ex:ingredient of an ex:VeganMeal is an ex:Plant; ex:lunch a ex:VeganMeal ; ex:ingredient ex:kale | ex:kale a ex:Plant |
owl:intersectionOf | ex:WorkingParent ≡ ex:Parent ⊓ ex:Worker; ex:pat is both | ex:pat a ex:WorkingParent |
owl:unionOf | ex:Pet ≡ ex:Cat ⊔ ex:Dog; ex:rex a ex:Dog | ex:rex a ex:Pet |
Declare the property characteristics as usual, for example ex:partOf a owl:TransitiveProperty. The profile also adds a few axiomatic triples, such as typing each resource as owl:Thing.
A worked rule: transitive properties
SELECT pgrdf.add_graph('urn:example:parts');
SELECT pgrdf.parse_turtle('
@prefix ex: <http://example.com/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
ex:partOf a owl:TransitiveProperty .
ex:tyre ex:partOf ex:wheel .
ex:wheel ex:partOf ex:car .
', pgrdf.graph_id('urn:example:parts'));
SELECT pgrdf.materialize(pgrdf.graph_id('urn:example:parts'));
SELECT * FROM pgrdf.sparql('
PREFIX ex: <http://example.com/>
SELECT ?o WHERE { ex:tyre ex:partOf ?o }');
-- {"o": "http://example.com/wheel"}
-- {"o": "http://example.com/car"}Asking "what is the tyre part of?" returns both the wheel and the car, without your application computing the transitive closure. With the 'rdfs' profile the same query returns only ex:wheel, because transitivity is an OWL rule.
What it doesn't entail
owl:propertyChainAxiom. A chain such asex:hasGrandparentdefined as( ex:hasParent ex:hasParent )produces no triples. Query the chain directly with two triple patterns,?a ex:hasParent ?b . ?b ex:hasParent ?c. SPARQL sequence pathsp1/p2aren't supported.- Anything outside OWL 2 RL. The W3C OWL 2 RL profile excludes, for example, general
owl:complementOfreasoning, full description-logic class equivalence, and the OWL 2 EL and QL profiles. An ontology that relies on those features (SNOMED-style EL ontologies, for example) needs a different reasoner for those parts. - Custom rules. There is no user-defined rule language. For a derived fact outside OWL 2 RL, write it with SPARQL UPDATE (
INSERT … WHERE). The result is then asserted, not inferred, andmaterializewon't replace it.
Constructs outside the rule set don't stop the rest of the ontology from materializing.
The lighter 'rdfs' profile
pgrdf.materialize(graph_id, 'rdfs') computes only the RDFS closures: rdfs:subClassOf, rdfs:subPropertyOf, rdfs:domain and rdfs:range. None of the OWL rules in the table above fire. It costs less per graph; pick it when you only need the class and property hierarchy. See Reasoning profiles.
Why it matters
Much of the ontology community publishes against OWL 2 RL because its rule set is tractable. Running that rule set inside the database means application queries written against the ontology's vocabulary also match what the ontology implies, without the application carrying the reasoning.
See also
- Mental model
- Worked example
- Scale of reasoning: the single-threaded cost model and how to size the graph you reason over.