As I continue to work on pyTER, there are some things that trouble me. Apart from getting the Rete algorithm in place without damaging it there are also other subtle little things that could be implemented in various ways. It's not that I can't figure out how to do it as much as I don't know which of all possible alternatives is correct.
One thing that I thought a lot about last week was Conflict Resolution. I was a bit confused because in most (high-level) descriptions I've read, I've interpreted Conflict Resolution as a way of sorting Rules (not Activations). Consider the following Conflict Set:
[ (Rule 1, [Fact 1, Fact2]),How do I determine which Activation to fire first?
(Rule 1, [Fact 3, Fact4]), ]
Luckily, the CLIPS documentation includes the CLIPS 6.24 Basic Programming Guide which (in section 5.3) explains the built-in Conflict Resolution Strategies in detail. Previously I had read about Conflict Resolution in Jess In Action (chapter 7.5) and Expert Systems - Principles and Programming (chapter 1.9). But I couldn't really parse sentences like "... the most recently activated rules to fire first, ..." until I read the CLIPS document.
Another thing that I (still) worry about is the Fact repository. Whenever a Fact is asserted I do 3 things:
1) The Fact is deconstructed into WMEs (Python tuples of size 4).
2) I modify the Fact's Class by adding it's __setattr__ to a function that automatically notifies the Working Memory's modify method.
3) Pass all of the WMEs through the Rete Network.
I'm not sure how others (Jess, JBoss Rules etc) are doing this. Whether it's tightly coupled (as in pyTER now) or if the Fact objects are removed from the program's environment and kept in a "shadow" repository that's not accessible from the outside.
I can see upsides and downsides with each of the implementations but I need to read more and study whatever effects this has on the client program using pyTER. For now, I'll keep with the tightly coupled design and hope that Python's dynamic abilities won't mess things up downstream.