On 20/03/14 10:59, Christophe FAGOT wrote:

Le 20 mars 2014 à 11:20, Dave Reynolds <[email protected]> a écrit :


On 20/03/14 09:46, Christophe FAGOT wrote:

Le 19 mars 2014 à 18:46, Dave Reynolds <[email protected]> a écrit :


On 19/03/14 16:46, Christophe FAGOT wrote:
Hi Jena folks,

since I need to use Jena with its RETEEngine, I’m actually investigating what 
is actually feasible / usable with this engine functionalities.

I would like to develop my own BuiltIn, used in the head of a forward rule, and 
doing some actions when a new rule context appears (due to triples adding) for 
the body rule, while doing some other actions when a rule context disappears 
(dur to triples removal) for this body rule.

It appears in the RETEConflictSet (line 180) that a BuiltIn can receive only … 
added RETERuleContext. Hence a BuiltIn action can only be called when a 
RETERuleContext is added, never when a RETERuleContext is removed.

Is their a reason for that ?

The existing head builtins expect to only be fired when a potitive deduction is 
made. This is a legacy of the fact that the rule system was designed for 
monotonic inference and all the remove/non-monotonic processing is a hack.

I don’t see the relationship between monotonic inference and remove prohibited. 
A monotonic inference only means that when adding some facts in the knowledge 
base, the previous inferred data can’t be removed, while when removing some 
facts, new facts can’t be produced. And this is exactly what Jena Rete engine 
perfectly does with « standard » triple patterns. But when the head is a 
BuiltIn, that BuiltIn does not have a single chance to act the same way. The 
BuildIn can only react to added triples. And the only mandatory thing for a 
BuiltIn is to declare is it is monotonic or not. But it’s behavior and the 
triples it adds/removes in the inference graph are never verified to check if 
it really has a (non-)monotonic behavior. But this is another story.

The point is that builtins in the head are only useful if they have some side effect. 
Jena indeed handles removes when the rules are monotonic. As soon as you have 
side-effecting builtins then all bets are off. Even if a builtin's effect is reversible 
(which I take to be the case you are interested in) it's hard to guarantee all the 
necessary rules will fire in "remove" mode in the way you expect without the 
rule equivalent of reference counting.

Absolutely agree. Would you be open to some little modifications in the RETE 
classes source code, if that modifications improve the ability to extend the 
RETE behavior (or to correct the problem of memory consumption), while 
preserving the actual behavior of existing rules sets using BuiltIn (hence, 
receiving only added data) ?

Sure, patches welcome.

I believe the right workflow would be to open a jira entry/ies for your enhancement and attach the changes as patch fines.

Warning: I'm petty overloaded right now [*] so may need prompting to review any patches.

Dave

[*] For values of "right now" that seem to be depressingly permanent!

Reply via email to