w3c / N3

W3C's Notation 3 (N3) Community Group
47 stars 18 forks source link

Give pointers for forward/backward chaining #141

Open VladimirAlexiev opened 1 year ago

VladimirAlexiev commented 1 year ago

https://w3c.github.io/N3/spec/#n3rulechaining:

A detailed discussion of these two reasoning modes, their subtle differences and impacts on performance, is beyond the scope of this primer.

That is fair. However, please provide some references to info about forward/backward chaining, in particular their sequencing/interaction.

BTW change the last word "primer" -> "specification" because the doc does start with "This document defines Notation 3"

doerthe commented 1 year ago

I did not describe that in my thesis, but you are right, it would be nice to have a document about that and we need to write one.

In general: forward-rules are executed till we get the full answer to our query (starting from the facts), backward-rules are executed "on demand" when the body of a rule requires the information (in that sense starting from the query or the queries). But instead of an informal(and incomplete) text as the answer to your issue you deserve a document. I will bring that up in our next group meeting.

VladimirAlexiev commented 1 year ago

I understand the general principle but

william-vw commented 1 year ago

are forward and backward ever interleaved? Or all forward are run first?

As far as I understand, forward rules are executed first; evaluating statements in their rule body (condition) may involve running backward rules. I.e., backward-chaining rules are executed purely "on-demand", when needed. But, @josd and @doerthe may shed more light here.

what happens if I insert a rule as part of executing another rule?

Then this rule will become part of the ruleset and will be executed as well. Try the example here: https://n3-editor.herokuapp.com/n3/editor/s/cL2VhgAd

are rules scoped?

Unsure what you mean.

VladimirAlexiev commented 1 year ago

@william-vw @josd @doerthe

Hybrid reasoning

forward and backward ever interleaved?

Rule dynamics

if I insert a rule X as part of executing another rule A ?

Rule scoping

are rules scoped? For example, at https://jena.apache.org/documentation/inference/#RULEsyntax we can see:

[allID: (?C rdf:type owl:Restriction), (?C owl:onProperty ?P),
(?C owl:allValuesFrom ?D)  -> (?C owl:equivalentClass all(?P, ?D)) ]
[all2: (?C rdfs:subClassOf all(?P, ?D)) -> 
print(‘Rule for ‘, ?C)
[all1b: (?Y rdf:type ?D) <- (?X ?P ?Y), (?X rdf:type ?C) ]    ### I mean this
]
  • RULEhybrid also says "we can use the forward rules to compile a set of backward rules from the ontology information in the dataset"
  • is it the same with N3?
josd commented 1 year ago

This is how it works in EYE https://eyereasoner.github.io/eye/#architecture-and-design