LISA and rule-based programming in Common Lisp - Lisp Propulsion Laboratory log

LISA and rule-based programming in Common Lisp

Given the current interest in Domain-Specific Languages, and the fact that Common Lisp is a multi-paradigm programming language, this looks like a good opportunity to talk about the LISA production rule language for Common Lisp.

LISA (Lisp-based Intelligent Software Agents), by David Young, is one of those little gems buried into Sourceforge. Many Lispers probably never heard of it, or don't know much about it.

Back in the AI spring, Lisp was one of the main languages for developing expert systems and shells (if you wonder what happaned to expert systems after the AI winter, see what I found last March). When I started studying expert systems last fall, and looked for free systems to play with, I mostly found a few such tools that were old, designed for specialized domains, or limited to toy problems for educational purposes. I guess many of the well known systems written in Lisp were either commercial products or never released research projects.

LISA is a notable exception. Based on the efficient Rete pattern matching algorithm, it is in the tradition of, and was inspired by, OPS5, CLIPS for C and JESS for Java. Work on LISA started around 2000, so it is a relatively recent system and leverages the experience of its predecessors.

LISA is powerful and integrates well with Common Lisp. From the web site:

[...] Lisa reasons over CLOS objects without requiring changes to an application's class hierarchy. In addition, the full power of Common Lisp is available for use within productions; there is no dichotomy between Lisa's programming language and her implementation.

The rule-based paradigm is certainly mind-stretching and worth learning. It can help solve problems in which complex logic and decisions are involved. I find this paradigm and the declarative style of rules intuitive, not to mention a "just works" feel -- but when it doesn't, debugging can be tough.

Over the past year or so, I bought from Amazon at bargain prices half a dozen used books on expert systems. They are most of the popular ones referenced in the literature on this field. Among these books, only the following ones usefully cover the practical issues of actually programming rule-based systems:

Expert Systems: Principles and Programming by Joseph C. Giarratano and Gary D. Riley (if you want a better deal, get an earlier edition: you won't miss much)

Programming Expert Systems in Ops5: An Introduction to Rule-Based Programming by Lee Brownston, R. Farrell and Elaine Kant.

Except for some discussion in the latter book, and efficiency considerations discussed in both, I have not been able to find any resources that cover the practical issues of designing a knowledge base.

If you want to give LISA a try, note that building it with ASDF (system name: lisa ) is possible, but a bit tricky because of the many subsystems involved. Be sure that your central registry contains these links:

lisa-debugger.asd -> src/debugger/lisa.debugger.asd lisa.asd -> lisa.asd lisa.config.asd -> src/config/config.asd lisa.core.asd -> src/2.0-core/core.asd lisa.epilogue.asd -> src/2.0-core/core.asd lisa.implementations.asd -> src/implementations/implementations.asd lisa.packages.asd -> src/packages/packages.asd lisa.reflect.asd -> src/reflect/reflect.asd lisa.rete.asd -> src/rete/reference/rete.asd lisa.utils.asd -> src/utils/utils.asd

It would also be useful if you could join the lisa-users mailing list. LISA is a mature system for niche applications, and list traffic tends to be -- very -- low. So, discussions and experience from a wider user base would be valuable.

Another interesting feature of LISA is that it provides good Lisp code to study. It was developed by an experienced programmer, and it shows. Source files tend to be short and contain small functions that focus on doing just one task. Symbol names are meaningful and explain what functions and macros do. Even basic familiarity with the problem domain is enough to understand what the code does most of the time. In short, this is one of those systems in which the code makes comments mostly unnecessary.