Skip to content

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 the reasonable reasoner.

What materializes ​

Each row shows asserted triples and a triple that materialize adds.

VocabularyAssertedInferred
rdfs:subClassOfex:Engineer rdfs:subClassOf ex:Person, ex:alice a ex:Engineerex:alice a ex:Person, across the whole chain
rdfs:subPropertyOfex:hasParent rdfs:subPropertyOf ex:hasRelative, ex:ann ex:hasParent ex:beaex:ann ex:hasRelative ex:bea
rdfs:domain / rdfs:rangeex:teaches rdfs:domain ex:Teacher ; rdfs:range ex:Course, ex:tom ex:teaches ex:mathsex:tom a ex:Teacher, ex:maths a ex:Course
owl:equivalentClassex:Human owl:equivalentClass ex:Person, ex:hal a ex:Humanex:hal a ex:Person
owl:equivalentPropertyex:likes owl:equivalentProperty ex:fancies, ex:ann ex:likes ex:teaex:ann ex:fancies ex:tea
owl:inverseOfex:knows owl:inverseOf ex:knownBy, ex:alice ex:knows ex:bobex:bob ex:knownBy ex:alice
owl:TransitivePropertyex:tyre ex:partOf ex:wheel, ex:wheel ex:partOf ex:carex:tyre ex:partOf ex:car
owl:SymmetricPropertyex:carol ex:marriedTo ex:daveex:dave ex:marriedTo ex:carol
owl:sameAsex:ali owl:sameAs ex:alice, ex:ali ex:worksAt ex:acmeex:alice ex:worksAt ex:acme
owl:FunctionalPropertyex:kid ex:hasMother ex:m1 , ex:m2ex:m1 owl:sameAs ex:m2
owl:InverseFunctionalPropertyex:x1 ex:hasSSN "123", ex:x2 ex:hasSSN "123"ex:x1 owl:sameAs ex:x2
owl:hasValue restrictionex:RedThing ≡ things with ex:colour ex:red; ex:apple ex:colour ex:redex:apple a ex:RedThing
owl:someValuesFrom restrictionex:Parent ≡ things with some ex:hasChild that is an ex:Person; ex:pat ex:hasChild ex:halex:pat a ex:Parent
owl:allValuesFrom restrictionevery ex:ingredient of an ex:VeganMeal is an ex:Plant; ex:lunch a ex:VeganMeal ; ex:ingredient ex:kaleex:kale a ex:Plant
owl:intersectionOfex:WorkingParent ≡ ex:Parent ⊓ ex:Worker; ex:pat is bothex:pat a ex:WorkingParent
owl:unionOfex:Pet ≡ ex:Cat ⊔ ex:Dog; ex:rex a ex:Dogex: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 ​

sql
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 as ex:hasGrandparent defined 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 paths p1/p2 aren't supported.
  • Anything outside OWL 2 RL. The W3C OWL 2 RL profile excludes, for example, general owl:complementOf reasoning, 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, and materialize won'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 ​

Next: Idempotence and scheduling →

pgRDF is released under the MIT license. Documentation built with VitePress, served via GitHub Pages.