2006-12-31

pyRete status 2

I've re-written the RuleParser to handle not and exists. Since not is a keyword in Python you'll have to do

>>> @pyRete.Rule
... def foo(a = int):
... if Not(a == 1):
... pass
and the equivalent for exists is:
>>> @pyRete.Rule
... def foo(a = int):
... if Exists(a == 1):
... pass
I've written about 75% of the Not-Node implementation but the Rule Compiler doesn't handle it yet so there's still some way to go before trying Ms Manners and other benchmarks. I'll implement Exists as two Nots and I intend to re-read the Rete papers to make sure I handle things like not(not(not())) and exists(exists()) correctly.

Things are starting to look better again though. It'll probably take a while to get an optimized Rete implementation. It was far too complex before and to make it simpler I've removed all Node sharing. I reckon I'll be able to add sharing later, once I get everything working as it should.

3 kommentarer:

woolfel sa...

my suggestion is to not allow (not (not (not) ) ) or (exist (exist) ). deeply nesting nots and exists leads to a nightmare on elm street. scary men with long sharp knives for fingers :)

Johan Lindberg sa...

And a good suggestion it is.

I started thinking about what *should* happen in the second Not node but since it's behaviour is nowhere near as simple as Negation in Boolean Logic I got a headache ;-)

At the moment the Ruleparser raises a SyntaxError exception if you nest Not/Exists calls and that's probably the way it stays.

woolfel sa...

even if some users complain, i'm of the opinion that having some walls makes life easier for the user. Keeping someone from doing something really stupid is sometimes a necessary evil :)

plus, depending on the user not not means different things. In english, "not not true" means it is true. In clips it's exists. In russian "not not" is different than english. In chinese, "not not true" can mean "really not true".

of course users never get confused ;P