Backwards chaining (also known as query rewriting) is an approach to semantic reasoning where queries are rewritten based on rules.
Backwards Chaining Advantages
-Can be used in conjunction with virtual graphs
-Does not need to do any upfront computation when ingesting a rule
Materializsation on the other hand is much more efficient, only having to do calculations once (on load, not at query time) and provides performance benefits on the order of 100-1000x.
Say we have this data:
Querying for all members of the :Personclass, will look like this:
}
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:
}
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:
We will add further depth to our class hierarchy.
But again, rewriting the query will work.