Back

What is backwards chaining?

Backwards chaining (also known as query rewriting) is an approach to semantic reasoning where queries are rewritten based on rules.

For instance, we might have this data:
:alice a :Woman.
:bob a :Man .
:sam a :Person .
:Woman rdfs:SubClassOf :Person .
:Man rdfs:SubClassOf :Person .

Querying for all members of the :Personclass, will look like this:
SELECT ?person
WHERE {
?person a :Person

}

Now, this pattern will only match Sam, as neither Alice nor Bob directly belong to the :Person class.

So a reasoner that uses backward chaining will rewrite the query to something like this:
SELECT ?person
WHERE {
?person a/rdfs:subClassOf* :Person

}

Where we use a property path to say that we are interested in paths beginning with a, and having 0 or more instances of rdfs:subClassOf.

 

If we now add these two triples:
:Charlie a :Boy .

:Boy rdfs:subClassOf :Man .

We will add further depth to our class hierarchy.
But again, rewriting the query will work.



Backwards Chaining vs Forwards Chaining (aka materialisation)

Backwards Chaining Advantages
-Can be used in conjunction with virtual graphs
-Does not need to do any upfront computation when ingesting a rule

Forward Chaining Disadvantages
-Reasoning cannot be used to improve performance
-In the past, reasoning was slow and has garnered a now unjust reputation for poor performance

What is RDF?

What is semantic inference?

How to build a graph database?

What is SPARQL?

Learn more about RDFox

Get yourself a free trial!

Contact us for more detail

Looking for more answers?

From the blog

High performance knowledge graph and semantic reasoning engine.