johanlindberg / minimal-production-system

MPS (Minimal Production System) is a small CLIPS-like production system for Lisp

This URL has Read+Write access

name age message
file .gitignore Sun Dec 14 06:21:11 -0800 2008 Don't track compiled files [johanlindberg]
file README.md Sun Oct 11 04:37:08 -0700 2009 Fixed markdown for code block. [johanlindberg]
file clips-attempt.lisp Tue Dec 23 06:10:03 -0800 2008 Abandoning CLIPS syntax. [johanlindberg]
directory examples/ Tue Sep 08 22:02:32 -0700 2009 Added data file for 32 guests. [johanlindberg]
file mps.asd Sat Sep 26 13:09:24 -0700 2009 Added system definition file. [johanlindberg]
file mps.lisp Wed Oct 21 07:13:46 -0700 2009 Implemented watch item for compilations (and re... [johanlindberg]
directory tests/ Wed Sep 23 13:35:52 -0700 2009 Modified tokens to contain fact indexes rather ... [johanlindberg]
README.md

Minimal Production System

Introduction

The Minimal Production System (MPS) started out as an experiment in Common Lisp macrology (the idea was to convert a subset of CLIPS syntax into executable Common Lisp code) but since the | character has special meaning to the Common Lisp reader it's difficult to implement the or-connective-constraint in pattern-CE's. So, instead I've focused on implementing a production system using Common Lisp syntax and defstructs.

There's a bit more info about the CLIPS experiment on my old (defunkt) blog // comments are lies!

Current Status

Currently (2009-10-11) MPS has a small (but growing) set of feature tests (see /tests) and works, more or less, as it should. The Not-CE can still only handle one Pattern-CE. I'll try to fix that during autumn.

Simplest example possible

CL-USER> (in-package :mps)
#<Package "MPS">
MPS> (watch activations facts rules)
T
MPS> (defstruct foo value)
FOO
MPS> (defrule test
       (foo (value ?value))
       =>
       (print ?value)
       (halt))
TEST
MPS> (assert-facts #S(foo :value 1) #S(foo :value 2) #S(foo :value 3))
=> FACT: F-1 #S(FOO :VALUE 1)
=> ACTIVATION: TEST (#S(FOO :VALUE 1))
=> FACT: F-2 #S(FOO :VALUE 2)
=> ACTIVATION: TEST (#S(FOO :VALUE 2))
=> FACT: F-3 #S(FOO :VALUE 3)
=> ACTIVATION: TEST (#S(FOO :VALUE 3))
3
MPS> (pprint (agenda))

(#S(ACTIVATION :RULE TEST :SALIENCE 0 :TOKEN (#S(FOO :VALUE 1)) :TIMESTAMP 1
               :RHS-FUNCTION #<Compiled-function RHS/TEST #x3000413FCB3F>
               :PRODUCTION-MEMORY MEMORY/PRODUCTION/TEST)
 #S(ACTIVATION :RULE TEST :SALIENCE 0 :TOKEN (#S(FOO :VALUE 2)) :TIMESTAMP 1
               :RHS-FUNCTION #<Compiled-function RHS/TEST #x3000413FCB3F>
               :PRODUCTION-MEMORY MEMORY/PRODUCTION/TEST)
 #S(ACTIVATION :RULE TEST :SALIENCE 0 :TOKEN (#S(FOO :VALUE 3)) :TIMESTAMP 1
               :RHS-FUNCTION #<Compiled-function RHS/TEST #x3000413FCB3F>
               :PRODUCTION-MEMORY MEMORY/PRODUCTION/TEST)); No value
MPS> (run)
FIRE: TEST (#S(FOO :VALUE 1))

1 1
MPS>