A Minimal Production System

I've been experimenting a bit with bits and pieces of a production system in Common Lisp for a few days now. It all started as a fun exercise in Common Lisp macrology (the idea was to convert CLIPS syntax into executable Common Lisp code) but since things have fallen into place so neatly. I thought maybe it would be worth implementing parts of CLIPS syntax and functionality. So now, the only question is: which parts to implement?

I'm not going to do anything about data types and built-in functions. I'll add support for ?variables but that's about it (no multifields and no globals) and as far as constructs go I'll manage with defrule and deftemplate (no implied/ordered facts). If it doesn't turn out to be too difficult I'll try to include connected constraints in defrule but I won't bother with slot constraints in deftemplates (types and such). I'm hoping to include all CEs but it depends on how hairy it gets.

So. What have I missed? Is there something unnecessary on the list?

[Update 2008-08-03]: Hm. I guess I forgot about a bunch of engine commands. So here goes. Assert and retract seem stupid to leave out, as does run. I'll probably be annoyed not to have facts so I guess that's in as well. Load, clear, reset and agenda feel necessary but I think I'll only work with one conflict resolution strategy (depth) though.

2 kommentarer:

fogus sa...

What RHS constructs are you considering? Will you provide the Lisp constructs, or were you considering providing a pure CLIPSy environment? Are you planning on implementing all 8 of the LHS conditional elements? Constraints?

Sounds like fun, I hope to see a github project for this. :)


Johan Lindberg sa...

Hi Mike,
and congratulations on the baby (yup, I followed the links in your profile).

Regarding RHS constructs, I'm planning to have all of Common Lisp available to the user. I'm not shadowing any symbols (for instance, I'm using assert-fact instead of assert) so it shouldn't be much of a problem.

I'm still hoping to get all of the CE's implemented but since MPS is a bit of a toy (mostly to teach myself good CL-macro writing style) I'm going to give up quickly if a small and clean solution is difficult to find.

I've got a version of the defrule macro that understands pattern-CEs *without* connected constraints. I'm hoping to add that soon though.

I'll share some code and a more detailed description of how it works in a few days.