Visual Expert System Designer is an extension of Computer Aided Knowledge Engineering (CAKE). Visual Expert System Designer simplifies the development of rule-based expert systems.
I developed Visual Expert System Designer in three phases:
- I designed a visual language for knowledge modeling.
- I developed an Integrated Development Environment (IDE) that allows visual knowledge development.
- I developed a compiler for the visual language and built it into the IDE.
Phase 1: Language Design
I designed the visual language to satisfy key requirements:
- The language efficiently models human knowledge.
- The language is easy to understand for field experts who are not familiar with expert systems (for example, doctors, engineers and lawyers).
- The language is easy to compile into expert system shells and languages.
The language focuses on rule manipulation, making that task easy for knowledge designers and modellers.
Phase 2: IDE Development
Since my language uses a rich set of graphical notations, the IDE must have strong diagram design capability. The IDE, moreover, must perform visual syntax check as well. I programmed Visio (in 1999 it wasn’t belong to Microsoft) to serve as the IDE for my visual language. Visio has a rich COM object model for extending and controlling new graphical shapes. When I finished IDE development, the resulted IDE was able to help knowledge designer to design, modify the modeled knowledge, parse and report errors.
Phase 3: Compiler Development
I designed the visual language to convert easily into expert system languages. The visual language can potentially translate into many different arterial intelligent languages. However, only one target language is currently supported due to developer time and resource limitations.
I chose CLIPS as the target language, based on my previous experience with it. CLIPS is a capable open source language very similar to LISP. CLIPS was originally developed at NASA's Johnson Space Center, and has since become a popular expert system shell.
The IDE produces a graphic representation of the knowledge system that displays different types of nodes and connectors. My compiler uses a graph traverse method, and generates relevant CLIPS code based on nodes and connectors. In situations where the graph contains multiple target branches for a node, the compiler uses a stack-like data structure (push-down automata) and generates the appropriate code.
A sample problem solved by Visual Expert System Designer
The Letter Boxes problem provides a good demonstration of how Visual Expert System Designer works.
Problem definition:
There are 6 boxes. Each box has a letter on it. The initial position of the boxes is shown in the following figure:
The goal is to put a box on top of another box using minimum number of moves (for example putting “F” on top of “B” with the fewest moves). Each move can transfer only one box.
Solution:
To solve the problem using a rule-based system, we use two stacks that contain the initial positions of the boxes. Then we apply the following four rules:
RULE 1: MOVE-DIRECTLY
IF
The goal is to move block ?upper on top of Block ?lower and
Block ?upper is the top block in its stack and
Block ?lower is the top block in its stack,
THEN
move block ?upper on top of block ?lower .
RULE 2: CLEAR-UPPER-BLOCK
IF
The goal is to move block ?x and
Block ?x is not the top block in it’s stack and
Block ?above is on top of block ?x ,
THEN
The goal is to move block ?above to the floor
RULE 3: CLEAR-LOWER-BLOCK
IF
The goal is to move another block on top of block ?x and
block ?x is not the top block in its stack and
block ?above is on top of block ?x ,
THEN
The goal is to move block ?above to the floor
RULE 4: MOVE-TO-FLOOR
IF
The goal is to move block ?upper on top of floor and
Block ?upper is the top block in its stack ,
THEN
move block ?upper on top of the floor .
We can model above four rules in Visual Expert System Designer like this:
Above knowledge model looks like this in the IDE:
In this case, Visual Expert System Designer generates the following code:
;;****************
;;* This Code Generated Automatically By Visual Expert System Designer
;;* Meta Model And Programming By Ali Moeen
;;* Important Note : This Code Works Only On Fuzzy Version Of Clips
;;* For Changing Threshold Value Of CF Use : (threshold r)
;;****************
;;* DEFFUNCTIONS *
;;****************
(deffunction ask-question (?question $?allowed-values)
(printout t ?question)
(bind ?answer (read))
(if (lexemep ?answer)
then (bind ?answer (lowcase ?answer)))
(while (not (member ?answer ?allowed-values)) do
(printout t ?question)
(bind ?answer (read))
(if (lexemep ?answer)
then (bind ?answer (lowcase ?answer))))
?answer)
;;;**********************
;;;* Initial Facts *
;;;**********************
(deffacts knowledge-base-Initialize
(stack A B C) CF 1
(stack) CF 1
(stack D E F) CF 1
(goal move C on-top-of E) CF 1
)
;;;**********************
;;;* Rules *
;;;**********************
(defrule move-directly
(declare (salience 0) (CF 1 ) )
?Delete.27<-(stack ?block2 $?rest2)
?Delete.28<-(stack ?block1 $?rest1)
?Delete<-(goal move ?block1 on-top-of ?block2)
=>
(retract ?Delete)
(retract ?Delete.27)
(retract ?Delete.28)
(printout t ?block1 " moved on top of " ?block2 crlf)
(assert (stack $?rest1) CF 1 )
(assert (stack ?block1 ?block2 $?rest2) CF 1 )
)
(defrule move-to-floor
(declare (salience 0) (CF 1 ) )
?Delete.48<-(stack ?block1 $?rest)
?Delete.47<-(goal move ?block1 on-top-of floor)
=>
(retract ?Delete.47)
(retract ?Delete.48)
(assert (stack $?rest) CF 1 )
(assert (stack ?block1) CF 1 )
(printout t ?block1 " moved on top of floor" crlf)
)
(defrule clear-upper-block
(declare (salience 0) (CF 1 ) )
(goal move ?block1 on-top-of ?)
(stack ?top $? ?block1 $?)
=>
(assert (goal move ?top on-top-of floor) CF 1 )
)
(defrule clear-lower-block
(declare (salience 0) (CF 1 ) )
(goal move ? on-top-of ?block1)
(stack ?top $? ?block1 $?)
=>
(assert (goal move ?top on-top-of floor) CF 1 )
) |
Conclusion
Visual Expert System Designer is an efficient tool that lets field experts model their knowledge with minimum effort. Visual Expert System Designer hides all the complexities of expert system shells, and is able to parse errors.