Creating an Expert System with CLIPS

Expert system diagram

CLIPS Expert SystemIn the post Creating an expert system I explained an ITGS lesson where students use a tool called eXpertise2Go to create basic expert systems for the HL topic Artificial Intelligence, Robotics, and Expert Systems. Unfortunately, eXpertise2Go no longer functions correctly due to changes in the latest Java plugins, so I have been forced to find an alternative tool.

Luckily, I came across CLIPS, which seems to meet my requirements. The system is quite easy to use, especially if you focus only on the knowledge base component (I used the included animal identification game example and replaced the knowledge base rules at the bottom of the file with my own rules, leaving the inference engine rules in tact). After a small amount of experimentation I was able to adapt the lesson ideas and tasks from my previous post with a minimum of fuss.

Expert system diagramAll expert systems have a goal (something we want to find out), and in CLIPS this is specified using the goal keyword and a variable name. The example I demonstrate to my students is the simple Mr-Mrs-Miss system from my previous post, because it is easy to understand and has a small number of outputs. In this case we would specify:

(goal is title)

The expert system will then stop (and provide us with an answer) once the variable title has a value. Questions (which I find it easier to limit to yes/no) are written with the question keyword like so:

(question male is "Are you a man?")

The user’s input is stored in the specified variable (male in this case). Rules are written in a similar style:

(rule (if male is yes)
 (then title is Mr))

At this point I leave it to the students to add the rules and question for the remaining outputs (Mrs and Miss). A good rule to remember is that if you are using a simple binary logic expert system there will be two rules for every question created.

CLIPS does have something of a learning curve, and the lack of a compiler means errors typically result in a flat refusal to work but no error message. However, if students are reminded that the system is case sensitive and that brackets must be balanced, success can be achieved quite quickly, even for non-programmers. In fact, in my class the students who do have programming experience initially found CLIPS more confusing, because of the non-linear nature of program execution compared to the Java code they are used to.

Another tip I discovered is that the long, clear variables names confuse some students – replacing them with x or a similar short name makes more sense to some of them (presumably because of their experiences in maths). Finally, variables names cannot contain spaces (replacing them with underscores works well).

CLIPS is open source: versions for Windows and Mac OS are available from Sourceforge. I gave students a Blank Knowledge Base file which was a modified version of the supplied animal identification example.

Be the first to comment

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.